void gpuNUFFT::TextureGpuNUFFTOperator::initKernel() { IndType kernelSize = (interpolationType > 1) ? calculateKernelSizeLinInt(osf, kernelWidth) : calculateGrid3KernelSize(osf, kernelWidth); this->kernel.dim.width = kernelSize; this->kernel.dim.height = interpolationType > 1 ? kernelSize : 1; this->kernel.dim.depth = interpolationType > 2 ? kernelSize : 1; if (this->kernel.data != NULL) free(this->kernel.data); this->kernel.data = (DType *)calloc(this->kernel.count(), sizeof(DType)); switch (interpolationType) { case TEXTURE_LOOKUP: load1DKernel(this->kernel.data, (int)kernelSize, (int)kernelWidth, osf); break; case TEXTURE2D_LOOKUP: load2DKernel(this->kernel.data, (int)kernelSize, (int)kernelWidth, osf); break; case TEXTURE3D_LOOKUP: load3DKernel(this->kernel.data, (int)kernelSize, (int)kernelWidth, osf); break; default: load1DKernel(this->kernel.data, (int)kernelSize, (int)kernelWidth, osf); } }
void gpuNUFFT::GpuNUFFTOperator::initKernel() { IndType kernelSize = calculateGrid3KernelSize(osf, kernelWidth/2.0f); this->kernel.dim.length = kernelSize; this->kernel.data = (DType*) calloc(this->kernel.count(),sizeof(DType)); load1DKernel(this->kernel.data,(int)kernelSize,(int)kernelWidth,osf); }
TEST(Test2DGPUGpuNUFFTConv,MatlabTest_8SK3w32) { //oversampling ratio float osr = DEFAULT_OVERSAMPLING_RATIO; //kernel width int kernel_width = 3; long kernel_entries = calculateGrid3KernelSize(osr, kernel_width/2.0f); DType *kern = (DType*) calloc(kernel_entries,sizeof(DType)); load1DKernel(kern,kernel_entries,kernel_width,osr); //Image int im_width = 32; //Data int data_entries = 1; DType2* data = (DType2*) calloc(data_entries,sizeof(DType2)); //2* re + im int data_cnt = 0; data[data_cnt].x = 0.0046f; data[data_cnt++].y = -0.0021f; //Coords //Scaled between -0.5 and 0.5 //in triplets (x,y,z) DType* coords = (DType*) calloc(2*data_entries,sizeof(DType));//2* x,y int coord_cnt = 0; coords[coord_cnt++] = 0.2500f; coords[coord_cnt++] = -0.4330f; //sectors of data, count and start indices int sector_width = 8; gpuNUFFT::Array<DType> kSpaceData; kSpaceData.data = coords; kSpaceData.dim.length = data_entries; gpuNUFFT::Dimensions imgDims(im_width,im_width); gpuNUFFT::GpuNUFFTOperatorFactory factory; gpuNUFFT::GpuNUFFTOperator *gpuNUFFTOp = factory.createGpuNUFFTOperator(kSpaceData,kernel_width,sector_width,osr,imgDims); gpuNUFFT::Array<DType2> dataArray; dataArray.data = data; dataArray.dim.length = data_entries; gpuNUFFT::Array<CufftType> gdataArray; gdataArray = gpuNUFFTOp->performGpuNUFFTAdj(dataArray,gpuNUFFT::CONVOLUTION); //Output Grid CufftType* gdata = gdataArray.data; /*for (int j=0; j<im_width; j++) { for (int i=0; i<im_width; i++) { float dpr = gdata[get2DC2lin(i,im_width-1-j,16,im_width)]; float dpi = gdata[get2DC2lin(i,im_width-1-j,16,im_width)+1]; if (abs(dpr) > 0.0f) printf("(%d,%d)= %.4f + %.4f i ",i,im_width-1-j,dpr,dpi); } printf("\n"); }*/ EXPECT_NEAR(gdata[get2DC2lin(23,3,im_width)].x,0.0012f,epsilon); EXPECT_NEAR(gdata[get2DC2lin(23,2,im_width)].x,0.0020f,epsilon); EXPECT_NEAR(gdata[get2DC2lin(23,1,im_width)].x,0.0007f,epsilon); EXPECT_NEAR(gdata[get2DC2lin(24,3,im_width)].x,0.0026f,epsilon);//Re EXPECT_NEAR(gdata[get2DC2lin(24,3,im_width)].y,-0.0012f,epsilon);//Im EXPECT_NEAR(gdata[get2DC2lin(24,2,im_width)].x,0.0045f,epsilon); EXPECT_NEAR(gdata[get2DC2lin(24,1,im_width)].x,0.0016f,epsilon); EXPECT_NEAR(gdata[get2DC2lin(25,3,im_width)].x,0.0012f,epsilon); EXPECT_NEAR(gdata[get2DC2lin(25,2,im_width)].x,0.0020f,epsilon);//Re EXPECT_NEAR(gdata[get2DC2lin(25,2,im_width)].y,-0.0009f,epsilon);//Im EXPECT_NEAR(gdata[get2DC2lin(25,1,im_width)].x,0.0007f,epsilon); free(data); free(coords); free(gdata); delete gpuNUFFTOp; }