Commit 852bfaea authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed a bug in random number generation for the CUDA platform. Updated test cases.

parent b2da8475
...@@ -869,7 +869,7 @@ int gpuAllocateInitialBuffers(gpuContext gpu) ...@@ -869,7 +869,7 @@ int gpuAllocateInitialBuffers(gpuContext gpu)
gpu->seed = 1; gpu->seed = 1;
gpu->sim.randomFrames = 20; gpu->sim.randomFrames = 20;
gpu->sim.randomIterations = gpu->sim.randomFrames; gpu->sim.randomIterations = gpu->sim.randomFrames;
gpu->sim.randoms = gpu->sim.randomFrames * gpu->sim.paddedNumberOfAtoms - 5 * GRID; gpu->sim.randoms = gpu->sim.randomFrames * gpu->sim.paddedNumberOfAtoms;
gpu->sim.totalRandoms = gpu->sim.randoms + gpu->sim.paddedNumberOfAtoms; gpu->sim.totalRandoms = gpu->sim.randoms + gpu->sim.paddedNumberOfAtoms;
gpu->sim.totalRandomsTimesTwo = gpu->sim.totalRandoms * 2; gpu->sim.totalRandomsTimesTwo = gpu->sim.totalRandoms * 2;
gpu->psRandom4 = new CUDAStream<float4>(gpu->sim.totalRandomsTimesTwo, 1, "Random4"); gpu->psRandom4 = new CUDAStream<float4>(gpu->sim.totalRandomsTimesTwo, 1, "Random4");
......
...@@ -121,7 +121,7 @@ void testTemperature() { ...@@ -121,7 +121,7 @@ void testTemperature() {
} }
pe /= steps; pe /= steps;
double expected = 0.5*numBonds*BOLTZ*temp; double expected = 0.5*numBonds*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, pe, 20*expected/std::sqrt((double) steps)); ASSERT_EQUAL_TOL(expected, pe, 0.1*expected);
} }
void testConstraints() { void testConstraints() {
......
...@@ -499,15 +499,15 @@ RealOpenMM damping = one;//(RealOpenMM) (iterations%2 == 0 ? 0.5 : 1.0); ...@@ -499,15 +499,15 @@ RealOpenMM damping = one;//(RealOpenMM) (iterations%2 == 0 ? 0.5 : 1.0);
} }
} }
} }
static int sum = 0; // static int sum = 0;
static int count = 0; // static int count = 0;
sum += iterations; // sum += iterations;
count++; // count++;
if (count == 100) { // if (count == 100) {
printf("%d iterations\n", sum); // printf("%d iterations\n", sum);
sum = 0; // sum = 0;
count = 0; // count = 0;
} // }
// diagnostics // diagnostics
......
...@@ -119,7 +119,7 @@ void testTemperature() { ...@@ -119,7 +119,7 @@ void testTemperature() {
} }
pe /= steps; pe /= steps;
double expected = 0.5*numBonds*BOLTZ*temp; double expected = 0.5*numBonds*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, pe, 20*expected/std::sqrt((double) steps)); ASSERT_EQUAL_TOL(expected, pe, 0.1*expected);
} }
void testConstraints() { void testConstraints() {
......
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