ignoramus
ignoramus

Reputation: 23

parfor executes as ordinary for loop on a computer?

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

Answers (1)

Cris Luengo
Cris Luengo

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 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.

Upvotes: 1

Related Questions