Commit aff7f7bd authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Mods to allow CudaAmoeba units tests to run w/o setting plugin directory

parent f9d0115f
......@@ -37,7 +37,6 @@ extern "C" void registerPlatforms() {
}
extern "C" OPENMMCUDA_EXPORT void registerKernelFactories() {
//fprintf( stderr,"In registerKernelFactories AmoebaCudaKernelFactory\n" ); fflush( stderr );
for( int ii = 0; ii < Platform::getNumPlatforms(); ii++ ){
Platform& platform = Platform::getPlatform(ii);
if( platform.getName() == "Cuda" ){
......@@ -62,6 +61,22 @@ extern "C" OPENMMCUDA_EXPORT void registerKernelFactories() {
}
}
extern "C" OPENMMCUDA_EXPORT void registerAmoebaCudaKernelFactories( void ) {
int hasCudaPlatform = 0;
for( int ii = 0; ii < Platform::getNumPlatforms() && hasCudaPlatform == 0; ii++ ){
Platform& platform = Platform::getPlatform(ii);
if( platform.getName() == "Cuda" ){
hasCudaPlatform = 1;
}
}
if( hasCudaPlatform == 0 ){
if (gpuIsAvailable() ){
Platform::registerPlatform(new CudaPlatform());
}
}
registerKernelFactories();
}
static std::map<ContextImpl*, AmoebaCudaData*> contextToAmoebaDataMap;
// look up AmoebaCudaData for input contextImpl in contextToAmoebaDataMap
......
......@@ -61,6 +61,8 @@
#include <typeinfo>
#include <time.h>
extern "C" void registerAmoebaCudaKernelFactories();
// force enums
#define MAX_PRINT 5
......
......@@ -2,7 +2,7 @@
# Testing
#
ENABLE_TESTING()
# INCLUDE(${CMAKE_SOURCE_DIR}/platforms/cuda/cuda-cmake/FindCuda.cmake)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE})
INCLUDE_DIRECTORIES(${OPENMM_DIR}/platforms/cuda/include)
INCLUDE_DIRECTORIES(${OPENMM_DIR}/openmmapi/include/openmm)
......@@ -13,23 +13,23 @@ SET(SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET "AmoebaTinkerParameterFile" )
SET(AMOEBA_TINKER_PARAMETER_FILE_SOURCE_FILES "AmoebaTinkerParameterFile.cpp" )
SET(AMOEBA_TINKER_PARAMETER_FILE_INCLUDE_FILES "AmoebaTinkerParameterFile.h" )
Set( SHARED_OPENMM__AMOEBA_TARGET OpenMMAmoeba)
Set( STATIC_OPENMM_TARGET OpenMMAmoeba_static)
Set( SHARED_CUDA_TARGET OpenMMAmoebaCuda )
Set( SHARED_OPENMM_AMOEBA_TARGET OpenMMAmoeba)
Set( SHARED_CUDA_TARGET OpenMMCuda )
Set( SHARED_AMOEBA_CUDA_TARGET OpenMMAmoebaCuda )
Set( STATIC_CUDA_TARGET OpenMMCuda_static OpenMMAmoebaCuda_static)
Set( STATIC_OPENMM_TARGET OpenMMAmoeba_static)
ADD_LIBRARY(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} SHARED ${AMOEBA_TINKER_PARAMETER_FILE_SOURCE_FILES} ${AMOEBA_TINKER_PARAMETER_FILE_INCLUDE_FILES} )
SET_TARGET_PROPERTIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DOPENMM_VALIDATE_BUILDING_SHARED_LIBRARY")
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME})
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} debug ${SHARED_OPENMM__AMOEBA_TARGET}_d optimized ${SHARED_OPENMM__AMOEBA_TARGET})
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} debug ${SHARED_CUDA_TARGET}_d optimized ${SHARED_CUDA_TARGET})
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} debug ${SHARED_OPENMM_AMOEBA_TARGET}_d optimized ${SHARED_OPENMM_AMOEBA_TARGET})
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} debug ${SHARED_AMOEBA_CUDA_TARGET}_d optimized ${SHARED_AMOEBA_CUDA_TARGET})
IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET(SHARED_CUDA_TARGET ${SHARED_CUDA_TARGET}_d)
SET(SHARED_AMOEBA_CUDA_TARGET ${SHARED_AMOEBA_CUDA_TARGET}_d)
SET(SHARED_OPENMM__AMOEBA_TARGET ${SHARED_OPENMM__AMOEBA_TARGET}_d)
#SET(STATIC_CUDA_TARGET ${STATIC_CUDA_TARGET}_d)
#Set(STATIC_OPENMM_TARGET ${STATIC_OPENMM_TARGET}_d)
ENDIF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
#LINK_DIRECTORIES
......@@ -42,7 +42,7 @@ FOREACH(TEST_PROG ${TEST_PROGS})
# Link with shared library
CUDA_ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG})
TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET} ${SHARED_OPENMM_TARGET} ${SHARED_CUDA_TARGET} ${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET})
TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET} ${SHARED_OPENMM_TARGET} ${SHARED_OPENMM_AMOEBA_TARGET} ${SHARED_CUDA_TARGET} ${SHARED_AMOEBA_CUDA_TARGET} ${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET})
ADD_TEST(${TEST_ROOT} ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT})
# Link with static library
......@@ -56,26 +56,3 @@ FOREACH(TEST_PROG ${TEST_PROGS})
# ADD_TEST(${TEST_STATIC} ${EXECUTABLE_OUTPUT_PATH}/${TEST_STATIC})
ENDFOREACH(TEST_PROG ${TEST_PROGS})
# TestCudaUsingParameterFile customized w/ command-line argument (input file name used in test)
#ADD_EXECUTABLE(TestAmoebaCudaUsingParameterFile TstAmoebaCudaUsingParameterFile.cpp)
#TARGET_LINK_LIBRARIES(TestAmoebaCudaUsingParameterFile ${SHARED_TARGET} ${SHARED_OPENMM_TARGET} ${SHARED_CUDA_TARGET})
#ADD_TEST(TestCudaUsingParameterFile "${EXECUTABLE_OUTPUT_PATH}/TestCudaUsingParameterFile" "-parameterFileName" "${CMAKE_CURRENT_SOURCE_DIR}/lambdaSdObcParameters.txt")
#ADD_TEST(TestCudaUsingParameterFile "${EXECUTABLE_OUTPUT_PATH}/TestCudaUsingParameterFile" "-parameterFileName" "${CMAKE_CURRENT_SOURCE_DIR}/bptiMdRfNoPbcParameters.txt")
#
#SET(TEST_ROOT TestCudaUsingParameterFile)
#SET(TEST_PROG TstCudaUsingParameterFile.cpp)
#SET(TEST_STATIC ${TEST_ROOT}Static)
#SET(INCLUDE_CUDA_STATIC 1)
#IF(INCLUDE_CUDA_STATIC)
# ADD_EXECUTABLE(${TEST_STATIC} ${TEST_PROG})
# SET_TARGET_PROPERTIES(${TEST_STATIC}
# PROPERTIES
# COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
# )
# TARGET_LINK_LIBRARIES(${TEST_STATIC} ${STATIC_TARGET} ${STATIC_BROOK_TARGET})
# ADD_TEST(${TEST_STATIC} "${EXECUTABLE_OUTPUT_PATH}/TestCudaUsingParameterFileStatic" "-parameterFileName" "${CMAKE_CURRENT_SOURCE_DIR}/lambdaSdObcParameters.txt")
# ADD_TEST(${TEST_STATIC} "${EXECUTABLE_OUTPUT_PATH}/TestCudaUsingParameterFileStatic" "-parameterFileName" "${CMAKE_CURRENT_SOURCE_DIR}/bptiMdRfNoPbcParameters.txt")
# ADD_TEST(${TEST_STATIC} "${EXECUTABLE_OUTPUT_PATH}/TestCudaUsingParameterFileStatic" "-parameterFileName" "${CMAKE_CURRENT_SOURCE_DIR}/bptiMdRfPbcParameters.txt" " +checkEnergyForceConsistent -checkForces" )
#ENDIF(INCLUDE_CUDA_STATIC)
......@@ -45,7 +45,7 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "Running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
if( numberOfArguments > 1 ){
MapStringString argumentMap;
argumentMap[INCLUDE_OBC_CAVITY_TERM] = "0";
......
......@@ -305,23 +305,15 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaHarmonicAngleForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
//FILE* log = fopen( "AmoebaHarmonicAngleForce.log", "w" );;
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
testOneAngle( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -34,6 +34,7 @@
*/
#include "../../../tests/AssertionUtilities.h"
#include "CudaPlatform.h"
#include "AmoebaTinkerParameterFile.h"
#include "openmm/Context.h"
#include "OpenMMAmoeba.h"
......@@ -45,7 +46,6 @@
using namespace OpenMM;
const double TOL = 1e-5;
static void computeAmoebaHarmonicBondForce(int bondIndex, std::vector<Vec3>& positions, AmoebaHarmonicBondForce& amoebaHarmonicBondForce,
std::vector<Vec3>& forces, double* energy ) {
......@@ -174,6 +174,7 @@ void testOneBond( FILE* log ) {
void testTwoBond( FILE* log ) {
System system;
registerAmoebaCudaKernelFactories();
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -194,6 +195,7 @@ void testTwoBond( FILE* log ) {
system.addForce(amoebaHarmonicBondForce);
Context context(system, integrator, Platform::getPlatformByName( "Cuda"));
//Context context(system, integrator, platform );
std::vector<Vec3> positions(3);
positions[0] = Vec3(0, 1, 0);
......@@ -208,24 +210,14 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaHarmonicBondForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//testOneBond( log );
testTwoBond( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -382,23 +382,14 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaHarmonicInPlaneAngleForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = fopen( "AmoebaHarmonicInPlaneAngleForce.log", "w" );;
testOneAngle( NULL );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -511,29 +511,16 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaOutOfPlaneBendForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
//FILE* log = stderr;
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = fopen( "AmoebaOutOfPlaneBendForce.log", "w" );;
testOneOutOfPlaneBend( log );
//testOneOutOfPlaneBend2( log, atoi( argv[1] ) );
//for( int ii = 1; ii <= 6; ii++ ){
// testOneOutOfPlaneBend2( log, ii );
//}
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -34,6 +34,7 @@
*/
#include "../../../tests/AssertionUtilities.h"
#include "AmoebaTinkerParameterFile.h"
#include "openmm/Context.h"
#include "CudaPlatform.h"
#include "openmm/AmoebaMultipoleForce.h"
......@@ -123,14 +124,12 @@ void testPMEWater() {
int main() {
try {
Platform::loadPluginsFromDirectory(Platform::getDefaultPluginsDirectory());
registerAmoebaCudaKernelFactories();
testPMEWater();
}
catch(const exception& e) {
} catch(const exception& e) {
cout << "exception: " << e.what() << endl;
return 1;
}
//cout << "Done" << endl;
std::cout << "Done" << std::endl;
return 0;
}
......
......@@ -308,24 +308,14 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaPiTorsionForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//FILE* log = fopen( "AmoebaPiTorsionForce1.log", "w" );;
testOnePiTorsion( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -292,24 +292,15 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaStretchBendForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//FILE* log = fopen( "AmoebaStretchBendForce1.log", "w" );;
testOneStretchBend( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......
......@@ -337,23 +337,15 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaTorsionForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
//FILE* log = stderr;
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = fopen( "AmoebaTorsionForce.log", "w" );;
testOneTorsion( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -34,11 +34,10 @@
*/
#include "../../../tests/AssertionUtilities.h"
//#include "AmoebaTinkerParameterFile.h"
const double DegreesToRadians = 3.14159265/180.0;
#include "openmm/Context.h"
#include "OpenMMAmoeba.h"
#include "openmm/System.h"
#include "AmoebaTinkerParameterFile.h"
#include "openmm/AmoebaTorsionTorsionForce.h"
#include "openmm/LangevinIntegrator.h"
#include <iostream>
......@@ -2684,25 +2683,15 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaTorsionTorsionForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//FILE* log = fopen( "AmoebaTorsionTorsionForce1.log", "w" );;
// testTorsionTorsion( log, 0 );
testTorsionTorsion( log, 1 );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......
......@@ -208,25 +208,15 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaUreyBradleyForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//testOneBond( log );
testTwoBond( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
......@@ -36,6 +36,7 @@
#include "../../../tests/AssertionUtilities.h"
#include "openmm/Context.h"
#include "OpenMMAmoeba.h"
#include "AmoebaTinkerParameterFile.h"
#include "openmm/System.h"
#include "openmm/AmoebaVdwForce.h"
#include "openmm/LangevinIntegrator.h"
......@@ -174,24 +175,15 @@ int main( int numberOfArguments, char* argv[] ) {
try {
std::cout << "TestCudaAmoebaVdwForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
registerAmoebaCudaKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//FILE* log = fopen( "AmoebaVdwForce1.log", "w" );;
testVdw( log );
#ifdef AMOEBA_DEBUG
if( log && log != stderr )
(void) fclose( log );
#endif
}
catch(const std::exception& e) {
} catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl;
return 1;
}
//std::cout << "PASS - Test succeeded." << std::endl;
std::cout << "Done" << std::endl;
return 0;
}
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