Getting Started
Multi-threaded matrix multiplication: matmul! and matmul
Octavian exports the functions matmul! and matmul, which provide multithreaded matrix multiplication in pure Julia.
Remember to start Julia with multiple threads with e.g. one of the following:
julia -t autojulia -t 4- Set the
JULIA_NUM_THREADSenvironment variable to4before starting Julia
julia> using Octavianjulia> A = [1 2 3; 4 5 6]2×3 Matrix{Int64}: 1 2 3 4 5 6julia> B = [7 8 9 10; 11 12 13 14; 15 16 17 18]3×4 Matrix{Int64}: 7 8 9 10 11 12 13 14 15 16 17 18julia> C = Matrix{Int}(undef, 2, 4)2×4 Matrix{Int64}: 218 140409852530968 140409852531368 140409852523120 219 140409852528512 140409852525272 140409852530344julia> matmul!(C, A, B) # (multi-threaded) multiply A×B and store the result in C (overwriting the contents of C)2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218julia> C2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218julia> C == A * Btrue
julia> using Octavianjulia> A = [1 2 3; 4 5 6]2×3 Matrix{Int64}: 1 2 3 4 5 6julia> B = [7 8 9 10; 11 12 13 14; 15 16 17 18]3×4 Matrix{Int64}: 7 8 9 10 11 12 13 14 15 16 17 18julia> C = matmul(A, B) # (multi-threaded) multiply A×B and return the result2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218julia> C2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218julia> C == A * Btrue