Fix deadlock by always deallocating views of views in serial

This commit is contained in:
Stan Moore
2024-09-23 14:59:51 -06:00
committed by Axel Kohlmeyer
parent dcfdbef0a0
commit 7c6ec1409f
2 changed files with 13 additions and 4 deletions

View File

@ -105,7 +105,16 @@ PairReaxFFKokkos<DeviceType>::~PairReaxFFKokkos()
memoryKK->destroy_kokkos(k_tmpbo,tmpbo);
tmpbo = nullptr;
// deallocate views of views in serial to prevent race condition in profiling tools
deallocate_views_of_views();
}
/* ---------------------------------------------------------------------- */
template<class DeviceType>
void PairReaxFFKokkos<DeviceType>::deallocate_views_of_views()
{
// deallocate views of views in serial to prevent race conditions
for (int i = 0; i < (int)k_LR.extent(0); i++) {
for (int j = 0; j < (int)k_LR.extent(1); j++) {
@ -409,8 +418,8 @@ void PairReaxFFKokkos<DeviceType>::init_md()
int ntypes = atom->ntypes;
Init_Lookup_Tables();
deallocate_views_of_views();
k_LR = tdual_LR_lookup_table_kk_2d("lookup:LR",ntypes+1,ntypes+1);
d_LR = k_LR.template view<DeviceType>();
for (int i = 1; i <= ntypes; ++i) {
if (map[i] == -1) continue;
@ -1392,7 +1401,7 @@ void PairReaxFFKokkos<DeviceType>::operator()(TagPairReaxComputeTabulatedLJCoulo
const int tmin = MIN(itype, jtype);
const int tmax = MAX(itype, jtype);
const LR_lookup_table_kk<DeviceType>& t = d_LR(tmin,tmax);
const LR_lookup_table_kk<DeviceType>& t = k_LR.template view<DeviceType>()(tmin,tmax);
/* Cubic Spline Interpolation */

View File

@ -384,6 +384,7 @@ class PairReaxFFKokkos : public PairReaxFF {
F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *dril, F_FLOAT *drjl, F_FLOAT *drkl) const;
protected:
void deallocate_views_of_views();
void allocate();
void allocate_array();
void setup();
@ -496,7 +497,6 @@ class PairReaxFFKokkos : public PairReaxFF {
typedef typename tdual_LR_lookup_table_kk_2d::t_dev t_LR_lookup_table_kk_2d;
tdual_LR_lookup_table_kk_2d k_LR;
t_LR_lookup_table_kk_2d d_LR;
DAT::tdual_int_2d k_tmpid;
DAT::tdual_ffloat_2d k_tmpbo;