Commit a170606b authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed some Valgrind warnings

parent 15899649
...@@ -223,7 +223,7 @@ void CudaCalcCustomBondForceKernel::initialize(const System& system, const Custo ...@@ -223,7 +223,7 @@ void CudaCalcCustomBondForceKernel::initialize(const System& system, const Custo
} }
gpuSetCustomBondParameters(data.gpu, particle1, particle2, params, force.getEnergyFunction(), paramNames, globalParamNames); gpuSetCustomBondParameters(data.gpu, particle1, particle2, params, force.getEnergyFunction(), paramNames, globalParamNames);
if (globalParamValues.size() > 0) if (globalParamValues.size() > 0)
SetCustomBondGlobalParams(&globalParamValues[0]); SetCustomBondGlobalParams(globalParamValues);
} }
void CudaCalcCustomBondForceKernel::executeForces(ContextImpl& context) { void CudaCalcCustomBondForceKernel::executeForces(ContextImpl& context) {
...@@ -246,7 +246,7 @@ void CudaCalcCustomBondForceKernel::updateGlobalParams(ContextImpl& context) { ...@@ -246,7 +246,7 @@ void CudaCalcCustomBondForceKernel::updateGlobalParams(ContextImpl& context) {
globalParamValues[i] = value; globalParamValues[i] = value;
} }
if (changed) if (changed)
SetCustomBondGlobalParams(&globalParamValues[0]); SetCustomBondGlobalParams(globalParamValues);
} }
CudaCalcHarmonicAngleForceKernel::~CudaCalcHarmonicAngleForceKernel() { CudaCalcHarmonicAngleForceKernel::~CudaCalcHarmonicAngleForceKernel() {
...@@ -514,7 +514,7 @@ void CudaCalcCustomNonbondedForceKernel::initialize(const System& system, const ...@@ -514,7 +514,7 @@ void CudaCalcCustomNonbondedForceKernel::initialize(const System& system, const
} }
gpuSetCustomNonbondedParameters(gpu, parameters, exclusionList, method, (float) force.getCutoffDistance(), force.getEnergyFunction(), paramNames, globalParamNames); gpuSetCustomNonbondedParameters(gpu, parameters, exclusionList, method, (float) force.getCutoffDistance(), force.getEnergyFunction(), paramNames, globalParamNames);
if (globalParamValues.size() > 0) if (globalParamValues.size() > 0)
SetCustomNonbondedGlobalParams(&globalParamValues[0]); SetCustomNonbondedGlobalParams(globalParamValues);
} }
void CudaCalcCustomNonbondedForceKernel::executeForces(ContextImpl& context) { void CudaCalcCustomNonbondedForceKernel::executeForces(ContextImpl& context) {
...@@ -535,7 +535,7 @@ void CudaCalcCustomNonbondedForceKernel::updateGlobalParams(ContextImpl& context ...@@ -535,7 +535,7 @@ void CudaCalcCustomNonbondedForceKernel::updateGlobalParams(ContextImpl& context
globalParamValues[i] = value; globalParamValues[i] = value;
} }
if (changed) if (changed)
SetCustomNonbondedGlobalParams(&globalParamValues[0]); SetCustomNonbondedGlobalParams(globalParamValues);
} }
CudaCalcGBSAOBCForceKernel::~CudaCalcGBSAOBCForceKernel() { CudaCalcGBSAOBCForceKernel::~CudaCalcGBSAOBCForceKernel() {
...@@ -613,7 +613,7 @@ void CudaCalcCustomExternalForceKernel::initialize(const System& system, const C ...@@ -613,7 +613,7 @@ void CudaCalcCustomExternalForceKernel::initialize(const System& system, const C
} }
gpuSetCustomExternalParameters(data.gpu, particle, params, force.getEnergyFunction(), paramNames, globalParamNames); gpuSetCustomExternalParameters(data.gpu, particle, params, force.getEnergyFunction(), paramNames, globalParamNames);
if (globalParamValues.size() > 0) if (globalParamValues.size() > 0)
SetCustomExternalGlobalParams(&globalParamValues[0]); SetCustomExternalGlobalParams(globalParamValues);
} }
void CudaCalcCustomExternalForceKernel::executeForces(ContextImpl& context) { void CudaCalcCustomExternalForceKernel::executeForces(ContextImpl& context) {
...@@ -636,7 +636,7 @@ void CudaCalcCustomExternalForceKernel::updateGlobalParams(ContextImpl& context) ...@@ -636,7 +636,7 @@ void CudaCalcCustomExternalForceKernel::updateGlobalParams(ContextImpl& context)
globalParamValues[i] = value; globalParamValues[i] = value;
} }
if (changed) if (changed)
SetCustomExternalGlobalParams(&globalParamValues[0]); SetCustomExternalGlobalParams(globalParamValues);
} }
static void initializeIntegration(const System& system, CudaPlatform::PlatformData& data, const Integrator& integrator) { static void initializeIntegration(const System& system, CudaPlatform::PlatformData& data, const Integrator& integrator) {
......
...@@ -113,10 +113,10 @@ extern void SetRandomSim(gpuContext gpu); ...@@ -113,10 +113,10 @@ extern void SetRandomSim(gpuContext gpu);
extern void GetRandomSim(gpuContext gpu); extern void GetRandomSim(gpuContext gpu);
extern void SetCustomBondForceExpression(const Expression<128>& expression); extern void SetCustomBondForceExpression(const Expression<128>& expression);
extern void SetCustomBondEnergyExpression(const Expression<128>& expression); extern void SetCustomBondEnergyExpression(const Expression<128>& expression);
extern void SetCustomBondGlobalParams(float* paramValues); extern void SetCustomBondGlobalParams(const std::vector<float>& paramValues);
extern void SetCustomExternalForceExpressions(const Expression<128>& expressionX, const Expression<128>& expressionY, const Expression<128>& expressionZ); extern void SetCustomExternalForceExpressions(const Expression<128>& expressionX, const Expression<128>& expressionY, const Expression<128>& expressionZ);
extern void SetCustomExternalEnergyExpression(const Expression<128>& expression); extern void SetCustomExternalEnergyExpression(const Expression<128>& expression);
extern void SetCustomExternalGlobalParams(float* paramValues); extern void SetCustomExternalGlobalParams(const std::vector<float>& paramValues);
extern void SetCustomNonbondedForceExpression(const Expression<128>& expression); extern void SetCustomNonbondedForceExpression(const Expression<128>& expression);
extern void SetCustomNonbondedEnergyExpression(const Expression<128>& expression); extern void SetCustomNonbondedEnergyExpression(const Expression<128>& expression);
extern void SetCustomNonbondedGlobalParams(float* paramValues); extern void SetCustomNonbondedGlobalParams(const std::vector<float>& paramValues);
...@@ -1863,6 +1863,7 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync) ...@@ -1863,6 +1863,7 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
for (int i = 0; i < MAX_TABULATED_FUNCTIONS; i++) for (int i = 0; i < MAX_TABULATED_FUNCTIONS; i++)
gpu->tabulatedFunctions[i].coefficients = NULL; gpu->tabulatedFunctions[i].coefficients = NULL;
gpu->sim.customExpressionStackSize = 0; gpu->sim.customExpressionStackSize = 0;
gpu->sim.customBonds = 0;
// Initialize output buffer before reading parameters // Initialize output buffer before reading parameters
gpu->pOutputBufferCounter = new unsigned int[gpu->sim.paddedNumberOfAtoms]; gpu->pOutputBufferCounter = new unsigned int[gpu->sim.paddedNumberOfAtoms];
......
...@@ -70,10 +70,10 @@ void SetCustomBondEnergyExpression(const Expression<128>& expression) ...@@ -70,10 +70,10 @@ void SetCustomBondEnergyExpression(const Expression<128>& expression)
RTERROR(status, "SetCustomBondEnergyExpression: cudaMemcpyToSymbol failed"); RTERROR(status, "SetCustomBondEnergyExpression: cudaMemcpyToSymbol failed");
} }
void SetCustomBondGlobalParams(float* paramValues) void SetCustomBondGlobalParams(const vector<float>& paramValues)
{ {
cudaError_t status; cudaError_t status;
status = cudaMemcpyToSymbol(globalParams, paramValues, sizeof(globalParams)); status = cudaMemcpyToSymbol(globalParams, &paramValues[0], paramValues.size()*sizeof(float));
RTERROR(status, "SetCustomBondGlobalParams: cudaMemcpyToSymbol failed"); RTERROR(status, "SetCustomBondGlobalParams: cudaMemcpyToSymbol failed");
} }
......
...@@ -74,10 +74,10 @@ void SetCustomExternalEnergyExpression(const Expression<128>& expression) ...@@ -74,10 +74,10 @@ void SetCustomExternalEnergyExpression(const Expression<128>& expression)
RTERROR(status, "SetCustomExternalEnergyExpression: cudaMemcpyToSymbol failed"); RTERROR(status, "SetCustomExternalEnergyExpression: cudaMemcpyToSymbol failed");
} }
void SetCustomExternalGlobalParams(float* paramValues) void SetCustomExternalGlobalParams(const vector<float>& paramValues)
{ {
cudaError_t status; cudaError_t status;
status = cudaMemcpyToSymbol(globalParams, paramValues, sizeof(globalParams)); status = cudaMemcpyToSymbol(globalParams, &paramValues[0], paramValues.size()*sizeof(float));
RTERROR(status, "SetCustomExternalGlobalParams: cudaMemcpyToSymbol failed"); RTERROR(status, "SetCustomExternalGlobalParams: cudaMemcpyToSymbol failed");
} }
......
...@@ -83,10 +83,10 @@ void SetCustomNonbondedEnergyExpression(const Expression<128>& expression) ...@@ -83,10 +83,10 @@ void SetCustomNonbondedEnergyExpression(const Expression<128>& expression)
RTERROR(status, "SetCustomNonbondedEnergyExpression: cudaMemcpyToSymbol failed"); RTERROR(status, "SetCustomNonbondedEnergyExpression: cudaMemcpyToSymbol failed");
} }
void SetCustomNonbondedGlobalParams(float* paramValues) void SetCustomNonbondedGlobalParams(const vector<float>& paramValues)
{ {
cudaError_t status; cudaError_t status;
status = cudaMemcpyToSymbol(globalParams, paramValues, sizeof(globalParams)); status = cudaMemcpyToSymbol(globalParams, &paramValues[0], paramValues.size()*sizeof(float));
RTERROR(status, "SetCustomNonbondedGlobalParams: cudaMemcpyToSymbol failed"); RTERROR(status, "SetCustomNonbondedGlobalParams: cudaMemcpyToSymbol failed");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment