Skip to content

Commit

Permalink
Correctly capture level by value in device lambda (#1091)
Browse files Browse the repository at this point in the history
We cannot capture the Castro class member level by value, we need to make a local copy.
  • Loading branch information
maxpkatz authored Jul 2, 2020
1 parent 537ad46 commit 4d30cba
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3200,6 +3200,8 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
const int8_t tagval = (int8_t) TagBox::SET;
const int8_t clearval = (int8_t) TagBox::CLEAR;

int lev = level;

if (err_list_names[j] == "density") {
amrex::ParallelFor(bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
Expand All @@ -3208,7 +3210,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
else if (err_list_names[j] == "Temp") {
Expand All @@ -3219,7 +3221,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
else if (err_list_names[j] == "pressure") {
Expand All @@ -3230,7 +3232,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
else if (err_list_names[j] == "x_velocity" || err_list_names[j] == "y_velocity" || err_list_names[j] == "z_velocity") {
Expand All @@ -3241,7 +3243,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
#ifdef REACTIONS
Expand All @@ -3253,7 +3255,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
else if (err_list_names[j] == "enuc") {
Expand All @@ -3264,7 +3266,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
#endif
Expand All @@ -3277,7 +3279,7 @@ Castro::apply_tagging_func(TagBoxArray& tags, Real time, int j)
(int8_t*) AMREX_ARR4_TO_FORTRAN_ANYD(tagfab),
AMREX_ARR4_TO_FORTRAN_ANYD(datfab), ncomp,
AMREX_ZFILL(dx.data()), AMREX_ZFILL(problo.data()),
tagval, clearval, time, level);
tagval, clearval, time, lev);
});
}
#endif
Expand Down

0 comments on commit 4d30cba

Please sign in to comment.