[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
Fri Aug 18 02:21:52 PDT 2017


grimar updated this revision to Diff 111640.
grimar added a comment.

- Addressed review comment.


https://reviews.llvm.org/D36607

Files:
  include/llvm/Support/Parallel.h


Index: include/llvm/Support/Parallel.h
===================================================================
--- include/llvm/Support/Parallel.h
+++ 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.111640.patch
Type: text/x-patch
Size: 775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170818/412b9e3a/attachment.bin>


More information about the llvm-commits mailing list