"platforms/vscode:/vscode.git/clone" did not exist on "5739788aea5f2a8da1996f1d7147bb33225edc78"
Commit e04a7368 authored by Jason Swails's avatar Jason Swails
Browse files

Attempt to move the implementation of separate osrngseed() calls for each

Context into the platform rather than hacked into getRandomNumberSeed...

Someone please check this.
parent 2284ac61
...@@ -105,8 +105,6 @@ public: ...@@ -105,8 +105,6 @@ public:
* Get the random number seed. See setRandomNumberSeed() for details. * Get the random number seed. See setRandomNumberSeed() for details.
*/ */
int getRandomNumberSeed() const { int getRandomNumberSeed() const {
if (randomNumberSeed == 0)
return osrngseed();
return randomNumberSeed; return randomNumberSeed;
} }
/** /**
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "Vec3.h" #include "Vec3.h"
#include <string> #include <string>
#include "internal/windowsExport.h" #include "internal/windowsExport.h"
#include "openmm/internal/OSRngSeed.h"
namespace OpenMM { namespace OpenMM {
...@@ -160,8 +159,6 @@ public: ...@@ -160,8 +159,6 @@ public:
* Get the random number seed. See setRandomNumberSeed() for details. * Get the random number seed. See setRandomNumberSeed() for details.
*/ */
int getRandomNumberSeed() const { int getRandomNumberSeed() const {
if (randomNumberSeed == 0)
return osrngseed();
return randomNumberSeed; return randomNumberSeed;
} }
/** /**
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "Force.h" #include "Force.h"
#include <string> #include <string>
#include "internal/windowsExport.h" #include "internal/windowsExport.h"
#include "openmm/internal/OSRngSeed.h"
namespace OpenMM { namespace OpenMM {
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <string> #include <string>
...@@ -46,7 +45,7 @@ BrownianIntegrator::BrownianIntegrator(double temperature, double frictionCoeff, ...@@ -46,7 +45,7 @@ BrownianIntegrator::BrownianIntegrator(double temperature, double frictionCoeff,
setFriction(frictionCoeff); setFriction(frictionCoeff);
setStepSize(stepSize); setStepSize(stepSize);
setConstraintTolerance(1e-5); setConstraintTolerance(1e-5);
setRandomNumberSeed(osrngseed()); setRandomNumberSeed(0);
} }
void BrownianIntegrator::initialize(ContextImpl& contextRef) { void BrownianIntegrator::initialize(ContextImpl& contextRef) {
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "openmm/internal/AssertionUtilities.h" #include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <set> #include <set>
#include <string> #include <string>
...@@ -45,7 +44,7 @@ using namespace std; ...@@ -45,7 +44,7 @@ using namespace std;
CustomIntegrator::CustomIntegrator(double stepSize) : globalsAreCurrent(true), forcesAreValid(false) { CustomIntegrator::CustomIntegrator(double stepSize) : globalsAreCurrent(true), forcesAreValid(false) {
setStepSize(stepSize); setStepSize(stepSize);
setConstraintTolerance(1e-5); setConstraintTolerance(1e-5);
setRandomNumberSeed(osrngseed()); setRandomNumberSeed(0);
kineticEnergy = "m*v*v/2"; kineticEnergy = "m*v*v/2";
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <string> #include <string>
...@@ -46,7 +45,7 @@ LangevinIntegrator::LangevinIntegrator(double temperature, double frictionCoeff, ...@@ -46,7 +45,7 @@ LangevinIntegrator::LangevinIntegrator(double temperature, double frictionCoeff,
setFriction(frictionCoeff); setFriction(frictionCoeff);
setStepSize(stepSize); setStepSize(stepSize);
setConstraintTolerance(1e-5); setConstraintTolerance(1e-5);
setRandomNumberSeed(osrngseed()); setRandomNumberSeed(0);
} }
void LangevinIntegrator::initialize(ContextImpl& contextRef) { void LangevinIntegrator::initialize(ContextImpl& contextRef) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "openmm/internal/MonteCarloAnisotropicBarostatImpl.h" #include "openmm/internal/MonteCarloAnisotropicBarostatImpl.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <cmath> #include <cmath>
...@@ -60,7 +61,10 @@ void MonteCarloAnisotropicBarostatImpl::initialize(ContextImpl& context) { ...@@ -60,7 +61,10 @@ void MonteCarloAnisotropicBarostatImpl::initialize(ContextImpl& context) {
numAttempted[i] = 0; numAttempted[i] = 0;
numAccepted[i] = 0; numAccepted[i] = 0;
} }
init_gen_rand(owner.getRandomNumberSeed(), random); int randSeed = owner.getRandomNumberSeed();
// A random seed of 0 means pull a new one from the clock
if (randSeed == 0) randSeed = osrngseed();
init_gen_rand(randSeed, random);
} }
void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) { void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "openmm/internal/MonteCarloBarostatImpl.h" #include "openmm/internal/MonteCarloBarostatImpl.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <cmath> #include <cmath>
...@@ -58,7 +59,10 @@ void MonteCarloBarostatImpl::initialize(ContextImpl& context) { ...@@ -58,7 +59,10 @@ void MonteCarloBarostatImpl::initialize(ContextImpl& context) {
volumeScale = 0.01*volume; volumeScale = 0.01*volume;
numAttempted = 0; numAttempted = 0;
numAccepted = 0; numAccepted = 0;
init_gen_rand(owner.getRandomNumberSeed(), random); int randSeed = owner.getRandomNumberSeed();
// A random seed of 0 means pull a new one from the clock
if (randSeed == 0) randSeed = osrngseed();
init_gen_rand(randSeed, random);
} }
void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) { void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "openmm/internal/MonteCarloMembraneBarostatImpl.h" #include "openmm/internal/MonteCarloMembraneBarostatImpl.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <cmath> #include <cmath>
...@@ -60,7 +61,10 @@ void MonteCarloMembraneBarostatImpl::initialize(ContextImpl& context) { ...@@ -60,7 +61,10 @@ void MonteCarloMembraneBarostatImpl::initialize(ContextImpl& context) {
numAttempted[i] = 0; numAttempted[i] = 0;
numAccepted[i] = 0; numAccepted[i] = 0;
} }
init_gen_rand(owner.getRandomNumberSeed(), random); int randSeed = owner.getRandomNumberSeed();
// A random seed of 0 means pull a new one from the clock
if (randSeed == 0) randSeed = osrngseed();
init_gen_rand(randSeed, random);
} }
void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) { void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include <limits> #include <limits>
#include <string> #include <string>
...@@ -48,7 +47,7 @@ VariableLangevinIntegrator::VariableLangevinIntegrator(double temperature, doubl ...@@ -48,7 +47,7 @@ VariableLangevinIntegrator::VariableLangevinIntegrator(double temperature, doubl
setFriction(frictionCoeff); setFriction(frictionCoeff);
setErrorTolerance(errorTol); setErrorTolerance(errorTol);
setConstraintTolerance(1e-5); setConstraintTolerance(1e-5);
setRandomNumberSeed(osrngseed()); setRandomNumberSeed(0);
setStepSize(0.0); setStepSize(0.0);
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "CudaIntegrationUtilities.h" #include "CudaIntegrationUtilities.h"
#include "CudaArray.h" #include "CudaArray.h"
#include "CudaKernelSources.h" #include "CudaKernelSources.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/HarmonicAngleForce.h" #include "openmm/HarmonicAngleForce.h"
#include "openmm/VirtualSite.h" #include "openmm/VirtualSite.h"
#include "quern.h" #include "quern.h"
...@@ -858,6 +859,7 @@ void CudaIntegrationUtilities::initRandomNumberGenerator(unsigned int randomNumb ...@@ -858,6 +859,7 @@ void CudaIntegrationUtilities::initRandomNumberGenerator(unsigned int randomNumb
vector<int4> seed(randomSeed->getSize()); vector<int4> seed(randomSeed->getSize());
unsigned int r = randomNumberSeed; unsigned int r = randomNumberSeed;
if (r == 0) r = (unsigned int) osrngseed();
for (int i = 0; i < randomSeed->getSize(); i++) { for (int i = 0; i < randomSeed->getSize(); i++) {
seed[i].x = r = (1664525*r + 1013904223) & 0xFFFFFFFF; seed[i].x = r = (1664525*r + 1013904223) & 0xFFFFFFFF;
seed[i].y = r = (1664525*r + 1013904223) & 0xFFFFFFFF; seed[i].y = r = (1664525*r + 1013904223) & 0xFFFFFFFF;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "OpenCLIntegrationUtilities.h" #include "OpenCLIntegrationUtilities.h"
#include "OpenCLArray.h" #include "OpenCLArray.h"
#include "OpenCLKernelSources.h" #include "OpenCLKernelSources.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/HarmonicAngleForce.h" #include "openmm/HarmonicAngleForce.h"
#include "openmm/VirtualSite.h" #include "openmm/VirtualSite.h"
#include "quern.h" #include "quern.h"
...@@ -1003,6 +1004,8 @@ void OpenCLIntegrationUtilities::initRandomNumberGenerator(unsigned int randomNu ...@@ -1003,6 +1004,8 @@ void OpenCLIntegrationUtilities::initRandomNumberGenerator(unsigned int randomNu
vector<mm_int4> seed(randomSeed->getSize()); vector<mm_int4> seed(randomSeed->getSize());
unsigned int r = randomNumberSeed; unsigned int r = randomNumberSeed;
// A seed of 0 means pull one from the clock
if (r == 0) r = (unsigned int) osrngseed();
for (int i = 0; i < randomSeed->getSize(); i++) { for (int i = 0; i < randomSeed->getSize(); i++) {
seed[i].x = r = (1664525*r + 1013904223) & 0xFFFFFFFF; seed[i].x = r = (1664525*r + 1013904223) & 0xFFFFFFFF;
seed[i].y = r = (1664525*r + 1013904223) & 0xFFFFFFFF; seed[i].y = r = (1664525*r + 1013904223) & 0xFFFFFFFF;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
// class of shared, static utility methods // class of shared, static utility methods
#include "openmm/internal/OSRngSeed.h"
#include "SimTKOpenMMUtilities.h" #include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMLog.h" #include "SimTKOpenMMLog.h"
#include "sfmt/SFMT.h" #include "sfmt/SFMT.h"
...@@ -361,6 +362,10 @@ void SimTKOpenMMUtilities::setRandomNumberSeed( uint32_t seed ) { ...@@ -361,6 +362,10 @@ void SimTKOpenMMUtilities::setRandomNumberSeed( uint32_t seed ) {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// If the seed is 0, generate one from the clock
if (seed == 0)
_randomNumberSeed = (uint32_t) osrngseed();
else
_randomNumberSeed = seed; _randomNumberSeed = seed;
_randomInitialized = false; _randomInitialized = false;
} }
......
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