Skip to content

Commit

Permalink
Free the GPU variables allocated for the Exp6 Forcefield
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed Sep 2, 2023
1 parent dfbbd92 commit 162e1ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/FFExp6.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct FF_EXP6 : public FFParticle {
: FFParticle(ff), expConst(NULL), expConst_1_4(NULL), rMin(NULL),
rMin_1_4(NULL), rMaxSq(NULL), rMaxSq_1_4(NULL) {}
virtual ~FF_EXP6() {
#ifdef GOMC_CUDA
DestroyExp6CUDAVars(ff.particles->getCUDAVars());
#endif
delete[] expConst;
delete[] expConst_1_4;
delete[] rMin;
Expand Down Expand Up @@ -141,7 +144,7 @@ inline void FF_EXP6::Init(ff_setup::Particle const &mie,
}
}
#ifdef GOMC_CUDA
InitExp6Variables(varCUDA, rMin, expConst, rMaxSq, size);
InitExp6VariablesCUDA(varCUDA, rMin, expConst, rMaxSq, size);
#endif
}

Expand Down
10 changes: 8 additions & 2 deletions src/GPU/ConstantDefinitionsCUDAKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ void InitCoordinatesCUDA(VariablesCUDA *vars, uint atomNumber,
checkLastErrorCUDA(__FILE__, __LINE__);
}

void InitExp6Variables(VariablesCUDA *vars, double *rMin, double *expConst,
double *rMaxSq, uint size) {
void InitExp6VariablesCUDA(VariablesCUDA *vars, double *rMin, double *expConst,
double *rMaxSq, uint size) {
CUMALLOC((void **)&vars->gpu_rMin, size * sizeof(double));
CUMALLOC((void **)&vars->gpu_rMaxSq, size * sizeof(double));
CUMALLOC((void **)&vars->gpu_expConst, size * sizeof(double));
Expand Down Expand Up @@ -309,6 +309,12 @@ void DestroyEwaldCUDAVars(VariablesCUDA *vars) {
delete[] vars->gpu_hsqrRef;
}

void DestroyExp6CUDAVars(VariablesCUDA *vars) {
CUFREE(vars->gpu_rMin);
CUFREE(vars->gpu_rMaxSq);
CUFREE(vars->gpu_expConst);
}

void DestroyCUDAVars(VariablesCUDA *vars) {
CUFREE(vars->gpu_sigmaSq);
CUFREE(vars->gpu_epsilon_Cn);
Expand Down
5 changes: 3 additions & 2 deletions src/GPU/ConstantDefinitionsCUDAKernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void InitGPUForceField(VariablesCUDA &vars, double const *sigmaSq,
void InitCoordinatesCUDA(VariablesCUDA *vars, uint atomNumber,
uint maxAtomsInMol, uint maxMolNumber);
void InitEwaldVariablesCUDA(VariablesCUDA *vars, uint imageTotal);
void InitExp6VariablesCUDA(VariablesCUDA *vars, double *rMin, double *expConst,
double *rMaxSq, uint size);
void CopyCurrentToRefCUDA(VariablesCUDA *vars, uint box, uint imageTotal);
void CopyRefToNewCUDA(VariablesCUDA *vars, uint box, uint imageTotal);
void UpdateRecipVecCUDA(VariablesCUDA *vars, uint box);
Expand All @@ -41,9 +43,8 @@ void UpdateInvCellBasisCUDA(VariablesCUDA *vars, uint box,
double *invCellBasis_x, double *invCellBasis_y,
double *invCellBasis_z);
void DestroyEwaldCUDAVars(VariablesCUDA *vars);
void DestroyExp6CUDAVars(VariablesCUDA *vars);
void DestroyCUDAVars(VariablesCUDA *vars);
void InitExp6Variables(VariablesCUDA *vars, double *rMin, double *expConst,
double *rMaxSq, uint size);

#endif /*GOMC_CUDA*/
#endif /*CONSTANT_DEFINITIONS_CUDA_KERNEL*/

0 comments on commit 162e1ce

Please sign in to comment.