[PATCH] [lld][Core] Implement parallel_for_each
Rui Ueyama
ruiu at google.com
Mon Mar 16 10:39:13 PDT 2015
No need to use recursion. Using for-loop like this is much simpler.
void parallel_for_each(Iterator begin, iterator end, Func func) {
TaskGroup tg;
int taskSize = distance(begin, end) / concurrency;
while (taskSize <= distance(begin, end)) {
tg.spawn([=, &func, &tg] { std::for_each(begin, begin + taskSize, func); });
begin += taskSize;
}
std::for_each(begin, end, func);
}
http://reviews.llvm.org/D8348
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list