diff options
author | Willem Jan Palenstijn <WillemJan.Palenstijn@uantwerpen.be> | 2014-04-02 14:21:59 +0000 |
---|---|---|
committer | wpalenst <WillemJan.Palenstijn@uantwerpen.be> | 2014-04-02 14:21:59 +0000 |
commit | 2895e27613dab0815e9f0f2f0ed7853d31f856b4 (patch) | |
tree | 851d7171e07aa6db322cbf9286107b3db20f6a4e | |
parent | 1d1e084d501883784eab283c622cb28510f36d27 (diff) | |
download | astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.gz astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.bz2 astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.xz astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.zip |
Add global astra_set_gpu_index function
32 files changed, 175 insertions, 114 deletions
diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index be50cbf..3e8bca1 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -57,6 +57,11 @@ MEXLDFLAGS='$$LDFLAGS $(LDFLAGS)' MEXLIBS ="-L.libs -lut" MEXSUFFIX = @MEXSUFFIX@ MEX = @MEX@ + +ifeq ($(cuda),yes) +MEXFLAGS += -DASTRA_CUDA +endif + endif LIBDIR=/usr/local/lib 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; } diff --git a/include/astra/CudaBackProjectionAlgorithm.h b/include/astra/CudaBackProjectionAlgorithm.h index 965c734..09a2a65 100644 --- a/include/astra/CudaBackProjectionAlgorithm.h +++ b/include/astra/CudaBackProjectionAlgorithm.h @@ -91,7 +91,7 @@ public: bool initialize(CProjector2D* _pProjector, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pReconstruction, - int _iGPUindex = 0, int _iPixelSuperSampling = 1); + int _iGPUindex = -1, int _iPixelSuperSampling = 1); /** Get a description of the class. * diff --git a/include/astra/CudaCglsAlgorithm.h b/include/astra/CudaCglsAlgorithm.h index 7734d6e..a529bfd 100644 --- a/include/astra/CudaCglsAlgorithm.h +++ b/include/astra/CudaCglsAlgorithm.h @@ -101,7 +101,7 @@ public: bool initialize(CProjector2D* _pProjector, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pReconstruction, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1, + int _iGPUindex = -1, int _iDetectorSuperSampling = 1, int _iPixelSuperSampling = 1); /** Get a description of the class. diff --git a/include/astra/CudaEMAlgorithm.h b/include/astra/CudaEMAlgorithm.h index ff22dd4..ca9c9f6 100644 --- a/include/astra/CudaEMAlgorithm.h +++ b/include/astra/CudaEMAlgorithm.h @@ -72,7 +72,7 @@ public: bool initialize(CProjector2D* _pProjector, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pReconstruction, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1, + int _iGPUindex = -1, int _iDetectorSuperSampling = 1, int _iPixelSuperSampling = 1); /** Get a description of the class. diff --git a/include/astra/CudaFilteredBackProjectionAlgorithm.h b/include/astra/CudaFilteredBackProjectionAlgorithm.h index 4b7b904..c496c8f 100644 --- a/include/astra/CudaFilteredBackProjectionAlgorithm.h +++ b/include/astra/CudaFilteredBackProjectionAlgorithm.h @@ -61,7 +61,7 @@ public: virtual ~CCudaFilteredBackProjectionAlgorithm(); virtual bool initialize(const Config& _cfg); - bool initialize(CFloat32ProjectionData2D * _pSinogram, CFloat32VolumeData2D * _pReconstruction, E_FBPFILTER _eFilter, const float * _pfFilter = NULL, int _iFilterWidth = 0, int _iGPUIndex = 0, float _fFilterParameter = -1.0f); + bool initialize(CFloat32ProjectionData2D * _pSinogram, CFloat32VolumeData2D * _pReconstruction, E_FBPFILTER _eFilter, const float * _pfFilter = NULL, int _iFilterWidth = 0, int _iGPUIndex = -1, float _fFilterParameter = -1.0f); virtual void run(int _iNrIterations = 0); diff --git a/include/astra/CudaForwardProjectionAlgorithm.h b/include/astra/CudaForwardProjectionAlgorithm.h index 53b6c8e..6a6ba24 100644 --- a/include/astra/CudaForwardProjectionAlgorithm.h +++ b/include/astra/CudaForwardProjectionAlgorithm.h @@ -103,7 +103,7 @@ public: CVolumeGeometry2D* _pVolumeGeometry, CFloat32VolumeData2D* _pVolume, CFloat32ProjectionData2D* _pSinogram, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1); + int _iGPUindex = -1, int _iDetectorSuperSampling = 1); /** Get all information parameters * diff --git a/include/astra/CudaForwardProjectionAlgorithm3D.h b/include/astra/CudaForwardProjectionAlgorithm3D.h index 72c6a00..3312eec 100644 --- a/include/astra/CudaForwardProjectionAlgorithm3D.h +++ b/include/astra/CudaForwardProjectionAlgorithm3D.h @@ -74,7 +74,7 @@ public: bool initialize(CProjector3D* _pProjector, CFloat32ProjectionData3DMemory* _pSinogram, CFloat32VolumeData3DMemory* _pReconstruction, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1); + int _iGPUindex = -1, int _iDetectorSuperSampling = 1); /** Get all information parameters diff --git a/include/astra/CudaReconstructionAlgorithm2D.h b/include/astra/CudaReconstructionAlgorithm2D.h index 88fc344..68f4b5d 100644 --- a/include/astra/CudaReconstructionAlgorithm2D.h +++ b/include/astra/CudaReconstructionAlgorithm2D.h @@ -90,7 +90,7 @@ public: virtual bool initialize(CProjector2D* _pProjector, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pReconstruction, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1, + int _iGPUindex = -1, int _iDetectorSuperSampling = 1, int _iPixelSuperSampling = 1); diff --git a/include/astra/CudaSartAlgorithm.h b/include/astra/CudaSartAlgorithm.h index 319e1e9..49845f2 100644 --- a/include/astra/CudaSartAlgorithm.h +++ b/include/astra/CudaSartAlgorithm.h @@ -93,7 +93,7 @@ public: bool initialize(CProjector2D* _pProjector, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pReconstruction, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1); + int _iGPUindex = -1, int _iDetectorSuperSampling = 1); /** Get a description of the class. * diff --git a/include/astra/CudaSirtAlgorithm.h b/include/astra/CudaSirtAlgorithm.h index 7f3d67b..34b5a66 100644 --- a/include/astra/CudaSirtAlgorithm.h +++ b/include/astra/CudaSirtAlgorithm.h @@ -107,7 +107,7 @@ public: bool initialize(CProjector2D* _pProjector, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pReconstruction, - int _iGPUindex = 0, int _iDetectorSuperSampling = 1, + int _iGPUindex = -1, int _iDetectorSuperSampling = 1, int _iPixelSuperSampling = 1); /** Get a description of the class. diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp index 0068664..816f1f3 100644 --- a/matlab/mex/astra_mex_c.cpp +++ b/matlab/mex/astra_mex_c.cpp @@ -36,6 +36,8 @@ $Id$ #include "astra/Globals.h" +#include "../cuda/2d/darthelper.h" + using namespace std; using namespace astra; @@ -72,6 +74,22 @@ void astra_mex_use_cuda(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs } //----------------------------------------------------------------------------------------- +/** set_gpu_index = astra_mex('set_gpu_index'); + * + * Set active GPU + */ +void astra_mex_set_gpu_index(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) +{ +#ifdef ASTRA_CUDA + if (nrhs >= 2) { + bool ret = astraCUDA::setGPUIndex((int)mxGetScalar(prhs[1])); + if (!ret) + mexPrintf("Failed to set GPU %d\n", (int)mxGetScalar(prhs[1])); + } +#endif +} + +//----------------------------------------------------------------------------------------- /** version_number = astra_mex('version'); * * Fetch the version number of the toolbox. @@ -117,6 +135,8 @@ void mexFunction(int nlhs, mxArray* plhs[], astra_mex_use_cuda(nlhs, plhs, nrhs, prhs); } else if (sMode == std::string("credits")) { astra_mex_credits(nlhs, plhs, nrhs, prhs); + } else if (sMode == std::string("set_gpu_index")) { + astra_mex_set_gpu_index(nlhs, plhs, nrhs, prhs); } else { printHelp(); } diff --git a/matlab/tools/astra_set_gpu_index.m b/matlab/tools/astra_set_gpu_index.m new file mode 100644 index 0000000..192ba00 --- /dev/null +++ b/matlab/tools/astra_set_gpu_index.m @@ -0,0 +1,18 @@ +function astra_set_gpu_index(index) + +%-------------------------------------------------------------------------- +% Set the index of the GPU to use +%-------------------------------------------------------------------------- +%------------------------------------------------------------------------ +% This file is part of the +% All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA-Toolbox") +% +% Copyright: iMinds-Vision Lab, University of Antwerp +% License: Open Source under GPLv3 +% Contact: mailto:astra@ua.ac.be +% Website: http://astra.ua.ac.be +%------------------------------------------------------------------------ +% $Id$ + +astra_mex('set_gpu_index', index); + diff --git a/src/CudaBackProjectionAlgorithm3D.cpp b/src/CudaBackProjectionAlgorithm3D.cpp index b60adf1..b096756 100644 --- a/src/CudaBackProjectionAlgorithm3D.cpp +++ b/src/CudaBackProjectionAlgorithm3D.cpp @@ -51,7 +51,7 @@ std::string CCudaBackProjectionAlgorithm3D::type = "BP3D_CUDA"; CCudaBackProjectionAlgorithm3D::CCudaBackProjectionAlgorithm3D() { m_bIsInitialized = false; - m_iGPUIndex = 0; + m_iGPUIndex = -1; m_iVoxelSuperSampling = 1; } @@ -101,7 +101,7 @@ bool CCudaBackProjectionAlgorithm3D::initialize(const Config& _cfg) return false; } - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); CC.markOptionParsed("GPUindex"); m_iVoxelSuperSampling = (int)_cfg.self->getOptionNumerical("VoxelSuperSampling", 1); CC.markOptionParsed("VoxelSuperSampling"); diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp index 07569a2..37d3592 100644 --- a/src/CudaCglsAlgorithm3D.cpp +++ b/src/CudaCglsAlgorithm3D.cpp @@ -51,7 +51,7 @@ CCudaCglsAlgorithm3D::CCudaCglsAlgorithm3D() { m_bIsInitialized = false; m_pCgls = 0; - m_iGPUIndex = 0; + m_iGPUIndex = -1; m_iVoxelSuperSampling = 1; m_iDetectorSuperSampling = 1; } @@ -106,7 +106,7 @@ bool CCudaCglsAlgorithm3D::initialize(const Config& _cfg) return false; } - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); CC.markOptionParsed("GPUindex"); m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1); CC.markOptionParsed("DetectorSuperSampling"); diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp index 9c9b83f..911e448 100644 --- a/src/CudaDartMaskAlgorithm.cpp +++ b/src/CudaDartMaskAlgorithm.cpp @@ -81,7 +81,7 @@ bool CCudaDartMaskAlgorithm::initialize(const Config& _cfg) CC.markNodeParsed("MaskDataId"); // Option: GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) diff --git a/src/CudaDartMaskAlgorithm3D.cpp b/src/CudaDartMaskAlgorithm3D.cpp index 7965587..f5d5d82 100644 --- a/src/CudaDartMaskAlgorithm3D.cpp +++ b/src/CudaDartMaskAlgorithm3D.cpp @@ -81,7 +81,7 @@ bool CCudaDartMaskAlgorithm3D::initialize(const Config& _cfg) CC.markNodeParsed("MaskDataId"); // Option: GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp index 91cde6d..e77606b 100644 --- a/src/CudaDartSmoothingAlgorithm.cpp +++ b/src/CudaDartSmoothingAlgorithm.cpp @@ -81,7 +81,7 @@ bool CCudaDartSmoothingAlgorithm::initialize(const Config& _cfg) CC.markNodeParsed("OutDataId"); // Option: GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) diff --git a/src/CudaDartSmoothingAlgorithm3D.cpp b/src/CudaDartSmoothingAlgorithm3D.cpp index 50ef847..e44970f 100644 --- a/src/CudaDartSmoothingAlgorithm3D.cpp +++ b/src/CudaDartSmoothingAlgorithm3D.cpp @@ -81,7 +81,7 @@ bool CCudaDartSmoothingAlgorithm3D::initialize(const Config& _cfg) CC.markNodeParsed("OutDataId"); // Option: GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) diff --git a/src/CudaDataOperationAlgorithm.cpp b/src/CudaDataOperationAlgorithm.cpp index ed2ac94..f27cab8 100644 --- a/src/CudaDataOperationAlgorithm.cpp +++ b/src/CudaDataOperationAlgorithm.cpp @@ -94,7 +94,7 @@ bool CCudaDataOperationAlgorithm::initialize(const Config& _cfg) CC.markNodeParsed("Scalar"); // Option: GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) diff --git a/src/CudaFDKAlgorithm3D.cpp b/src/CudaFDKAlgorithm3D.cpp index 8f9e7b8..6b65641 100644 --- a/src/CudaFDKAlgorithm3D.cpp +++ b/src/CudaFDKAlgorithm3D.cpp @@ -48,7 +48,7 @@ std::string CCudaFDKAlgorithm3D::type = "FDK_CUDA"; CCudaFDKAlgorithm3D::CCudaFDKAlgorithm3D() { m_bIsInitialized = false; - m_iGPUIndex = 0; + m_iGPUIndex = -1; m_iVoxelSuperSampling = 1; } @@ -100,7 +100,7 @@ bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg) return false; } - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); CC.markOptionParsed("GPUindex"); m_iVoxelSuperSampling = (int)_cfg.self->getOptionNumerical("VoxelSuperSampling", 1); CC.markOptionParsed("VoxelSuperSampling"); diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp index 75a1534..3656f3f 100644 --- a/src/CudaFilteredBackProjectionAlgorithm.cpp +++ b/src/CudaFilteredBackProjectionAlgorithm.cpp @@ -153,7 +153,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg) ASTRA_DELETE(node); // GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); CC.markOptionParsed("GPUindex"); // Pixel supersampling factor @@ -286,7 +286,7 @@ bool CCudaFilteredBackProjectionAlgorithm::check() ASTRA_CONFIG_CHECK(m_pReconstruction->isInitialized(), "FBP_CUDA", "Reconstruction Data Object Not Initialized."); // check gpu index - ASTRA_CONFIG_CHECK(m_iGPUIndex >= 0, "FBP_CUDA", "GPUIndex must be a non-negative integer."); + ASTRA_CONFIG_CHECK(m_iGPUIndex >= -1, "FBP_CUDA", "GPUIndex must be a non-negative integer."); // check pixel supersampling ASTRA_CONFIG_CHECK(m_iPixelSuperSampling >= 0, "FBP_CUDA", "PixelSuperSampling must be a non-negative integer."); diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp index 965c4af..bd9cffb 100644 --- a/src/CudaForwardProjectionAlgorithm.cpp +++ b/src/CudaForwardProjectionAlgorithm.cpp @@ -87,7 +87,7 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg) CC.markNodeParsed("VolumeDataId"); // GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) @@ -153,7 +153,7 @@ bool CCudaForwardProjectionAlgorithm::check() //ASTRA_CONFIG_CHECK((iImageSideBlocks * G_BLOCKIMAGESIZE) == m_pVolume->getHeight(), "FP_CUDA", "Volume Height must be a multiple of G_BLOCKIMAGESIZE"); //ASTRA_CONFIG_CHECK(m_pProjectionGeometry->getDetectorCount() == (m_pVolume->getWidth() * 3 / 2), "SIRT_CUDA", "Number of detectors must be 1.5 times the width of the image"); - ASTRA_CONFIG_CHECK(m_iGPUIndex >= 0, "FP_CUDA", "GPUIndex must be a non-negative integer."); + ASTRA_CONFIG_CHECK(m_iGPUIndex >= -1, "FP_CUDA", "GPUIndex must be a non-negative integer."); // success m_bIsInitialized = true; diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp index e9289f1..f64620f 100644 --- a/src/CudaForwardProjectionAlgorithm3D.cpp +++ b/src/CudaForwardProjectionAlgorithm3D.cpp @@ -54,7 +54,7 @@ std::string CCudaForwardProjectionAlgorithm3D::type = "FP3D_CUDA"; CCudaForwardProjectionAlgorithm3D::CCudaForwardProjectionAlgorithm3D() { m_bIsInitialized = false; - m_iGPUIndex = 0; + m_iGPUIndex = -1; m_iDetectorSuperSampling = 1; m_pProjector = 0; m_pProjections = 0; @@ -107,7 +107,7 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg) CC.markNodeParsed("ProjectorId"); // GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); CC.markOptionParsed("GPUindex"); m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1); CC.markOptionParsed("DetectorSuperSampling"); @@ -160,7 +160,7 @@ bool CCudaForwardProjectionAlgorithm3D::check() ASTRA_CONFIG_CHECK(m_pVolume->isInitialized(), "FP3D_CUDA", "Volume Data Object Not Initialized."); ASTRA_CONFIG_CHECK(m_iDetectorSuperSampling >= 1, "FP3D_CUDA", "DetectorSuperSampling must be a positive integer."); - ASTRA_CONFIG_CHECK(m_iGPUIndex >= 0, "FP3D_CUDA", "GPUIndex must be a non-negative integer."); + ASTRA_CONFIG_CHECK(m_iGPUIndex >= -1, "FP3D_CUDA", "GPUIndex must be a non-negative integer."); // check compatibility between projector and data classes // ASTRA_CONFIG_CHECK(m_pSinogram->getGeometry()->isEqual(m_pProjector->getProjectionGeometry()), "SIRT_CUDA", "Projection Data not compatible with the specified Projector."); diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp index d567158..385cef1 100644 --- a/src/CudaReconstructionAlgorithm2D.cpp +++ b/src/CudaReconstructionAlgorithm2D.cpp @@ -76,7 +76,7 @@ void CCudaReconstructionAlgorithm2D::_clear() m_bAlgoInit = false; CReconstructionAlgorithm2D::_clear(); - m_iGPUIndex = 0; + m_iGPUIndex = -1; m_iDetectorSuperSampling = 1; m_iPixelSuperSampling = 1; } @@ -153,7 +153,7 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg) } // GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) @@ -240,7 +240,7 @@ bool CCudaReconstructionAlgorithm2D::_check() ASTRA_CONFIG_CHECK(m_iDetectorSuperSampling >= 1, "SIRT_CUDA", "DetectorSuperSampling must be a positive integer."); ASTRA_CONFIG_CHECK(m_iPixelSuperSampling >= 1, "SIRT_CUDA", "PixelSuperSampling must be a positive integer."); - ASTRA_CONFIG_CHECK(m_iGPUIndex >= 0, "SIRT_CUDA", "GPUIndex must be a non-negative integer."); + ASTRA_CONFIG_CHECK(m_iGPUIndex >= -1, "SIRT_CUDA", "GPUIndex must be a non-negative integer."); // check compatibility between projector and data classes // ASTRA_CONFIG_CHECK(m_pSinogram->getGeometry()->isEqual(m_pProjector->getProjectionGeometry()), "SIRT_CUDA", "Projection Data not compatible with the specified Projector."); diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp index f835c59..bbe2235 100644 --- a/src/CudaRoiSelectAlgorithm.cpp +++ b/src/CudaRoiSelectAlgorithm.cpp @@ -74,7 +74,7 @@ bool CCudaRoiSelectAlgorithm::initialize(const Config& _cfg) CC.markNodeParsed("DataId"); // Option: GPU number - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self->hasOption("GPUindex")) diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp index f23d0f6..179ded8 100644 --- a/src/CudaSirtAlgorithm3D.cpp +++ b/src/CudaSirtAlgorithm3D.cpp @@ -52,7 +52,7 @@ CCudaSirtAlgorithm3D::CCudaSirtAlgorithm3D() { m_bIsInitialized = false; m_pSirt = 0; - m_iGPUIndex = 0; + m_iGPUIndex = -1; m_iVoxelSuperSampling = 1; m_iDetectorSuperSampling = 1; } @@ -107,7 +107,7 @@ bool CCudaSirtAlgorithm3D::initialize(const Config& _cfg) return false; } - m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", 0); + m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1); CC.markOptionParsed("GPUindex"); m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1); CC.markOptionParsed("DetectorSuperSampling"); |