Commit 55873e46 authored by Christopher Bruns's avatar Christopher Bruns
Browse files

Created separate windows export macro for Cuda plugin.

Exported some symbols from Cuda plugin, for use by external NML plugin.
  cudaOpenMMInitializeIntegration, gpuSetConstants, CudaPlatform
  (but I couldn't figure out how to export kGenerateRandoms)
Also turned off TestRandomCuda on Windows, since it always fails and makes the dashboard look bad.
Renamed InitializeIntegration method to cudaOpenMMInitializeIntegration, now that symbol is being exported.
parent a37f4b76
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "openmm/Platform.h" #include "openmm/Platform.h"
#include "windowsExportCuda.h"
struct _gpuContext; struct _gpuContext;
...@@ -37,7 +38,7 @@ namespace OpenMM { ...@@ -37,7 +38,7 @@ namespace OpenMM {
* This Platform subclass uses CUDA implementations of the OpenMM kernels to run on NVidia GPUs. * This Platform subclass uses CUDA implementations of the OpenMM kernels to run on NVidia GPUs.
*/ */
class OPENMM_EXPORT CudaPlatform : public Platform { class OPENMMCUDA_EXPORT CudaPlatform : public Platform {
public: public:
class PlatformData; class PlatformData;
CudaPlatform(); CudaPlatform();
......
#ifndef OPENMM_WINDOWSEXPORTCUDA_H_
#define OPENMM_WINDOWSEXPORTCUDA_H_
/*
* Shared libraries are messy in Visual Studio. We have to distinguish three
* cases:
* (1) this header is being used to build the OpenMM shared library
* (dllexport)
* (2) this header is being used by a *client* of the OpenMM shared
* library (dllimport)
* (3) we are building the OpenMM static library, or the client is
* being compiled with the expectation of linking with the
* OpenMM static library (nothing special needed)
* In the CMake script for building this library, we define one of the symbols
* OpenMMCUDA_BUILDING_{SHARED|STATIC}_LIBRARY
* Client code normally has no special symbol defined, in which case we'll
* assume it wants to use the shared library. However, if the client defines
* the symbol OPENMM_USE_STATIC_LIBRARIES we'll suppress the dllimport so
* that the client code can be linked with static libraries. Note that
* the client symbol is not library dependent, while the library symbols
* affect only the OpenMM library, meaning that other libraries can
* be clients of this one. However, we are assuming all-static or all-shared.
*/
#ifdef _MSC_VER
// We don't want to hear about how sprintf is "unsafe".
#pragma warning(disable:4996)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#if defined(OPENMMCUDA_BUILDING_SHARED_LIBRARY)
#define OPENMMCUDA_EXPORT __declspec(dllexport)
#elif defined(OPENMMCUDA_BUILDING_STATIC_LIBRARY) || defined(OPENMMCUDA_USE_STATIC_LIBRARIES)
#define OPENMMCUDA_EXPORT
#else
#define OPENMMCUDA_EXPORT __declspec(dllimport) // i.e., a client of a shared library
#endif
#else
#define OPENMMCUDA_EXPORT // Linux, Mac
#endif
#endif // OPENMM_WINDOWSEXPORTCUDA_H_
...@@ -18,6 +18,6 @@ CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/jama/include) ...@@ -18,6 +18,6 @@ CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/jama/include)
CUDA_ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES}) CUDA_ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
TARGET_LINK_LIBRARIES(${SHARED_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME} ${CUFFT_TARGET_LINK}) TARGET_LINK_LIBRARIES(${SHARED_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME} ${CUFFT_TARGET_LINK})
SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY") SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMMCUDA_BUILDING_SHARED_LIBRARY")
INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${SHARED_TARGET}) INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${SHARED_TARGET})
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "../src/SimTKUtilities/SimTKOpenMMRealType.h" #include "../src/SimTKUtilities/SimTKOpenMMRealType.h"
#include <cmath> #include <cmath>
extern "C" int gpuSetConstants( gpuContext gpu ); extern "C" int OPENMMCUDA_EXPORT gpuSetConstants( gpuContext gpu );
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
...@@ -737,7 +737,7 @@ void CudaCalcCustomExternalForceKernel::updateGlobalParams(ContextImpl& context) ...@@ -737,7 +737,7 @@ void CudaCalcCustomExternalForceKernel::updateGlobalParams(ContextImpl& context)
SetCustomExternalGlobalParams(globalParamValues); SetCustomExternalGlobalParams(globalParamValues);
} }
static void initializeIntegration(const System& system, CudaPlatform::PlatformData& data, const Integrator& integrator) { void OPENMMCUDA_EXPORT OpenMM::cudaOpenMMInitializeIntegration(const System& system, CudaPlatform::PlatformData& data, const Integrator& integrator) {
// Initialize any terms that haven't already been handled by a Force. // Initialize any terms that haven't already been handled by a Force.
...@@ -803,7 +803,7 @@ CudaIntegrateVerletStepKernel::~CudaIntegrateVerletStepKernel() { ...@@ -803,7 +803,7 @@ CudaIntegrateVerletStepKernel::~CudaIntegrateVerletStepKernel() {
} }
void CudaIntegrateVerletStepKernel::initialize(const System& system, const VerletIntegrator& integrator) { void CudaIntegrateVerletStepKernel::initialize(const System& system, const VerletIntegrator& integrator) {
initializeIntegration(system, data, integrator); cudaOpenMMInitializeIntegration(system, data, integrator);
prevStepSize = -1.0; prevStepSize = -1.0;
} }
...@@ -833,7 +833,7 @@ CudaIntegrateLangevinStepKernel::~CudaIntegrateLangevinStepKernel() { ...@@ -833,7 +833,7 @@ CudaIntegrateLangevinStepKernel::~CudaIntegrateLangevinStepKernel() {
} }
void CudaIntegrateLangevinStepKernel::initialize(const System& system, const LangevinIntegrator& integrator) { void CudaIntegrateLangevinStepKernel::initialize(const System& system, const LangevinIntegrator& integrator) {
initializeIntegration(system, data, integrator); cudaOpenMMInitializeIntegration(system, data, integrator);
_gpuContext* gpu = data.gpu; _gpuContext* gpu = data.gpu;
gpu->seed = (unsigned long) integrator.getRandomNumberSeed(); gpu->seed = (unsigned long) integrator.getRandomNumberSeed();
gpuInitializeRandoms(gpu); gpuInitializeRandoms(gpu);
...@@ -877,7 +877,7 @@ CudaIntegrateBrownianStepKernel::~CudaIntegrateBrownianStepKernel() { ...@@ -877,7 +877,7 @@ CudaIntegrateBrownianStepKernel::~CudaIntegrateBrownianStepKernel() {
} }
void CudaIntegrateBrownianStepKernel::initialize(const System& system, const BrownianIntegrator& integrator) { void CudaIntegrateBrownianStepKernel::initialize(const System& system, const BrownianIntegrator& integrator) {
initializeIntegration(system, data, integrator); cudaOpenMMInitializeIntegration(system, data, integrator);
_gpuContext* gpu = data.gpu; _gpuContext* gpu = data.gpu;
gpu->seed = (unsigned long) integrator.getRandomNumberSeed(); gpu->seed = (unsigned long) integrator.getRandomNumberSeed();
gpuInitializeRandoms(gpu); gpuInitializeRandoms(gpu);
...@@ -918,7 +918,7 @@ CudaIntegrateVariableVerletStepKernel::~CudaIntegrateVariableVerletStepKernel() ...@@ -918,7 +918,7 @@ CudaIntegrateVariableVerletStepKernel::~CudaIntegrateVariableVerletStepKernel()
} }
void CudaIntegrateVariableVerletStepKernel::initialize(const System& system, const VariableVerletIntegrator& integrator) { void CudaIntegrateVariableVerletStepKernel::initialize(const System& system, const VariableVerletIntegrator& integrator) {
initializeIntegration(system, data, integrator); cudaOpenMMInitializeIntegration(system, data, integrator);
prevErrorTol = -1.0; prevErrorTol = -1.0;
} }
...@@ -953,7 +953,7 @@ CudaIntegrateVariableLangevinStepKernel::~CudaIntegrateVariableLangevinStepKerne ...@@ -953,7 +953,7 @@ CudaIntegrateVariableLangevinStepKernel::~CudaIntegrateVariableLangevinStepKerne
} }
void CudaIntegrateVariableLangevinStepKernel::initialize(const System& system, const VariableLangevinIntegrator& integrator) { void CudaIntegrateVariableLangevinStepKernel::initialize(const System& system, const VariableLangevinIntegrator& integrator) {
initializeIntegration(system, data, integrator); cudaOpenMMInitializeIntegration(system, data, integrator);
_gpuContext* gpu = data.gpu; _gpuContext* gpu = data.gpu;
gpu->seed = (unsigned long) integrator.getRandomNumberSeed(); gpu->seed = (unsigned long) integrator.getRandomNumberSeed();
gpuInitializeRandoms(gpu); gpuInitializeRandoms(gpu);
......
...@@ -40,6 +40,9 @@ class CudaVerletDynamics; ...@@ -40,6 +40,9 @@ class CudaVerletDynamics;
namespace OpenMM { namespace OpenMM {
// Export internal cudaOpenMMInitializeIntegration() method so it can be used by NML plugin
void OPENMMCUDA_EXPORT cudaOpenMMInitializeIntegration(const System& system, CudaPlatform::PlatformData& data, const Integrator& integrator);
/** /**
* This kernel is invoked at the beginning and end of force and energy computations. It gives the * This kernel is invoked at the beginning and end of force and energy computations. It gives the
* Platform a chance to clear buffers and do other initialization at the beginning, and to do any * Platform a chance to clear buffers and do other initialization at the beginning, and to do any
......
...@@ -38,7 +38,7 @@ using std::map; ...@@ -38,7 +38,7 @@ using std::map;
using std::string; using std::string;
using std::stringstream; using std::stringstream;
extern "C" OPENMM_EXPORT void registerPlatforms() { extern "C" OPENMMCUDA_EXPORT void registerPlatforms() {
if (gpuIsAvailable()) if (gpuIsAvailable())
Platform::registerPlatform(new CudaPlatform()); Platform::registerPlatform(new CudaPlatform());
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "cudatypes.h" #include "cudatypes.h"
#include "cudaCompact.h" #include "cudaCompact.h"
#include <vector> #include <vector>
#include "windowsExportCuda.h"
struct gpuAtomType { struct gpuAtomType {
std::string name; std::string name;
...@@ -268,7 +269,7 @@ extern "C" ...@@ -268,7 +269,7 @@ extern "C"
void gpuSetMass(gpuContext gpu, const std::vector<float>& mass); void gpuSetMass(gpuContext gpu, const std::vector<float>& mass);
extern "C" extern "C"
void gpuInitializeRandoms(gpuContext gpu); void OPENMMCUDA_EXPORT gpuInitializeRandoms(gpuContext gpu);
extern "C" extern "C"
void* gpuInit(int numAtoms, unsigned int device = 0, bool useBlockingSync = false); void* gpuInit(int numAtoms, unsigned int device = 0, bool useBlockingSync = false);
...@@ -298,7 +299,7 @@ extern "C" ...@@ -298,7 +299,7 @@ extern "C"
void gpuBuildExclusionList(gpuContext gpu); void gpuBuildExclusionList(gpuContext gpu);
extern "C" extern "C"
int gpuSetConstants(gpuContext gpu); int OPENMMCUDA_EXPORT gpuSetConstants(gpuContext gpu);
extern "C" extern "C"
void gpuReorderAtoms(gpuContext gpu); void gpuReorderAtoms(gpuContext gpu);
......
...@@ -21,7 +21,7 @@ CUDA_ADD_LIBRARY(${STATIC_TARGET} STATIC ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ...@@ -21,7 +21,7 @@ CUDA_ADD_LIBRARY(${STATIC_TARGET} STATIC ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES}
# required for getting OPENMM_EXPORT to be set correctly in 'class OPENMM_EXPORT CudaStreamFactory', ... # required for getting OPENMM_EXPORT to be set correctly in 'class OPENMM_EXPORT CudaStreamFactory', ...
# see OpenMM/openmmapi/include/internal/windowsExport.h for details # see OpenMM/openmmapi/include/internal/windowsExport.h for details
SET(CUDA_STATIC_COMPILE_FLAG "-DOPENMM_BUILDING_STATIC_LIBRARY -DOPENMM_USE_STATIC_LIBRARIES -DCUDPP_STATIC_LIB") SET(CUDA_STATIC_COMPILE_FLAG "-DOPENMMCUDA_BUILDING_STATIC_LIBRARY -DOPENMMCUDA_USE_STATIC_LIBRARIES -DCUDPP_STATIC_LIB")
SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES COMPILE_FLAGS ${CUDA_STATIC_COMPILE_FLAG}) SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES COMPILE_FLAGS ${CUDA_STATIC_COMPILE_FLAG})
TARGET_LINK_LIBRARIES(${STATIC_TARGET} optimized ${OPENMM_LIBRARY_NAME}_static) TARGET_LINK_LIBRARIES(${STATIC_TARGET} optimized ${OPENMM_LIBRARY_NAME}_static)
......
...@@ -9,6 +9,11 @@ INCLUDE_DIRECTORIES(${CUDA_INCLUDE}) ...@@ -9,6 +9,11 @@ INCLUDE_DIRECTORIES(${CUDA_INCLUDE})
# Automatically create tests using files named "Test*.cpp" # Automatically create tests using files named "Test*.cpp"
FILE(GLOB TEST_PROGS "*Test*.cpp") FILE(GLOB TEST_PROGS "*Test*.cpp")
# TestCudaRandom has never worked on windows, so let's stop polluting the dashboard with it.
IF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
FILE(GLOB TEST_CUDA_RANDOM_PROG "*TestCudaRandom.cpp")
LIST(REMOVE_ITEM TEST_PROGS "${TEST_CUDA_RANDOM_PROG}")
ENDIF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
FOREACH(TEST_PROG ${TEST_PROGS}) FOREACH(TEST_PROG ${TEST_PROGS})
GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE)
......
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