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

Fixed bugs with kernel (re)compiling when the global device got clear and reinitialized
This commit is contained in:
Axel Kohlmeyer
2020-01-08 16:17:13 -05:00
committed by GitHub
6 changed files with 24 additions and 6 deletions

View File

@ -26,15 +26,16 @@ BaseAtomicT::BaseAtomic() : _compiled(false), _max_bytes(0) {
ans=new Answer<numtyp,acctyp>(); ans=new Answer<numtyp,acctyp>();
nbor=new Neighbor(); nbor=new Neighbor();
pair_program=NULL; pair_program=NULL;
ucl_device=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_fast.clear();
k_pair.clear(); k_pair.clear();
if (pair_program) delete pair_program;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -78,6 +79,8 @@ int BaseAtomicT::init_atomic(const int nlocal, const int nall,
if (success!=0) if (success!=0)
return success; return success;
if (ucl_device!=device->gpu) _compiled=false;
ucl_device=device->gpu; ucl_device=device->gpu;
atom=&device->atom; atom=&device->atom;

View File

@ -26,15 +26,16 @@ BaseChargeT::BaseCharge() : _compiled(false), _max_bytes(0) {
ans=new Answer<numtyp,acctyp>(); ans=new Answer<numtyp,acctyp>();
nbor=new Neighbor(); nbor=new Neighbor();
pair_program=NULL; pair_program=NULL;
ucl_device=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_fast.clear();
k_pair.clear(); k_pair.clear();
if (pair_program) delete pair_program;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -78,6 +79,8 @@ int BaseChargeT::init_atomic(const int nlocal, const int nall,
if (success!=0) if (success!=0)
return success; return success;
if (ucl_device!=device->gpu) _compiled=false;
ucl_device=device->gpu; ucl_device=device->gpu;
atom=&device->atom; atom=&device->atom;

View File

@ -26,15 +26,16 @@ BaseDipoleT::BaseDipole() : _compiled(false), _max_bytes(0) {
ans=new Answer<numtyp,acctyp>(); ans=new Answer<numtyp,acctyp>();
nbor=new Neighbor(); nbor=new Neighbor();
pair_program=NULL; pair_program=NULL;
ucl_device=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_fast.clear();
k_pair.clear(); k_pair.clear();
if (pair_program) delete pair_program;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -79,6 +80,8 @@ int BaseDipoleT::init_atomic(const int nlocal, const int nall,
if (success!=0) if (success!=0)
return success; return success;
if (ucl_device!=device->gpu) _compiled=false;
ucl_device=device->gpu; ucl_device=device->gpu;
atom=&device->atom; atom=&device->atom;

View File

@ -26,15 +26,16 @@ BaseDPDT::BaseDPD() : _compiled(false), _max_bytes(0) {
ans=new Answer<numtyp,acctyp>(); ans=new Answer<numtyp,acctyp>();
nbor=new Neighbor(); nbor=new Neighbor();
pair_program=NULL; pair_program=NULL;
ucl_device=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_fast.clear();
k_pair.clear(); k_pair.clear();
if (pair_program) delete pair_program;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -79,6 +80,8 @@ int BaseDPDT::init_atomic(const int nlocal, const int nall,
if (success!=0) if (success!=0)
return success; return success;
if (ucl_device!=device->gpu) _compiled=false;
ucl_device=device->gpu; ucl_device=device->gpu;
atom=&device->atom; atom=&device->atom;

View File

@ -36,6 +36,7 @@ BaseEllipsoidT::BaseEllipsoid() : _compiled(false), _max_bytes(0) {
nbor_program=NULL; nbor_program=NULL;
ellipsoid_program=NULL; ellipsoid_program=NULL;
lj_program=NULL; lj_program=NULL;
ucl_device=NULL;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -92,7 +93,9 @@ int BaseEllipsoidT::init_base(const int nlocal, const int nall,
max_nbors,cell_size,true,1); max_nbors,cell_size,true,1);
if (success!=0) if (success!=0)
return success; return success;
if (ucl_device!=device->gpu) _compiled=false;
ucl_device=device->gpu; ucl_device=device->gpu;
atom=&device->atom; atom=&device->atom;

View File

@ -28,6 +28,7 @@ BaseThreeT::BaseThree() : _compiled(false), _max_bytes(0) {
ans2=new Answer<numtyp,acctyp>(); ans2=new Answer<numtyp,acctyp>();
#endif #endif
pair_program=NULL; pair_program=NULL;
ucl_device=NULL;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -37,12 +38,12 @@ BaseThreeT::~BaseThree() {
#ifdef THREE_CONCURRENT #ifdef THREE_CONCURRENT
delete ans2; delete ans2;
#endif #endif
if (pair_program) delete pair_program;
k_three_center.clear(); k_three_center.clear();
k_three_end.clear(); k_three_end.clear();
k_three_end_vatom.clear(); k_three_end_vatom.clear();
k_pair.clear(); k_pair.clear();
k_short_nbor.clear(); k_short_nbor.clear();
if (pair_program) delete pair_program;
} }
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
@ -94,6 +95,8 @@ int BaseThreeT::init_three(const int nlocal, const int nall,
if (success!=0) if (success!=0)
return success; return success;
if (ucl_device!=device->gpu) _compiled=false;
ucl_device=device->gpu; ucl_device=device->gpu;
atom=&device->atom; atom=&device->atom;