[PATCH] D26689: Use one task per iteration in parallel_for_loop

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 11:59:26 PST 2016


rafael created this revision.
rafael added reviewers: ruiu, grimar.
rafael added a subscriber: llvm-commits.

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.


https://reviews.llvm.org/D26689

Files:
  include/lld/Core/Parallel.h


Index: include/lld/Core/Parallel.h
===================================================================
--- include/lld/Core/Parallel.h
+++ include/lld/Core/Parallel.h
@@ -284,12 +284,8 @@
 template <class Iterator, class Func>
 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26689.78047.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/a8321a93/attachment.bin>


More information about the llvm-commits mailing list