Commit 88402c54 authored by peastman's avatar peastman
Browse files

Merge pull request #401 from rmcgibbo/disable

Disable OpenCL platform on known-buggy macs
parents 31fc3693 9edaf653
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
} }
double getSpeed() const; double getSpeed() const;
bool supportsDoublePrecision() const; bool supportsDoublePrecision() const;
static bool isPlatformSupported();
const std::string& getPropertyValue(const Context& context, const std::string& property) 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 setPropertyValue(Context& context, const std::string& property, const std::string& value) const;
void contextCreated(ContextImpl& context, const std::map<std::string, std::string>& properties) const; void contextCreated(ContextImpl& context, const std::map<std::string, std::string>& properties) const;
......
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
#include "openmm/System.h" #include "openmm/System.h"
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#ifdef __APPLE__
#include "sys/sysctl.h"
#endif
using namespace OpenMM; using namespace OpenMM;
using std::map; using std::map;
...@@ -42,10 +46,12 @@ using std::vector; ...@@ -42,10 +46,12 @@ using std::vector;
#ifdef OPENMM_OPENCL_BUILDING_STATIC_LIBRARY #ifdef OPENMM_OPENCL_BUILDING_STATIC_LIBRARY
extern "C" void registerOpenCLPlatform() { extern "C" void registerOpenCLPlatform() {
if (OpenCLPlatform::isPlatformSupported())
Platform::registerPlatform(new OpenCLPlatform()); Platform::registerPlatform(new OpenCLPlatform());
} }
#else #else
extern "C" OPENMM_EXPORT_OPENCL void registerPlatforms() { extern "C" OPENMM_EXPORT_OPENCL void registerPlatforms() {
if (OpenCLPlatform::isPlatformSupported())
Platform::registerPlatform(new OpenCLPlatform()); Platform::registerPlatform(new OpenCLPlatform());
} }
#endif #endif
...@@ -102,6 +108,33 @@ bool OpenCLPlatform::supportsDoublePrecision() const { ...@@ -102,6 +108,33 @@ bool OpenCLPlatform::supportsDoublePrecision() const {
return true; return true;
} }
bool OpenCLPlatform::isPlatformSupported() {
// Return false for OpenCL implementations that are known
// to be buggy (Apple OSX since 10.7.5)
#ifdef __APPLE__
char str[256];
size_t size = sizeof(str);
int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
if (ret != 0)
return false;
int major, minor, micro;
if (sscanf(str, "%d.%d.%d", &major, &minor, &micro) != 3)
return false;
if ((major > 11) || (major == 11 && minor > 4) || (major == 11 && minor == 4 && micro >= 2))
// 11.4.2 is the darwin release corresponding to OSX 10.7.5, which is the
// point at which a number of serious bugs were introduced into the
// Apple OpenCL libraries, resulting in catistrophically incorrect MD simulations
// (see https://github.com/SimTk/openmm/issues/395 for example). Once a fix is released,
// this version check should be updated.
return false;
#endif
return true;
}
const string& OpenCLPlatform::getPropertyValue(const Context& context, const string& property) const { const string& OpenCLPlatform::getPropertyValue(const Context& context, const string& property) const {
const ContextImpl& impl = getContextImpl(context); const ContextImpl& impl = getContextImpl(context);
const PlatformData* data = reinterpret_cast<const PlatformData*>(impl.getPlatformData()); const PlatformData* data = reinterpret_cast<const PlatformData*>(impl.getPlatformData());
......
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