summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cuda/2d/astra.cu4
-rw-r--r--cuda/2d/fft.cu31
-rw-r--r--cuda/2d/util.cu8
-rw-r--r--cuda/3d/util3d.cu12
-rw-r--r--src/ConeProjectionGeometry3D.cpp4
-rw-r--r--src/Config.cpp7
-rw-r--r--src/CudaFilteredBackProjectionAlgorithm.cpp4
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp4
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp4
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp4
-rw-r--r--src/FilteredBackProjectionAlgorithm.cpp4
11 files changed, 55 insertions, 31 deletions
diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu
index bcc1a50..71fd089 100644
--- a/cuda/2d/astra.cu
+++ b/cuda/2d/astra.cu
@@ -47,6 +47,8 @@ $Id$
#include "../../include/astra/FanFlatProjectionGeometry2D.h"
#include "../../include/astra/FanFlatVecProjectionGeometry2D.h"
+#include "../../include/astra/Logging.h"
+
// For fan beam FBP weighting
#include "../3d/fdk.h"
@@ -562,7 +564,7 @@ bool AstraFBP::setFilter(E_FBPFILTER _eFilter, const float * _pfHostFilter /* =
}
default:
{
- fprintf(stderr, "AstraFBP::setFilter: Unknown filter type requested");
+ astra::CLogger::error(__FILE__,__LINE__,"AstraFBP::setFilter: Unknown filter type requested");
delete [] pHostFilter;
return false;
}
diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu
index 5fef360..468c7c2 100644
--- a/cuda/2d/fft.cu
+++ b/cuda/2d/fft.cu
@@ -34,6 +34,7 @@ $Id$
#include <cuda.h>
#include <fstream>
+#include "../../include/astra/Logging.h"
using namespace astra;
@@ -42,22 +43,22 @@ using namespace astra;
#define CHECK_ERROR(errorMessage) do { \
cudaError_t err = cudaThreadSynchronize(); \
if( cudaSuccess != err) { \
- fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", \
- errorMessage, __FILE__, __LINE__, cudaGetErrorString( err) );\
+ astra::CLogger::error(__FILE__,__LINE__,"Cuda error %s : %s", \
+ errorMessage,cudaGetErrorString( err)); \
exit(EXIT_FAILURE); \
} } while (0)
#define SAFE_CALL( call) do { \
cudaError err = call; \
if( cudaSuccess != err) { \
- fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \
- __FILE__, __LINE__, cudaGetErrorString( err) ); \
+ astra::CLogger::error(__FILE__,__LINE__,"Cuda error: %s ", \
+ cudaGetErrorString( err)); \
exit(EXIT_FAILURE); \
} \
err = cudaThreadSynchronize(); \
if( cudaSuccess != err) { \
- fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \
- __FILE__, __LINE__, cudaGetErrorString( err) ); \
+ astra::CLogger::error(__FILE__,__LINE__,"Cuda error: %s : ", \
+ cudaGetErrorString( err)); \
exit(EXIT_FAILURE); \
} } while (0)
@@ -136,7 +137,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount,
result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to plan 1d r2c fft" << std::endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d r2c fft");
return false;
}
@@ -145,7 +146,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount,
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to exec 1d r2c fft" << std::endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d r2c fft");
return false;
}
@@ -162,7 +163,7 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount,
result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to plan 1d c2r fft" << std::endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d c2r fft");
return false;
}
@@ -173,7 +174,7 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount,
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to exec 1d c2r fft" << std::endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d c2r fft");
return false;
}
@@ -629,7 +630,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount,
}
default:
{
- std::cerr << "Cannot serve requested filter" << std::endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Cannot serve requested filter");
}
}
@@ -763,13 +764,13 @@ void testCudaFFT()
result = cufftPlan1d(&plan, iDetectorCount, CUFFT_R2C, iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to plan 1d r2c fft" << endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d r2c fft");
}
result = cufftExecR2C(plan, pfDevProj, pDevFourProj);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to exec 1d r2c fft" << endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d r2c fft");
}
cufftDestroy(plan);
@@ -793,13 +794,13 @@ void testCudaFFT()
result = cufftPlan1d(&plan, iDetectorCount, CUFFT_C2R, iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to plan 1d c2r fft" << endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d c2r fft");
}
result = cufftExecC2R(plan, pDevFourProj, pfDevInFourProj);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to exec 1d c2r fft" << endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d c2r fft");
}
cufftDestroy(plan);
diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu
index 81e368f..6ced557 100644
--- a/cuda/2d/util.cu
+++ b/cuda/2d/util.cu
@@ -30,6 +30,8 @@ $Id$
#include <cassert>
#include "util.h"
+#include "../../include/astra/Logging.h"
+
namespace astraCUDA {
bool copyVolumeToDevice(const float* in_data, unsigned int in_pitch,
@@ -91,7 +93,7 @@ bool allocateVolume(float*& ptr, unsigned int width, unsigned int height, unsign
cudaError_t ret = cudaMallocPitch((void**)&ptr, &p, sizeof(float)*width, height);
if (ret != cudaSuccess) {
reportCudaError(ret);
- fprintf(stderr, "Failed to allocate %dx%d GPU buffer\n", width, height);
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%d GPU buffer", width, height);
return false;
}
@@ -259,7 +261,7 @@ bool cudaTextForceKernelsCompletion()
cudaError_t returnedCudaError = cudaThreadSynchronize();
if(returnedCudaError != cudaSuccess) {
- fprintf(stderr, "Failed to force completion of cuda kernels: %d: %s.\n", returnedCudaError, cudaGetErrorString(returnedCudaError));
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError));
return false;
}
@@ -269,7 +271,7 @@ bool cudaTextForceKernelsCompletion()
void reportCudaError(cudaError_t err)
{
if(err != cudaSuccess)
- fprintf(stderr, "CUDA error %d: %s.\n", err, cudaGetErrorString(err));
+ astra::CLogger::error(__FILE__,__LINE__,"CUDA error %d: %s.", err, cudaGetErrorString(err));
}
diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu
index d85a928..f2d16b3 100644
--- a/cuda/3d/util3d.cu
+++ b/cuda/3d/util3d.cu
@@ -31,6 +31,8 @@ $Id$
#include "util3d.h"
#include "../2d/util.h"
+#include "../../include/astra/Logging.h"
+
namespace astraCUDA3d {
@@ -46,7 +48,7 @@ cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims)
cudaError err = cudaMalloc3D(&volData, extentV);
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU buffer\n", dims.iVolX, dims.iVolY, dims.iVolZ);
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU buffer", dims.iVolX, dims.iVolY, dims.iVolZ);
volData.ptr = 0;
// TODO: return 0 somehow?
}
@@ -65,7 +67,7 @@ cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims)
cudaError err = cudaMalloc3D(&projData, extentP);
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU buffer\n", dims.iProjU, dims.iProjAngles, dims.iProjV);
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU buffer", dims.iProjU, dims.iProjAngles, dims.iProjV);
projData.ptr = 0;
// TODO: return 0 somehow?
}
@@ -303,7 +305,7 @@ cudaArray* allocateVolumeArray(const SDimensions3D& dims)
cudaError err = cudaMalloc3DArray(&cuArray, &channelDesc, extentA);
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU array\n", dims.iVolX, dims.iVolY, dims.iVolZ);
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU array", dims.iVolX, dims.iVolY, dims.iVolZ);
return 0;
}
@@ -321,7 +323,7 @@ cudaArray* allocateProjectionArray(const SDimensions3D& dims)
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU array\n", dims.iProjU, dims.iProjAngles, dims.iProjV);
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU array", dims.iProjU, dims.iProjAngles, dims.iProjV);
return 0;
}
@@ -397,7 +399,7 @@ bool cudaTextForceKernelsCompletion()
cudaError_t returnedCudaError = cudaThreadSynchronize();
if(returnedCudaError != cudaSuccess) {
- fprintf(stderr, "Failed to force completion of cuda kernels: %d: %s.\n", returnedCudaError, cudaGetErrorString(returnedCudaError));
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError));
return false;
}
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index eb9adcf..13f147b 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -28,6 +28,8 @@ $Id$
#include "astra/ConeProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include <boost/lexical_cast.hpp>
#include <cstring>
@@ -257,7 +259,7 @@ void CConeProjectionGeometry3D::projectPoint(float32 fX, float32 fY, float32 fZ,
// Scale fS to detector plane
fU = detectorOffsetXToColIndexFloat( (fS * (m_fOriginSourceDistance + m_fOriginDetectorDistance)) / fD );
- fprintf(stderr, "alpha: %f, D: %f, V: %f, S: %f, U: %f\n", alpha, fD, fV, fS, fU);
+ astra::CLogger::debug(__FILE__,__LINE__,"alpha: %f, D: %f, V: %f, S: %f, U: %f", alpha, fD, fV, fS, fU);
}
diff --git a/src/Config.cpp b/src/Config.cpp
index 653935e..0a85b3c 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -37,6 +37,9 @@ $Id$
#include "astra/Projector2D.h"
#include "astra/Projector3D.h"
+#include "astra/Logging.h"
+#include <sstream>
+
using namespace astra;
using namespace std;
@@ -144,7 +147,9 @@ bool ConfigStackCheck<T>::stopParsing()
nodes.clear();
if (!errors.empty()) {
- cout << "Warning: " << name << ": unused configuration options: " << errors << std::endl;
+ ostringstream os;
+ os << "Warning: " << name << ": unused configuration options: " << errors;
+ astra::CLogger::warn(__FILE__,__LINE__,os.str().c_str());
return false;
}
diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp
index 77bd412..26b848e 100644
--- a/src/CudaFilteredBackProjectionAlgorithm.cpp
+++ b/src/CudaFilteredBackProjectionAlgorithm.cpp
@@ -34,6 +34,8 @@ $Id$
#include "astra/AstraObjectManager.h"
#include "../cuda/2d/astra.h"
+#include "astra/Logging.h"
+
using namespace std;
using namespace astra;
@@ -483,7 +485,7 @@ E_FBPFILTER CCudaFilteredBackProjectionAlgorithm::_convertStringToFilter(const c
}
else
{
- cerr << "Failed to convert \"" << _filterType << "\" into a filter." << endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Failed to convert \"%s\" into a filter.",_filterType);
}
return output;
diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp
index ab0d643..1ae6b83 100644
--- a/src/CudaForwardProjectionAlgorithm.cpp
+++ b/src/CudaForwardProjectionAlgorithm.cpp
@@ -42,6 +42,8 @@ $Id$
#include "astra/FanFlatVecProjectionGeometry2D.h"
#include "astra/CudaProjector2D.h"
+#include "astra/Logging.h"
+
using namespace std;
namespace astra {
@@ -104,7 +106,7 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
id = boost::lexical_cast<int>(node->getContent());
CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- cout << "Warning: non-CUDA Projector2D passed to FP_CUDA" << std::endl;
+ astra::CLogger::warn(__FILE__,__LINE__,"Warning: non-CUDA Projector2D passed to FP_CUDA");
}
delete node;
}
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index bb122e0..57e1094 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -40,6 +40,8 @@ $Id$
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include "../cuda/3d/astra3d.h"
using namespace std;
@@ -265,7 +267,7 @@ void CCudaForwardProjectionAlgorithm3D::run(int)
for (int k = 0; k < 2; ++k) {
float fU, fV;
projgeom->projectPoint(fX[i], fY[j], fZ[k], a, fU, fV);
- fprintf(stderr, "%3d %c1,%c1,%c1 -> %12f %12f\n", a, i ? ' ' : '-', j ? ' ' : '-', k ? ' ' : '-', fU, fV);
+ astra::CLogger::debug(__FILE__,__LINE__,"%3d %c1,%c1,%c1 -> %12f %12f", a, i ? ' ' : '-', j ? ' ' : '-', k ? ' ' : '-', fU, fV);
}
}
#endif
diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp
index d3dedc5..b434e8a 100644
--- a/src/CudaReconstructionAlgorithm2D.cpp
+++ b/src/CudaReconstructionAlgorithm2D.cpp
@@ -37,6 +37,8 @@ $Id$
#include "astra/FanFlatVecProjectionGeometry2D.h"
#include "astra/CudaProjector2D.h"
+#include "astra/Logging.h"
+
#include "../cuda/2d/algo.h"
#include <ctime>
@@ -176,7 +178,7 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg)
id = boost::lexical_cast<int>(node->getContent());
CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- cout << "Warning: non-CUDA Projector2D passed" << std::endl;
+ astra::CLogger::warn(__FILE__,__LINE__,"Warning: non-CUDA Projector2D passed");
}
delete node;
}
diff --git a/src/FilteredBackProjectionAlgorithm.cpp b/src/FilteredBackProjectionAlgorithm.cpp
index 50cf939..47315bb 100644
--- a/src/FilteredBackProjectionAlgorithm.cpp
+++ b/src/FilteredBackProjectionAlgorithm.cpp
@@ -39,6 +39,8 @@ $Id$
#include "astra/Fourier.h"
#include "astra/DataProjector.h"
+#include "astra/Logging.h"
+
using namespace std;
namespace astra {
@@ -133,7 +135,7 @@ bool CFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
for (int i = 0; i < angleCount; i ++) {
if (projectionIndex[i] > m_pProjector->getProjectionGeometry()->getProjectionAngleCount() -1 )
{
- cout << "Invalid Projection Index" << endl;
+ astra::CLogger::error(__FILE__,__LINE__,"Invalid Projection Index");
return false;
} else {
int orgIndex = (int)projectionIndex[i];