[lld] r287042 - Use one task per iteration in parallel_for_loop.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 14:13:16 PST 2016


Author: rafael
Date: Tue Nov 15 16:13:16 2016
New Revision: 287042

URL: http://llvm.org/viewvc/llvm-project?rev=287042&view=rev
Log:
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.

Modified:
    lld/trunk/include/lld/Core/Parallel.h

Modified: lld/trunk/include/lld/Core/Parallel.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Parallel.h?rev=287042&r1=287041&r2=287042&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Parallel.h (original)
+++ lld/trunk/include/lld/Core/Parallel.h Tue Nov 15 16:13:16 2016
@@ -284,12 +284,8 @@ void parallel_for_each(Iterator begin, I
 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




More information about the llvm-commits mailing list