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 auto
julia -t 4
- Set the
JULIA_NUM_THREADS
environment variable to4
before starting Julia
julia> using Octavian
julia> A = [1 2 3; 4 5 6]
2×3 Matrix{Int64}: 1 2 3 4 5 6
julia> 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 18
julia> C = Matrix{Int}(undef, 2, 4)
2×4 Matrix{Int64}: 139746093640176 139746093640208 139746093640240 139746075907424 139746075907344 139746075907376 139746093640272 139746075907440
julia> 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 218
julia> C
2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218
julia> C == A * B
true
julia> using Octavian
julia> A = [1 2 3; 4 5 6]
2×3 Matrix{Int64}: 1 2 3 4 5 6
julia> 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 18
julia> C = matmul(A, B) # (multi-threaded) multiply A×B and return the result
2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218
julia> C
2×4 Matrix{Int64}: 74 80 86 92 173 188 203 218
julia> C == A * B
true