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