0

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?

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.

3 Comments

Well, you basically stole my edit and changed 1 word. But yea, looks good now.
That is correct only in the context of a "MATLAB Function Block".
@Edric thank you for the information. I included this in the answer as to make it complete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.