From dbbe077dc2f406e2364907e4c155c5b73cdfb4bf Mon Sep 17 00:00:00 2001 From: Nguyen Date: Wed, 7 Dec 2011 17:02:52 -0500 Subject: [PATCH] clear the first-part kernels in the eam destructor --- lib/gpu/lal_eam.cpp | 12 ++++++++++-- lib/gpu/lal_eam.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/gpu/lal_eam.cpp b/lib/gpu/lal_eam.cpp index 07955373bf..636bf19afd 100644 --- a/lib/gpu/lal_eam.cpp +++ b/lib/gpu/lal_eam.cpp @@ -27,7 +27,8 @@ using namespace LAMMPS_AL; extern Device device; template -EAMT::EAM() : BaseAtomic(), _allocated(false) { +EAMT::EAM() : BaseAtomic(), + _compiled_energy(false), _allocated(false) { } template @@ -70,7 +71,8 @@ int EAMT::init(const int ntypes, double host_cutforcesq, k_energy_fast.set_function(*(this->pair_program),"kernel_energy_fast"); fp_tex.get_texture(*(this->pair_program),"fp_tex"); fp_tex.bind_float(dev_fp,1); - + _compiled_energy = true; + // Initialize timers for selected GPU time_pair2.init(*(this->ucl_device)); time_pair2.zero(); @@ -248,6 +250,12 @@ void EAMT::clear() { time_fp1.clear(); time_fp2.clear(); + if (_compiled_energy) { + k_energy_fast.clear(); + k_energy.clear(); + _compiled_energy=false; + } + this->clear_atomic(); } diff --git a/lib/gpu/lal_eam.h b/lib/gpu/lal_eam.h index b37bd18d69..60e550ffcd 100644 --- a/lib/gpu/lal_eam.h +++ b/lib/gpu/lal_eam.h @@ -119,6 +119,9 @@ class EAM : public BaseAtomic { int _max_fp_size; + /// True of energy kernels are compiled + bool _compiled_energy; + /// Per-atom arrays UCL_H_Vec host_fp; UCL_D_Vec dev_fp;