summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-01-26 14:57:57 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-02-08 14:39:01 +0100
commitd85a660f064e8130b27e11c7fd762221c754c315 (patch)
tree72382e8414c8dc51a7a7ef45845b4c61b25dfed9 /include
parentebd5fe932fd2d6c4a516bc1cdc69e37aa4f5cf55 (diff)
downloadastra-d85a660f064e8130b27e11c7fd762221c754c315.tar.gz
astra-d85a660f064e8130b27e11c7fd762221c754c315.tar.bz2
astra-d85a660f064e8130b27e11c7fd762221c754c315.tar.xz
astra-d85a660f064e8130b27e11c7fd762221c754c315.zip
Start work on CFloat32Data3DGPU to allow persistent/external GPU memory
Diffstat (limited to 'include')
-rw-r--r--include/astra/CompositeGeometryManager.h43
-rw-r--r--include/astra/CudaBackProjectionAlgorithm3D.h8
-rw-r--r--include/astra/CudaFDKAlgorithm3D.h8
-rw-r--r--include/astra/CudaForwardProjectionAlgorithm3D.h8
-rw-r--r--include/astra/Float32Data3D.h2
-rw-r--r--include/astra/Float32Data3DGPU.h108
-rw-r--r--include/astra/Float32ProjectionData3DGPU.h92
-rw-r--r--include/astra/Float32VolumeData3DGPU.h92
8 files changed, 329 insertions, 32 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/Float32Data3D.h b/include/astra/Float32Data3D.h
index 2b3b88e..aca82ab 100644
--- a/include/astra/Float32Data3D.h
+++ b/include/astra/Float32Data3D.h
@@ -32,6 +32,8 @@ 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 {
/**
diff --git a/include/astra/Float32Data3DGPU.h b/include/astra/Float32Data3DGPU.h
new file mode 100644
index 0000000..0802105
--- /dev/null
+++ b/include/astra/Float32Data3DGPU.h
@@ -0,0 +1,108 @@
+/*
+-----------------------------------------------------------------------
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
+
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+
+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/>.
+
+-----------------------------------------------------------------------
+$Id$
+*/
+
+#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 three-dimensional block of float32ing 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 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 _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/Float32ProjectionData3DGPU.h b/include/astra/Float32ProjectionData3DGPU.h
new file mode 100644
index 0000000..135c718
--- /dev/null
+++ b/include/astra/Float32ProjectionData3DGPU.h
@@ -0,0 +1,92 @@
+/*
+-----------------------------------------------------------------------
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
+
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+
+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/>.
+
+-----------------------------------------------------------------------
+$Id$
+*/
+
+#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/Float32VolumeData3DGPU.h b/include/astra/Float32VolumeData3DGPU.h
new file mode 100644
index 0000000..377ed75
--- /dev/null
+++ b/include/astra/Float32VolumeData3DGPU.h
@@ -0,0 +1,92 @@
+/*
+-----------------------------------------------------------------------
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
+
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+
+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/>.
+
+-----------------------------------------------------------------------
+$Id$
+*/
+
+#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