Reputation: 23
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?
Upvotes: 0
Views: 96
Reputation: 60660
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 orM
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.
Upvotes: 1