Commit 6d1814ac authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Added ReferenceFreeEnergyPlatform & CudaFreeEnergyPlatform

parent 0d42a187
#ifndef OPENMM_CUDA_FREE_ENERGY_PLATFORM_H_
#define OPENMM_CUDA_FREE_ENERGY_PLATFORM_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "CudaPlatform.h"
struct _gpuContext;
namespace OpenMM {
/**
* This Platform subclass uses CUDA implementations of the OpenMM kernels to run on NVidia GPUs.
*/
class OPENMM_EXPORT CudaFreeEnergyPlatform : public CudaPlatform {
public:
//class PlatformData;
CudaFreeEnergyPlatform();
const std::string& getName() const {
static const std::string name = "CudaFreeEnergy";
return name;
}
#if 0
double getSpeed() const {
return 100;
}
bool supportsDoublePrecision() const;
const std::string& getPropertyValue(const Context& context, const std::string& property) const;
void setPropertyValue(Context& context, const std::string& property, const std::string& value) const;
void contextCreated(ContextImpl& context) const;
void contextDestroyed(ContextImpl& context) const;
/**
* This is the name of the parameter for selecting which CUDA device to use.
*/
static const std::string& CudaDevice() {
static const std::string key = "CudaDevice";
return key;
}
/**
* This is the name of the parameter for selecting whether CUDA should sync or spin loop while waiting for results.
*/
static const std::string& CudaUseBlockingSync() {
static const std::string key = "CudaUseBlockingSync";
return key;
}
#endif
};
#if 0
class CudaPlatform::PlatformData {
public:
PlatformData(_gpuContext* gpu);
_gpuContext* gpu;
bool removeCM;
bool hasBonds, hasAngles, hasPeriodicTorsions, hasRB, hasNonbonded, hasCustomNonbonded;
int nonbondedMethod, customNonbondedMethod;
int cmMotionFrequency;
int stepCount, computeForceCount;
double time, ewaldSelfEnergy;
std::map<std::string, std::string> propertyValues;
};
#endif
} // namespace OpenMM
#endif /*OPENMM_CUDA_FREE_ENERGY_PLATFORM_H_*/
......@@ -30,39 +30,8 @@
#include "openmm/internal/ContextImpl.h"
#include "openmm/OpenMMException.h"
#if defined(OPENMM_BUILDING_SHARED_LIBRARY)
#if defined(WIN32)
#include <windows.h>
extern "C" void initOpenMMCudaFreeEnergyPlugin();
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
initOpenMMCudaFreeEnergyPlugin();
return TRUE;
}
#else
extern "C" void __attribute__((constructor)) initOpenMMCudaFreeEnergyPlugin();
#endif
#endif
using namespace OpenMM;
extern "C" void initOpenMMCudaFreeEnergyPlugin() {
//(void) fprintf( stderr, "initOpenMMCudaFreeEnergyPlugin called ");
if ( gpuIsAvailable() ){
CudaPlatform* cudaPlatform = new CudaPlatform();
CudaFreeEnergyKernelFactory* factory = new CudaFreeEnergyKernelFactory();
//(void) fprintf( stderr, "gpu is available platform=%p", cudaPlatform);
cudaPlatform->registerKernelFactory(CalcNonbondedSoftcoreForceKernel::Name(), factory);
cudaPlatform->registerKernelFactory(CalcGBSAOBCSoftcoreForceKernel::Name(), factory);
cudaPlatform->registerKernelFactory(CalcGBVISoftcoreForceKernel::Name(), factory);
Platform::registerPlatform(cudaPlatform);
}
//(void) fprintf( stderr, "\n");
}
KernelImpl* CudaFreeEnergyKernelFactory::createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const {
CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData());
......
......@@ -193,7 +193,7 @@ static void getForceMap(const System& system, MapStringInt& forceMap, FILE* log)
}
if( log ){
(void) fprintf( stderr, "Map: Force %d %s\n", i, forceName.c_str() );
(void) fprintf( log, "Map: Force %d %s\n", i, forceName.c_str() );
}
}
}
......
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "CudaFreeEnergyPlatform.h"
#include "CudaFreeEnergyKernelFactory.h"
#include "openmm/freeEnergyKernels.h"
#include "kernels/gputypes.h"
using namespace OpenMM;
#if defined(OPENMM_BUILDING_SHARED_LIBRARY)
#if defined(WIN32)
#include <windows.h>
extern "C" void initOpenMMCudaFreeEnergyPlugin();
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
initOpenMMCudaFreeEnergyPlugin();
return TRUE;
}
#else
extern "C" void __attribute__((constructor)) initOpenMMCudaFreeEnergyPlugin();
#endif
#endif
using namespace OpenMM;
extern "C" void initOpenMMCudaFreeEnergyPlugin() {
//(void) fprintf( stderr, "initOpenMMCudaFreeEnergyPlugin called\n");
if ( gpuIsAvailable() ){
Platform::registerPlatform(new CudaFreeEnergyPlatform());
}
}
CudaFreeEnergyPlatform::CudaFreeEnergyPlatform( void ){
CudaFreeEnergyKernelFactory* factory = new CudaFreeEnergyKernelFactory();
registerKernelFactory(CalcNonbondedSoftcoreForceKernel::Name(), factory);
registerKernelFactory(CalcGBSAOBCSoftcoreForceKernel::Name(), factory);
registerKernelFactory(CalcGBVISoftcoreForceKernel::Name(), factory);
}
#ifndef OPENMM_REFERENCE_FREE_ENERGY_PLATFORM_H_
#define OPENMM_REFERENCE_FREE_ENERGY_PLATFORM_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "ReferencePlatform.h"
namespace OpenMM {
/**
* This Platform subclass uses the reference implementations of all the OpenMM kernels.
*/
class OPENMM_EXPORT ReferenceFreeEnergyPlatform : public ReferencePlatform {
public:
// class PlatformData;
ReferenceFreeEnergyPlatform();
const std::string& getName() const {
static const std::string name = "ReferenceFreeEnergyPlatform";
return name;
}
#if 0
double getSpeed() const {
return 1;
}
bool supportsDoublePrecision() const;
void contextCreated(ContextImpl& context) const;
void contextDestroyed(ContextImpl& context) const;
#endif
};
#if 0
class ReferencePlatform::PlatformData {
public:
PlatformData(int numParticles);
~PlatformData();
int numParticles, stepCount;
double time;
void* positions;
void* velocities;
void* forces;
};
#endif
} // namespace OpenMM
#endif /*OPENMM_REFERENCE_FREE_ENERGY_PLATFORM_H_*/
......@@ -34,38 +34,8 @@
#include "openmm/internal/ContextImpl.h"
#include "openmm/OpenMMException.h"
// using PluginInitializer.h and initOpenMMPlugin() does not seem to work
//#include "openmm/PluginInitializer.h"
#if defined(OPENMM_BUILDING_SHARED_LIBRARY)
#if defined(WIN32)
#include <windows.h>
extern "C" void initOpenMMReferenceFreeEnergyPlugin();
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
initOpenMMReferenceFreeEnergyPlugin();
return TRUE;
}
#else
extern "C" void __attribute__((constructor)) initOpenMMReferenceFreeEnergyPlugin();
#endif
#endif
using namespace OpenMM;
extern "C" void initOpenMMReferenceFreeEnergyPlugin() {
ReferencePlatform* referencePlatform = new ReferencePlatform();
//(void) fprintf( stderr, "In initOpenMMReferenceFreeEnergyPlugin platform=%p\n", referencePlatform );
ReferenceFreeEnergyKernelFactory* factory = new ReferenceFreeEnergyKernelFactory();
referencePlatform->registerKernelFactory(CalcNonbondedSoftcoreForceKernel::Name(), factory);
referencePlatform->registerKernelFactory(CalcGBSAOBCSoftcoreForceKernel::Name(), factory);
referencePlatform->registerKernelFactory(CalcGBVISoftcoreForceKernel::Name(), factory);
Platform::registerPlatform(referencePlatform);
}
KernelImpl* ReferenceFreeEnergyKernelFactory::createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const {
ReferencePlatform::PlatformData& data = *static_cast<ReferencePlatform::PlatformData*>(context.getPlatformData());
......
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "ReferenceFreeEnergyPlatform.h"
#include "openmm/freeEnergyKernels.h"
#include "ReferenceFreeEnergyKernelFactory.h"
// using PluginInitializer.h and initOpenMMPlugin() does not seem to work
//#include "openmm/PluginInitializer.h"
#if defined(OPENMM_BUILDING_SHARED_LIBRARY)
#if defined(WIN32)
#include <windows.h>
extern "C" void initOpenMMReferenceFreeEnergyPlugin();
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
initOpenMMReferenceFreeEnergyPlugin();
return TRUE;
}
#else
extern "C" void __attribute__((constructor)) initOpenMMReferenceFreeEnergyPlugin();
#endif
#endif
using namespace OpenMM;
extern "C" void initOpenMMReferenceFreeEnergyPlugin() {
Platform::registerPlatform( new ReferenceFreeEnergyPlatform() );
}
ReferenceFreeEnergyPlatform::ReferenceFreeEnergyPlatform( void ){
ReferenceFreeEnergyKernelFactory* factory = new ReferenceFreeEnergyKernelFactory();
registerKernelFactory(CalcNonbondedSoftcoreForceKernel::Name(), factory);
registerKernelFactory(CalcGBSAOBCSoftcoreForceKernel::Name(), factory);
registerKernelFactory(CalcGBVISoftcoreForceKernel::Name(), factory);
}
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