From e5cd5ecd2ec73737cc7a38daeb7a38a4ad165d7a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 15 Nov 2016 22:13:16 +0000 Subject: [PATCH] Use one task per iteration in parallel_for_loop. This seems far more natural. A user can create larger chunks if the overhead is too large. With this linking xul with "--threads --build-id=sha1 goes from 13.938177535 to 11.035953538 seconds on linux. llvm-svn: 287042 --- lld/include/lld/Core/Parallel.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lld/include/lld/Core/Parallel.h b/lld/include/lld/Core/Parallel.h index 0ceb3e6..eaf1390 100644 --- a/lld/include/lld/Core/Parallel.h +++ b/lld/include/lld/Core/Parallel.h @@ -284,12 +284,8 @@ void parallel_for_each(Iterator begin, Iterator end, Func func) { template void parallel_for_each(Iterator begin, Iterator end, Func func) { TaskGroup tg; - ptrdiff_t taskSize = 1024; - while (taskSize <= std::distance(begin, end)) { - tg.spawn([=, &func] { std::for_each(begin, begin + taskSize, func); }); - begin += taskSize; - } - std::for_each(begin, end, func); + for (; begin != end; ++begin) + tg.spawn([=, &func] { func(*begin); }); } #endif } // end namespace lld -- 2.7.4