Skip to content

Commit

Permalink
ReduceOps: reset result readiness flag
Browse files Browse the repository at this point in the history
In AMReX-Codes#3421, a change was made to avoid a common mistake of calling
ReduceData::value multiple times. Unfortunately, it breaks codes that using
one ReduceOps with multiple ReduceData objects. This PR fixes both cases.
  • Loading branch information
WeiqunZhang committed Sep 15, 2023
1 parent 5829296 commit 966f651
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Src/Base/AMReX_Reduce.H
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public:
* m_max_blocks * sizeof(Type)))),
m_fn_value([&reduce_op,this] () -> Type { return this->value(reduce_op); })
{
reduce_op.m_result_is_ready = false;
static_assert(std::is_trivially_copyable<Type>(),
"ReduceData::Type must be trivially copyable");
static_assert(std::is_trivially_destructible<Type>(),
Expand Down Expand Up @@ -993,6 +994,7 @@ public:
: m_tuple(OpenMP::in_parallel() ? 1 : OpenMP::get_max_threads()),
m_fn_value([&reduce_op,this] () -> Type { return this->value(reduce_op); })
{
reduce_op.m_result_is_ready = false;
for (auto& t : m_tuple) {
Reduce::detail::for_each_init<0, Type, Ps...>(t);
}
Expand Down

0 comments on commit 966f651

Please sign in to comment.