diff options
author | Willem Jan Palenstijn <wjp@usecode.org> | 2017-02-09 18:01:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-09 18:01:03 +0100 |
commit | 981d6adc0e3c98a67403b92b1ec4cdb881c62fda (patch) | |
tree | cccde0fd4a3a2d92919338df4e162c9abfd079e1 /include | |
parent | 03c3e5b5043cc8cba9aceeb8641d497edd1be7cf (diff) | |
parent | 4c665b0d5af3841f20501a5dc01a23e671367856 (diff) | |
download | astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.gz astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.bz2 astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.xz astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.zip |
Merge pull request #93 from wjp/GPULink
GPULink support
Diffstat (limited to 'include')
-rw-r--r-- | include/astra/CompositeGeometryManager.h | 43 | ||||
-rw-r--r-- | include/astra/CudaBackProjectionAlgorithm3D.h | 8 | ||||
-rw-r--r-- | include/astra/CudaFDKAlgorithm3D.h | 8 | ||||
-rw-r--r-- | include/astra/CudaForwardProjectionAlgorithm3D.h | 8 | ||||
-rw-r--r-- | include/astra/Float32Data2D.h | 2 | ||||
-rw-r--r-- | include/astra/Float32Data3D.h | 20 | ||||
-rw-r--r-- | include/astra/Float32Data3DGPU.h | 107 | ||||
-rw-r--r-- | include/astra/Float32Data3DMemory.h | 66 | ||||
-rw-r--r-- | include/astra/Float32ProjectionData3D.h | 49 | ||||
-rw-r--r-- | include/astra/Float32ProjectionData3DGPU.h | 91 | ||||
-rw-r--r-- | include/astra/Float32ProjectionData3DMemory.h | 49 | ||||
-rw-r--r-- | include/astra/Float32VolumeData3D.h | 66 | ||||
-rw-r--r-- | include/astra/Float32VolumeData3DGPU.h | 91 | ||||
-rw-r--r-- | include/astra/Float32VolumeData3DMemory.h | 49 | ||||
-rw-r--r-- | include/astra/Globals.h | 12 |
15 files changed, 342 insertions, 327 deletions
diff --git a/include/astra/CompositeGeometryManager.h b/include/astra/CompositeGeometryManager.h index c0acf4f..08eb7af 100644 --- a/include/astra/CompositeGeometryManager.h +++ b/include/astra/CompositeGeometryManager.h @@ -42,9 +42,9 @@ namespace astra { class CCompositeVolume; class CCompositeProjections; -class CFloat32Data3DMemory; -class CFloat32ProjectionData3DMemory; -class CFloat32VolumeData3DMemory; +class CFloat32Data3D; +class CFloat32ProjectionData3D; +class CFloat32VolumeData3D; class CVolumeGeometry3D; class CProjectionGeometry3D; class CProjector3D; @@ -77,7 +77,7 @@ public: PART_VOL, PART_PROJ } eType; - CFloat32Data3DMemory* pData; + CFloat32Data3D* pData; unsigned int subX; unsigned int subY; unsigned int subZ; @@ -88,8 +88,11 @@ public: virtual void splitY(TPartList& out, size_t maxSize, size_t maxDim, int div) = 0; virtual void splitZ(TPartList& out, size_t maxSize, size_t maxDim, int div) = 0; virtual CPart* reduce(const CPart *other) = 0; - virtual void getDims(size_t &x, size_t &y, size_t &z) = 0; - size_t getSize(); + virtual void getDims(size_t &x, size_t &y, size_t &z) const = 0; + size_t getSize() const; + + bool canSplitAndReduce() const; + bool isFull() const; }; class CVolumePart : public CPart { @@ -104,7 +107,7 @@ public: virtual void splitY(TPartList& out, size_t maxSize, size_t maxDim, int div); virtual void splitZ(TPartList& out, size_t maxSize, size_t maxDim, int div); virtual CPart* reduce(const CPart *other); - virtual void getDims(size_t &x, size_t &y, size_t &z); + virtual void getDims(size_t &x, size_t &y, size_t &z) const; CVolumePart* clone() const; }; @@ -120,7 +123,7 @@ public: virtual void splitY(TPartList& out, size_t maxSize, size_t maxDim, int div); virtual void splitZ(TPartList& out, size_t maxSize, size_t maxDim, int div); virtual CPart* reduce(const CPart *other); - virtual void getDims(size_t &x, size_t &y, size_t &z); + virtual void getDims(size_t &x, size_t &y, size_t &z) const; CProjectionPart* clone() const; }; @@ -150,23 +153,23 @@ public: bool doJobs(TJobList &jobs); SJob createJobFP(CProjector3D *pProjector, - CFloat32VolumeData3DMemory *pVolData, - CFloat32ProjectionData3DMemory *pProjData); + CFloat32VolumeData3D *pVolData, + CFloat32ProjectionData3D *pProjData); SJob createJobBP(CProjector3D *pProjector, - CFloat32VolumeData3DMemory *pVolData, - CFloat32ProjectionData3DMemory *pProjData); + CFloat32VolumeData3D *pVolData, + CFloat32ProjectionData3D *pProjData); // Convenience functions for creating and running a single FP or BP job - bool doFP(CProjector3D *pProjector, CFloat32VolumeData3DMemory *pVolData, - CFloat32ProjectionData3DMemory *pProjData); - bool doBP(CProjector3D *pProjector, CFloat32VolumeData3DMemory *pVolData, - CFloat32ProjectionData3DMemory *pProjData); - bool doFDK(CProjector3D *pProjector, CFloat32VolumeData3DMemory *pVolData, - CFloat32ProjectionData3DMemory *pProjData, bool bShortScan, + bool doFP(CProjector3D *pProjector, CFloat32VolumeData3D *pVolData, + CFloat32ProjectionData3D *pProjData); + bool doBP(CProjector3D *pProjector, CFloat32VolumeData3D *pVolData, + CFloat32ProjectionData3D *pProjData); + bool doFDK(CProjector3D *pProjector, CFloat32VolumeData3D *pVolData, + CFloat32ProjectionData3D *pProjData, bool bShortScan, const float *pfFilter = 0); - bool doFP(CProjector3D *pProjector, const std::vector<CFloat32VolumeData3DMemory *>& volData, const std::vector<CFloat32ProjectionData3DMemory *>& projData); - bool doBP(CProjector3D *pProjector, const std::vector<CFloat32VolumeData3DMemory *>& volData, const std::vector<CFloat32ProjectionData3DMemory *>& projData); + bool doFP(CProjector3D *pProjector, const std::vector<CFloat32VolumeData3D *>& volData, const std::vector<CFloat32ProjectionData3D *>& projData); + bool doBP(CProjector3D *pProjector, const std::vector<CFloat32VolumeData3D *>& volData, const std::vector<CFloat32ProjectionData3D *>& projData); void setGPUIndices(const std::vector<int>& GPUIndices); diff --git a/include/astra/CudaBackProjectionAlgorithm3D.h b/include/astra/CudaBackProjectionAlgorithm3D.h index 6738988..114d6f3 100644 --- a/include/astra/CudaBackProjectionAlgorithm3D.h +++ b/include/astra/CudaBackProjectionAlgorithm3D.h @@ -69,8 +69,8 @@ public: * @param _pReconstruction VolumeData3D object for storing the reconstructed volume. */ CCudaBackProjectionAlgorithm3D(CProjector3D* _pProjector, - CFloat32ProjectionData3DMemory* _pProjectionData, - CFloat32VolumeData3DMemory* _pReconstruction); + CFloat32ProjectionData3D* _pProjectionData, + CFloat32VolumeData3D* _pReconstruction); /** Copy constructor. */ @@ -99,8 +99,8 @@ public: * @return initialization successful? */ bool initialize(CProjector3D* _pProjector, - CFloat32ProjectionData3DMemory* _pSinogram, - CFloat32VolumeData3DMemory* _pReconstruction); + CFloat32ProjectionData3D* _pSinogram, + CFloat32VolumeData3D* _pReconstruction); /** Get all information parameters * diff --git a/include/astra/CudaFDKAlgorithm3D.h b/include/astra/CudaFDKAlgorithm3D.h index 386129e..1c4c622 100644 --- a/include/astra/CudaFDKAlgorithm3D.h +++ b/include/astra/CudaFDKAlgorithm3D.h @@ -81,8 +81,8 @@ public: * @param _pReconstruction VolumeData3D object for storing the reconstructed volume. */ CCudaFDKAlgorithm3D(CProjector3D* _pProjector, - CFloat32ProjectionData3DMemory* _pProjectionData, - CFloat32VolumeData3DMemory* _pReconstruction); + CFloat32ProjectionData3D* _pProjectionData, + CFloat32VolumeData3D* _pReconstruction); /** Copy constructor. */ @@ -111,8 +111,8 @@ public: * @return initialization successful? */ bool initialize(CProjector3D* _pProjector, - CFloat32ProjectionData3DMemory* _pSinogram, - CFloat32VolumeData3DMemory* _pReconstruction); + CFloat32ProjectionData3D* _pSinogram, + CFloat32VolumeData3D* _pReconstruction); /** Get all information parameters * diff --git a/include/astra/CudaForwardProjectionAlgorithm3D.h b/include/astra/CudaForwardProjectionAlgorithm3D.h index 95af73a..9dc889e 100644 --- a/include/astra/CudaForwardProjectionAlgorithm3D.h +++ b/include/astra/CudaForwardProjectionAlgorithm3D.h @@ -71,8 +71,8 @@ public: * @return initialization successful? */ bool initialize(CProjector3D* _pProjector, - CFloat32ProjectionData3DMemory* _pSinogram, - CFloat32VolumeData3DMemory* _pReconstruction, + CFloat32ProjectionData3D* _pSinogram, + CFloat32VolumeData3D* _pReconstruction, int _iGPUindex = -1, int _iDetectorSuperSampling = 1); @@ -116,8 +116,8 @@ public: protected: CProjector3D* m_pProjector; - CFloat32ProjectionData3DMemory* m_pProjections; - CFloat32VolumeData3DMemory* m_pVolume; + CFloat32ProjectionData3D* m_pProjections; + CFloat32VolumeData3D* m_pVolume; int m_iGPUIndex; int m_iDetectorSuperSampling; diff --git a/include/astra/Float32Data2D.h b/include/astra/Float32Data2D.h index b33bcd0..1524683 100644 --- a/include/astra/Float32Data2D.h +++ b/include/astra/Float32Data2D.h @@ -41,7 +41,7 @@ public: }; /** - * This class represents a two-dimensional block of float32ing point data. + * This class represents a 2-dimensional block of 32-bit floating point data. * It contains member functions for accessing this data and for performing * elementary computations on the data. * The data block is "owned" by the class, meaning that the class is diff --git a/include/astra/Float32Data3D.h b/include/astra/Float32Data3D.h index 1cd9c20..226689e 100644 --- a/include/astra/Float32Data3D.h +++ b/include/astra/Float32Data3D.h @@ -32,10 +32,12 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "Float32Data.h" #include "Float32Data2D.h" +#include "../../cuda/3d/mem3d.h" + namespace astra { /** - * This class represents a three-dimensional block of float32ing point data. + * This class represents a 3-dimensional block of 32-bit floating point data. */ class _AstraExport CFloat32Data3D : public CFloat32Data { @@ -107,22 +109,6 @@ public: */ int getDimensionCount() const; - /** - * Clamp data to minimum value - * - * @param _fMin minimum value - * @return l-value - */ - virtual CFloat32Data3D& clampMin(float32& _fMin) = 0; - - /** - * Clamp data to maximum value - * - * @param _fMax maximum value - * @return l-value - */ - virtual CFloat32Data3D& clampMax(float32& _fMax) = 0; - /** get a description of the class * * @return description string diff --git a/include/astra/Float32Data3DGPU.h b/include/astra/Float32Data3DGPU.h new file mode 100644 index 0000000..1247e65 --- /dev/null +++ b/include/astra/Float32Data3DGPU.h @@ -0,0 +1,107 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp + 2014-2016, CWI, Amsterdam + +Contact: astra@uantwerpen.be +Website: http://www.astra-toolbox.com/ + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +The ASTRA Toolbox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. + +----------------------------------------------------------------------- +*/ + +#ifndef _INC_ASTRA_FLOAT32DATA3DGPU +#define _INC_ASTRA_FLOAT32DATA3DGPU + +#ifdef ASTRA_CUDA + +#include "Globals.h" +#include "Float32Data3D.h" + +#include "../../cuda/3d/mem3d.h" + +namespace astra { + + +astraCUDA3d::MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); + + +/** + * This class represents a 3-dimensional block of 32-bit floating point data. + * The data block is stored on a GPU, and owned by external code. + * + * TODO: Store/remember which GPU the data is stored on + */ +class _AstraExport CFloat32Data3DGPU : public virtual CFloat32Data3D { + +protected: + /** Handle for the memory block */ + astraCUDA3d::MemHandle3D m_hnd; + + /** Clear all member variables, setting all numeric variables to 0 and all pointers to NULL. + */ + void _clear(); + + /** Un-initialize the object, bringing it back in the unitialized state. + */ + void _unInit(); + + /** Initialization. Initializes an instance of the CFloat32Data3DGPU class. + * Can only be called by derived classes. + * + * This function does not set m_bInitialized to true if everything is ok. + * + * @param _iWidth width of the 3D data (x-axis), must be > 0 + * @param _iHeight height of the 3D data (y-axis), must be > 0 + * @param _iDepth depth of the 3D data (z-axis), must be > 0 + * @param _hnd the CUDA memory handle + */ + + bool _initialize(int _iWidth, int _iHeight, int _iDepth, astraCUDA3d::MemHandle3D _hnd); + +public: + + /** Default constructor. Sets all numeric member variables to 0 and all pointer member variables to NULL. + * + * If an object is constructed using this default constructor, it must always be followed by a call + * to one of the initialize() methods before the object can be used. Any use before calling init() is not allowed, + * except calling the member function isInitialized(). + * + */ + CFloat32Data3DGPU(); + + /** Destructor. + */ + virtual ~CFloat32Data3DGPU(); + + /** which type is this class? + * + * @return DataType: ASTRA_DATATYPE_FLOAT32_PROJECTION or + * ASTRA_DATATYPE_FLOAT32_VOLUME + */ + virtual EDataType getType() const { return BASE; } + + astraCUDA3d::MemHandle3D getHandle() const { return m_hnd; } + +}; + +} // end namespace astra + +#endif + +#endif // _INC_ASTRA_FLOAT32DATA3DGPU diff --git a/include/astra/Float32Data3DMemory.h b/include/astra/Float32Data3DMemory.h index d885101..876aa37 100644 --- a/include/astra/Float32Data3DMemory.h +++ b/include/astra/Float32Data3DMemory.h @@ -34,7 +34,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. namespace astra { /** - * This class represents a three-dimensional block of float32ing point data. + * This class represents a 3-dimensional block of 32-bit floating point data. * It contains member functions for accessing this data and for performing * elementary computations on the data. * The data block is "owned" by the class, meaning that the class is @@ -106,8 +106,8 @@ protected: * This function does not set m_bInitialized to true if everything is ok. * * @param _iWidth width of the 3D data (x-axis), must be > 0 - * @param _iHeight height of the 3D data (y-axis), must be > 0 - * @param _iDepth depth of the 3D data (z-axis), must be > 0 + * @param _iHeight height of the 3D data (y-axis), must be > 0 + * @param _iDepth depth of the 3D data (z-axis), must be > 0 * @return initialization of the base class successfull */ bool _initialize(int _iWidth, int _iHeight, int _iDepth); @@ -121,9 +121,9 @@ protected: * object is reinitialized and memory is freed and reallocated if necessary. * This function does not set m_bInitialized to true if everything is ok. * - * @param _iWidth width of the 2D data (x-axis), must be > 0 - * @param _iHeight height of the 2D data (y-axis), must be > 0 - * @param _iDepth depth of the 2D data (z-axis), must be > 0 + * @param _iWidth width of the 3D data (x-axis), must be > 0 + * @param _iHeight height of the 3D data (y-axis), must be > 0 + * @param _iDepth depth of the 3D data (z-axis), must be > 0 * @param _pfData pointer to a one-dimensional float32 data block * @return initialization of the base class successfull */ @@ -138,9 +138,9 @@ protected: * object is reinitialized and memory is freed and reallocated if necessary. * This function does not set m_bInitialized to true if everything is ok. * - * @param _iWidth width of the 2D data (x-axis), must be > 0 - * @param _iHeight height of the 2D data (y-axis), must be > 0 - * @param _iDepth depth of the 2D data (z-axis), must be > 0 + * @param _iWidth width of the 3D data (x-axis), must be > 0 + * @param _iHeight height of the 3D data (y-axis), must be > 0 + * @param _iDepth depth of the 3D data (z-axis), must be > 0 * @param _fScalar scalar value to fill the data * @return initialization of the base class successfull */ @@ -157,9 +157,9 @@ protected: * object is reinitialized and memory is freed and reallocated if necessary. * This function does not set m_bInitialized to true if everything is ok. * - * @param _iWidth width of the 2D data (x-axis), must be > 0 - * @param _iHeight height of the 2D data (y-axis), must be > 0 - * @param _iDepth depth of the 2D data (z-axis), must be > 0 + * @param _iWidth width of the 3D data (x-axis), must be > 0 + * @param _iHeight height of the 3D data (y-axis), must be > 0 + * @param _iDepth depth of the 3D data (z-axis), must be > 0 * @param _pCustomMemory the custom memory handle */ @@ -237,35 +237,11 @@ public: * After the call p = getData3D(), use p[iy][ix] to access element (ix, iy, iz). * The data memory and pointer array are still "owned" by the CFloat32Data3DMemory * instance; this memory may NEVER be freed by the caller of this function. - * If changes are made to this data, the function updateStatistics() - * should be called after completion of all changes. * * @return pointer to the 3-dimensional 32-bit floating point data block */ const float32*** getData3DConst() const; - /** Update data statistics, such as minimum and maximum value, after the data has been modified. - */ - virtual void updateStatistics(); - - /** Get the minimum value in the data block. - * If the data has been changed after construction, the function - * updateStatistics() must be called at least once before - * a query can be made on this value. - * - * @return minimum value in the data block - */ - virtual float32 getGlobalMin() const; - - /** Get the maximum value in the data block - * If the data has been changed after construction, the function - * updateStatistics() must be called at least once before - * a query can be made on this value. - * - * @return maximum value in the data block - */ - virtual float32 getGlobalMax() const; - /** which type is this class? * * @return DataType: ASTRA_DATATYPE_FLOAT32_PROJECTION or @@ -306,26 +282,11 @@ inline CFloat32Data3DMemory::EDataType CFloat32Data3DMemory::getType() const } //---------------------------------------------------------------------------------------- -// Get the minimum value in the data block. -inline float32 CFloat32Data3DMemory::getGlobalMin() const -{ - ASTRA_ASSERT(m_bInitialized); - return m_fGlobalMin; -} - -//---------------------------------------------------------------------------------------- -// Get the maximum value in the data block -inline float32 CFloat32Data3DMemory::getGlobalMax() const -{ - ASTRA_ASSERT(m_bInitialized); - return m_fGlobalMax; -} - -//---------------------------------------------------------------------------------------- // Get a pointer to the data block, represented as a 1-dimensional array of float32 values. inline float32* CFloat32Data3DMemory::getData() { ASTRA_ASSERT(m_bInitialized); + return m_pfData; } @@ -334,6 +295,7 @@ inline float32* CFloat32Data3DMemory::getData() inline const float32* CFloat32Data3DMemory::getDataConst() const { ASTRA_ASSERT(m_bInitialized); + return (const float32*)m_pfData; } diff --git a/include/astra/Float32ProjectionData3D.h b/include/astra/Float32ProjectionData3D.h index ae0664b..1634eeb 100644 --- a/include/astra/Float32ProjectionData3D.h +++ b/include/astra/Float32ProjectionData3D.h @@ -85,55 +85,6 @@ public: */ virtual CFloat32Data3D::EDataType getType() const; - /** Fetch a COPY of a projection of the data. Note that if you update the 2D data slice, the data in the - * 3d data object will remain unaltered. To copy the data back in the 3D-volume you must return the data by calling 'returnProjection'. - * - * @param _iProjectionNr projection number - * @return Volume data object - */ - virtual CFloat32VolumeData2D* fetchProjection(int _iProjectionNr) const = 0; - - /** Return a projection slice to the 3d data. The data will be deleted. If the slice was fetched with - * 'fetchProjection', the data will be stored first. - * - * @param _iProjectionNr projection number - * @param _pProjection 2D Projection Data - */ - virtual void returnProjection(int _iProjectionNr, CFloat32VolumeData2D* _pProjection) = 0; - - /** Fetch a COPY of a sinogram slice of the data. Note that if you update the 2D data slice, the data in the - * 3d data object will remain unaltered. To copy the data back in the 3D-volume you must return the data by calling 'returnSlice'. - * - * @param _iSliceNr slice number - * @return Sinogram data object - */ - virtual CFloat32ProjectionData2D* fetchSinogram(int _iSliceNr) const = 0; - - /** Return a sinogram slice to the 3d data. The data will be stored in the 3D Data object. - * - * @param _iSliceNr slice number - * @param _pSinogram2D 2D Sinogram Object. - */ - virtual void returnSinogram(int _iSliceNr, CFloat32ProjectionData2D* _pSinogram2D) = 0; - - /** This SLOW function returns a detector value stored a specific index in the array. - * Reading values in this way might cause a lot of unnecessar__y memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @return The value the location specified by _iIndex - */ - virtual float32 getDetectorValue(int _iIndex) = 0; - - /** This SLOW function stores a detector value at a specific index in the array. - * Writing values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @param _fValue The value to be stored at the location specified by _iIndex - */ - virtual void setDetectorValue(int _iIndex, float32 _fValue) = 0; - /** * Overloaded Operator: data += data (pointwise) * diff --git a/include/astra/Float32ProjectionData3DGPU.h b/include/astra/Float32ProjectionData3DGPU.h new file mode 100644 index 0000000..cbf9b6f --- /dev/null +++ b/include/astra/Float32ProjectionData3DGPU.h @@ -0,0 +1,91 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp + 2014-2016, CWI, Amsterdam + +Contact: astra@uantwerpen.be +Website: http://www.astra-toolbox.com/ + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +The ASTRA Toolbox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. + +----------------------------------------------------------------------- +*/ + +#ifndef _INC_ASTRA_FLOAT32PROJECTIONDATA3DGPU +#define _INC_ASTRA_FLOAT32PROJECTIONDATA3DGPU + +#include "Float32Data3DGPU.h" +#include "ProjectionGeometry3D.h" +#include "Float32ProjectionData3D.h" + +#ifdef ASTRA_CUDA + +namespace astra { + +/** + * This class represents three-dimensional Projection Data where the entire data block is stored in GPU memory. + */ +class _AstraExport CFloat32ProjectionData3DGPU : public CFloat32Data3DGPU, public CFloat32ProjectionData3D +{ +public: + + /** Default constructor. Sets all numeric member variables to 0 and all pointer member variables to NULL. + * + * If an object is constructed using this default constructor, it must always be followed by a call + * to one of the init() methods before the object can be used. Any use before calling init() is not allowed, + * except calling the member function isInitialized(). + * + */ + CFloat32ProjectionData3DGPU(); + + /** Construction. + * + * @param _pGeometry 3D volume geometry + * @param _hnd the CUDA memory handle + */ + + CFloat32ProjectionData3DGPU(CProjectionGeometry3D* _pGeometry, astraCUDA3d::MemHandle3D _hnd); + + virtual ~CFloat32ProjectionData3DGPU(); + + /** Initialization. + * + * @param _pGeometry 3D volume geometry + * @param _hnd the CUDA memory handle + */ + + bool initialize(CProjectionGeometry3D* _pGeometry, astraCUDA3d::MemHandle3D _hnd); + + /** Which type is this class? + * + * @return DataType: PROJECTION + */ + virtual CFloat32Data3D::EDataType getType() const { return PROJECTION; } + + /** Get the volume geometry. + * + * @return pointer to volume geometry. + */ + CProjectionGeometry3D* getGeometry() const { ASTRA_ASSERT(m_bInitialized); return m_pGeometry; } + +}; + +} // end namesProjection astra + +#endif + +#endif // _INC_ASTRA_FLOAT32PROJECTIONDATA3DGPU diff --git a/include/astra/Float32ProjectionData3DMemory.h b/include/astra/Float32ProjectionData3DMemory.h index 14bae36..732c31a 100644 --- a/include/astra/Float32ProjectionData3DMemory.h +++ b/include/astra/Float32ProjectionData3DMemory.h @@ -166,55 +166,6 @@ public: - /** Fetch a COPY of a projection of the data. Note that if you update the 2D data slice, the data in the - * 3D data object will remain unaltered. To copy the data back in the 3D-volume you must return the data by calling 'returnProjection'. - * - * @param _iProjectionNr projection number - * @return Volume data object - */ - virtual CFloat32VolumeData2D* fetchProjection(int _iProjectionNr) const; - - /** Return a projection slice to the 3D data. The data will be deleted. If the slice was fetched with - * 'fetchProjection', the data will be stored first. - * - * @param _iProjectionNr projection number - * @param _pProjection 2D Projection image - */ - virtual void returnProjection(int _iProjectionNr, CFloat32VolumeData2D* _pProjection); - - /** Fetch a COPY of a sinogram slice of the data. Note that if you update the 2D data slice, the data in the - * 3D data object will remain unaltered. To copy the data back in the 3D-volume you must return the data by calling 'returnSlice'. - * - * @param _iSliceNr slice number - * @return Sinogram data object - */ - virtual CFloat32ProjectionData2D* fetchSinogram(int _iSliceNr) const; - - /** This SLOW function returns a detector value stored a specific index in the array. - * Reading values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @return The value the location specified by _iIndex - */ - virtual float32 getDetectorValue(int _iIndex); - - /** This SLOW function stores a detector value at a specific index in the array. - * Writing values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @param _fValue The value to be stored at the location specified by _iIndex - */ - virtual void setDetectorValue(int _iIndex, float32 _fValue); - - /** Return a sinogram slice to the 3d data. The data will be stored in the 3D Data object. - * - * @param _iSliceNr slice number - * @param _pSinogram2D 2D Sinogram Object. - */ - virtual void returnSinogram(int _iSliceNr, CFloat32ProjectionData2D* _pSinogram2D); - /** Which type is this class? * * @return DataType: PROJECTION diff --git a/include/astra/Float32VolumeData3D.h b/include/astra/Float32VolumeData3D.h index 7a32efe..535e960 100644 --- a/include/astra/Float32VolumeData3D.h +++ b/include/astra/Float32VolumeData3D.h @@ -85,72 +85,6 @@ public: */ virtual CFloat32Data3D::EDataType getType() const; - /** Fetch a slice from the data in the x direction. Note that if you update the 2D data slice, the data in the - * 3d data object will remain unaltered. To copy the data you must return the data by calling 'returnSliceX'. - * You should not delete data fetched with this function yourself, instead call the 'returnSliceX' function. - * - * @param _iColumnIndex slice number - * @return Volume data object - */ - virtual CFloat32VolumeData2D* fetchSliceX(int _iColumnIndex) const = 0; - - /** Fetch a slice from the data in the y direction. Note that if you update the 2D data slice, the data in the - * 3d data object will remain unaltered. To copy the data you must return the data by calling 'returnSliceY'. - * You should not delete data fetched with this function yourself, instead call the 'returnSliceY' function. - * - * @param _iRowIndex slice number - * @return Volume data object - */ - virtual CFloat32VolumeData2D* fetchSliceY(int _iRowIndex) const = 0; - - /** Fetch a slice from the data in the z direction. Note that if you update the 2D data slice, the data in the - * 3d data object will remain unaltered. To copy the data you must return the data by calling 'returnSliceZ'. - * You should not delete data fetched with this function yourself, instead call the 'returnSliceZ' function. - * - * @param _iSliceIndex slice number - * @return Volume data object - */ - virtual CFloat32VolumeData2D* fetchSliceZ(int _iSliceIndex) const = 0; - - /** Return a slice from the data in the x direction to the 3d data. The data will be deleted. If the slice was - * fetched with 'fetchSliceX', the data will be stored first. - * - * @param _iColumnIndex slice number - */ - virtual void returnSliceX(int _iColumnIndex, CFloat32VolumeData2D * _pSlice) = 0; - - /** Return a slice from the data in the y direction to the 3d data. The data will be deleted. If the slice was - * fetched with 'fetchSliceY', the data will be stored first. - * - * @param _iRowIndex slice number - */ - virtual void returnSliceY(int _iRowIndex, CFloat32VolumeData2D * _pSlice) = 0; - - /** Return a slice from the data in the z direction to the 3d data. The data will be deleted. If the slice was - * fetched with 'fetchSliceZ', the data will be stored first. - * - * @param _iSliceIndex slice number - */ - virtual void returnSliceZ(int _iSliceIndex, CFloat32VolumeData2D * _pSlice) = 0; - - /** This SLOW function returns a voxel value stored at a specific index in the array. - * Reading values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @return The value stored at the location specified by _iIndex - */ - virtual float32 getVoxelValue(int _iIndex) = 0; - - /** This SLOW function stores a voxel value at a specific index in the array. - * Writing values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @param _fValue The value to be stored at the location specified by _iIndex - */ - virtual void setVoxelValue(int _iIndex, float32 _fValue) = 0; - /** * Overloaded Operator: data += data (pointwise) * diff --git a/include/astra/Float32VolumeData3DGPU.h b/include/astra/Float32VolumeData3DGPU.h new file mode 100644 index 0000000..ddeb469 --- /dev/null +++ b/include/astra/Float32VolumeData3DGPU.h @@ -0,0 +1,91 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp + 2014-2016, CWI, Amsterdam + +Contact: astra@uantwerpen.be +Website: http://www.astra-toolbox.com/ + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +The ASTRA Toolbox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. + +----------------------------------------------------------------------- +*/ + +#ifndef _INC_ASTRA_FLOAT32VOLUMEDATA3DGPU +#define _INC_ASTRA_FLOAT32VOLUMEDATA3DGPU + +#include "Float32Data3DGPU.h" +#include "VolumeGeometry3D.h" +#include "Float32VolumeData3D.h" + +#ifdef ASTRA_CUDA + +namespace astra { + +/** + * This class represents three-dimensional Volume Data where the entire data block is stored in GPU memory. + */ +class _AstraExport CFloat32VolumeData3DGPU : public CFloat32Data3DGPU, public CFloat32VolumeData3D +{ +public: + + /** Default constructor. Sets all numeric member variables to 0 and all pointer member variables to NULL. + * + * If an object is constructed using this default constructor, it must always be followed by a call + * to one of the init() methods before the object can be used. Any use before calling init() is not allowed, + * except calling the member function isInitialized(). + * + */ + CFloat32VolumeData3DGPU(); + + /** Construction. + * + * @param _pGeometry 3D volume geometry + * @param _hnd the CUDA memory handle + */ + + CFloat32VolumeData3DGPU(CVolumeGeometry3D* _pGeometry, astraCUDA3d::MemHandle3D _hnd); + + virtual ~CFloat32VolumeData3DGPU(); + + /** Initialization. + * + * @param _pGeometry 3D volume geometry + * @param _hnd the CUDA memory handle + */ + + bool initialize(CVolumeGeometry3D* _pGeometry, astraCUDA3d::MemHandle3D _hnd); + + /** Which type is this class? + * + * @return DataType: VOLUME + */ + virtual CFloat32Data3D::EDataType getType() const { return VOLUME; } + + /** Get the volume geometry. + * + * @return pointer to volume geometry. + */ + CVolumeGeometry3D* getGeometry() const { ASTRA_ASSERT(m_bInitialized); return m_pGeometry; } + +}; + +} // end namespace astra + +#endif + +#endif // _INC_ASTRA_FLOAT32VOLUMEDATA3DGPU diff --git a/include/astra/Float32VolumeData3DMemory.h b/include/astra/Float32VolumeData3DMemory.h index 70f0939..4a70f65 100644 --- a/include/astra/Float32VolumeData3DMemory.h +++ b/include/astra/Float32VolumeData3DMemory.h @@ -159,55 +159,6 @@ public: CVolumeGeometry3D* getGeometry() const; /** - * Gets a slice, containing all voxels with a given x (= column) index. - */ - CFloat32VolumeData2D * fetchSliceX(int _iColumnIndex) const; - - /** - * Gets a slice, containing all voxels with a given y (= row) index. - */ - CFloat32VolumeData2D * fetchSliceY(int _iRowIndex) const; - - /** - * Gets a slice, containing all voxels with a given z (= slice) index. - */ - CFloat32VolumeData2D * fetchSliceZ(int _iSliceIndex) const; - - /** - * Gets a slice, containing all voxels with a given x (= column) index. - */ - void returnSliceX(int _iColumnIndex, CFloat32VolumeData2D * _pSliceData); - - /** - * Gets a slice, containing all voxels with a given y (= row) index. - */ - void returnSliceY(int _iRowIndex, CFloat32VolumeData2D * _pSliceData); - - /** - * Copies data from a 2D slice containing all voxels with a given z (= slice) index to the - * 3D memory stored in this class. - */ - void returnSliceZ(int _iSliceIndex, CFloat32VolumeData2D * _pSliceData); - - /** This SLOW function returns a volume value stored a specific index in the array. - * Reading values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @return The value the location specified by _iIndex - */ - virtual float32 getVoxelValue(int _iIndex); - - /** This SLOW function stores a voxel value at a specific index in the array. - * Writing values in this way might cause a lot of unnecessary memory operations, don't - * use it in time-critical code. - * - * @param _iIndex Index in the array if the data were stored completely in main memory - * @param _fValue The value to be stored at the location specified by _iIndex - */ - virtual void setVoxelValue(int _iIndex, float32 _fValue); - - /** * Overloaded Operator: data = data (pointwise) * * @param _dataIn r-value diff --git a/include/astra/Globals.h b/include/astra/Globals.h index dec978d..44a77b0 100644 --- a/include/astra/Globals.h +++ b/include/astra/Globals.h @@ -53,8 +53,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include <iostream> #include <fstream> #include <math.h> -#include <boost/static_assert.hpp> -#include <boost/throw_exception.hpp> //---------------------------------------------------------------------------------------- // macro's @@ -227,16 +225,6 @@ namespace astra { int m_iSliceIndex; }; } -//---------------------------------------------------------------------------------------- -// some toys - -// safe reinterpret cast -template <class To, class From> -To safe_reinterpret_cast(From from) -{ - BOOST_STATIC_ASSERT(sizeof(From) <= sizeof(To)); - return reinterpret_cast<To>(from); -} //---------------------------------------------------------------------------------------- // functions for testing |