Commit 7c35e413 authored by Peter Eastman's avatar Peter Eastman
Browse files

Another attempt at getting device selection to work correctly on all platforms

parent ebfcfe24
......@@ -1692,8 +1692,11 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
int SMMinor = 0;
// Select which device to use
cudaError_t status = cudaSetDevice(device);
RTERROR(status, "Error setting CUDA device")
int currentDevice;
cudaError_t status = cudaGetDevice(&currentDevice);
RTERROR(status, "Error getting CUDA device")
if (device != currentDevice)
cudaSetDevice(device); // Ignore errors
status = cudaGetDevice(&gpu->device);
RTERROR(status, "Error getting CUDA device")
status = cudaSetDeviceFlags(useBlockingSync ? cudaDeviceBlockingSync : cudaDeviceScheduleAuto);
......@@ -1702,7 +1705,7 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
// Determine kernel call configuration
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, gpu->device);
cudaGetDeviceProperties(&deviceProp, currentDevice);
// Determine SM version
if (deviceProp.major == 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