Search code examples
matlabparallel-processingparfor

How to run 2 parfor's in parallel in MATLAB?


I have 2 different parfor's in my script. With different number of iterations but no dependencies.

Is there a simple way that does not require re-writing to make MATLAB run both of them in parallel (with each other)?


Solution

  • As Matt alluded to, the easiest way to do this is involves some rewriting. parfor loops inherently take over the whole parallel pool so (as far as I know) you can't do what you're asking.

    My preferred way of handling this would be to move the body of each loop into a function and then use parfeval.