From 7c6ec1409f63eaa0ba287a71d7797dee1ffa258f Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Mon, 23 Sep 2024 14:59:51 -0600 Subject: [PATCH] Fix deadlock by always deallocating views of views in serial --- src/KOKKOS/pair_reaxff_kokkos.cpp | 15 ++++++++++++--- src/KOKKOS/pair_reaxff_kokkos.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 21e82f7afa..3e0af57235 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -105,7 +105,16 @@ PairReaxFFKokkos::~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 +void PairReaxFFKokkos::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::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(); for (int i = 1; i <= ntypes; ++i) { if (map[i] == -1) continue; @@ -1392,7 +1401,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTabulatedLJCoulo const int tmin = MIN(itype, jtype); const int tmax = MAX(itype, jtype); - const LR_lookup_table_kk& t = d_LR(tmin,tmax); + const LR_lookup_table_kk& t = k_LR.template view()(tmin,tmax); /* Cubic Spline Interpolation */ diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 5f228ebd19..eafd7f7c4a 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -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;