Commit 133c1a52 authored by Peter Eastman's avatar Peter Eastman
Browse files

Avoid uninitialized memory

parent c7e1b591
...@@ -827,9 +827,9 @@ void CudaContext::validateMolecules() { ...@@ -827,9 +827,9 @@ void CudaContext::validateMolecules() {
vector<int4> newCellOffsets(numAtoms); vector<int4> newCellOffsets(numAtoms);
if (useDoublePrecision) { if (useDoublePrecision) {
vector<double4> oldPosq(paddedNumAtoms); vector<double4> oldPosq(paddedNumAtoms);
vector<double4> newPosq(paddedNumAtoms); vector<double4> newPosq(paddedNumAtoms, make_double4(0, 0, 0, 0));
vector<double4> oldVelm(paddedNumAtoms); vector<double4> oldVelm(paddedNumAtoms);
vector<double4> newVelm(paddedNumAtoms); vector<double4> newVelm(paddedNumAtoms, make_double4(0, 0, 0, 0));
posq->download(oldPosq); posq->download(oldPosq);
velm->download(oldVelm); velm->download(oldVelm);
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numAtoms; i++) {
...@@ -843,11 +843,11 @@ void CudaContext::validateMolecules() { ...@@ -843,11 +843,11 @@ void CudaContext::validateMolecules() {
} }
else if (useMixedPrecision) { else if (useMixedPrecision) {
vector<float4> oldPosq(paddedNumAtoms); vector<float4> oldPosq(paddedNumAtoms);
vector<float4> newPosq(paddedNumAtoms); vector<float4> newPosq(paddedNumAtoms, make_float4(0, 0, 0, 0));
vector<float4> oldPosqCorrection(paddedNumAtoms); vector<float4> oldPosqCorrection(paddedNumAtoms);
vector<float4> newPosqCorrection(paddedNumAtoms); vector<float4> newPosqCorrection(paddedNumAtoms, make_float4(0, 0, 0, 0));
vector<double4> oldVelm(paddedNumAtoms); vector<double4> oldVelm(paddedNumAtoms);
vector<double4> newVelm(paddedNumAtoms); vector<double4> newVelm(paddedNumAtoms, make_double4(0, 0, 0, 0));
posq->download(oldPosq); posq->download(oldPosq);
velm->download(oldVelm); velm->download(oldVelm);
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numAtoms; i++) {
...@@ -863,9 +863,9 @@ void CudaContext::validateMolecules() { ...@@ -863,9 +863,9 @@ void CudaContext::validateMolecules() {
} }
else { else {
vector<float4> oldPosq(paddedNumAtoms); vector<float4> oldPosq(paddedNumAtoms);
vector<float4> newPosq(paddedNumAtoms); vector<float4> newPosq(paddedNumAtoms, make_float4(0, 0, 0, 0));
vector<float4> oldVelm(paddedNumAtoms); vector<float4> oldVelm(paddedNumAtoms);
vector<float4> newVelm(paddedNumAtoms); vector<float4> newVelm(paddedNumAtoms, make_float4(0, 0, 0, 0));
posq->download(oldPosq); posq->download(oldPosq);
velm->download(oldVelm); velm->download(oldVelm);
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numAtoms; i++) {
...@@ -905,9 +905,9 @@ template <class Real, class Real4, class Mixed, class Mixed4> ...@@ -905,9 +905,9 @@ template <class Real, class Real4, class Mixed, class Mixed4>
void CudaContext::reorderAtomsImpl(bool enforcePeriodic) { void CudaContext::reorderAtomsImpl(bool enforcePeriodic) {
// Find the range of positions and the number of bins along each axis. // Find the range of positions and the number of bins along each axis.
vector<Real4> oldPosq(paddedNumAtoms); vector<Real4> oldPosq(paddedNumAtoms, (Real4) {0, 0, 0, 0});
vector<Real4> oldPosqCorrection(paddedNumAtoms); vector<Real4> oldPosqCorrection(paddedNumAtoms, (Real4) {0, 0, 0, 0});
vector<Mixed4> oldVelm(paddedNumAtoms); vector<Mixed4> oldVelm(paddedNumAtoms, (Mixed4) {0, 0, 0, 0});
posq->download(oldPosq); posq->download(oldPosq);
velm->download(oldVelm); velm->download(oldVelm);
if (useMixedPrecision) if (useMixedPrecision)
......
...@@ -1409,7 +1409,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon ...@@ -1409,7 +1409,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
CudaArray& posq = cu.getPosq(); CudaArray& posq = cu.getPosq();
float4* posqf = (float4*) cu.getPinnedBuffer(); float4* posqf = (float4*) cu.getPinnedBuffer();
double4* posqd = (double4*) cu.getPinnedBuffer(); double4* posqd = (double4*) cu.getPinnedBuffer();
vector<float2> sigmaEpsilonVector(cu.getPaddedNumAtoms()); vector<float2> sigmaEpsilonVector(cu.getPaddedNumAtoms(), make_float2(0, 0));
vector<vector<int> > exclusionList(numParticles); vector<vector<int> > exclusionList(numParticles);
double sumSquaredCharges = 0.0; double sumSquaredCharges = 0.0;
hasCoulomb = false; hasCoulomb = false;
...@@ -1747,7 +1747,7 @@ void CudaCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& context, ...@@ -1747,7 +1747,7 @@ void CudaCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& context,
posq.download(cu.getPinnedBuffer()); posq.download(cu.getPinnedBuffer());
float4* posqf = (float4*) cu.getPinnedBuffer(); float4* posqf = (float4*) cu.getPinnedBuffer();
double4* posqd = (double4*) cu.getPinnedBuffer(); double4* posqd = (double4*) cu.getPinnedBuffer();
vector<float2> sigmaEpsilonVector(cu.getPaddedNumAtoms()); vector<float2> sigmaEpsilonVector(cu.getPaddedNumAtoms(), make_float2(0, 0));
double sumSquaredCharges = 0.0; double sumSquaredCharges = 0.0;
const vector<int>& order = cu.getAtomIndex(); const vector<int>& order = cu.getAtomIndex();
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
...@@ -2026,7 +2026,7 @@ void CudaCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOBCF ...@@ -2026,7 +2026,7 @@ void CudaCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOBCF
CudaArray& posq = cu.getPosq(); CudaArray& posq = cu.getPosq();
float4* posqf = (float4*) cu.getPinnedBuffer(); float4* posqf = (float4*) cu.getPinnedBuffer();
double4* posqd = (double4*) cu.getPinnedBuffer(); double4* posqd = (double4*) cu.getPinnedBuffer();
vector<float2> paramsVector(cu.getPaddedNumAtoms()); vector<float2> paramsVector(cu.getPaddedNumAtoms(), make_float2(1, 1));
const double dielectricOffset = 0.009; const double dielectricOffset = 0.009;
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
double charge, radius, scalingFactor; double charge, radius, scalingFactor;
...@@ -2144,7 +2144,7 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c ...@@ -2144,7 +2144,7 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
float4* posqf = (float4*) cu.getPinnedBuffer(); float4* posqf = (float4*) cu.getPinnedBuffer();
double4* posqd = (double4*) cu.getPinnedBuffer(); double4* posqd = (double4*) cu.getPinnedBuffer();
posq.download(cu.getPinnedBuffer()); posq.download(cu.getPinnedBuffer());
vector<float2> paramsVector(cu.getPaddedNumAtoms()); vector<float2> paramsVector(cu.getPaddedNumAtoms(), make_float2(1, 1));
const double dielectricOffset = 0.009; const double dielectricOffset = 0.009;
for (int i = 0; i < numParticles; i++) { for (int i = 0; i < numParticles; i++) {
double charge, radius, scalingFactor; double charge, radius, scalingFactor;
......
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