[PATCH] D36607: [Support/Parallel] - Do not spawn thread for single/last task.
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 11 08:14:52 PDT 2017
zturner added a reviewer: mclow.lists.
zturner added a comment.
I think there is a balance between what the library should do for you and what the programmer should be responsible for. Writing:
for (int I=0; I < 65000; ++I)
parallel_for_each_n(0, 1, callback);
is kind of a bad thing to do, but at the same time I guess it shouldn't give pathologically bad performance.
Microsoft apparently implements this optimization in ConcRT, so that gives me some confidence that it might be an ok optimization.
On the other hand, task-based threading is fraught with potential for subtle "anti-optimizations" that are hard to evaluate. I think a lot of people have probably thought about this before, so perhaps we could ask someone on the libc++ side who is responsible for / going to be responsible for parallelism algorithms in libc++? I don't know who that would be off the top of my head, but +mclow as if it's not him, he should at least know who it is.
More information about the llvm-commits