Star
Star

Reputation: 2299

MATLAB Coder and parfor in MATLAB R2014b

Does the MATLAB Coder in MATLAB R2014b support parfor?

If I check the documentation, it reports:

Treated as a for-loop in a MATLAB Function block.

Does that mean that there is no speed improvement?

Upvotes: 0

Views: 279

Answers (2)

Adriaan
Adriaan

Reputation: 18187

Does Matlab Coder in Matlab-r2014b support parfor?

Yes, the list provided in you reference tells you it is supported.

Does that mean that there is no speed reduction?

Yes. You literally quote "it is treated as a for loop".

So in the strict sense of the word parfor is supported, since it will not throw an error. However, it is treated the same way MATLAB would treat it when the parallellisation toolbox is not installed, as a regular for loop. Thus yes, you can compile MATLAB code containing parfor loops, but they will be treated as serial for loops.

Note that the above only holds true for function blocks; as @Edric pointed out:

parfor ... ... creates a loop in a generated MEX function or in C/C++ code that runs in parallel on shared-memory multicore platforms.

Upvotes: 3

Edric
Edric

Reputation: 25160

The loop runs in a serial manner only in the context of a "MATLAB Function" block

If you check the MATLAB Coder parfor reference page:

http://www.mathworks.com/help/coder/ref/parfor.html

You can see this information:

parfor ... ... creates a loop in a generated MEX function or in C/C++ code that runs in parallel on shared-memory multicore platforms.

Upvotes: 4

Related Questions