[PATCH] [lld][Core] Implement parallel_for_each
Rui Ueyama
ruiu at google.com
Mon Mar 16 12:36:19 PDT 2015
================
Comment at: include/lld/Core/Parallel.h:300
@@ +299,3 @@
+ const ptrdiff_t minParallelSizeForEach = 1024;
+ int64_t length = distance(begin, end);
+ int64_t taskSize = (length < minParallelSizeForEach)
----------------
Does this compile without std::?
================
Comment at: include/lld/Core/Parallel.h:303
@@ +302,3 @@
+ ? length
+ : length / minParallelSizeForEach;
+ while (taskSize <= distance(begin, end)) {
----------------
This expression doesn't make sense again. You divide length of the array with minSize, which is equal to how many minSize chunks in the array. It's not a task size.
Let's make this simple as a starter. Just set 1024 to taskSize unconditionally. That's probably large enough. You may still have to run a test with that number, though.
================
Comment at: include/lld/Core/Parallel.h:304
@@ +303,3 @@
+ : length / minParallelSizeForEach;
+ while (taskSize <= distance(begin, end)) {
+ tg.spawn([=, &func, &tg] { std::for_each(begin, begin + taskSize, func); });
----------------
This doesn't seem to compile with std::.
http://reviews.llvm.org/D8348
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list