Skip to content

Commit

Permalink
Don't emit atomics for thread-safe assignment patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
Infinoid committed Feb 10, 2021
1 parent 1114197 commit 5e5ef41
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index_notation/transformations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,14 @@ IndexStmt scalarPromote(IndexStmt stmt, ProvenanceGraph provGraph,
return;
}

stmt = forall(i, body, foralli.getParallelUnit(),
foralli.getOutputRaceStrategy(), foralli.getUnrollFactor());
auto parallelunit = foralli.getParallelUnit();
auto racestrategy = foralli.getOutputRaceStrategy();
auto unrollfactor = foralli.getUnrollFactor();
// compilers reject openmp atomic pragmas for assignments from thread-local temporaries. See bug #316.
if(parallelunit == ParallelUnit::CPUThread && racestrategy == OutputRaceStrategy::Atomics) {
racestrategy = OutputRaceStrategy::IgnoreRaces;
}
stmt = forall(i, body, parallelunit, racestrategy, unrollfactor);
for (const auto& consumer : consumers) {
stmt = where(consumer, stmt);
}
Expand Down

0 comments on commit 5e5ef41

Please sign in to comment.