From be98d0bbd95a67400c5900504fc585a1b6e69811 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 26 Aug 2021 09:36:16 -0600 Subject: [PATCH] Fix memory issue in fix_nvt_sllod_kokkos --- src/KOKKOS/fix_nvt_sllod_kokkos.cpp | 7 ++++--- src/KOKKOS/fix_nvt_sllod_kokkos.h | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/KOKKOS/fix_nvt_sllod_kokkos.cpp b/src/KOKKOS/fix_nvt_sllod_kokkos.cpp index d0af72f17f..5ba0e6b666 100644 --- a/src/KOKKOS/fix_nvt_sllod_kokkos.cpp +++ b/src/KOKKOS/fix_nvt_sllod_kokkos.cpp @@ -65,8 +65,6 @@ void FixNVTSllodKokkos::init() { FixNHKokkos::init(); - vdelu = typename ArrayTypes::t_v_array("nvt/sllod/kk:vdelu", atomKK->nlocal); - if (!this->temperature->tempbias) this->error->all(FLERR,"Temperature for fix nvt/sllod does not have a bias"); @@ -100,7 +98,7 @@ void FixNVTSllodKokkos::nh_v_temp() // calculate temperature since some computes require temp // computed on current nlocal atoms to remove bias - if (nondeformbias){ + if (nondeformbias) { atomKK->sync(this->temperature->execution_space,this->temperature->datamask_read); this->temperature->compute_scalar(); atomKK->modified(this->temperature->execution_space,this->temperature->datamask_modify); @@ -115,6 +113,9 @@ void FixNVTSllodKokkos::nh_v_temp() d_h_two = Few(h_two); + if (vdelu.extent(0) < atomKK->nmax) + vdelu = typename AT::t_v_array(Kokkos::NoInit("nvt/sllod/kk:vdelu"), atomKK->nmax); + this->copymode = 1; Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal),*this); this->copymode = 0; diff --git a/src/KOKKOS/fix_nvt_sllod_kokkos.h b/src/KOKKOS/fix_nvt_sllod_kokkos.h index 6057ce44d0..84e57ab2c3 100644 --- a/src/KOKKOS/fix_nvt_sllod_kokkos.h +++ b/src/KOKKOS/fix_nvt_sllod_kokkos.h @@ -35,6 +35,9 @@ struct TagFixNVTSllod_temp2{}; template class FixNVTSllodKokkos : public FixNHKokkos { public: + typedef DeviceType device_type; + typedef ArrayTypes AT; + FixNVTSllodKokkos(class LAMMPS *, int, char **); ~FixNVTSllodKokkos() {} void init(); @@ -51,14 +54,14 @@ class FixNVTSllodKokkos : public FixNHKokkos { void nh_v_temp(); protected: - typename ArrayTypes::t_x_array x; - typename ArrayTypes::t_v_array v; - typename ArrayTypes::t_v_array vdelu; - typename ArrayTypes::t_f_array_const f; - typename ArrayTypes::t_float_1d rmass; - typename ArrayTypes::t_float_1d mass; - typename ArrayTypes::t_int_1d type; - typename ArrayTypes::t_int_1d mask; + typename AT::t_x_array x; + typename AT::t_v_array v; + typename AT::t_v_array vdelu; + typename AT::t_f_array_const f; + typename AT::t_float_1d rmass; + typename AT::t_float_1d mass; + typename AT::t_int_1d type; + typename AT::t_int_1d mask; Few d_h_two;