When does Matlab choose to thread when using codegen and parfor

做~自己de王妃 提交于 2019-12-04 19:24:17

It will only thread the parfor loop itself, it would be dangerous for the coder to guess, and impossible to calculate where there is appropriate parallelism.

If I were you, I would try to put parfor in place of anywhere in the Matlab code that I could.

And now how to determine whether a loop is acceptable to parallelize:

  1. Does it use any results from a previous calculation, if so, then don't try, seriously, it will only make it worse
  2. Does it use IO in any form, if so, then don't, it will slow it down and remove any determinism from the code

  3. Is there a loop for parfor to replace? If not, then you'll have to deal with the performance because there might not be anything to parallelize.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!