0
votes

I have two computers, and a MATLAB code that works.

1) On one computer, a line that contains parfor carries out a parallelized computation, as expected.

2) On another computer, the parfor executes as if it is an ordinary for loop, without any parallelization. This happens even for asking as little as 2 things in parallel.

On neither computer does the code error.

What is going on?

1
Things to check: (1) do you have Parallel Computing Toolbox installed in both places, and (2) do you have the "Automatically create parallel pools" setting set to true in both places. uk.mathworks.com/help/parallel-computing/…Edric

1 Answers

1
votes

The documentation to parfor says:

By default, MATLAB uses the available workers in your parallel pool. [...] You can override the default number of workers in a parallel pool by using parpool. When no workers are available in the pool or M is zero, MATLAB still executes the loop body in a nondeterministic order, but not in parallel. Use this syntax to switch between parallel and serial execution when testing your code.

So if the one computer has no workers available, the loop is executed sequentially.