Commit 9edaf653 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Disable OpenCL platform on known-buggy macs

parent 44d4d6b2
......@@ -48,6 +48,7 @@ public:
}
double getSpeed() const;
bool supportsDoublePrecision() const;
static bool isPlatformSupported();
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 std::map<std::string, std::string>& properties) const;
......
......@@ -33,6 +33,10 @@
#include "openmm/System.h"
#include <algorithm>
#include <sstream>
#ifdef __APPLE__
#include "sys/sysctl.h"
#endif
using namespace OpenMM;
using std::map;
......@@ -42,10 +46,12 @@ using std::vector;
#ifdef OPENMM_OPENCL_BUILDING_STATIC_LIBRARY
extern "C" void registerOpenCLPlatform() {
if (OpenCLPlatform::isPlatformSupported())
Platform::registerPlatform(new OpenCLPlatform());
}
#else
extern "C" OPENMM_EXPORT_OPENCL void registerPlatforms() {
if (OpenCLPlatform::isPlatformSupported())
Platform::registerPlatform(new OpenCLPlatform());
}
#endif
......@@ -102,6 +108,33 @@ bool OpenCLPlatform::supportsDoublePrecision() const {
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 ContextImpl& impl = getContextImpl(context);
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