Commit b3d6d9f8 authored by Dan Ibanez's avatar Dan Ibanez Committed by Stan Moore
Browse files

fix memory leak via NeighListKokkos::clean_copy()

There were several clean_copy() calls in pair
styles *outside device code*.
They seem to have been left over from an abandoned
effort to copy the Kokkos neighbor list as
a member of the pair style, instead of copying
out the individual views needed.
These leftover clean_copy() calls were setting
pointers to NULL that had not been freed,
leading to large memory leaks.
I've removed the clean_copy() function entirely,
and replaced it with the copymode flag system used
in many other Kokkos objects.
The copymode flag is only set to one in
functors that hold copies of the neighbor list.
parent 2c930657
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -217,8 +217,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;
+0 −2
Original line number Diff line number Diff line
@@ -624,8 +624,6 @@ void FixShardlowKokkos<DeviceType>::initial_integrate(int vflag)
  d_neighbors = k_list->d_neighbors;
  d_ilist = k_list->d_ilist;

  k_list->clean_copy();
  //cleanup_copy();
  copymode = 1;

  dtsqrt = sqrt(update->dt);
+6 −13
Original line number Diff line number Diff line
@@ -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;
};

/* ---------------------------------------------------------------------- */

+1 −6
Original line number Diff line number Diff line
@@ -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 {
+1 −1
Original line number Diff line number Diff line
@@ -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
Loading