diff --git a/stim/cuda/cudatools/devices.h b/stim/cuda/cudatools/devices.h index 9b32b38..249d7e0 100644 --- a/stim/cuda/cudatools/devices.h +++ b/stim/cuda/cudatools/devices.h @@ -1,5 +1,5 @@ -#ifndef RTS_CUDA_DEVICES -#define RTS_CUDA_DEVICES +#ifndef STIM_CUDA_DEVICES +#define STIM_CUDA_DEVICES #include @@ -35,11 +35,15 @@ namespace stim{ bool testDevice(int d, int major, int minor){ int nd; cudaGetDeviceCount(&nd); //get the number of CUDA devices - if(d < nd && d > 0) { //if the given ID has an associated device + if(d <= nd && d >= 0) { //if the given ID has an associated device cudaDeviceProp props; cudaGetDeviceProperties(&props, d); //get the device properties structure - if(props.major >= major && props.minor >= minor) - return true; + if(props.major > major){ + return true; + } + else if(props.major == major && props.minor >= minor){ + return true; + } } return false; } @@ -54,6 +58,23 @@ namespace stim{ } return valid; } + + void printDevice(int device){ + int nd; + cudaGetDeviceCount(&nd); //get the number of CUDA devices + printf("CUDA Device Diagnosis: [%i]\n", device); + if(device < 0){ + printf("Device %i is an invalid device ID\n", device); + } + else if(device >= nd){ + printf("Device %i is unavailable - only %i devices are detected", device, nd); + } + else{ + cudaDeviceProp props; + cudaGetDeviceProperties(&props, device); //get the device properties structure + printf("compute capability: %i.%i\n", props.major, props.minor); + } + } } //end namespace rts #endif -- libgit2 0.21.4