I am trying to solve many matrix equations Ax=b of fixed size. A simplified version of the code is as follows:
function ser_solve(A,b,res,nu) for i in(1:nu) res[i,:]=A[i,:,:]\b[i,:] end return res; end nu = 10000; si = 100; A = randn(nu,si,si); b = randn(nu,si); res = zeros(nu,si); ser_solve(A,b,res,nu);
The above code is small for now, but that’s just to demonstrate the problem. The sizes of the problems will grow. How would I go about using distributed computing for this code? I have attempted to use @threads in the for loop, but the speedup is nearly non-existent. My attempts at using @distributed and shared arrays haven’t seemed to work. How would I do this the correct way? Is there possibly a way to use pmap to do this?
I should also mention that the matrices in the code I am running are actually populated by some auxiliary functions. So what would be the best way to both parallelize that population of the matrices and then solve them?