3
$\begingroup$

I am trying to find a good way to handle the following problem: Let C be an N by 3 array (corresponding to points in $\mathbb{R}^3$). There is a method I am interested in testing which requires constructing, for i=1....N, a matrix $A_i$ of size $n_i <<N$ and a vector $b_i$ of size $n_i$ using only data from the row i of C. Then, we seek the solution $x_i = A_i^{-1} b_i$.

I currently am running this in MATLAB as a large for loop going from i=1 to i=N, and doing the above operations. For N = 30,000, this takes a while and I was hoping to find some way to speed things up. Since each iteration is independent of the other, I was hoping I could parallelize the for loop. However, I am unfamiliar with parallel programming.

I do not have access to the matlab parallel toolbox, so I cannot simply invoke parfor to parallelize the loop. If it helps, I am familiar with Python+Numpy+Scipy, and also a bit with C/C++ and eager to learn MPI or CUDA or whatever would be useful.

Am I correct in thinking that this for loop could be parallelized for faster performance? Can anyone point me to some resources to get started for a parallel (or, faster) implementation?

Thanks!

$\endgroup$
2
  • 4
    $\begingroup$ What you need is probably OpenMP with MEX files. $\endgroup$
    – Inquest
    Nov 10, 2013 at 22:47
  • 1
    $\begingroup$ MATLAB is rather slow with small matrices. A simple MEX file (without parallelisation) - Eigen is good for this since it is header only - yields nearly an order of magnitude speed-up in my experience. $\endgroup$
    – Damien
    Nov 11, 2013 at 11:51

1 Answer 1

3
$\begingroup$

You could do this in Numpy with Python's Multiprocessing (specfically by building a Pool and using Pool.map over the matrices you want to solve).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.