summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-10-07 18:14:39 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-10-09 11:42:43 +0200
commit43a38c117405f99e3a1b498f899de4ba6d01a044 (patch)
tree1d8fe2f08b6a07c1303ca3de7fc6d05d36aad41e /src
parent0ebd8dfe60cc0d1f05d65d3840278defce0da091 (diff)
downloadastra-43a38c117405f99e3a1b498f899de4ba6d01a044.tar.gz
astra-43a38c117405f99e3a1b498f899de4ba6d01a044.tar.bz2
astra-43a38c117405f99e3a1b498f899de4ba6d01a044.tar.xz
astra-43a38c117405f99e3a1b498f899de4ba6d01a044.zip
Improve option passing through CudaProjector3D
Not all constructors were reading options from the projector. Also allow passing GPUIndex via CudaProjector3D. Thanks to Nicola Vigano for part of the patch.
Diffstat (limited to 'src')
-rw-r--r--src/CudaBackProjectionAlgorithm3D.cpp43
-rw-r--r--src/CudaCglsAlgorithm3D.cpp47
-rw-r--r--src/CudaFDKAlgorithm3D.cpp40
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp46
-rw-r--r--src/CudaProjector3D.cpp7
-rw-r--r--src/CudaSirtAlgorithm3D.cpp48
6 files changed, 161 insertions, 70 deletions
diff --git a/src/CudaBackProjectionAlgorithm3D.cpp b/src/CudaBackProjectionAlgorithm3D.cpp
index e8e0433..c9d9447 100644
--- a/src/CudaBackProjectionAlgorithm3D.cpp
+++ b/src/CudaBackProjectionAlgorithm3D.cpp
@@ -38,6 +38,8 @@ $Id$
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include "../cuda/3d/astra3d.h"
using namespace std;
@@ -87,6 +89,24 @@ bool CCudaBackProjectionAlgorithm3D::_check()
}
//---------------------------------------------------------------------------------------
+void CCudaBackProjectionAlgorithm3D::initializeFromProjector()
+{
+ m_iVoxelSuperSampling = 1;
+ m_iGPUIndex = -1;
+
+ CCudaProjector3D* pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ if (m_pProjector) {
+ ASTRA_WARN("non-CUDA Projector3D passed to BP3D_CUDA");
+ }
+ } else {
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iGPUIndex = pCudaProjector->getGPUIndex();
+ }
+
+}
+
+//---------------------------------------------------------------------------------------
// Initialize - Config
bool CCudaBackProjectionAlgorithm3D::initialize(const Config& _cfg)
{
@@ -103,21 +123,18 @@ bool CCudaBackProjectionAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- CCudaProjector3D* pCudaProjector = 0;
- pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
- if (!pCudaProjector) {
- // TODO: Report
- }
-
- m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
- CC.markOptionParsed("GPUindex");
-
+ initializeFromProjector();
- m_iVoxelSuperSampling = 1;
- if (pCudaProjector)
- m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ // Deprecated options
m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("VoxelSuperSampling");
+ CC.markOptionParsed("GPUIndex");
+ if (!_cfg.self.hasOption("GPUIndex"))
+ CC.markOptionParsed("GPUindex");
+
+
CFloat32ProjectionData3DMemory* pSinoMem = dynamic_cast<CFloat32ProjectionData3DMemory*>(m_pSinogram);
ASTRA_ASSERT(pSinoMem);
@@ -151,6 +168,8 @@ bool CCudaBackProjectionAlgorithm3D::initialize(CProjector3D* _pProjector,
m_pSinogram = _pSinogram;
m_pReconstruction = _pReconstruction;
+ initializeFromProjector();
+
// success
m_bIsInitialized = _check();
return m_bIsInitialized;
diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp
index f527dc5..1cccb6a 100644
--- a/src/CudaCglsAlgorithm3D.cpp
+++ b/src/CudaCglsAlgorithm3D.cpp
@@ -37,6 +37,8 @@ $Id$
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include "../cuda/3d/astra3d.h"
using namespace std;
@@ -90,6 +92,26 @@ bool CCudaCglsAlgorithm3D::_check()
}
//---------------------------------------------------------------------------------------
+void CCudaCglsAlgorithm3D::initializeFromProjector()
+{
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
+ m_iGPUIndex = -1;
+
+ CCudaProjector3D* pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ if (m_pProjector) {
+ ASTRA_WARN("non-CUDA Projector3D passed to CGLS3D_CUDA");
+ }
+ } else {
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iGPUIndex = pCudaProjector->getGPUIndex();
+ }
+
+}
+
+//---------------------------------------------------------------------------------------
// Initialize - Config
bool CCudaCglsAlgorithm3D::initialize(const Config& _cfg)
{
@@ -107,27 +129,20 @@ bool CCudaCglsAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- CCudaProjector3D* pCudaProjector = 0;
- pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
- if (!pCudaProjector) {
- // TODO: Report
- }
+ initializeFromProjector();
- m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
- CC.markOptionParsed("GPUindex");
-
- m_iVoxelSuperSampling = 1;
- m_iDetectorSuperSampling = 1;
- if (pCudaProjector) {
- // New interface
- m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
- m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
- }
// Deprecated options
m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("VoxelSuperSampling");
CC.markOptionParsed("DetectorSuperSampling");
+ CC.markOptionParsed("GPUIndex");
+ if (!_cfg.self.hasOption("GPUIndex"))
+ CC.markOptionParsed("GPUindex");
+
+
m_pCgls = new AstraCGLS3d();
@@ -155,6 +170,8 @@ bool CCudaCglsAlgorithm3D::initialize(CProjector3D* _pProjector,
m_pSinogram = _pSinogram;
m_pReconstruction = _pReconstruction;
+ initializeFromProjector();
+
m_pCgls = new AstraCGLS3d;
m_bAstraCGLSInit = false;
diff --git a/src/CudaFDKAlgorithm3D.cpp b/src/CudaFDKAlgorithm3D.cpp
index 667d926..625d02a 100644
--- a/src/CudaFDKAlgorithm3D.cpp
+++ b/src/CudaFDKAlgorithm3D.cpp
@@ -35,6 +35,8 @@ $Id$
#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include "../cuda/3d/astra3d.h"
using namespace std;
@@ -85,6 +87,24 @@ bool CCudaFDKAlgorithm3D::_check()
}
//---------------------------------------------------------------------------------------
+void CCudaFDKAlgorithm3D::initializeFromProjector()
+{
+ m_iVoxelSuperSampling = 1;
+ m_iGPUIndex = -1;
+
+ CCudaProjector3D* pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ if (m_pProjector) {
+ ASTRA_WARN("non-CUDA Projector3D passed to FDK_CUDA");
+ }
+ } else {
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iGPUIndex = pCudaProjector->getGPUIndex();
+ }
+
+}
+
+//---------------------------------------------------------------------------------------
// Initialize - Config
bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg)
{
@@ -101,20 +121,18 @@ bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- CCudaProjector3D* pCudaProjector = 0;
- pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
- if (!pCudaProjector) {
- // TODO: Report
- }
-
- m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
- CC.markOptionParsed("GPUindex");
+ initializeFromProjector();
- m_iVoxelSuperSampling = 1;
- if (pCudaProjector)
- m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ // Deprecated options
m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("VoxelSuperSampling");
+ CC.markOptionParsed("GPUIndex");
+ if (!_cfg.self.hasOption("GPUIndex"))
+ CC.markOptionParsed("GPUindex");
+
+
m_bShortScan = _cfg.self.getOptionBool("ShortScan", false);
CC.markOptionParsed("ShortScan");
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index 46dab12..6498885 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -72,6 +72,23 @@ CCudaForwardProjectionAlgorithm3D::~CCudaForwardProjectionAlgorithm3D()
}
//---------------------------------------------------------------------------------------
+void CCudaForwardProjectionAlgorithm3D::initializeFromProjector()
+{
+ m_iDetectorSuperSampling = 1;
+ m_iGPUIndex = -1;
+
+ CCudaProjector3D* pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ if (m_pProjector) {
+ ASTRA_WARN("non-CUDA Projector3D passed to FP3D_CUDA");
+ }
+ } else {
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iGPUIndex = pCudaProjector->getGPUIndex();
+ }
+}
+
+//---------------------------------------------------------------------------------------
// Initialize - Config
bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
{
@@ -97,29 +114,21 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
// optional: projector
node = _cfg.self.getSingleNode("ProjectorId");
- CCudaProjector3D* pCudaProjector = 0;
m_pProjector = 0;
if (node) {
id = boost::lexical_cast<int>(node.getContent());
m_pProjector = CProjector3DManager::getSingleton().get(id);
- pCudaProjector = dynamic_cast<CCudaProjector3D*>(CProjector3DManager::getSingleton().get(id));
- m_pProjector = pCudaProjector;
- if (!pCudaProjector) {
- // TODO: Report
- }
}
CC.markNodeParsed("ProjectorId");
- // GPU number
- m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
- CC.markOptionParsed("GPUindex");
-
+ initializeFromProjector();
- m_iDetectorSuperSampling = 1;
- if (pCudaProjector)
- m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ // Deprecated options
m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex);
CC.markOptionParsed("DetectorSuperSampling");
+ CC.markOptionParsed("GPUindex");
+
// success
m_bIsInitialized = check();
@@ -142,8 +151,15 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(CProjector3D* _pProjector,
m_pProjections = _pProjections;
m_pVolume = _pVolume;
- m_iDetectorSuperSampling = _iDetectorSuperSampling;
- m_iGPUIndex = _iGPUindex;
+ CCudaProjector3D* pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ m_iDetectorSuperSampling = _iDetectorSuperSampling;
+ m_iGPUIndex = _iGPUindex;
+ } else {
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iGPUIndex = pCudaProjector->getGPUIndex();
+ }
// success
m_bIsInitialized = check();
diff --git a/src/CudaProjector3D.cpp b/src/CudaProjector3D.cpp
index d2fd74c..bbfbd34 100644
--- a/src/CudaProjector3D.cpp
+++ b/src/CudaProjector3D.cpp
@@ -64,6 +64,7 @@ void CCudaProjector3D::_clear()
m_projectionKernel = ker3d_default;
m_iVoxelSuperSampling = 1;
m_iDetectorSuperSampling = 1;
+ m_iGPUIndex = -1;
}
//----------------------------------------------------------------------------------------
@@ -128,6 +129,12 @@ bool CCudaProjector3D::initialize(const Config& _cfg)
m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
CC.markOptionParsed("DetectorSuperSampling");
+ 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"))
+ CC.markOptionParsed("GPUindex");
+
m_bIsInitialized = _check();
return m_bIsInitialized;
}
diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp
index abbb9fd..67594f4 100644
--- a/src/CudaSirtAlgorithm3D.cpp
+++ b/src/CudaSirtAlgorithm3D.cpp
@@ -38,6 +38,8 @@ $Id$
#include "astra/ConeVecProjectionGeometry3D.h"
#include "astra/CudaProjector3D.h"
+#include "astra/Logging.h"
+
#include "../cuda/3d/astra3d.h"
using namespace std;
@@ -90,7 +92,27 @@ bool CCudaSirtAlgorithm3D::_check()
return true;
}
-//---------------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------
+void CCudaSirtAlgorithm3D::initializeFromProjector()
+{
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
+ m_iGPUIndex = -1;
+
+ CCudaProjector3D* pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ if (m_pProjector) {
+ ASTRA_WARN("non-CUDA Projector3D passed to SIRT3D_CUDA");
+ }
+ } else {
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iGPUIndex = pCudaProjector->getGPUIndex();
+ }
+
+}
+
+//--------------------------------------------------------------------------------------
// Initialize - Config
bool CCudaSirtAlgorithm3D::initialize(const Config& _cfg)
{
@@ -108,28 +130,20 @@ bool CCudaSirtAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- CCudaProjector3D* pCudaProjector = 0;
- pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
- if (!pCudaProjector) {
- // TODO: Report
- }
+ initializeFromProjector();
- m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
- CC.markOptionParsed("GPUindex");
-
-
- m_iVoxelSuperSampling = 1;
- m_iDetectorSuperSampling = 1;
- if (pCudaProjector) {
- // New interface
- m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
- m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
- }
// Deprecated options
m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("VoxelSuperSampling");
CC.markOptionParsed("DetectorSuperSampling");
+ CC.markOptionParsed("GPUIndex");
+ if (!_cfg.self.hasOption("GPUIndex"))
+ CC.markOptionParsed("GPUindex");
+
+
m_pSirt = new AstraSIRT3d();