[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 08:03:48 PDT 2017

grimar added a comment.

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

> Then why does it take so much time in some test cases if both are the same in the big-O? It should never create 65k+ threads. If it does, something's broken. This patch seems to be trying to fix at a wrong place.

Because it calls:

  void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn)

where Begin == 0, End == 1. And creates thread for a single task, when it should not.
Because there is no reason to take separate thread in this case, when main thread is free
for the same.

And creating 65k threads takes that time.
I really believe patch is fine, lets see what other think.


More information about the llvm-commits mailing list