[PATCH] D36607: [Support/Parallel] - Do not use a task group for a very small task.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 01:02:09 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL311312: [Support/Parallel] - Do not use a task group for a very small task. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D36607?vs=111640&id=111935#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36607

Files:
  llvm/trunk/include/llvm/Support/Parallel.h


Index: llvm/trunk/include/llvm/Support/Parallel.h
===================================================================
--- llvm/trunk/include/llvm/Support/Parallel.h
+++ llvm/trunk/include/llvm/Support/Parallel.h
@@ -158,11 +158,11 @@
     TaskSize = 1;
 
   TaskGroup TG;
-  while (TaskSize <= std::distance(Begin, End)) {
+  while (TaskSize < std::distance(Begin, End)) {
     TG.spawn([=, &Fn] { std::for_each(Begin, Begin + TaskSize, Fn); });
     Begin += TaskSize;
   }
-  TG.spawn([=, &Fn] { std::for_each(Begin, End, Fn); });
+  std::for_each(Begin, End, Fn);
 }
 
 template <class IndexTy, class FuncTy>
@@ -179,10 +179,8 @@
         Fn(J);
     });
   }
-  TG.spawn([=, &Fn] {
-    for (IndexTy J = I; J < End; ++J)
-      Fn(J);
-  });
+  for (IndexTy J = I; J < End; ++J)
+    Fn(J);
 }
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36607.111935.patch
Type: text/x-patch
Size: 808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170821/0a00489f/attachment.bin>


More information about the llvm-commits mailing list