Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
b1d6a0db
Commit
b1d6a0db
authored
Jun 30, 2015
by
peastman
Browse files
Merge pull request #995 from rmcgibbo/loadFailures
Record plugin load failures
parents
bca01957
1a37f02a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
12 deletions
+43
-12
olla/include/openmm/Platform.h
olla/include/openmm/Platform.h
+15
-9
olla/src/Platform.cpp
olla/src/Platform.cpp
+11
-2
wrappers/generateWrappers.py
wrappers/generateWrappers.py
+16
-1
wrappers/python/src/swig_doxygen/swigInputConfig.py
wrappers/python/src/swig_doxygen/swigInputConfig.py
+1
-0
No files found.
olla/include/openmm/Platform.h
View file @
b1d6a0db
...
@@ -171,6 +171,10 @@ public:
...
@@ -171,6 +171,10 @@ public:
* Get a registered Platform by index.
* Get a registered Platform by index.
*/
*/
static
Platform
&
getPlatform
(
int
index
);
static
Platform
&
getPlatform
(
int
index
);
/**
* Get any failures caused during the last call to loadPluginsFromDirectory
*/
static
std
::
vector
<
std
::
string
>
getPluginLoadFailures
();
/**
/**
* Get the registered Platform with a particular name. If no Platform with that name has been
* Get the registered Platform with a particular name. If no Platform with that name has been
* registered, this throws an exception.
* registered, this throws an exception.
...
@@ -201,7 +205,7 @@ public:
...
@@ -201,7 +205,7 @@ public:
* Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from a single directory.
* Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from a single directory.
* This method loops over every file contained in the specified directory and calls loadPluginLibrary()
* This method loops over every file contained in the specified directory and calls loadPluginLibrary()
* for each one. If an error occurs while trying to load a particular file, that file is simply
* for each one. If an error occurs while trying to load a particular file, that file is simply
* ignored.
* ignored.
You can retrieve a list of all such errors by calling getPluginLoadFailures().
*
*
* @param directory the path to the directory containing libraries to load
* @param directory the path to the directory containing libraries to load
* @return the names of all files which were successfully loaded as libraries
* @return the names of all files which were successfully loaded as libraries
...
@@ -233,8 +237,10 @@ private:
...
@@ -233,8 +237,10 @@ private:
std
::
map
<
std
::
string
,
KernelFactory
*>
kernelFactories
;
std
::
map
<
std
::
string
,
KernelFactory
*>
kernelFactories
;
std
::
map
<
std
::
string
,
std
::
string
>
defaultProperties
;
std
::
map
<
std
::
string
,
std
::
string
>
defaultProperties
;
static
std
::
vector
<
Platform
*>&
getPlatforms
();
static
std
::
vector
<
Platform
*>&
getPlatforms
();
static
std
::
vector
<
std
::
string
>
pluginLoadFailures
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
#endif
/*OPENMM_PLATFORM_H_*/
#endif
/*OPENMM_PLATFORM_H_*/
olla/src/Platform.cpp
View file @
b1d6a0db
...
@@ -51,6 +51,8 @@
...
@@ -51,6 +51,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
std
::
vector
<
std
::
string
>
Platform
::
pluginLoadFailures
;
static
int
registerPlatforms
()
{
static
int
registerPlatforms
()
{
// Register the Platforms built into the main library. This should eventually be moved elsewhere.
// Register the Platforms built into the main library. This should eventually be moved elsewhere.
...
@@ -140,6 +142,10 @@ Platform& Platform::getPlatform(int index) {
...
@@ -140,6 +142,10 @@ Platform& Platform::getPlatform(int index) {
throw
OpenMMException
(
"Invalid platform index"
);
throw
OpenMMException
(
"Invalid platform index"
);
}
}
std
::
vector
<
std
::
string
>
Platform
::
getPluginLoadFailures
()
{
return
pluginLoadFailures
;
}
Platform
&
Platform
::
getPlatformByName
(
const
string
&
name
)
{
Platform
&
Platform
::
getPlatformByName
(
const
string
&
name
)
{
for
(
int
i
=
0
;
i
<
getNumPlatforms
();
i
++
)
for
(
int
i
=
0
;
i
<
getNumPlatforms
();
i
++
)
if
(
getPlatform
(
i
).
getName
()
==
name
)
if
(
getPlatform
(
i
).
getName
()
==
name
)
...
@@ -196,8 +202,9 @@ static void* loadOneLibrary(const string& file) {
...
@@ -196,8 +202,9 @@ static void* loadOneLibrary(const string& file) {
throw
OpenMMException
(
"Loading dynamic libraries is not supported on PNaCl"
);
throw
OpenMMException
(
"Loading dynamic libraries is not supported on PNaCl"
);
#else
#else
void
*
handle
=
dlopen
(
file
.
c_str
(),
RTLD_LAZY
|
RTLD_GLOBAL
);
void
*
handle
=
dlopen
(
file
.
c_str
(),
RTLD_LAZY
|
RTLD_GLOBAL
);
if
(
handle
==
NULL
)
if
(
handle
==
NULL
)
{
throw
OpenMMException
(
"Error loading library "
+
file
+
": "
+
dlerror
());
throw
OpenMMException
(
"Error loading library "
+
file
+
": "
+
dlerror
());
}
return
handle
;
return
handle
;
#endif
#endif
}
}
...
@@ -261,12 +268,14 @@ vector<string> Platform::loadPluginsFromDirectory(const string& directory) {
...
@@ -261,12 +268,14 @@ vector<string> Platform::loadPluginsFromDirectory(const string& directory) {
vector
<
void
*>
plugins
;
vector
<
void
*>
plugins
;
#endif
#endif
vector
<
string
>
loadedLibraries
;
vector
<
string
>
loadedLibraries
;
pluginLoadFailures
.
resize
(
0
);
for
(
unsigned
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
try
{
try
{
plugins
.
push_back
(
loadOneLibrary
(
directory
+
dirSeparator
+
files
[
i
]));
plugins
.
push_back
(
loadOneLibrary
(
directory
+
dirSeparator
+
files
[
i
]));
loadedLibraries
.
push_back
(
files
[
i
]);
loadedLibraries
.
push_back
(
files
[
i
]);
}
catch
(
OpenMMException
&
ex
)
{
}
catch
(
OpenMMException
&
ex
)
{
// Just ignore it.
pluginLoadFailures
.
push_back
(
ex
.
what
());
}
}
}
}
initializePlugins
(
plugins
);
initializePlugins
(
plugins
);
...
...
wrappers/generateWrappers.py
View file @
b1d6a0db
...
@@ -68,7 +68,7 @@ class WrapperGenerator:
...
@@ -68,7 +68,7 @@ class WrapperGenerator:
def
__init__
(
self
,
inputDirname
,
output
):
def
__init__
(
self
,
inputDirname
,
output
):
self
.
skipClasses
=
[
'OpenMM::Vec3'
,
'OpenMM::XmlSerializer'
,
'OpenMM::Kernel'
,
'OpenMM::KernelImpl'
,
'OpenMM::KernelFactory'
,
'OpenMM::ContextImpl'
,
'OpenMM::SerializationNode'
,
'OpenMM::SerializationProxy'
]
self
.
skipClasses
=
[
'OpenMM::Vec3'
,
'OpenMM::XmlSerializer'
,
'OpenMM::Kernel'
,
'OpenMM::KernelImpl'
,
'OpenMM::KernelFactory'
,
'OpenMM::ContextImpl'
,
'OpenMM::SerializationNode'
,
'OpenMM::SerializationProxy'
]
self
.
skipMethods
=
[
'OpenMM::Context::getState'
,
'OpenMM::Platform::loadPluginsFromDirectory'
,
'OpenMM::Context::createCheckpoint'
,
'OpenMM::Context::loadCheckpoint'
,
'OpenMM::Context::getMolecules'
]
self
.
skipMethods
=
[
'OpenMM::Context::getState'
,
'OpenMM::Platform::loadPluginsFromDirectory'
,
'OpenMM::Platform::getPluginLoadFailures'
,
'OpenMM::Context::createCheckpoint'
,
'OpenMM::Context::loadCheckpoint'
,
'OpenMM::Context::getMolecules'
]
self
.
hideClasses
=
[
'Kernel'
,
'KernelImpl'
,
'KernelFactory'
,
'ContextImpl'
,
'SerializationNode'
,
'SerializationProxy'
]
self
.
hideClasses
=
[
'Kernel'
,
'KernelImpl'
,
'KernelFactory'
,
'ContextImpl'
,
'SerializationNode'
,
'SerializationProxy'
]
self
.
nodeByID
=
{}
self
.
nodeByID
=
{}
...
@@ -398,6 +398,7 @@ extern OPENMM_EXPORT void %(name)s_insert(%(name)s* set, %(type)s value);""" % v
...
@@ -398,6 +398,7 @@ extern OPENMM_EXPORT void %(name)s_insert(%(name)s* set, %(type)s value);""" % v
Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself. */
Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself. */
extern OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types, int enforcePeriodicBox);
extern OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types, int enforcePeriodicBox);
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory);
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory);
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_getPluginLoadFailures();
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeSystem(const OpenMM_System* system);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeSystem(const OpenMM_System* system);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeState(const OpenMM_State* state);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeState(const OpenMM_State* state);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeIntegrator(const OpenMM_Integrator* integrator);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeIntegrator(const OpenMM_Integrator* integrator);
...
@@ -804,6 +805,10 @@ OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const
...
@@ -804,6 +805,10 @@ OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const
vector<string> result = Platform::loadPluginsFromDirectory(string(directory));
vector<string> result = Platform::loadPluginsFromDirectory(string(directory));
return reinterpret_cast<OpenMM_StringArray*>(new vector<string>(result));
return reinterpret_cast<OpenMM_StringArray*>(new vector<string>(result));
}
}
OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_getPluginLoadFailures() {
vector<string> result = Platform::getPluginLoadFailures();
return reinterpret_cast<OpenMM_StringArray*>(new vector<string>(result));
}
static char* createStringFromStream(stringstream& stream) {
static char* createStringFromStream(stringstream& stream) {
int length = stream.str().size();
int length = stream.str().size();
char* result = (char*) malloc(length+1);
char* result = (char*) malloc(length+1);
...
@@ -1314,6 +1319,10 @@ MODULE OpenMM
...
@@ -1314,6 +1319,10 @@ MODULE OpenMM
character(*) directory
character(*) directory
type(OpenMM_StringArray) result
type(OpenMM_StringArray) result
end subroutine
end subroutine
subroutine OpenMM_Platform_getPluginLoadFailures(result)
use OpenMM_Types; implicit none
type(OpenMM_StringArray) result
end subroutine
subroutine OpenMM_XmlSerializer_serializeSystemToC(system, result, result_length)
subroutine OpenMM_XmlSerializer_serializeSystemToC(system, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_System), intent(in) :: system
type(OpenMM_System), intent(in) :: system
...
@@ -1988,6 +1997,12 @@ OPENMM_EXPORT void openmm_platform_loadpluginsfromdirectory_(const char* directo
...
@@ -1988,6 +1997,12 @@ OPENMM_EXPORT void openmm_platform_loadpluginsfromdirectory_(const char* directo
OPENMM_EXPORT void OPENMM_PLATFORM_LOADPLUGINSFROMDIRECTORY(const char* directory, OpenMM_StringArray*& result, int length) {
OPENMM_EXPORT void OPENMM_PLATFORM_LOADPLUGINSFROMDIRECTORY(const char* directory, OpenMM_StringArray*& result, int length) {
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
}
}
OPENMM_EXPORT void openmm_platform_getpluginloadfailures_(OpenMM_StringArray*& result) {
result = OpenMM_Platform_getPluginLoadFailures();
}
OPENMM_EXPORT void OPENMM_PLATFORM_GETPLUGINLOADFAILURES(OpenMM_StringArray*& result) {
result = OpenMM_Platform_getPluginLoadFailures();
}
OPENMM_EXPORT void openmm_xmlserializer_serializesystemtoc_(OpenMM_System*& system, char*& result, int& result_length) {
OPENMM_EXPORT void openmm_xmlserializer_serializesystemtoc_(OpenMM_System*& system, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeSystem(system), result, result_length);
convertStringToChars(OpenMM_XmlSerializer_serializeSystem(system), result, result_length);
}
}
...
...
wrappers/python/src/swig_doxygen/swigInputConfig.py
View file @
b1d6a0db
...
@@ -180,6 +180,7 @@ UNITS = {
...
@@ -180,6 +180,7 @@ UNITS = {
(
"*"
,
"getParticleMass"
)
:
(
"unit.amu"
,
()),
(
"*"
,
"getParticleMass"
)
:
(
"unit.amu"
,
()),
(
"*"
,
"getPlatform"
)
:
(
None
,
()),
(
"*"
,
"getPlatform"
)
:
(
None
,
()),
(
"*"
,
"getPlatformByName"
)
:
(
None
,
()),
(
"*"
,
"getPlatformByName"
)
:
(
None
,
()),
(
"*"
,
"getPluginLoadFailures"
):
(
None
,
()),
(
"*"
,
"getRandomNumberSeed"
)
:
(
None
,
()),
(
"*"
,
"getRandomNumberSeed"
)
:
(
None
,
()),
(
"*"
,
"getReactionFieldDielectric"
)
:
(
None
,
()),
(
"*"
,
"getReactionFieldDielectric"
)
:
(
None
,
()),
(
"*"
,
"getSoluteDielectric"
)
:
(
None
,
()),
(
"*"
,
"getSoluteDielectric"
)
:
(
None
,
()),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment