[PATCH] D36607: [Support/Parallel] - Do not spawn thread for single/last task.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 07:54:37 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D36607#839086, @ruiu wrote:

> Because the last one is not parallelized by the taskgroup, no?


And at the end of `parallel_for_each_n()` it will wait for all threads to finish anyways.
I think there is no difference will last one be executed on main thread or on another thread if we anyways will wait them all, no ?

If we have infinite number of threads and each task 0..N eats time T, then:

1. Original code will take total time T. Because each task will be assigned to own thread which takes T to finish. Main thread will wait T until secondaty threads finish.
2. My code will take total time T, because tasks 0..(N-1) will take time T and main thread will also take time T for task N at the same time. Total time will be T.


https://reviews.llvm.org/D36607





More information about the llvm-commits mailing list