问题
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