Hi everybody,
I just want to stress test on all of my CPU threads with the multiplication of two random matrices but I got the following error:
What should I do as a Julia new user?
Thank you
Hi everybody,
I just want to stress test on all of my CPU threads with the multiplication of two random matrices but I got the following error:
What should I do as a Julia new user?
Thank you
You need to either write Threads.@threads
or import the symbol. The correct way to import the symbol would be using .Threads: @threads
, but as a beginner, simply using .Threads
would be okay as well.
Also, if you have not done so please read Please read: make it easier to help you (especially point 2 about posting code).
Also note that Threads.nthreads()
just returns the number of threads you’re using (e.g. 8
). It does not enable anything. The -t
flag you pass to the julia
executable is what enables multithreading.
Furthermore, A[i, :]
and B[:, j]
make copies. Assuming that is not what you want, you should use view
s:
# These are all equivalent
C[i, j] = dot(view(A, i, :), view(B, :, j))
C[i, j] = dot(@view(A[i, :]), @view(B[:, j]))
@views C[i, j] = dot(A[i, :], B[:, j])