Fixing issues with growing memory allocation with multiple init calls
This commit is contained in:
@ -25,12 +25,16 @@ BaseChargeT::BaseCharge() : _compiled(false), _max_bytes(0) {
|
||||
device=&global_device;
|
||||
ans=new Answer<numtyp,acctyp>();
|
||||
nbor=new Neighbor();
|
||||
pair_program=NULL;
|
||||
}
|
||||
|
||||
template <class numtyp, class acctyp>
|
||||
BaseChargeT::~BaseCharge() {
|
||||
delete ans;
|
||||
delete nbor;
|
||||
if (pair_program) delete pair_program;
|
||||
k_pair_fast.clear();
|
||||
k_pair.clear();
|
||||
}
|
||||
|
||||
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,
|
||||
_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();
|
||||
hd_balancer.clear();
|
||||
|
||||
nbor->clear();
|
||||
ans->clear();
|
||||
device->clear();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -291,6 +287,7 @@ void BaseChargeT::compile_kernels(UCL_Device &dev, const void *pair_str,
|
||||
return;
|
||||
|
||||
std::string s_fast=std::string(kname)+"_fast";
|
||||
if (pair_program) delete pair_program;
|
||||
pair_program=new UCL_Program(dev);
|
||||
pair_program->load_string(pair_str,device->compile_string().c_str());
|
||||
k_pair_fast.set_function(*pair_program,s_fast.c_str());
|
||||
|
||||
Reference in New Issue
Block a user