c++ two tbb::parallel_for loops efficiency

北战南征 提交于 2019-12-08 11:59:41

问题


In my code I call parallel_for twice:

parallel_for( do some stuff ); // I want this operation to finish first
parallel_for( do some other stuff ); // then I want to do this

1) Does this approach create physical threads twice ? and makes it slower ?

2) If needed, what would be the best method to replace those two calls of parallel_for ?


回答1:


1) No, TBB has single shared pool of threads which are created lazily on demand. So lazily that completion of the first parallel_for does not guarantee creation of all the threads.

2) Not needed.



来源:https://stackoverflow.com/questions/38618074/c-two-tbbparallel-for-loops-efficiency

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