Commit 72e81e04 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed lots of compilation errors on Windows

parent 06db7ac4
......@@ -299,6 +299,8 @@ IF(DL_LIBRARY)
IF(OPENMM_BUILD_STATIC_LIB)
TARGET_LINK_LIBRARIES(${STATIC_TARGET} ${DL_LIBRARY} ${PTHREADS_LIB})
ENDIF(OPENMM_BUILD_STATIC_LIB)
ELSE(DL_LIBRARY)
TARGET_LINK_LIBRARIES(${SHARED_TARGET} ${PTHREADS_LIB})
ENDIF(DL_LIBRARY)
IF(WIN32)
MARK_AS_ADVANCED(DL_LIBRARY)
......
......@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#define NOMINMAX
#include "windowsExport.h"
#include <pthread.h>
#include <vector>
......
......@@ -44,6 +44,7 @@
#include <dlfcn.h>
#else
#ifdef WIN32
#define NOMINMAX
#include <windows.h>
#else
#include <dlfcn.h>
......
......@@ -62,55 +62,55 @@ public:
void store(float* v) const {
_mm_storeu_ps(v, val);
}
fvec4 operator+(fvec4 other) const {
fvec4 operator+(const fvec4& other) const {
return _mm_add_ps(val, other);
}
fvec4 operator-(fvec4 other) const {
fvec4 operator-(const fvec4& other) const {
return _mm_sub_ps(val, other);
}
fvec4 operator*(fvec4 other) const {
fvec4 operator*(const fvec4& other) const {
return _mm_mul_ps(val, other);
}
fvec4 operator/(fvec4 other) const {
fvec4 operator/(const fvec4& other) const {
return _mm_div_ps(val, other);
}
void operator+=(fvec4 other) {
void operator+=(const fvec4& other) {
val = _mm_add_ps(val, other);
}
void operator-=(fvec4 other) {
void operator-=(const fvec4& other) {
val = _mm_sub_ps(val, other);
}
void operator*=(fvec4 other) {
void operator*=(const fvec4& other) {
val = _mm_mul_ps(val, other);
}
void operator/=(fvec4 other) {
void operator/=(const fvec4& other) {
val = _mm_div_ps(val, other);
}
fvec4 operator-() const {
return _mm_sub_ps(_mm_set1_ps(0.0f), val);
}
fvec4 operator&(fvec4 other) const {
fvec4 operator&(const fvec4& other) const {
return _mm_and_ps(val, other);
}
fvec4 operator|(fvec4 other) const {
fvec4 operator|(const fvec4& other) const {
return _mm_or_ps(val, other);
}
fvec4 operator==(fvec4 other) const {
fvec4 operator==(const fvec4& other) const {
return _mm_cmpeq_ps(val, other);
}
fvec4 operator!=(fvec4 other) const {
fvec4 operator!=(const fvec4& other) const {
return _mm_cmpneq_ps(val, other);
}
fvec4 operator>(fvec4 other) const {
fvec4 operator>(const fvec4& other) const {
return _mm_cmpgt_ps(val, other);
}
fvec4 operator<(fvec4 other) const {
fvec4 operator<(const fvec4& other) const {
return _mm_cmplt_ps(val, other);
}
fvec4 operator>=(fvec4 other) const {
fvec4 operator>=(const fvec4& other) const {
return _mm_cmpge_ps(val, other);
}
fvec4 operator<=(fvec4 other) const {
fvec4 operator<=(const fvec4& other) const {
return _mm_cmple_ps(val, other);
}
operator ivec4() const;
......@@ -139,49 +139,49 @@ public:
void store(int* v) const {
_mm_storeu_si128((__m128i*) v, val);
}
ivec4 operator+(ivec4 other) const {
ivec4 operator+(const ivec4& other) const {
return _mm_add_epi32(val, other);
}
ivec4 operator-(ivec4 other) const {
ivec4 operator-(const ivec4& other) const {
return _mm_sub_epi32(val, other);
}
ivec4 operator*(ivec4 other) const {
ivec4 operator*(const ivec4& other) const {
return _mm_mul_epi32(val, other);
}
void operator+=(ivec4 other) {
void operator+=(const ivec4& other) {
val = _mm_add_epi32(val, other);
}
void operator-=(ivec4 other) {
void operator-=(const ivec4& other) {
val = _mm_sub_epi32(val, other);
}
void operator*=(ivec4 other) {
void operator*=(const ivec4& other) {
val = _mm_mul_epi32(val, other);
}
ivec4 operator-() const {
return _mm_sub_epi32(_mm_set1_epi32(0), val);
}
ivec4 operator&(ivec4 other) const {
ivec4 operator&(const ivec4& other) const {
return _mm_and_si128(val, other);
}
ivec4 operator|(ivec4 other) const {
ivec4 operator|(const ivec4& other) const {
return _mm_or_si128(val, other);
}
ivec4 operator==(ivec4 other) const {
ivec4 operator==(const ivec4& other) const {
return _mm_cmpeq_epi32(val, other);
}
ivec4 operator!=(ivec4 other) const {
ivec4 operator!=(const ivec4& other) const {
return _mm_xor_si128(*this==other, _mm_set1_epi32(0xFFFFFFFF));
}
ivec4 operator>(ivec4 other) const {
ivec4 operator>(const ivec4& other) const {
return _mm_cmpgt_epi32(val, other);
}
ivec4 operator<(ivec4 other) const {
ivec4 operator<(const ivec4& other) const {
return _mm_cmplt_epi32(val, other);
}
ivec4 operator>=(ivec4 other) const {
ivec4 operator>=(const ivec4& other) const {
return _mm_xor_si128(_mm_cmplt_epi32(val, other), _mm_set1_epi32(0xFFFFFFFF));
}
ivec4 operator<=(ivec4 other) const {
ivec4 operator<=(const ivec4& other) const {
return _mm_xor_si128(_mm_cmpgt_epi32(val, other), _mm_set1_epi32(0xFFFFFFFF));
}
operator fvec4() const;
......@@ -199,40 +199,40 @@ inline ivec4::operator fvec4() const {
// Functions that operate on fvec4s.
static inline fvec4 floor(fvec4 v) {
static inline fvec4 floor(const fvec4& v) {
return fvec4(_mm_floor_ps(v.val));
}
static inline fvec4 ceil(fvec4 v) {
static inline fvec4 ceil(const fvec4& v) {
return fvec4(_mm_ceil_ps(v.val));
}
static inline fvec4 round(fvec4 v) {
static inline fvec4 round(const fvec4& v) {
return fvec4(_mm_round_ps(v.val, _MM_FROUND_TO_NEAREST_INT));
}
static inline fvec4 min(fvec4 v1, fvec4 v2) {
static inline fvec4 min(const fvec4& v1, const fvec4& v2) {
return fvec4(_mm_min_ps(v1.val, v2.val));
}
static inline fvec4 max(fvec4 v1, fvec4 v2) {
static inline fvec4 max(const fvec4& v1, const fvec4& v2) {
return fvec4(_mm_max_ps(v1.val, v2.val));
}
static inline fvec4 abs(fvec4 v) {
static inline fvec4 abs(const fvec4& v) {
static const __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF));
return fvec4(_mm_and_ps(v.val, mask));
}
static inline fvec4 sqrt(fvec4 v) {
static inline fvec4 sqrt(const fvec4& v) {
return fvec4(_mm_sqrt_ps(v.val));
}
static inline float dot3(fvec4 v1, fvec4 v2) {
static inline float dot3(const fvec4& v1, const fvec4& v2) {
return _mm_cvtss_f32(_mm_dp_ps(v1, v2, 0x71));
}
static inline float dot4(fvec4 v1, fvec4 v2) {
static inline float dot4(const fvec4& v1, const fvec4& v2) {
return _mm_cvtss_f32(_mm_dp_ps(v1, v2, 0xF1));
}
......@@ -242,43 +242,43 @@ static inline void transpose(fvec4& v1, fvec4& v2, fvec4& v3, fvec4& v4) {
// Functions that operate on ivec4s.
static inline ivec4 min(ivec4 v1, ivec4 v2) {
static inline ivec4 min(const ivec4& v1, const ivec4& v2) {
return ivec4(_mm_min_epi32(v1.val, v2.val));
}
static inline ivec4 max(ivec4 v1, ivec4 v2) {
static inline ivec4 max(const ivec4& v1, const ivec4& v2) {
return ivec4(_mm_max_epi32(v1.val, v2.val));
}
static inline ivec4 abs(ivec4 v) {
static inline ivec4 abs(const ivec4& v) {
return ivec4(_mm_abs_epi32(v.val));
}
static inline bool any(ivec4 v) {
static inline bool any(const ivec4& v) {
return !_mm_test_all_zeros(v, _mm_set1_epi32(0xFFFFFFFF));
}
// Mathematical operators involving a scalar and a vector.
static inline fvec4 operator+(float v1, fvec4 v2) {
static inline fvec4 operator+(float v1, const fvec4& v2) {
return fvec4(v1)+v2;
}
static inline fvec4 operator-(float v1, fvec4 v2) {
static inline fvec4 operator-(float v1, const fvec4& v2) {
return fvec4(v1)-v2;
}
static inline fvec4 operator*(float v1, fvec4 v2) {
static inline fvec4 operator*(float v1, const fvec4& v2) {
return fvec4(v1)*v2;
}
static inline fvec4 operator/(float v1, fvec4 v2) {
static inline fvec4 operator/(float v1, const fvec4& v2) {
return fvec4(v1)/v2;
}
// Operations for blending fvec4s based on an ivec4.
static inline fvec4 blend(fvec4 v1, fvec4 v2, ivec4 mask) {
static inline fvec4 blend(const fvec4& v1, const fvec4& v2, const ivec4& mask) {
return fvec4(_mm_blendv_ps(v1.val, v2.val, _mm_castsi128_ps(mask.val)));
}
......
......@@ -123,7 +123,7 @@ private:
/**
* Evaluate log(x) using a lookup table for speed.
*/
fvec4 fastLog(fvec4 x);
fvec4 fastLog(const fvec4& x);
};
} // namespace OpenMM
......
......@@ -74,12 +74,12 @@ protected:
/**
* Compute a fast approximation to erfc(x).
*/
static fvec4 erfcApprox(fvec4 x);
static fvec4 erfcApprox(const fvec4& x);
/**
* Evaluate the scale factor used with Ewald and PME: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
*/
fvec4 ewaldScaleFunction(fvec4 x);
fvec4 ewaldScaleFunction(const fvec4& x);
};
} // namespace OpenMM
......
......@@ -25,9 +25,10 @@
#ifndef OPENMM_CPU_NONBONDED_FORCE_VEC8_H__
#define OPENMM_CPU_NONBONDED_FORCE_VEC8_H__
#include "CpuNonbondedForce.h"
#ifdef __AVX__
#include "CpuNonbondedForce.h"
#include "openmm/internal/vectorize8.h"
// ---------------------------------------------------------------------------------------
......@@ -72,12 +73,12 @@ protected:
/**
* Compute a fast approximation to erfc(x).
*/
static fvec8 erfcApprox(fvec8 x);
static fvec8 erfcApprox(const fvec8& x);
/**
* Evaluate the scale factor used with Ewald and PME: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
*/
fvec8 ewaldScaleFunction(fvec8 x);
fvec8 ewaldScaleFunction(const fvec8& x);
};
} // namespace OpenMM
......
......@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include "sfmt/SFMT.h"
#include "windowsExportCpu.h"
#include <vector>
namespace OpenMM {
......@@ -40,7 +41,7 @@ namespace OpenMM {
/**
* This class provides a multithreaded random number generator.
*/
class OPENMM_EXPORT CpuRandom {
class OPENMM_EXPORT_CPU CpuRandom {
public:
CpuRandom();
~CpuRandom();
......
......@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include "ReferenceSETTLEAlgorithm.h"
#include "windowsExportCpu.h"
#include "openmm/System.h"
#include "openmm/internal/ThreadPool.h"
#include <vector>
......@@ -42,7 +43,7 @@ namespace OpenMM {
/**
* This class uses multiple ReferenceSETTLEAlgorithm objects to execute the algorithm in parallel.
*/
class OPENMM_EXPORT CpuSETTLE : public ReferenceConstraintAlgorithm {
class OPENMM_EXPORT_CPU CpuSETTLE : public ReferenceConstraintAlgorithm {
public:
class ApplyToPositionsTask;
class ApplyToVelocitiesTask;
......
......@@ -26,7 +26,9 @@
#include "SimTKOpenMMRealType.h"
#include "openmm/internal/vectorize.h"
#include "gmx_atomic.h"
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
using namespace OpenMM;
......@@ -391,7 +393,7 @@ void CpuGBSAOBCForce::getDeltaR(const fvec4& posI, const fvec4& x, const fvec4&
r2 = dx*dx + dy*dy + dz*dz;
}
fvec4 CpuGBSAOBCForce::fastLog(fvec4 x) {
fvec4 CpuGBSAOBCForce::fastLog(const fvec4& x) {
// Evaluate log(x) using a lookup table for speed.
if (any((x < TABLE_MIN) | (x >= TABLE_MAX)))
......
......@@ -154,7 +154,7 @@ public:
return VoxelIndex(x, y);
}
void getNeighbors(vector<int>& neighbors, int blockIndex, fvec4 blockCenter, fvec4 blockWidth, const vector<int>& sortedAtoms, vector<char>& exclusions, float maxDistance, const vector<int>& blockAtoms, const float* atomLocations, const vector<VoxelIndex>& atomVoxelIndex) const {
void getNeighbors(vector<int>& neighbors, int blockIndex, const fvec4& blockCenter, const fvec4& blockWidth, const vector<int>& sortedAtoms, vector<char>& exclusions, float maxDistance, const vector<int>& blockAtoms, const float* atomLocations, const vector<VoxelIndex>& atomVoxelIndex) const {
neighbors.resize(0);
exclusions.resize(0);
fvec4 boxSize(periodicBoxSize[0], periodicBoxSize[1], periodicBoxSize[2], 0);
......
......@@ -30,6 +30,7 @@
#include "ReferenceForce.h"
#include "ReferencePME.h"
#include "gmx_atomic.h"
#include <algorithm>
// In case we're using some primitive version of Visual Studio this will
// make sure that erf() and erfc() are defined.
......@@ -182,7 +183,7 @@ void CpuNonbondedForce::calculateReciprocalIxn(int numberOfAtoms, float* posq, c
static const float epsilon = 1.0;
int kmax = (ewald ? std::max(numRx, std::max(numRy,numRz)) : 0);
int kmax = (ewald ? max(numRx, max(numRy,numRz)) : 0);
float factorEwald = -1 / (4*alphaEwald*alphaEwald);
float TWO_PI = 2.0 * PI_M;
float recipCoeff = (float)(ONE_4PI_EPS0*4*PI_M/(periodicBoxSize[0] * periodicBoxSize[1] * periodicBoxSize[2]) /epsilon);
......
......@@ -273,7 +273,7 @@ void CpuNonbondedForceVec4::getDeltaR(const float* posI, const fvec4& x, const f
r2 = dx*dx + dy*dy + dz*dz;
}
fvec4 CpuNonbondedForceVec4::erfcApprox(fvec4 x) {
fvec4 CpuNonbondedForceVec4::erfcApprox(const fvec4& x) {
// This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as
// the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum
// error of 3e-7.
......@@ -285,7 +285,7 @@ fvec4 CpuNonbondedForceVec4::erfcApprox(fvec4 x) {
return 1.0f/(t*t);
}
fvec4 CpuNonbondedForceVec4::ewaldScaleFunction(fvec4 x) {
fvec4 CpuNonbondedForceVec4::ewaldScaleFunction(const fvec4& x) {
// Compute the tabulated Ewald scale factor: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
fvec4 x1 = x*ewaldDXInv;
......
......@@ -25,6 +25,7 @@
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMUtilities.h"
#include "CpuNonbondedForceVec8.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/hardware.h"
using namespace std;
......@@ -296,7 +297,7 @@ void CpuNonbondedForceVec8::getDeltaR(const float* posI, const fvec8& x, const f
r2 = dx*dx + dy*dy + dz*dz;
}
fvec8 CpuNonbondedForceVec8::erfcApprox(fvec8 x) {
fvec8 CpuNonbondedForceVec8::erfcApprox(const fvec8& x) {
// This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as
// the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum
// error of 3e-7.
......@@ -308,7 +309,7 @@ fvec8 CpuNonbondedForceVec8::erfcApprox(fvec8 x) {
return 1.0f/(t*t);
}
fvec8 CpuNonbondedForceVec8::ewaldScaleFunction(fvec8 x) {
fvec8 CpuNonbondedForceVec8::ewaldScaleFunction(const fvec8& x) {
// Compute the tabulated Ewald scale factor: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
fvec8 x1 = x*ewaldDXInv;
......
......@@ -40,7 +40,7 @@ namespace OpenMM {
* This KernelFactory creates all kernels for ReferencePlatform.
*/
class ReferenceKernelFactory : public KernelFactory {
class OPENMM_EXPORT ReferenceKernelFactory : public KernelFactory {
public:
KernelImpl* createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const;
};
......
......@@ -26,10 +26,11 @@
#define __ReferenceLJCoulomb14_H__
#include "ReferenceBondIxn.h"
#include "openmm/internal/windowsExport.h"
// ---------------------------------------------------------------------------------------
class ReferenceLJCoulomb14 : public ReferenceBondIxn {
class OPENMM_EXPORT ReferenceLJCoulomb14 : public ReferenceBondIxn {
public:
......
......@@ -30,6 +30,7 @@
*/
#include "SimTKOpenMMCommon.h"
#include "openmm/internal/windowsExport.h"
#include <vector>
typedef RealOpenMM rvec[3];
......@@ -52,7 +53,7 @@ pme_t;
* pme_order Interpolation order, almost always 4
* epsilon_r Dielectric coefficient, typically 1.0.
*/
int
int OPENMM_EXPORT
pme_init(pme_t * ppme,
RealOpenMM ewaldcoeff,
int natoms,
......@@ -73,7 +74,7 @@ pme_init(pme_t * ppme,
* energy Total energy (will be written in units of kJ/mol)
* pme_virial Long-range part of the virial, output.
*/
int
int OPENMM_EXPORT
pme_exec(pme_t pme,
const std::vector<OpenMM::RealVec>& atomCoordinates,
std::vector<OpenMM::RealVec>& forces,
......@@ -85,5 +86,5 @@ pme_exec(pme_t pme,
/* Release all memory in pme structure */
int
int OPENMM_EXPORT
pme_destroy(pme_t pme);
......@@ -26,10 +26,11 @@
#define __ReferenceStochasticDynamics_H__
#include "ReferenceDynamics.h"
#include "openmm/internal/windowsExport.h"
// ---------------------------------------------------------------------------------------
class ReferenceStochasticDynamics : public ReferenceDynamics {
class OPENMM_EXPORT ReferenceStochasticDynamics : public ReferenceDynamics {
protected:
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaAngleForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaAngleForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaAngleForceProxy : public SerializationProxy {
public:
AmoebaAngleForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaBondForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaBondForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaBondForceProxy : public SerializationProxy {
public:
AmoebaBondForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
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