Fixing memory leak in Kokkos neighborlist

This commit is contained in:
Stan Moore
2017-06-26 10:51:26 -06:00
parent 1370385c8c
commit b889776557
17 changed files with 15 additions and 48 deletions

View File

@ -218,8 +218,6 @@ void FixQEqReaxKokkos<DeviceType>::pre_force(int vflag)
d_ilist = k_list->d_ilist;
inum = list->inum;
k_list->clean_copy();
//cleanup_copy();
copymode = 1;
int teamsize = TEAMSIZE;

View File

@ -22,21 +22,14 @@ enum{NSQ,BIN,MULTI};
/* ---------------------------------------------------------------------- */
template<class Device>
void NeighListKokkos<Device>::clean_copy()
NeighListKokkos<Device>::NeighListKokkos(class LAMMPS *lmp):NeighList(lmp)
{
ilist = NULL;
numneigh = NULL;
firstneigh = NULL;
firstdouble = NULL;
dnum = 0;
iskip = NULL;
ijskip = NULL;
ipage = NULL;
dpage = NULL;
_stride = 1;
maxneighs = 16;
kokkos = 1;
maxatoms = 0;
}
execution_space = ExecutionSpaceFromDevice<Device>::space;
};
/* ---------------------------------------------------------------------- */

View File

@ -68,18 +68,13 @@ class NeighListKokkos: public NeighList {
public:
int maxneighs;
void clean_copy();
void grow(int nmax);
typename ArrayTypes<Device>::t_neighbors_2d d_neighbors;
typename DAT::tdual_int_1d k_ilist; // local indices of I atoms
typename ArrayTypes<Device>::t_int_1d d_ilist;
typename ArrayTypes<Device>::t_int_1d d_numneigh; // # of J neighs for each I
NeighListKokkos(class LAMMPS *lmp):
NeighList(lmp) {_stride = 1; maxneighs = 16; kokkos = 1; maxatoms = 0;
execution_space = ExecutionSpaceFromDevice<Device>::space;
};
~NeighListKokkos() {numneigh = NULL; ilist = NULL;};
NeighListKokkos(class LAMMPS *lmp);
KOKKOS_INLINE_FUNCTION
AtomNeighbors get_neighbors(const int &i) const {

View File

@ -265,7 +265,7 @@ class NeighborKokkosExecute
h_new_maxneighs() = neigh_list.maxneighs;
};
~NeighborKokkosExecute() {neigh_list.clean_copy();};
~NeighborKokkosExecute() {neigh_list.copymode = 1;};
template<int HalfNeigh, int Newton, int Tri>
KOKKOS_FUNCTION

View File

@ -120,9 +120,6 @@ void PairCoulDSFKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
int inum = list->inum;
// Call cleanup_copy which sets allocations NULL which are destructed by the PairStyle
k_list->clean_copy();
copymode = 1;
// loop over neighbors of my atoms

View File

@ -121,9 +121,6 @@ void PairCoulWolfKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
int inum = list->inum;
// Call cleanup_copy which sets allocations NULL which are destructed by the PairStyle
k_list->clean_copy();
copymode = 1;
// loop over neighbors of my atoms

View File

@ -122,9 +122,6 @@ void PairEAMAlloyKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_ilist = k_list->d_ilist;
int inum = list->inum;
// Call cleanup_copy which sets allocations NULL which are destructed by the PairStyle
k_list->clean_copy();
copymode = 1;
// zero out density

View File

@ -122,9 +122,6 @@ void PairEAMFSKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_ilist = k_list->d_ilist;
int inum = list->inum;
// Call cleanup_copy which sets allocations NULL which are destructed by the PairStyle
k_list->clean_copy();
copymode = 1;
// zero out density

View File

@ -117,9 +117,6 @@ void PairEAMKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_ilist = k_list->d_ilist;
int inum = list->inum;
// Call cleanup_copy which sets allocations NULL which are destructed by the PairStyle
k_list->clean_copy();
copymode = 1;
// zero out density
@ -868,4 +865,4 @@ template class PairEAMKokkos<LMPDeviceType>;
#ifdef KOKKOS_HAVE_CUDA
template class PairEAMKokkos<LMPHostType>;
#endif
}
}

View File

@ -87,7 +87,7 @@ struct PairComputeFunctor {
vatom(c.d_vatom),list(*list_ptr) {};
// Call cleanup_copy which sets allocations NULL which are destructed by the PairStyle
~PairComputeFunctor() {c.cleanup_copy();list.clean_copy();};
~PairComputeFunctor() {c.cleanup_copy();list.copymode = 1;};
KOKKOS_INLINE_FUNCTION int sbmask(const int& j) const {
return j >> SBBITS & 3;
@ -344,7 +344,7 @@ struct PairComputeFunctor<PairStyle,N2,STACKPARAMS,Specialisation> {
PairComputeFunctor(PairStyle* c_ptr,
NeighListKokkos<device_type>* list_ptr):
c(*c_ptr),list(*list_ptr) {};
~PairComputeFunctor() {c.cleanup_copy();list.clean_copy();};
~PairComputeFunctor() {c.cleanup_copy();list.copymode = 1;};
KOKKOS_INLINE_FUNCTION int sbmask(const int& j) const {
return j >> SBBITS & 3;

View File

@ -709,8 +709,6 @@ void PairReaxCKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_neighbors = k_list->d_neighbors;
d_ilist = k_list->d_ilist;
k_list->clean_copy();
if (eflag_global) {
for (int i = 0; i < 14; i++)
pvector[i] = 0.0;
@ -3985,7 +3983,6 @@ void PairReaxCKokkos<DeviceType>::FindBond(int &numbonds)
const int inum = list->inum;
NeighListKokkos<DeviceType>* k_list = static_cast<NeighListKokkos<DeviceType>*>(list);
d_ilist = k_list->d_ilist;
k_list->clean_copy();
numbonds = 0;
PairReaxCKokkosFindBondFunctor<DeviceType> find_bond_functor(this);

View File

@ -115,7 +115,6 @@ void PairSWKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_numneigh = k_list->d_numneigh;
d_neighbors = k_list->d_neighbors;
k_list->clean_copy();
copymode = 1;
EV_FLOAT ev;

View File

@ -200,7 +200,6 @@ void PairTersoffKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_neighbors = k_list->d_neighbors;
d_ilist = k_list->d_ilist;
k_list->clean_copy();
copymode = 1;
EV_FLOAT ev;

View File

@ -200,7 +200,6 @@ void PairTersoffMODKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_neighbors = k_list->d_neighbors;
d_ilist = k_list->d_ilist;
k_list->clean_copy();
copymode = 1;
EV_FLOAT ev;

View File

@ -214,7 +214,6 @@ void PairTersoffZBLKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
d_neighbors = k_list->d_neighbors;
d_ilist = k_list->d_ilist;
k_list->clean_copy();
copymode = 1;
EV_FLOAT ev;

View File

@ -48,6 +48,7 @@ NeighList::NeighList(LAMMPS *lmp) : Pointers(lmp)
ghost = 0;
ssa = 0;
copy = 0;
copymode = 0;
dnum = 0;
// ptrs
@ -85,6 +86,7 @@ NeighList::NeighList(LAMMPS *lmp) : Pointers(lmp)
NeighList::~NeighList()
{
if (copymode) return;
if (!copy) {
memory->destroy(ilist);
memory->destroy(numneigh);

View File

@ -34,7 +34,8 @@ class NeighList : protected Pointers {
int occasional; // 0 if build every reneighbor, 1 if not
int ghost; // 1 if list stores neighbors of ghosts
int ssa; // 1 if list stores Shardlow data
int copy; // 1 if this list copied from another list
int copy; // 1 if this list is (host) copied from another list
int copymode; // 1 if this is a Kokkos on-device copy
int dnum; // # of doubles per neighbor, 0 if none
// data structs to store neighbor pairs I,J and associated values