Commit a4673043 authored by Peter Eastman's avatar Peter Eastman
Browse files

A cl::Context only specifies the particular device it is using, not all devices

parent 59131379
...@@ -75,9 +75,8 @@ OpenCLContext::OpenCLContext(int numParticles, int platformIndex, int deviceInde ...@@ -75,9 +75,8 @@ OpenCLContext::OpenCLContext(int numParticles, int platformIndex, int deviceInde
cl::Platform::get(&platforms); cl::Platform::get(&platforms);
if (platformIndex < 0 || platformIndex >= platforms.size()) if (platformIndex < 0 || platformIndex >= platforms.size())
throw OpenMMException("Illegal value for OpenCL platform index"); throw OpenMMException("Illegal value for OpenCL platform index");
cl_context_properties cprops[] = {CL_CONTEXT_PLATFORM, (cl_context_properties) platforms[platformIndex](), 0}; vector<cl::Device> devices;
context = cl::Context(CL_DEVICE_TYPE_ALL, cprops, errorCallback); platforms[platformIndex].getDevices(CL_DEVICE_TYPE_ALL, &devices);
vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
const int minThreadBlockSize = 32; const int minThreadBlockSize = 32;
if (deviceIndex < 0 || deviceIndex >= (int) devices.size()) { if (deviceIndex < 0 || deviceIndex >= (int) devices.size()) {
// Try to figure out which device is the fastest. // Try to figure out which device is the fastest.
...@@ -203,6 +202,10 @@ OpenCLContext::OpenCLContext(int numParticles, int platformIndex, int deviceInde ...@@ -203,6 +202,10 @@ OpenCLContext::OpenCLContext(int numParticles, int platformIndex, int deviceInde
compilationDefines["SUPPORTS_64_BIT_ATOMICS"] = ""; compilationDefines["SUPPORTS_64_BIT_ATOMICS"] = "";
if (supportsDoublePrecision) if (supportsDoublePrecision)
compilationDefines["SUPPORTS_DOUBLE_PRECISION"] = ""; compilationDefines["SUPPORTS_DOUBLE_PRECISION"] = "";
vector<cl::Device> contextDevices;
contextDevices.push_back(device);
cl_context_properties cprops[] = {CL_CONTEXT_PLATFORM, (cl_context_properties) platforms[platformIndex](), 0};
context = cl::Context(contextDevices, cprops, errorCallback);
queue = cl::CommandQueue(context, device); queue = cl::CommandQueue(context, device);
numAtoms = numParticles; numAtoms = numParticles;
paddedNumAtoms = TileSize*((numParticles+TileSize-1)/TileSize); paddedNumAtoms = TileSize*((numParticles+TileSize-1)/TileSize);
......
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