diff options
Diffstat (limited to 'cuda/2d')
-rw-r--r-- | cuda/2d/cgls.cu | 61 | ||||
-rw-r--r-- | cuda/2d/em.cu | 65 | ||||
-rw-r--r-- | cuda/2d/fan_bp.cu | 67 | ||||
-rw-r--r-- | cuda/2d/fan_fp.cu | 85 | ||||
-rw-r--r-- | cuda/2d/fft.cu | 207 | ||||
-rw-r--r-- | cuda/2d/par_bp.cu | 56 | ||||
-rw-r--r-- | cuda/2d/par_fp.cu | 66 | ||||
-rw-r--r-- | cuda/2d/sirt.cu | 63 |
8 files changed, 0 insertions, 670 deletions
diff --git a/cuda/2d/cgls.cu b/cuda/2d/cgls.cu index 905b960..e7238b9 100644 --- a/cuda/2d/cgls.cu +++ b/cuda/2d/cgls.cu @@ -29,10 +29,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> @@ -206,60 +202,3 @@ float CGLS::computeDiffNorm() } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_sinoData; - - SDimensions dims; - dims.iVolWidth = 1024; - dims.iVolHeight = 1024; - dims.iProjAngles = 512; - dims.iProjDets = 1536; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - unsigned int volumePitch, sinoPitch; - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - zeroVolume(D_volumeData, volumePitch, dims.iVolWidth, dims.iVolHeight); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_sinoData, dims.iProjDets, dims.iProjAngles, sinoPitch); - zeroVolume(D_sinoData, sinoPitch, dims.iProjDets, dims.iProjAngles); - printf("pitch: %u\n", sinoPitch); - - unsigned int y, x; - float* sino = loadImage("sino.png", y, x); - - float* img = new float[dims.iVolWidth*dims.iVolHeight]; - - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_sinoData, sinoPitch); - - float* angle = new float[dims.iProjAngles]; - - for (unsigned int i = 0; i < dims.iProjAngles; ++i) - angle[i] = i*(M_PI/dims.iProjAngles); - - CGLS cgls; - - cgls.setGeometry(dims, angle); - cgls.init(); - - cgls.setBuffers(D_volumeData, volumePitch, D_sinoData, sinoPitch); - - cgls.iterate(25); - - delete[] angle; - - copyVolumeFromDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - - saveImage("vol.png",dims.iVolHeight,dims.iVolWidth,img); - - return 0; -} -#endif diff --git a/cuda/2d/em.cu b/cuda/2d/em.cu index aa272d8..df140ec 100644 --- a/cuda/2d/em.cu +++ b/cuda/2d/em.cu @@ -29,10 +29,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> @@ -168,64 +164,3 @@ float EM::computeDiffNorm() } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_sinoData; - - SDimensions dims; - dims.iVolWidth = 1024; - dims.iVolHeight = 1024; - dims.iProjAngles = 512; - dims.iProjDets = 1536; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - unsigned int volumePitch, sinoPitch; - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - zeroVolume(D_volumeData, volumePitch, dims.iVolWidth, dims.iVolHeight); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_sinoData, dims.iProjDets, dims.iProjAngles, sinoPitch); - zeroVolume(D_sinoData, sinoPitch, dims.iProjDets, dims.iProjAngles); - printf("pitch: %u\n", sinoPitch); - - unsigned int y, x; - float* sino = loadImage("sino.png", y, x); - - float* img = new float[dims.iVolWidth*dims.iVolHeight]; - - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_sinoData, sinoPitch); - - float* angle = new float[dims.iProjAngles]; - - for (unsigned int i = 0; i < dims.iProjAngles; ++i) - angle[i] = i*(M_PI/dims.iProjAngles); - - EM em; - - em.setGeometry(dims, angle); - em.init(); - - // TODO: Initialize D_volumeData with an unfiltered backprojection - - em.setBuffers(D_volumeData, volumePitch, D_sinoData, sinoPitch); - - em.iterate(25); - - - delete[] angle; - - copyVolumeFromDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - - saveImage("vol.png",dims.iVolHeight,dims.iVolWidth,img); - - return 0; -} - -#endif diff --git a/cuda/2d/fan_bp.cu b/cuda/2d/fan_bp.cu index d9d993b..76d2fb9 100644 --- a/cuda/2d/fan_bp.cu +++ b/cuda/2d/fan_bp.cu @@ -28,10 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> #include <iostream> @@ -438,66 +434,3 @@ bool FanBP_FBPWeighted(float* D_volumeData, unsigned int volumePitch, } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_projData; - - SDimensions dims; - dims.iVolWidth = 128; - dims.iVolHeight = 128; - dims.iProjAngles = 180; - dims.iProjDets = 256; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - unsigned int volumePitch, projPitch; - - SFanProjection projs[180]; - - projs[0].fSrcX = 0.0f; - projs[0].fSrcY = 1536.0f; - projs[0].fDetSX = 128.0f; - projs[0].fDetSY = -512.0f; - projs[0].fDetUX = -1.0f; - projs[0].fDetUY = 0.0f; - -#define ROTATE0(name,i,alpha) do { projs[i].f##name##X = projs[0].f##name##X * cos(alpha) - projs[0].f##name##Y * sin(alpha); projs[i].f##name##Y = projs[0].f##name##X * sin(alpha) + projs[0].f##name##Y * cos(alpha); } while(0) - - for (int i = 1; i < 180; ++i) { - ROTATE0(Src, i, i*2*M_PI/180); - ROTATE0(DetS, i, i*2*M_PI/180); - ROTATE0(DetU, i, i*2*M_PI/180); - } - -#undef ROTATE0 - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_projData, dims.iProjDets, dims.iProjAngles, projPitch); - printf("pitch: %u\n", projPitch); - - unsigned int y, x; - float* sino = loadImage("sino.png", y, x); - - float* img = new float[dims.iVolWidth*dims.iVolHeight]; - - memset(img, 0, dims.iVolWidth*dims.iVolHeight*sizeof(float)); - - copyVolumeToDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_projData, projPitch); - - FanBP(D_volumeData, volumePitch, D_projData, projPitch, dims, projs, 1.0f); - - copyVolumeFromDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - - saveImage("vol.png",dims.iVolHeight,dims.iVolWidth,img); - - return 0; -} -#endif diff --git a/cuda/2d/fan_fp.cu b/cuda/2d/fan_fp.cu index 3479650..60c02f8 100644 --- a/cuda/2d/fan_fp.cu +++ b/cuda/2d/fan_fp.cu @@ -28,10 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> #include <iostream> @@ -308,84 +304,3 @@ bool FanFP(float* D_volumeData, unsigned int volumePitch, } } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_projData; - - SDimensions dims; - dims.iVolWidth = 128; - dims.iVolHeight = 128; - dims.iProjAngles = 180; - dims.iProjDets = 256; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - unsigned int volumePitch, projPitch; - - SFanProjection projs[180]; - - projs[0].fSrcX = 0.0f; - projs[0].fSrcY = 1536.0f; - projs[0].fDetSX = 128.0f; - projs[0].fDetSY = -512.0f; - projs[0].fDetUX = -1.0f; - projs[0].fDetUY = 0.0f; - -#define ROTATE0(name,i,alpha) do { projs[i].f##name##X = projs[0].f##name##X * cos(alpha) - projs[0].f##name##Y * sin(alpha); projs[i].f##name##Y = projs[0].f##name##X * sin(alpha) + projs[0].f##name##Y * cos(alpha); } while(0) - - for (int i = 1; i < 180; ++i) { - ROTATE0(Src, i, i*2*M_PI/180); - ROTATE0(DetS, i, i*2*M_PI/180); - ROTATE0(DetU, i, i*2*M_PI/180); - } - -#undef ROTATE0 - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_projData, dims.iProjDets, dims.iProjAngles, projPitch); - printf("pitch: %u\n", projPitch); - - unsigned int y, x; - float* img = loadImage("phantom128.png", y, x); - - float* sino = new float[dims.iProjAngles * dims.iProjDets]; - - memset(sino, 0, dims.iProjAngles * dims.iProjDets * sizeof(float)); - - copyVolumeToDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_projData, projPitch); - - float* angle = new float[dims.iProjAngles]; - - for (unsigned int i = 0; i < dims.iProjAngles; ++i) - angle[i] = i*(M_PI/dims.iProjAngles); - - FanFP(D_volumeData, volumePitch, D_projData, projPitch, dims, projs, 1.0f); - - delete[] angle; - - copySinogramFromDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_projData, projPitch); - - float s = 0.0f; - for (unsigned int y = 0; y < dims.iProjAngles; ++y) - for (unsigned int x = 0; x < dims.iProjDets; ++x) - s += sino[y*dims.iProjDets+x] * sino[y*dims.iProjDets+x]; - printf("cpu norm: %f\n", s); - - //zeroVolume(D_projData, projPitch, dims.iProjDets, dims.iProjAngles); - s = dotProduct2D(D_projData, projPitch, dims.iProjDets, dims.iProjAngles); - printf("gpu norm: %f\n", s); - - saveImage("sino.png",dims.iProjAngles,dims.iProjDets,sino); - - - return 0; -} -#endif diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu index 2e94b79..8361ad2 100644 --- a/cuda/2d/fft.cu +++ b/cuda/2d/fft.cu @@ -314,210 +314,3 @@ void genCuFFTFilter(const SFilterConfig &_cfg, int _iProjectionCount, } - - -#ifdef STANDALONE - -__global__ static void doubleFourierOutput_kernel(int _iProjectionCount, - int _iDetectorCount, - cufftComplex* _pFourierOutput) -{ - int iIndex = threadIdx.x + blockIdx.x * blockDim.x; - int iProjectionIndex = iIndex / _iDetectorCount; - int iDetectorIndex = iIndex % _iDetectorCount; - - if(iProjectionIndex >= _iProjectionCount) - { - return; - } - - if(iDetectorIndex <= (_iDetectorCount / 2)) - { - return; - } - - int iOtherDetectorIndex = _iDetectorCount - iDetectorIndex; - - _pFourierOutput[iProjectionIndex * _iDetectorCount + iDetectorIndex].x = _pFourierOutput[iProjectionIndex * _iDetectorCount + iOtherDetectorIndex].x; - _pFourierOutput[iProjectionIndex * _iDetectorCount + iDetectorIndex].y = -_pFourierOutput[iProjectionIndex * _iDetectorCount + iOtherDetectorIndex].y; -} - -static void doubleFourierOutput(int _iProjectionCount, int _iDetectorCount, - cufftComplex * _pFourierOutput) -{ - const int iBlockSize = 256; - int iElementCount = _iProjectionCount * _iDetectorCount; - int iBlockCount = (iElementCount + iBlockSize - 1) / iBlockSize; - - doubleFourierOutput_kernel<<< iBlockCount, iBlockSize >>>(_iProjectionCount, - _iDetectorCount, - _pFourierOutput); - CHECK_ERROR("doubleFourierOutput_kernel failed"); -} - - - -static void writeToMatlabFile(const char * _fileName, const float * _pfData, - int _iRowCount, int _iColumnCount) -{ - std::ofstream out(_fileName); - - for(int iRowIndex = 0; iRowIndex < _iRowCount; iRowIndex++) - { - for(int iColumnIndex = 0; iColumnIndex < _iColumnCount; iColumnIndex++) - { - out << _pfData[iColumnIndex + iRowIndex * _iColumnCount] << " "; - } - - out << std::endl; - } -} - -static void convertComplexToRealImg(const cufftComplex * _pComplex, - int _iElementCount, - float * _pfReal, float * _pfImaginary) -{ - for(int iIndex = 0; iIndex < _iElementCount; iIndex++) - { - _pfReal[iIndex] = _pComplex[iIndex].x; - _pfImaginary[iIndex] = _pComplex[iIndex].y; - } -} - -void testCudaFFT() -{ - const int iProjectionCount = 2; - const int iDetectorCount = 1024; - const int iTotalElementCount = iProjectionCount * iDetectorCount; - - float * pfHostProj = new float[iTotalElementCount]; - memset(pfHostProj, 0, sizeof(float) * iTotalElementCount); - - for(int iProjectionIndex = 0; iProjectionIndex < iProjectionCount; iProjectionIndex++) - { - for(int iDetectorIndex = 0; iDetectorIndex < iDetectorCount; iDetectorIndex++) - { -// int - -// pfHostProj[iIndex] = (float)rand() / (float)RAND_MAX; - } - } - - writeToMatlabFile("proj.mat", pfHostProj, iProjectionCount, iDetectorCount); - - float * pfDevProj = NULL; - SAFE_CALL(cudaMalloc((void **)&pfDevProj, sizeof(float) * iTotalElementCount)); - SAFE_CALL(cudaMemcpy(pfDevProj, pfHostProj, sizeof(float) * iTotalElementCount, cudaMemcpyHostToDevice)); - - cufftComplex * pDevFourProj = NULL; - SAFE_CALL(cudaMalloc((void **)&pDevFourProj, sizeof(cufftComplex) * iTotalElementCount)); - - cufftHandle plan; - cufftResult result; - - result = cufftPlan1d(&plan, iDetectorCount, CUFFT_R2C, iProjectionCount); - if(result != CUFFT_SUCCESS) - { - ASTRA_ERROR("Failed to plan 1d r2c fft"); - } - - result = cufftExecR2C(plan, pfDevProj, pDevFourProj); - if(result != CUFFT_SUCCESS) - { - ASTRA_ERROR("Failed to exec 1d r2c fft"); - } - - cufftDestroy(plan); - - doubleFourierOutput(iProjectionCount, iDetectorCount, pDevFourProj); - - cufftComplex * pHostFourProj = new cufftComplex[iTotalElementCount]; - SAFE_CALL(cudaMemcpy(pHostFourProj, pDevFourProj, sizeof(cufftComplex) * iTotalElementCount, cudaMemcpyDeviceToHost)); - - float * pfHostFourProjReal = new float[iTotalElementCount]; - float * pfHostFourProjImaginary = new float[iTotalElementCount]; - - convertComplexToRealImg(pHostFourProj, iTotalElementCount, pfHostFourProjReal, pfHostFourProjImaginary); - - writeToMatlabFile("proj_four_real.mat", pfHostFourProjReal, iProjectionCount, iDetectorCount); - writeToMatlabFile("proj_four_imaginary.mat", pfHostFourProjImaginary, iProjectionCount, iDetectorCount); - - float * pfDevInFourProj = NULL; - SAFE_CALL(cudaMalloc((void **)&pfDevInFourProj, sizeof(float) * iTotalElementCount)); - - result = cufftPlan1d(&plan, iDetectorCount, CUFFT_C2R, iProjectionCount); - if(result != CUFFT_SUCCESS) - { - ASTRA_ERROR("Failed to plan 1d c2r fft"); - } - - result = cufftExecC2R(plan, pDevFourProj, pfDevInFourProj); - if(result != CUFFT_SUCCESS) - { - ASTRA_ERROR("Failed to exec 1d c2r fft"); - } - - cufftDestroy(plan); - - rescaleInverseFourier(iProjectionCount, iDetectorCount, pfDevInFourProj); - - float * pfHostInFourProj = new float[iTotalElementCount]; - SAFE_CALL(cudaMemcpy(pfHostInFourProj, pfDevInFourProj, sizeof(float) * iTotalElementCount, cudaMemcpyDeviceToHost)); - - writeToMatlabFile("in_four.mat", pfHostInFourProj, iProjectionCount, iDetectorCount); - - SAFE_CALL(cudaFree(pDevFourProj)); - SAFE_CALL(cudaFree(pfDevProj)); - - delete [] pfHostInFourProj; - delete [] pfHostFourProjReal; - delete [] pfHostFourProjImaginary; - delete [] pfHostProj; - delete [] pHostFourProj; -} - -void downloadDebugFilterComplex(float * _pfHostSinogram, int _iProjectionCount, - int _iDetectorCount, - cufftComplex * _pDevFilter, - int _iFilterDetCount) -{ - cufftComplex * pHostFilter = NULL; - size_t complMemSize = sizeof(cufftComplex) * _iFilterDetCount * _iProjectionCount; - pHostFilter = (cufftComplex *)malloc(complMemSize); - SAFE_CALL(cudaMemcpy(pHostFilter, _pDevFilter, complMemSize, cudaMemcpyDeviceToHost)); - - for(int iTargetProjIndex = 0; iTargetProjIndex < _iProjectionCount; iTargetProjIndex++) - { - for(int iTargetDetIndex = 0; iTargetDetIndex < min(_iDetectorCount, _iFilterDetCount); iTargetDetIndex++) - { - cufftComplex source = pHostFilter[iTargetDetIndex + iTargetProjIndex * _iFilterDetCount]; - float fReadValue = sqrtf(source.x * source.x + source.y * source.y); - _pfHostSinogram[iTargetDetIndex + iTargetProjIndex * _iDetectorCount] = fReadValue; - } - } - - free(pHostFilter); -} - -void downloadDebugFilterReal(float * _pfHostSinogram, int _iProjectionCount, - int _iDetectorCount, float * _pfDevFilter, - int _iFilterDetCount) -{ - float * pfHostFilter = NULL; - size_t memSize = sizeof(float) * _iFilterDetCount * _iProjectionCount; - pfHostFilter = (float *)malloc(memSize); - SAFE_CALL(cudaMemcpy(pfHostFilter, _pfDevFilter, memSize, cudaMemcpyDeviceToHost)); - - for(int iTargetProjIndex = 0; iTargetProjIndex < _iProjectionCount; iTargetProjIndex++) - { - for(int iTargetDetIndex = 0; iTargetDetIndex < min(_iDetectorCount, _iFilterDetCount); iTargetDetIndex++) - { - float fSource = pfHostFilter[iTargetDetIndex + iTargetProjIndex * _iFilterDetCount]; - _pfHostSinogram[iTargetDetIndex + iTargetProjIndex * _iDetectorCount] = fSource; - } - } - - free(pfHostFilter); -} - -#endif diff --git a/cuda/2d/par_bp.cu b/cuda/2d/par_bp.cu index 3bf78ee..f080abb 100644 --- a/cuda/2d/par_bp.cu +++ b/cuda/2d/par_bp.cu @@ -28,10 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> #include <iostream> @@ -297,55 +293,3 @@ bool BP_SART(float* D_volumeData, unsigned int volumePitch, } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_projData; - - SDimensions dims; - dims.iVolWidth = 1024; - dims.iVolHeight = 1024; - dims.iProjAngles = 512; - dims.iProjDets = 1536; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - - unsigned int volumePitch, projPitch; - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_projData, dims.iProjDets, dims.iProjAngles, projPitch); - printf("pitch: %u\n", projPitch); - - unsigned int y, x; - float* sino = loadImage("sino.png", y, x); - - float* img = new float[dims.iVolWidth*dims.iVolHeight]; - - memset(img, 0, dims.iVolWidth*dims.iVolHeight*sizeof(float)); - - copyVolumeToDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_projData, projPitch); - - float* angle = new float[dims.iProjAngles]; - - for (unsigned int i = 0; i < dims.iProjAngles; ++i) - angle[i] = i*(M_PI/dims.iProjAngles); - - BP(D_volumeData, volumePitch, D_projData, projPitch, dims, angle, 0, 1.0f); - - delete[] angle; - - copyVolumeFromDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - - saveImage("vol.png",dims.iVolHeight,dims.iVolWidth,img); - - return 0; -} -#endif diff --git a/cuda/2d/par_fp.cu b/cuda/2d/par_fp.cu index e03381c..ea436c3 100644 --- a/cuda/2d/par_fp.cu +++ b/cuda/2d/par_fp.cu @@ -28,10 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> #include <iostream> @@ -373,65 +369,3 @@ bool FP(float* D_volumeData, unsigned int volumePitch, } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_projData; - - SDimensions dims; - dims.iVolWidth = 1024; - dims.iVolHeight = 1024; - dims.iProjAngles = 512; - dims.iProjDets = 1536; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - unsigned int volumePitch, projPitch; - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_projData, dims.iProjDets, dims.iProjAngles, projPitch); - printf("pitch: %u\n", projPitch); - - unsigned int y, x; - float* img = loadImage("phantom.png", y, x); - - float* sino = new float[dims.iProjAngles * dims.iProjDets]; - - memset(sino, 0, dims.iProjAngles * dims.iProjDets * sizeof(float)); - - copyVolumeToDevice(img, dims.iVolWidth, dims.iVolWidth, dims.iVolHeight, D_volumeData, volumePitch); - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_projData, projPitch); - - float* angle = new float[dims.iProjAngles]; - - for (unsigned int i = 0; i < dims.iProjAngles; ++i) - angle[i] = i*(M_PI/dims.iProjAngles); - - FP(D_volumeData, volumePitch, D_projData, projPitch, dims, angle, 0, 1.0f); - - delete[] angle; - - copySinogramFromDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_projData, projPitch); - - float s = 0.0f; - for (unsigned int y = 0; y < dims.iProjAngles; ++y) - for (unsigned int x = 0; x < dims.iProjDets; ++x) - s += sino[y*dims.iProjDets+x] * sino[y*dims.iProjDets+x]; - printf("cpu norm: %f\n", s); - - //zeroVolume(D_projData, projPitch, dims.iProjDets, dims.iProjAngles); - s = dotProduct2D(D_projData, projPitch, dims.iProjDets, dims.iProjAngles, 1, 0); - printf("gpu norm: %f\n", s); - - saveImage("sino.png",dims.iProjAngles,dims.iProjDets,sino); - - - return 0; -} -#endif diff --git a/cuda/2d/sirt.cu b/cuda/2d/sirt.cu index 2621490..2c5fdc9 100644 --- a/cuda/2d/sirt.cu +++ b/cuda/2d/sirt.cu @@ -29,10 +29,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/cuda/2d/util.h" #include "astra/cuda/2d/arith.h" -#ifdef STANDALONE -#include "testutil.h" -#endif - #include <cstdio> #include <cassert> @@ -302,62 +298,3 @@ float SIRT::computeDiffNorm() } - -#ifdef STANDALONE - -using namespace astraCUDA; - -int main() -{ - float* D_volumeData; - float* D_sinoData; - - SDimensions dims; - dims.iVolWidth = 1024; - dims.iVolHeight = 1024; - dims.iProjAngles = 512; - dims.iProjDets = 1536; - dims.fDetScale = 1.0f; - dims.iRaysPerDet = 1; - unsigned int volumePitch, sinoPitch; - - allocateVolume(D_volumeData, dims.iVolWidth, dims.iVolHeight, volumePitch); - zeroVolume(D_volumeData, volumePitch, dims.iVolWidth, dims.iVolHeight); - printf("pitch: %u\n", volumePitch); - - allocateVolume(D_sinoData, dims.iProjDets, dims.iProjAngles, sinoPitch); - zeroVolume(D_sinoData, sinoPitch, dims.iProjDets, dims.iProjAngles); - printf("pitch: %u\n", sinoPitch); - - unsigned int y, x; - float* sino = loadImage("sino.png", y, x); - - float* img = new float[dims.iVolWidth*dims.iVolHeight]; - - copySinogramToDevice(sino, dims.iProjDets, dims.iProjDets, dims.iProjAngles, D_sinoData, sinoPitch); - - float* angle = new float[dims.iProjAngles]; - - for (unsigned int i = 0; i < dims.iProjAngles; ++i) - angle[i] = i*(M_PI/dims.iProjAngles); - - SIRT sirt; - - sirt.setGeometry(dims, angle); - sirt.init(); - - sirt.setBuffers(D_volumeData, volumePitch, D_sinoData, sinoPitch); - - sirt.iterate(25); - - - delete[] angle; - - copyVolumeFromDevice(img, dims.iVolWidth, dims, D_volumeData, volumePitch); - - saveImage("vol.png",dims.iVolHeight,dims.iVolWidth,img); - - return 0; -} -#endif - |