Commit 832b8a42 authored by Christopher Bruns's avatar Christopher Bruns
Browse files

NML loading sanity test gets much farther on Linux, but still fails

parent f46ebafb
......@@ -33,6 +33,9 @@
#include "openmm/internal/ContextImpl.h"
#include "ReferenceNMLKernelFactory.h"
#include "ReferenceIntegrateNMLStepKernel.h"
#include <iostream>
using namespace std;
namespace OpenMM {
......
......@@ -36,20 +36,33 @@
using namespace OpenMM;
using namespace std;
extern "C" void registerPlatforms() {
cout << "calling NML registerPlatforms()..." << endl;
}
extern "C" void registerKernelFactories() {
cout << "Initializing Normal Mode Langevin OpenMM plugin..." << endl;
// for (int p = 0; p < Platform::getNumPlatforms(); ++p) {
for (int p = 0; p < Platform::getNumPlatforms(); ++p) {
cout << "Plugin number " << p << endl;
cout << "Platform " << p << " name = " << Platform::getPlatform(p).getName() << endl;
}
// Only register cuda kernels if cuda platform is found
cout << "NML looking for Cuda plugin..." << endl;
try {
Platform& platform = Platform::getPlatformByName("CudaPlatform");
Platform& platform = Platform::getPlatformByName("Cuda");
cout << "NML found Cuda platform..." << endl;
// platform.registerKernelFactory("CudaNMLKernelFactory", new CudaNMLKernelFactory());
} catch (std::exception exc) { // non fatal
} catch (const std::exception& exc) { // non fatal
}
cout << "NML looking for Reference plugin..." << endl;
try {
Platform& platform = Platform::getPlatformByName("ReferencePlatform");
Platform& platform = Platform::getPlatformByName("Reference");
cout << "NML found Reference platform..." << endl;
platform.registerKernelFactory("ReferenceNMLKernelFactory", new ReferenceNMLKernelFactory());
} catch (std::exception exc) { // non fatal
} catch (const std::exception& exc) { // non fatal
cout << "NML Reference platform not found. " << exc.what() << endl;
}
}
# Copy plugin to test_plugin_dir
set(test_plugin_dir "${CMAKE_BINARY_DIR}/test_plugin_dir")
file(MAKE_DIRECTORY "${test_plugin_dir}")
get_target_property(old_loc NormalModeLangevin LOCATION)
get_filename_component(new_loc ${old_loc} NAME)
set(new_loc "${test_plugin_dir}/${new_loc}")
add_custom_command(
DEPENDS ${old_loc} NormalModeLangevin
OUTPUT ${new_loc}
COMMAND ${CMAKE_COMMAND} -E copy ${old_loc} ${new_loc})
add_custom_target(CopyTestNmlPlugin ALL
DEPENDS "${new_loc}"
COMMENT "Copying normal mode langevin plugin for testing")
add_executable(TestNormalModeLangevin TestNormalModeLangevin.cpp)
target_link_libraries(TestNormalModeLangevin ${SHARED_TARGET})
add_test(TestNormalModeLangevin "${EXECUTABLE_OUTPUT_PATH}/TestNormalModeLangevin")
# pass OPENMM_PLUGIN_DIR as command line argument
add_test(TestNormalModeLangevin
"${EXECUTABLE_OUTPUT_PATH}/TestNormalModeLangevin"
"${test_plugin_dir}")
# does not work - nice try - maybe in cmake 2.8
set_tests_properties(TestNormalModeLangevin PROPERTIES
ENVIRONMENT "OPENMM_PLUGIN_DIR=${test_plugin_dir}")
......@@ -23,8 +23,9 @@ void testLoadNMLPlugin()
cout << "Default plugins directory = " << pluginDir << endl;
Platform::loadPluginsFromDirectory(pluginDir);
vector<string> kernelName;
kernelName.push_back("IntegrateNMLStepKernel");
kernelName.push_back("IntegrateNMLStep");
// Was NormalModeLangevin plugin loaded?
cout << "Searching for kernel IntegrateNMLStep = " << pluginDir << endl;
Platform& platform = Platform::findPlatform(kernelName); // throws if no platform with kernel
}
......@@ -43,9 +44,10 @@ int main(int argc, const char* argv[])
cout << "tests passed" << endl;
return 0;
}
catch (...)
catch (const std::exception& exc)
{
cout << "FAILED" << endl;
cout << "FAILED: " << exc.what() << endl;
return 1;
}
}
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