diff options
Diffstat (limited to 'cuda/2d/darthelper.cu')
-rw-r--r-- | cuda/2d/darthelper.cu | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cuda/2d/darthelper.cu b/cuda/2d/darthelper.cu index db0036e..28b77cc 100644 --- a/cuda/2d/darthelper.cu +++ b/cuda/2d/darthelper.cu @@ -344,12 +344,14 @@ void dartSmoothing(float* out, const float* in, float b, unsigned int radius, un bool setGPUIndex(int iGPUIndex) { - cudaSetDevice(iGPUIndex); - cudaError_t err = cudaGetLastError(); + if (iGPUIndex != -1) { + cudaSetDevice(iGPUIndex); + cudaError_t err = cudaGetLastError(); - // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) - return false; + // Ignore errors caused by calling cudaSetDevice multiple times + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + return false; + } return true; } |