diff options
Diffstat (limited to 'cuda/2d/astra.cu')
-rw-r--r-- | cuda/2d/astra.cu | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 5d53da0..2240629 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -195,13 +195,15 @@ bool AstraFBP::init(int iGPUIndex) return false; } - 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; + } } bool ok = allocateVolume(pData->D_volumeData, pData->dims.iVolWidth+2, pData->dims.iVolHeight+2, pData->volumePitch); @@ -563,13 +565,14 @@ bool astraCudaFP(const float* pfVolume, float* pfSinogram, dims.iVolWidth = iVolWidth; dims.iVolHeight = iVolHeight; - cudaSetDevice(iGPUIndex); - cudaError_t err = cudaGetLastError(); - - // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) - return false; + if (iGPUIndex != -1) { + cudaSetDevice(iGPUIndex); + cudaError_t err = cudaGetLastError(); + // Ignore errors caused by calling cudaSetDevice multiple times + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + return false; + } bool ok; @@ -649,13 +652,14 @@ bool astraCudaFanFP(const float* pfVolume, float* pfSinogram, dims.iVolWidth = iVolWidth; dims.iVolHeight = iVolHeight; - cudaSetDevice(iGPUIndex); - cudaError_t err = cudaGetLastError(); - - // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) - return false; + if (iGPUIndex != -1) { + cudaSetDevice(iGPUIndex); + cudaError_t err = cudaGetLastError(); + // Ignore errors caused by calling cudaSetDevice multiple times + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + return false; + } bool ok; @@ -759,13 +763,14 @@ bool astraCudaFanFP(const float* pfVolume, float* pfSinogram, dims.iVolWidth = iVolWidth; dims.iVolHeight = iVolHeight; - cudaSetDevice(iGPUIndex); - cudaError_t err = cudaGetLastError(); - - // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) - return false; + if (iGPUIndex != -1) { + cudaSetDevice(iGPUIndex); + cudaError_t err = cudaGetLastError(); + // Ignore errors caused by calling cudaSetDevice multiple times + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + return false; + } bool ok; |