I would like to know if it is possible to solve a sparse linear system with multiple threads in Julia.
Here is a redundant MRE
using LinearAlgebra
using SparseArrays
function create_sparse_poisson_matrix(n::Int)
diagonal = spdiagm(0 => [2.0 for i in 1:n])
off_diagonal = spdiagm(-1 => [-1.0 for i in 2:n])
additional_subdiagonal = spdiagm(-3 => [-1.0 for i in 4:n])
sparse_poisson_matrix = diagonal + off_diagonal + off_diagonal' + additional_subdiagonal + additional_subdiagonal'
return sparse_poisson_matrix
end
n = 1000000 # Size of the matrix
A = create_sparse_poisson_matrix(n)
lu_A = lu(A , check=true);
x = zeros(n);
for i = 1:1000
x = lu_A x;
end
On my machine it seams it is only be using one thread/core. How can I use the rest of the machine resources to solve a LU sparse system?
New contributor
mysn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.