Commit 9fd73edf authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed compilation errors and warnings on Windows

parent 65c389ff
......@@ -124,7 +124,7 @@ public:
* @param index the index of the particle to check
*/
bool isVirtualSite(int index) const {
return (index < virtualSites.size() && virtualSites[index] != NULL);
return (index < (int) virtualSites.size() && virtualSites[index] != NULL);
}
/**
* Get VirtualSite object for a particle. If the particle is not a virtual
......
......@@ -57,6 +57,6 @@ void OPENMM_EXPORT throwException(const char* file, int line, const std::string&
#define ASSERT_USUALLY_EQUAL_TOL(expected, found, tol) {double _scale_ = std::abs(expected) > 1.0 ? std::abs(expected) : 1.0; if (!(std::abs((expected)-(found))/_scale_ <= (tol))) {std::stringstream details; details << "Expected "<<(expected)<<", found "<<(found)<<" (This test is stochastic and may occasionally fail)"; throwException(__FILE__, __LINE__, details.str());}};
#define ASSERT_VALID_INDEX(index, vector) {if (index < 0 || index >= vector.size()) throwException(__FILE__, __LINE__, "Index out of range");};
#define ASSERT_VALID_INDEX(index, vector) {if (index < 0 || index >= (int) vector.size()) throwException(__FILE__, __LINE__, "Index out of range");};
#endif /*OPENMM_ASSERTIONUTILITIES_H_*/
......@@ -62,13 +62,13 @@ void System::setParticleMass(int index, double mass) {
void System::setVirtualSite(int index, VirtualSite* virtualSite) {
if (index >= virtualSites.size())
if (index >= (int) virtualSites.size())
virtualSites.resize(getNumParticles(), NULL);
virtualSites[index] = virtualSite;
}
const VirtualSite& System::getVirtualSite(int index) const {
if (index >= virtualSites.size() || virtualSites[index] == NULL)
if (index >= (int) virtualSites.size() || virtualSites[index] == NULL)
throw OpenMMException("This particle is not a virtual site");
return *virtualSites[index];
}
......
......@@ -29,6 +29,7 @@
#include "OpenCLContext.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/windowsExport.h"
#include <iostream>
#include <sstream>
#include <vector>
......@@ -40,7 +41,7 @@ namespace OpenMM {
* and for copying data to and from the OpenCL Buffer.
*/
class OpenCLArray {
class OPENMM_EXPORT OpenCLArray {
public:
/**
* Create an OpenCLArray object. The object is allocated on the heap with the "new" operator.
......
......@@ -49,7 +49,7 @@ void OpenCLBondedUtilities::addInteraction(const vector<vector<int> >& atoms, co
forceSource.push_back(source);
forceGroup.push_back(group);
int width = 1;
while (width < atoms[0].size())
while (width < (int) atoms[0].size())
width *= 2;
indexWidth.push_back(width);
}
......@@ -124,7 +124,7 @@ void OpenCLBondedUtilities::initialize(const System& system) {
while (unmerged.size() > 0) {
int sum = numBuffers[unmerged.back()];
int i;
for (i = 0; i < unmerged.size()-1; i++) {
for (i = 0; i < (int) unmerged.size()-1; i++) {
if (sum+numBuffers[unmerged[i]] > bufferLimit)
break;
sum += numBuffers[unmerged[i]];
......@@ -142,7 +142,7 @@ void OpenCLBondedUtilities::initialize(const System& system) {
bufferIndices.resize(numForces);
for (int i = 0; i < (int) forceSets.size(); i++)
for (int j = 0; j < forceSets[i].size(); j++) {
for (int j = 0; j < (int) forceSets[i].size(); j++) {
int force = forceSets[i][j];
int numBonds = forceAtoms[force].size();
int numAtoms = forceAtoms[force][0].size();
......
......@@ -73,7 +73,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
contextIndex = platformData.contexts.size();
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
if (platformIndex < 0 || platformIndex >= platforms.size())
if (platformIndex < 0 || platformIndex >= (int) platforms.size())
throw OpenMMException("Illegal value for OpenCL platform index");
string platformVendor = platforms[platformIndex].getInfo<CL_PLATFORM_VENDOR>();
vector<cl::Device> devices;
......
......@@ -277,7 +277,7 @@ void OpenCLUpdateStateDataKernel::loadCheckpoint(ContextImpl& context, istream&
contexts[i]->setPeriodicBoxSize(box.x, box.y, box.z);
cl.getIntegrationUtilities().loadCheckpoint(stream);
SimTKOpenMMUtilities::loadCheckpoint(stream);
for (int i = 0; i < cl.getReorderListeners().size(); i++)
for (int i = 0; i < (int) cl.getReorderListeners().size(); i++)
cl.getReorderListeners()[i]->execute();
}
......@@ -4832,8 +4832,8 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
cl.executeKernel(kernels[i][0], numAtoms);
}
else if (stepType[i] == CustomIntegrator::ComputeGlobal && !merged[i]) {
kernels[i][0].setArg<cl_float>(3, SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber());
kernels[i][0].setArg<cl_float>(4, SimTKOpenMMUtilities::getNormallyDistributedRandomNumber());
kernels[i][0].setArg<cl_float>(3, (cl_float) SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber());
kernels[i][0].setArg<cl_float>(4, (cl_float) SimTKOpenMMUtilities::getNormallyDistributedRandomNumber());
cl.executeKernel(kernels[i][0], 1, 1);
}
else if (stepType[i] == CustomIntegrator::ComputeSum) {
......
......@@ -118,7 +118,7 @@ void testManyParameters() {
forceField->addPerBondParameter("h");
forceField->addPerBondParameter("i");
vector<double> parameters(forceField->getNumPerBondParameters());
for (int i = 0; i < parameters.size(); i++)
for (int i = 0; i < (int) parameters.size(); i++)
parameters[i] = i;
forceField->addBond(0, 1, parameters);
system.addForce(forceField);
......@@ -179,4 +179,3 @@ int main() {
return 0;
}
......@@ -60,7 +60,7 @@ void testTransform() {
vector<mm_float2> original(xsize*ysize*zsize);
vector<t_complex> reference(original.size());
for (int i = 0; i < (int) original.size(); i++) {
mm_float2 value = mm_float2(genrand_real2(sfmt), genrand_real2(sfmt));
mm_float2 value = mm_float2((cl_float) genrand_real2(sfmt), (cl_float) genrand_real2(sfmt));
original[i] = value;
reference[i] = t_complex(value.x, value.y);
}
......
......@@ -308,7 +308,7 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy( int numParticles,
RealOpenMM sigmaI = sigmas[ii];
RealOpenMM epsilonI = epsilons[ii];
for( std::set<int>::iterator jj = allExclusions[ii].begin(); jj != allExclusions[ii].end(); jj++ ){
for( std::set<int>::const_iterator jj = allExclusions[ii].begin(); jj != allExclusions[ii].end(); jj++ ){
exclusions[*jj] = 1;
}
......@@ -341,7 +341,7 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy( int numParticles,
}
}
for( std::set<int>::iterator jj = allExclusions[ii].begin(); jj != allExclusions[ii].end(); jj++ ){
for( std::set<int>::const_iterator jj = allExclusions[ii].begin(); jj != allExclusions[ii].end(); jj++ ){
exclusions[*jj] = 0;
}
}
......
......@@ -544,7 +544,7 @@ void setupAndGetForcesEnergyVdwWater( const std::string& sigmaCombiningRule, con
// addParticle: ivIndex, radius, epsilon, reductionFactor
int classIndex = 0;
for( unsigned int ii = 0; ii < numberOfParticles; ii += 3 ){
for( int ii = 0; ii < numberOfParticles; ii += 3 ){
system.addParticle( 1.5995000e+01 );
amoebaVdwForce->addParticle( ii, 1.7025000e-01, 4.6024000e-01, 0.0000000e+00 );
......@@ -559,7 +559,7 @@ void setupAndGetForcesEnergyVdwWater( const std::string& sigmaCombiningRule, con
// exclusions
std::vector< int > exclusions(3);
for( unsigned int ii = 0; ii < numberOfParticles; ii += 3 ){
for( int ii = 0; ii < numberOfParticles; ii += 3 ){
exclusions[0] = ii;
exclusions[1] = ii+1;
exclusions[2] = ii+2;
......
......@@ -138,15 +138,15 @@ void OpenCLIntegrateRPMDStepKernel::execute(ContextImpl& context, const RPMDInte
const double dt = integrator.getStepSize();
pileKernel.setArg<cl_uint>(5, integration.prepareRandomNumbers(numParticles*numCopies));
pileKernel.setArg<cl::Buffer>(4, integration.getRandom().getDeviceBuffer()); // Do this *after* prepareRandomNumbers(), which might rebuild the array.
pileKernel.setArg<cl_float>(6, dt);
pileKernel.setArg<cl_float>(7, integrator.getTemperature()*BOLTZ);
pileKernel.setArg<cl_float>(8, integrator.getFriction());
pileKernel.setArg<cl_float>(6, (cl_float) dt);
pileKernel.setArg<cl_float>(7, (cl_float) (integrator.getTemperature()*BOLTZ));
pileKernel.setArg<cl_float>(8, (cl_float) integrator.getFriction());
cl.executeKernel(pileKernel, numParticles*numCopies, workgroupSize);
// Update positions and velocities.
stepKernel.setArg<cl_float>(7, dt);
stepKernel.setArg<cl_float>(8, integrator.getTemperature()*BOLTZ);
stepKernel.setArg<cl_float>(7, (cl_float) dt);
stepKernel.setArg<cl_float>(8, (cl_float) (integrator.getTemperature()*BOLTZ));
cl.executeKernel(stepKernel, numParticles*numCopies, workgroupSize);
// Calculate forces based on the updated positions.
......@@ -154,7 +154,7 @@ void OpenCLIntegrateRPMDStepKernel::execute(ContextImpl& context, const RPMDInte
computeForces(context);
// Update velocities.
velocitiesKernel.setArg<cl_float>(2, dt);
velocitiesKernel.setArg<cl_float>(2, (cl_float) dt);
cl.executeKernel(velocitiesKernel, numParticles*numCopies, workgroupSize);
// Apply the PILE-L thermostat again.
......@@ -193,7 +193,7 @@ void OpenCLIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& p
vector<mm_float4> posq(cl.getPaddedNumAtoms());
cl.getPosq().download(posq);
for (int i = 0; i < numParticles; i++)
posq[i] = mm_float4(pos[i][0], pos[i][1], pos[i][2], posq[i].w);
posq[i] = mm_float4((cl_float) pos[i][0], (cl_float) pos[i][1], (cl_float) pos[i][2], posq[i].w);
cl.getQueue().enqueueWriteBuffer(positions->getDeviceBuffer(), CL_TRUE, copy*cl.getPaddedNumAtoms()*sizeof(mm_float4), numParticles*sizeof(mm_float4), &posq[0]);
}
......@@ -205,7 +205,7 @@ void OpenCLIntegrateRPMDStepKernel::setVelocities(int copy, const vector<Vec3>&
vector<mm_float4> velm(cl.getPaddedNumAtoms());
cl.getVelm().download(velm);
for (int i = 0; i < numParticles; i++)
velm[i] = mm_float4(vel[i][0], vel[i][1], vel[i][2], velm[i].w);
velm[i] = mm_float4((cl_float) vel[i][0], (cl_float) vel[i][1], (cl_float) vel[i][2], velm[i].w);
cl.getQueue().enqueueWriteBuffer(velocities->getDeviceBuffer(), CL_TRUE, copy*cl.getPaddedNumAtoms()*sizeof(mm_float4), numParticles*sizeof(mm_float4), &velm[0]);
}
......
......@@ -81,7 +81,7 @@ void testSerialization() {
ASSERT_EQUAL(b2, b2);
ASSERT_EQUAL(c2, c2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
}
......
......@@ -80,7 +80,7 @@ void testSerialization() {
ASSERT_EQUAL(a1, a2);
ASSERT_EQUAL(b2, b2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
}
......
......@@ -79,7 +79,7 @@ void testSerialization() {
force2.getParticleParameters(i, particle2, params2);
ASSERT_EQUAL(particle1, particle2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
}
......
......@@ -109,7 +109,7 @@ void testSerialization() {
force.getParticleParameters(i, params1);
force2.getParticleParameters(i, params2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
ASSERT_EQUAL(force.getNumExclusions(), force2.getNumExclusions());
......@@ -131,7 +131,7 @@ void testSerialization() {
ASSERT_EQUAL(min1, min2);
ASSERT_EQUAL(max1, max2);
ASSERT_EQUAL(val1.size(), val2.size());
for (int j = 0; j < val1.size(); j++)
for (int j = 0; j < (int) val1.size(); j++)
ASSERT_EQUAL(val1[j], val2[j]);
}
}
......
......@@ -101,7 +101,7 @@ void testSerialization() {
ASSERT_EQUAL(b1, b2);
ASSERT_EQUAL(c1, c2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
ASSERT_EQUAL(force.getNumAcceptors(), force2.getNumAcceptors());
......@@ -114,7 +114,7 @@ void testSerialization() {
ASSERT_EQUAL(b1, b2);
ASSERT_EQUAL(c1, c2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
ASSERT_EQUAL(force.getNumExclusions(), force2.getNumExclusions());
......@@ -136,7 +136,7 @@ void testSerialization() {
ASSERT_EQUAL(min1, min2);
ASSERT_EQUAL(max1, max2);
ASSERT_EQUAL(val1.size(), val2.size());
for (int j = 0; j < val1.size(); j++)
for (int j = 0; j < (int) val1.size(); j++)
ASSERT_EQUAL(val1[j], val2[j]);
}
}
......
......@@ -87,7 +87,7 @@ void testSerialization() {
force.getParticleParameters(i, params1);
force2.getParticleParameters(i, params2);
ASSERT_EQUAL(params1.size(), params2.size());
for (int j = 0; j < params1.size(); j++)
for (int j = 0; j < (int) params1.size(); j++)
ASSERT_EQUAL(params1[j], params2[j]);
}
ASSERT_EQUAL(force.getNumExclusions(), force2.getNumExclusions());
......@@ -109,7 +109,7 @@ void testSerialization() {
ASSERT_EQUAL(min1, min2);
ASSERT_EQUAL(max1, max2);
ASSERT_EQUAL(val1.size(), val2.size());
for (int j = 0; j < val1.size(); j++)
for (int j = 0; j < (int) val1.size(); j++)
ASSERT_EQUAL(val1[j], val2[j]);
}
}
......
......@@ -41,7 +41,7 @@ using namespace std;
void testSerialization() {
// Create a Force.
MonteCarloBarostat force(25.5, 250.0, 0.2);
MonteCarloBarostat force(25.5, 250.0, 14);
force.setRandomNumberSeed(3);
// Serialize and then deserialize it.
......
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