diff options
Diffstat (limited to 'cuda')
| -rw-r--r-- | cuda/2d/algo.cu | 12 | ||||
| -rw-r--r-- | cuda/2d/astra.cu | 53 | ||||
| -rw-r--r-- | cuda/2d/darthelper.cu | 12 | ||||
| -rw-r--r-- | cuda/2d/darthelper.h | 2 | ||||
| -rw-r--r-- | cuda/3d/astra3d.cu | 89 | ||||
| -rw-r--r-- | cuda/3d/darthelper3d.cu | 12 | 
6 files changed, 99 insertions, 81 deletions
diff --git a/cuda/2d/algo.cu b/cuda/2d/algo.cu index 5ae5d08..f04607f 100644 --- a/cuda/2d/algo.cu +++ b/cuda/2d/algo.cu @@ -99,12 +99,14 @@ void ReconAlgo::reset()  bool ReconAlgo::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;  } 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; 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;  } diff --git a/cuda/2d/darthelper.h b/cuda/2d/darthelper.h index e05f01e..3694b96 100644 --- a/cuda/2d/darthelper.h +++ b/cuda/2d/darthelper.h @@ -29,8 +29,6 @@ $Id$  #ifndef _CUDA_ARITH2_H  #define _CUDA_ARITH2_H -#include <cuda.h> -  namespace astraCUDA {  	void roiSelect(float* out, float radius, unsigned int width, unsigned int height); 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); diff --git a/cuda/3d/darthelper3d.cu b/cuda/3d/darthelper3d.cu index 68330a1..6e60ec2 100644 --- a/cuda/3d/darthelper3d.cu +++ b/cuda/3d/darthelper3d.cu @@ -215,12 +215,14 @@ namespace astraCUDA3d {  	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;  	}  | 
