Reduce memory use in Kokkos package

This commit is contained in:
Stan Moore
2022-03-11 00:07:47 -05:00
parent 9b989b1860
commit e8a550aa22
6 changed files with 113 additions and 5 deletions

View File

@ -449,8 +449,24 @@ void FixACKS2ReaxFFKokkos<DeviceType>::allocate_matrix()
// determine the total space for the H matrix
m_cap = 0;
FixACKS2ReaxFFKokkosNumNeighFunctor<DeviceType> neigh_functor(this);
Kokkos::parallel_reduce(nn,neigh_functor,m_cap);
// limit scope of functor to allow deallocation of views
{
FixACKS2ReaxFFKokkosNumNeighFunctor<DeviceType> neigh_functor(this);
Kokkos::parallel_reduce(nn,neigh_functor,m_cap);
}
// deallocate first to reduce memory overhead
d_firstnbr = typename AT::t_int_1d();
d_numnbrs = typename AT::t_int_1d();
d_jlist = typename AT::t_int_1d();
d_val = typename AT::t_ffloat_1d();
d_firstnbr_X = typename AT::t_int_1d();
d_numnbrs_X = typename AT::t_int_1d();
d_jlist_X = typename AT::t_int_1d();
d_val_X = typename AT::t_ffloat_1d();
// H matrix

View File

@ -309,6 +309,8 @@ void FixQEqReaxFFKokkos<DeviceType>::pre_force(int /*vflag*/)
dup_o = decltype(dup_o)();
atomKK->modified(execution_space,datamask_modify);
d_neighbors = typename AT::t_neighbors_2d();
}
/* ---------------------------------------------------------------------- */
@ -331,8 +333,19 @@ void FixQEqReaxFFKokkos<DeviceType>::allocate_matrix()
// determine the total space for the H matrix
m_cap = 0;
FixQEqReaxFFKokkosNumNeighFunctor<DeviceType> neigh_functor(this);
Kokkos::parallel_reduce(nn,neigh_functor,m_cap);
// limit scope of functor to allow deallocation of views
{
FixQEqReaxFFKokkosNumNeighFunctor<DeviceType> neigh_functor(this);
Kokkos::parallel_reduce(nn,neigh_functor,m_cap);
}
// deallocate first to reduce memory overhead
d_firstnbr = typename AT::t_int_1d();
d_numnbrs = typename AT::t_int_1d();
d_jlist = typename AT::t_int_1d();
d_val = typename AT::t_ffloat_1d();
d_firstnbr = typename AT::t_int_1d("qeq/kk:firstnbr",nmax);
d_numnbrs = typename AT::t_int_1d("qeq/kk:numnbrs",nmax);

View File

@ -42,6 +42,7 @@ void NeighListKokkos<DeviceType>::grow(int nmax)
k_ilist = DAT::tdual_int_1d("neighlist:ilist",maxatoms);
d_ilist = k_ilist.view<DeviceType>();
d_numneigh = typename ArrayTypes<DeviceType>::t_int_1d("neighlist:numneigh",maxatoms);
d_neighbors = typename ArrayTypes<DeviceType>::t_neighbors_2d();
d_neighbors = typename ArrayTypes<DeviceType>::t_neighbors_2d(Kokkos::NoInit("neighlist:neighbors"),maxatoms,maxneighs);
}

View File

@ -320,7 +320,10 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::build(NeighList *list_)
if (data.h_resize()) {
list->maxneighs = data.h_new_maxneighs() * 1.2;
list->d_neighbors = typename AT::t_neighbors_2d(Kokkos::NoInit("neighbors"), list->d_neighbors.extent(0), list->maxneighs);
int maxatoms = list->d_neighbors.extent(0);
data.neigh_list.d_neighbors = typename AT::t_neighbors_2d();
list->d_neighbors = typename AT::t_neighbors_2d();
list->d_neighbors = typename AT::t_neighbors_2d(Kokkos::NoInit("neighlist:neighbors"), maxatoms, list->maxneighs);
data.neigh_list.d_neighbors = list->d_neighbors;
data.neigh_list.maxneighs = list->maxneighs;
}

View File

@ -1121,6 +1121,8 @@ void PairReaxFFKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
//dup_Cdbopi = decltype(dup_Cdbopi)();
//dup_Cdbopi2 = decltype(dup_Cdbopi2)();
}
d_neighbors = typename AT::t_neighbors_2d();
}
/* ---------------------------------------------------------------------- */
@ -1503,6 +1505,10 @@ void PairReaxFFKokkos<DeviceType>::operator()(TagPairReaxComputeTabulatedLJCoulo
template<class DeviceType>
void PairReaxFFKokkos<DeviceType>::allocate_array()
{
// deallocate first to reduce memory overhead
deallocate_array();
if (cut_hbsq > 0.0) {
d_hb_first = typename AT::t_int_1d("reaxff/kk:hb_first",nmax);
d_hb_num = typename AT::t_int_1d("reaxff/kk:hb_num",nmax);
@ -1568,6 +1574,74 @@ void PairReaxFFKokkos<DeviceType>::allocate_array()
/* ---------------------------------------------------------------------- */
template<class DeviceType>
void PairReaxFFKokkos<DeviceType>::deallocate_array()
{
if (cut_hbsq > 0.0) {
d_hb_first = typename AT::t_int_1d();
d_hb_num = typename AT::t_int_1d();
d_hb_list = typename AT::t_int_1d();
}
d_bo_first = typename AT::t_int_1d();
d_bo_num = typename AT::t_int_1d();
d_bo_list = typename AT::t_int_1d();
d_BO = typename AT::t_ffloat_2d_dl();
d_BO_s = typename AT::t_ffloat_2d_dl();
d_BO_pi = typename AT::t_ffloat_2d_dl();
d_BO_pi2 = typename AT::t_ffloat_2d_dl();
d_dln_BOp_pix = typename AT::t_ffloat_2d_dl();
d_dln_BOp_piy = typename AT::t_ffloat_2d_dl();
d_dln_BOp_piz = typename AT::t_ffloat_2d_dl();
d_dln_BOp_pi2x = typename AT::t_ffloat_2d_dl();
d_dln_BOp_pi2y = typename AT::t_ffloat_2d_dl();
d_dln_BOp_pi2z = typename AT::t_ffloat_2d_dl();
d_C1dbo = typename AT::t_ffloat_2d_dl();
d_C2dbo = typename AT::t_ffloat_2d_dl();
d_C3dbo = typename AT::t_ffloat_2d_dl();
d_C1dbopi = typename AT::t_ffloat_2d_dl();
d_C2dbopi = typename AT::t_ffloat_2d_dl();
d_C3dbopi = typename AT::t_ffloat_2d_dl();
d_C4dbopi = typename AT::t_ffloat_2d_dl();
d_C1dbopi2 = typename AT::t_ffloat_2d_dl();
d_C2dbopi2 = typename AT::t_ffloat_2d_dl();
d_C3dbopi2 = typename AT::t_ffloat_2d_dl();
d_C4dbopi2 = typename AT::t_ffloat_2d_dl();
d_dBOpx = typename AT::t_ffloat_2d_dl();
d_dBOpy = typename AT::t_ffloat_2d_dl();
d_dBOpz = typename AT::t_ffloat_2d_dl();
d_dDeltap_self = typename AT::t_ffloat_2d_dl();
d_Deltap_boc = typename AT::t_ffloat_1d();
d_Deltap = typename AT::t_ffloat_1d();
d_total_bo = typename AT::t_ffloat_1d();
d_Cdbo = typename AT::t_ffloat_2d_dl();
d_Cdbopi = typename AT::t_ffloat_2d_dl();
d_Cdbopi2 = typename AT::t_ffloat_2d_dl();
d_Delta = typename AT::t_ffloat_1d();
d_Delta_boc = typename AT::t_ffloat_1d();
d_dDelta_lp = typename AT::t_ffloat_1d();
d_Delta_lp = typename AT::t_ffloat_1d();
d_Delta_lp_temp = typename AT::t_ffloat_1d();
d_CdDelta = typename AT::t_ffloat_1d();
d_sum_ovun = typename AT::t_ffloat_2d_dl();
// FixReaxFFBonds
d_abo = typename AT::t_ffloat_2d();
d_neighid = typename AT::t_tagint_2d();
d_numneigh_bonds = typename AT::t_int_1d();
}
/* ---------------------------------------------------------------------- */
template<class DeviceType>
KOKKOS_INLINE_FUNCTION
void PairReaxFFKokkos<DeviceType>::operator()(TagPairReaxZero, const int &n) const {

View File

@ -350,6 +350,7 @@ class PairReaxFFKokkos : public PairReaxFF {
protected:
void allocate();
void allocate_array();
void deallocate_array();
void setup();
void init_md();
int Init_Lookup_Tables();