Unverified Commit b6313621 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1735 from ndtrung81/gpu-mem-leak-init

Gpu mem leak with init invoked multiple times
parents c5b7b964 86f64497
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -25,12 +25,16 @@ BaseAtomicT::BaseAtomic() : _compiled(false), _max_bytes(0) {
  device=&global_device;
  device=&global_device;
  ans=new Answer<numtyp,acctyp>();
  ans=new Answer<numtyp,acctyp>();
  nbor=new Neighbor();
  nbor=new Neighbor();
  pair_program=NULL;
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
BaseAtomicT::~BaseAtomic() {
BaseAtomicT::~BaseAtomic() {
  delete ans;
  delete ans;
  delete nbor;
  delete nbor;
  if (pair_program) delete pair_program;
  k_pair_fast.clear();
  k_pair.clear();
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
@@ -109,19 +113,11 @@ void BaseAtomicT::clear_atomic() {
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);


  if (_compiled) {
    k_pair_fast.clear();
    k_pair.clear();
    delete pair_program;
    _compiled=false;
  }

  time_pair.clear();
  time_pair.clear();
  hd_balancer.clear();
  hd_balancer.clear();


  nbor->clear();
  nbor->clear();
  ans->clear();
  ans->clear();
  device->clear();
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -276,6 +272,7 @@ void BaseAtomicT::compile_kernels(UCL_Device &dev, const void *pair_str,
    return;
    return;


  std::string s_fast=std::string(kname)+"_fast";
  std::string s_fast=std::string(kname)+"_fast";
  if (pair_program) delete pair_program;
  pair_program=new UCL_Program(dev);
  pair_program=new UCL_Program(dev);
  pair_program->load_string(pair_str,device->compile_string().c_str());
  pair_program->load_string(pair_str,device->compile_string().c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
+5 −8
Original line number Original line Diff line number Diff line
@@ -25,12 +25,16 @@ BaseChargeT::BaseCharge() : _compiled(false), _max_bytes(0) {
  device=&global_device;
  device=&global_device;
  ans=new Answer<numtyp,acctyp>();
  ans=new Answer<numtyp,acctyp>();
  nbor=new Neighbor();
  nbor=new Neighbor();
  pair_program=NULL;
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
BaseChargeT::~BaseCharge() {
BaseChargeT::~BaseCharge() {
  delete ans;
  delete ans;
  delete nbor;
  delete nbor;
  if (pair_program) delete pair_program;
  k_pair_fast.clear();
  k_pair.clear();
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
@@ -111,19 +115,11 @@ void BaseChargeT::clear_atomic() {
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);


  if (_compiled) {
    k_pair_fast.clear();
    k_pair.clear();
    delete pair_program;
    _compiled=false;
  }

  time_pair.clear();
  time_pair.clear();
  hd_balancer.clear();
  hd_balancer.clear();


  nbor->clear();
  nbor->clear();
  ans->clear();
  ans->clear();
  device->clear();
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -291,6 +287,7 @@ void BaseChargeT::compile_kernels(UCL_Device &dev, const void *pair_str,
    return;
    return;


  std::string s_fast=std::string(kname)+"_fast";
  std::string s_fast=std::string(kname)+"_fast";
  if (pair_program) delete pair_program;
  pair_program=new UCL_Program(dev);
  pair_program=new UCL_Program(dev);
  pair_program->load_string(pair_str,device->compile_string().c_str());
  pair_program->load_string(pair_str,device->compile_string().c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
+5 −8
Original line number Original line Diff line number Diff line
@@ -25,12 +25,16 @@ BaseDipoleT::BaseDipole() : _compiled(false), _max_bytes(0) {
  device=&global_device;
  device=&global_device;
  ans=new Answer<numtyp,acctyp>();
  ans=new Answer<numtyp,acctyp>();
  nbor=new Neighbor();
  nbor=new Neighbor();
  pair_program=NULL;
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
BaseDipoleT::~BaseDipole() {
BaseDipoleT::~BaseDipole() {
  delete ans;
  delete ans;
  delete nbor;
  delete nbor;
  if (pair_program) delete pair_program;
  k_pair_fast.clear();
  k_pair.clear();
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
@@ -113,19 +117,11 @@ void BaseDipoleT::clear_atomic() {
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);


  if (_compiled) {
    k_pair_fast.clear();
    k_pair.clear();
    delete pair_program;
    _compiled=false;
  }

  time_pair.clear();
  time_pair.clear();
  hd_balancer.clear();
  hd_balancer.clear();


  nbor->clear();
  nbor->clear();
  ans->clear();
  ans->clear();
  device->clear();
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -299,6 +295,7 @@ void BaseDipoleT::compile_kernels(UCL_Device &dev, const void *pair_str,
    return;
    return;


  std::string s_fast=std::string(kname)+"_fast";
  std::string s_fast=std::string(kname)+"_fast";
  if (pair_program) delete pair_program;
  pair_program=new UCL_Program(dev);
  pair_program=new UCL_Program(dev);
  pair_program->load_string(pair_str,device->compile_string().c_str());
  pair_program->load_string(pair_str,device->compile_string().c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
+5 −8
Original line number Original line Diff line number Diff line
@@ -25,12 +25,16 @@ BaseDPDT::BaseDPD() : _compiled(false), _max_bytes(0) {
  device=&global_device;
  device=&global_device;
  ans=new Answer<numtyp,acctyp>();
  ans=new Answer<numtyp,acctyp>();
  nbor=new Neighbor();
  nbor=new Neighbor();
  pair_program=NULL;
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
BaseDPDT::~BaseDPD() {
BaseDPDT::~BaseDPD() {
  delete ans;
  delete ans;
  delete nbor;
  delete nbor;
  if (pair_program) delete pair_program;
  k_pair_fast.clear();
  k_pair.clear();
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
@@ -112,19 +116,11 @@ void BaseDPDT::clear_atomic() {
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
  device->output_times(time_pair,*ans,*nbor,avg_split,_max_bytes+_max_an_bytes,
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);
                       _gpu_overhead,_driver_overhead,_threads_per_atom,screen);


  if (_compiled) {
    k_pair_fast.clear();
    k_pair.clear();
    delete pair_program;
    _compiled=false;
  }

  time_pair.clear();
  time_pair.clear();
  hd_balancer.clear();
  hd_balancer.clear();


  nbor->clear();
  nbor->clear();
  ans->clear();
  ans->clear();
  device->clear();
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -297,6 +293,7 @@ void BaseDPDT::compile_kernels(UCL_Device &dev, const void *pair_str,
    return;
    return;


  std::string s_fast=std::string(kname)+"_fast";
  std::string s_fast=std::string(kname)+"_fast";
  if (pair_program) delete pair_program;
  pair_program=new UCL_Program(dev);
  pair_program=new UCL_Program(dev);
  pair_program->load_string(pair_str,device->compile_string().c_str());
  pair_program->load_string(pair_str,device->compile_string().c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
  k_pair_fast.set_function(*pair_program,s_fast.c_str());
+17 −15
Original line number Original line Diff line number Diff line
@@ -33,12 +33,25 @@ BaseEllipsoidT::BaseEllipsoid() : _compiled(false), _max_bytes(0) {
  device=&global_device;
  device=&global_device;
  ans=new Answer<numtyp,acctyp>();
  ans=new Answer<numtyp,acctyp>();
  nbor=new Neighbor();
  nbor=new Neighbor();
  nbor_program=NULL;
  ellipsoid_program=NULL;
  lj_program=NULL;
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
BaseEllipsoidT::~BaseEllipsoid() {
BaseEllipsoidT::~BaseEllipsoid() {
  delete ans;
  delete ans;
  delete nbor;
  delete nbor;
  k_nbor_fast.clear();
  k_nbor.clear();
  k_ellipsoid.clear();
  k_ellipsoid_sphere.clear();
  k_sphere_ellipsoid.clear();
  k_lj_fast.clear();
  k_lj.clear();
  if (nbor_program) delete nbor_program;
  if (ellipsoid_program) delete ellipsoid_program;
  if (lj_program) delete lj_program;
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
@@ -146,20 +159,6 @@ void BaseEllipsoidT::clear_base() {
  output_times();
  output_times();
  host_olist.clear();
  host_olist.clear();


  if (_compiled) {
    k_nbor_fast.clear();
    k_nbor.clear();
    k_ellipsoid.clear();
    k_ellipsoid_sphere.clear();
    k_sphere_ellipsoid.clear();
    k_lj_fast.clear();
    k_lj.clear();
    delete nbor_program;
    delete ellipsoid_program;
    delete lj_program;
    _compiled=false;
  }

  time_nbor1.clear();
  time_nbor1.clear();
  time_ellipsoid.clear();
  time_ellipsoid.clear();
  time_nbor2.clear();
  time_nbor2.clear();
@@ -171,7 +170,6 @@ void BaseEllipsoidT::clear_base() {


  nbor->clear();
  nbor->clear();
  ans->clear();
  ans->clear();
  device->clear();
}
}


template <class numtyp, class acctyp>
template <class numtyp, class acctyp>
@@ -437,6 +435,7 @@ int** BaseEllipsoidT::compute(const int ago, const int inum_full, const int nall
  ans->copy_answers(eflag,vflag,eatom,vatom);
  ans->copy_answers(eflag,vflag,eatom,vatom);
  device->add_ans_object(ans);
  device->add_ans_object(ans);
  hd_balancer.stop_timer();
  hd_balancer.stop_timer();

  return nbor->host_jlist.begin()-host_start;
  return nbor->host_jlist.begin()-host_start;
}
}


@@ -462,18 +461,21 @@ void BaseEllipsoidT::compile_kernels(UCL_Device &dev,


  std::string flags=device->compile_string();
  std::string flags=device->compile_string();


  if (nbor_program) delete nbor_program;
  nbor_program=new UCL_Program(dev);
  nbor_program=new UCL_Program(dev);
  nbor_program->load_string(ellipsoid_nbor,flags.c_str());
  nbor_program->load_string(ellipsoid_nbor,flags.c_str());
  k_nbor_fast.set_function(*nbor_program,"kernel_nbor_fast");
  k_nbor_fast.set_function(*nbor_program,"kernel_nbor_fast");
  k_nbor.set_function(*nbor_program,"kernel_nbor");
  k_nbor.set_function(*nbor_program,"kernel_nbor");
  neigh_tex.get_texture(*nbor_program,"pos_tex");
  neigh_tex.get_texture(*nbor_program,"pos_tex");


  if (ellipsoid_program) delete ellipsoid_program;
  ellipsoid_program=new UCL_Program(dev);
  ellipsoid_program=new UCL_Program(dev);
  ellipsoid_program->load_string(ellipsoid_string,flags.c_str());
  ellipsoid_program->load_string(ellipsoid_string,flags.c_str());
  k_ellipsoid.set_function(*ellipsoid_program,kname);
  k_ellipsoid.set_function(*ellipsoid_program,kname);
  pos_tex.get_texture(*ellipsoid_program,"pos_tex");
  pos_tex.get_texture(*ellipsoid_program,"pos_tex");
  quat_tex.get_texture(*ellipsoid_program,"quat_tex");
  quat_tex.get_texture(*ellipsoid_program,"quat_tex");


  if (lj_program) delete lj_program;
  lj_program=new UCL_Program(dev);
  lj_program=new UCL_Program(dev);
  lj_program->load_string(lj_string,flags.c_str());
  lj_program->load_string(lj_string,flags.c_str());
  k_sphere_ellipsoid.set_function(*lj_program,s_sphere_ellipsoid.c_str());
  k_sphere_ellipsoid.set_function(*lj_program,s_sphere_ellipsoid.c_str());
Loading