From 2895e27613dab0815e9f0f2f0ed7853d31f856b4 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 2 Apr 2014 14:21:59 +0000 Subject: Add global astra_set_gpu_index function --- cuda/2d/darthelper.cu | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cuda/2d/darthelper.cu') 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; } -- cgit v1.2.3