summaryrefslogtreecommitdiffstats
path: root/cuda/3d/astra3d.cu
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <WillemJan.Palenstijn@uantwerpen.be>2014-04-02 14:21:59 +0000
committerwpalenst <WillemJan.Palenstijn@uantwerpen.be>2014-04-02 14:21:59 +0000
commit2895e27613dab0815e9f0f2f0ed7853d31f856b4 (patch)
tree851d7171e07aa6db322cbf9286107b3db20f6a4e /cuda/3d/astra3d.cu
parent1d1e084d501883784eab283c622cb28510f36d27 (diff)
downloadastra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.gz
astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.bz2
astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.xz
astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.zip
Add global astra_set_gpu_index function
Diffstat (limited to 'cuda/3d/astra3d.cu')
-rw-r--r--cuda/3d/astra3d.cu89
1 files changed, 49 insertions, 40 deletions
diff --git a/cuda/3d/astra3d.cu b/cuda/3d/astra3d.cu
index fd4b370..4447775 100644
--- a/cuda/3d/astra3d.cu
+++ b/cuda/3d/astra3d.cu
@@ -381,12 +381,14 @@ bool AstraSIRT3d::enableSinogramMask()
bool AstraSIRT3d::setGPUIndex(int index)
{
- cudaSetDevice(index);
- cudaError_t err = cudaGetLastError();
+ if (index != -1) {
+ cudaSetDevice(index);
+ 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;
}
@@ -858,12 +860,14 @@ bool AstraCGLS3d::enableSinogramMask()
bool AstraCGLS3d::setGPUIndex(int index)
{
- cudaSetDevice(index);
- cudaError_t err = cudaGetLastError();
+ if (index != -1) {
+ cudaSetDevice(index);
+ 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;
}
@@ -1156,13 +1160,14 @@ bool astraCudaConeFP(const float* pfVolume, float* pfProjections,
if (iDetectorSuperSampling == 0)
return false;
- 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;
+ }
cudaPitchedPtr D_volumeData = allocateVolumeData(dims);
bool ok = D_volumeData.ptr;
@@ -1264,13 +1269,14 @@ bool astraCudaPar3DFP(const float* pfVolume, float* pfProjections,
if (iDetectorSuperSampling == 0)
return false;
- 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;
+ }
cudaPitchedPtr D_volumeData = allocateVolumeData(dims);
@@ -1382,13 +1388,14 @@ bool astraCudaConeBP(float* pfVolume, const float* pfProjections,
if (iProjAngles == 0 || iProjU == 0 || iProjV == 0 || pfAngles == 0)
return false;
- 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;
+ }
cudaPitchedPtr D_volumeData = allocateVolumeData(dims);
bool ok = D_volumeData.ptr;
@@ -1487,13 +1494,14 @@ bool astraCudaPar3DBP(float* pfVolume, const float* pfProjections,
if (iProjAngles == 0 || iProjU == 0 || iProjV == 0 || pfAngles == 0)
return false;
- 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;
+ }
cudaPitchedPtr D_volumeData = allocateVolumeData(dims);
@@ -1568,13 +1576,14 @@ bool astraCudaFDK(float* pfVolume, const float* pfProjections,
if (iVoxelSuperSampling == 0)
return false;
- 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;
+ }
cudaPitchedPtr D_volumeData = allocateVolumeData(dims);