Commit c3a2ed0d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

plug small memory leak in USER-OMP variants of pppm kspace styles

parent 23033404
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -55,13 +55,11 @@ PPPMCGOMP::PPPMCGOMP(LAMMPS *lmp, int narg, char **arg) :
}

/* ----------------------------------------------------------------------
   allocate memory that depends on # of K-vectors and order
   clean up per-thread allocations
------------------------------------------------------------------------- */

void PPPMCGOMP::allocate()
PPPMCGOMP::~PPPMCGOMP()
{
  PPPMCG::allocate();

#if defined(_OPENMP)
#pragma omp parallel default(none)
#endif
@@ -72,17 +70,17 @@ void PPPMCGOMP::allocate()
    const int tid = 0;
#endif
    ThrData *thr = fix->get_thr(tid);
    thr->init_pppm(order,memory);
    thr->init_pppm(-order,memory);
  }
}

/* ----------------------------------------------------------------------
   free memory that depends on # of K-vectors and order
   allocate memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */

void PPPMCGOMP::deallocate()
void PPPMCGOMP::allocate()
{
  PPPMCG::deallocate();
  PPPMCG::allocate();

#if defined(_OPENMP)
#pragma omp parallel default(none)
@@ -94,7 +92,7 @@ void PPPMCGOMP::deallocate()
    const int tid = 0;
#endif
    ThrData *thr = fix->get_thr(tid);
    thr->init_pppm(-order,memory);
    thr->init_pppm(order,memory);
  }
}

+1 −2
Original line number Diff line number Diff line
@@ -28,12 +28,11 @@ namespace LAMMPS_NS {
class PPPMCGOMP : public PPPMCG, public ThrOMP {
 public:
  PPPMCGOMP(class LAMMPS *, int, char **);
  virtual ~PPPMCGOMP () {};
  virtual ~PPPMCGOMP ();
  virtual void compute(int, int);

 protected:
  virtual void allocate();
  virtual void deallocate();

  virtual void compute_gf_ik();
  virtual void compute_gf_ad();
+10 −21
Original line number Diff line number Diff line
@@ -55,17 +55,6 @@ PPPMDispOMP::PPPMDispOMP(LAMMPS *lmp, int narg, char **arg) :

PPPMDispOMP::~PPPMDispOMP()
{
  deallocate();
}

/* ----------------------------------------------------------------------
   allocate memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */

void PPPMDispOMP::allocate()
{
  PPPMDisp::allocate();

#if defined(_OPENMP)
#pragma omp parallel default(none)
#endif
@@ -75,25 +64,24 @@ void PPPMDispOMP::allocate()
#else
    const int tid = 0;
#endif

    if (function[0]) {
      ThrData * thr = fix->get_thr(tid);
      thr->init_pppm(order,memory);
      thr->init_pppm(-order,memory);
    }
    if (function[1] + function[2]) {
      ThrData * thr = fix->get_thr(tid);
      thr->init_pppm_disp(order_6,memory);
      thr->init_pppm_disp(-order_6,memory);
    }
  }
}

/* ----------------------------------------------------------------------
   free memory that depends on # of K-vectors and order
   allocate memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */

void PPPMDispOMP::deallocate()
void PPPMDispOMP::allocate()
{
  PPPMDisp::deallocate();
  PPPMDisp::allocate();

#if defined(_OPENMP)
#pragma omp parallel default(none)
@@ -104,13 +92,14 @@ void PPPMDispOMP::deallocate()
#else
    const int tid = 0;
#endif

    if (function[0]) {
      ThrData *thr = fix->get_thr(tid);
      thr->init_pppm(-order,memory);
      thr->init_pppm(order,memory);
    }
    if (function[1] + function[2]) {
      ThrData * thr = fix->get_thr(tid);
      thr->init_pppm_disp(-order_6,memory);
      thr->init_pppm_disp(order_6,memory);
    }
  }
}
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ namespace LAMMPS_NS {

 protected:
  virtual void allocate();
  virtual void deallocate();

  virtual void compute_gf();
  virtual void compute_gf_6();
+12 −16
Original line number Diff line number Diff line
@@ -52,13 +52,10 @@ PPPMDispTIP4POMP::PPPMDispTIP4POMP(LAMMPS *lmp, int narg, char **arg) :
  suffix_flag |= Suffix::OMP;
}

/* ----------------------------------------------------------------------
   allocate memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */

void PPPMDispTIP4POMP::allocate()
PPPMDispTIP4POMP::~PPPMDispTIP4POMP()
{
  PPPMDispTIP4P::allocate();

#if defined(_OPENMP)
#pragma omp parallel default(none)
@@ -69,25 +66,24 @@ void PPPMDispTIP4POMP::allocate()
#else
    const int tid = 0;
#endif

    if (function[0]) {
      ThrData * thr = fix->get_thr(tid);
      thr->init_pppm(order,memory);
      thr->init_pppm(-order,memory);
    }
    if (function[1] + function[2]) {
      ThrData * thr = fix->get_thr(tid);
      thr->init_pppm_disp(order_6,memory);
      thr->init_pppm_disp(-order_6,memory);
    }
  }
}

/* ----------------------------------------------------------------------
   free memory that depends on # of K-vectors and order
   allocate memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */

void PPPMDispTIP4POMP::deallocate()
void PPPMDispTIP4POMP::allocate()
{
  PPPMDispTIP4P::deallocate();
  PPPMDispTIP4P::allocate();

#if defined(_OPENMP)
#pragma omp parallel default(none)
@@ -98,18 +94,18 @@ void PPPMDispTIP4POMP::deallocate()
#else
    const int tid = 0;
#endif

    if (function[0]) {
      ThrData *thr = fix->get_thr(tid);
      thr->init_pppm(-order,memory);
      thr->init_pppm(order,memory);
    }
    if (function[1] + function[2]) {
      ThrData * thr = fix->get_thr(tid);
      thr->init_pppm_disp(-order_6,memory);
      thr->init_pppm_disp(order_6,memory);
    }
  }
}


/* ----------------------------------------------------------------------
   Compute the modified (hockney-eastwood) coulomb green function
------------------------------------------------------------------------- */
Loading