Skip to content

Commit

Permalink
Switch from C++ parallel for_each to TBB because Mac complains.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-zint committed Nov 6, 2024
1 parent f627bef commit 37720a0
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/wmtk/Scheduler.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "Scheduler.hpp"

#include <algorithm>
#include <execution>

#include <wmtk/attribute/TypedAttributeHandle.hpp>
#include <wmtk/simplex/k_ring.hpp>
#include <wmtk/simplex/link.hpp>
Expand Down Expand Up @@ -476,31 +473,27 @@ SchedulerStats Scheduler::run_operation_on_all_with_coloring(
std::atomic_int fail_cnt = 0;

if (parallel_execution) {
std::for_each(
std::execution::par,
one_color_vertices.begin(),
one_color_vertices.end(),
[&](const simplex::Simplex& s) {
const auto mods = op(s);
if (mods.empty()) {
fail_cnt++;
} else {
suc_cnt++;
tbb::parallel_for(
tbb::blocked_range<int64_t>(0, one_color_vertices.size()),
[&](tbb::blocked_range<int64_t> r) {
for (int64_t k = r.begin(); k < r.end(); ++k) {
auto mods = op(one_color_vertices[k]);
if (mods.empty()) {
fail_cnt++;

Check warning on line 482 in src/wmtk/Scheduler.cpp

View check run for this annotation

Codecov / codecov/patch

src/wmtk/Scheduler.cpp#L482

Added line #L482 was not covered by tests
} else {
suc_cnt++;
}
}
});
} else {
std::for_each(
std::execution::seq,
one_color_vertices.begin(),
one_color_vertices.end(),
[&](const simplex::Simplex& s) {
const auto mods = op(s);
if (mods.empty()) {
fail_cnt++;
} else {
suc_cnt++;
}
});
for (const simplex::Simplex& s : one_color_vertices) {
auto mods = op(s);
if (mods.empty()) {
fail_cnt++;

Check warning on line 492 in src/wmtk/Scheduler.cpp

View check run for this annotation

Codecov / codecov/patch

src/wmtk/Scheduler.cpp#L492

Added line #L492 was not covered by tests
} else {
suc_cnt++;
}
}
}

res.m_num_op_success = suc_cnt;
Expand Down

0 comments on commit 37720a0

Please sign in to comment.