Commit a476152e authored by David Rohr's avatar David Rohr
Browse files

remove unnecessary copies

parent 07546137
...@@ -505,13 +505,10 @@ int bioem::createConvolutedProjectionMap(int iMap, int iConv, mycomplex_t* lproj ...@@ -505,13 +505,10 @@ int bioem::createConvolutedProjectionMap(int iMap, int iConv, mycomplex_t* lproj
// *************** and Backtransforming it to real Space ******************************** // *************** and Backtransforming it to real Space ********************************
// ************************************************************************************** // **************************************************************************************
myfloat_t* localconvFFT;
localconvFFT = (myfloat_t *) myfftw_malloc(sizeof(myfloat_t) * param.param_device.NumberPixels * param.param_device.NumberPixels);
mycomplex_t* tmp; mycomplex_t* tmp;
tmp = (mycomplex_t*) myfftw_malloc(sizeof(mycomplex_t) * param.param_device.NumberPixels * param.param_device.NumberFFTPixels1D); tmp = (mycomplex_t*) myfftw_malloc(sizeof(mycomplex_t) * param.param_device.NumberPixels * param.param_device.NumberFFTPixels1D);
// **** Multiplying FFTmap with corresponding kernel **** // **** Multiplying FFTmap with corresponding kernel ****
const mycomplex_t* refCTF = &param.refCTF[iConv * param.FFTMapSize]; const mycomplex_t* refCTF = &param.refCTF[iConv * param.FFTMapSize];
for(int i = 0; i < param.param_device.NumberPixels * param.param_device.NumberFFTPixels1D; i++) for(int i = 0; i < param.param_device.NumberPixels * param.param_device.NumberFFTPixels1D; i++)
{ {
...@@ -524,24 +521,15 @@ int bioem::createConvolutedProjectionMap(int iMap, int iConv, mycomplex_t* lproj ...@@ -524,24 +521,15 @@ int bioem::createConvolutedProjectionMap(int iMap, int iConv, mycomplex_t* lproj
memcpy(tmp, localmultFFT, sizeof(mycomplex_t) * param.param_device.NumberPixels * param.param_device.NumberFFTPixels1D); memcpy(tmp, localmultFFT, sizeof(mycomplex_t) * param.param_device.NumberPixels * param.param_device.NumberFFTPixels1D);
// **** Bringing convoluted Map to real Space **** // **** Bringing convoluted Map to real Space ****
myfftw_execute_dft_c2r(param.fft_plan_c2r_backward, tmp, localconvFFT); myfftw_execute_dft_c2r(param.fft_plan_c2r_backward, tmp, Mapconv);
// ****Asigning convolution fftw_complex to bioem_map ****
for(int i = 0; i < param.param_device.NumberPixels ; i++ )
{
for(int j = 0; j < param.param_device.NumberPixels ; j++ )
{
Mapconv[i * param.param_device.NumberPixels + j] = localconvFFT[i * param.param_device.NumberPixels + j];
}
}
// *** Calculating Cross-correlations of cal-convoluted map with its self ***** // *** Calculating Cross-correlations of cal-convoluted map with its self *****
sumC = 0; sumC = 0;
sumsquareC = 0; sumsquareC = 0;
for(int i = 0; i < param.param_device.NumberPixels * param.param_device.NumberPixels; i++) for(int i = 0; i < param.param_device.NumberPixels * param.param_device.NumberPixels; i++)
{ {
sumC += localconvFFT[i]; sumC += Mapconv[i];
sumsquareC += localconvFFT[i] * localconvFFT[i]; sumsquareC += Mapconv[i] * Mapconv[i];
} }
// *** The DTF gives an unnormalized value so have to divded by the total number of pixels in Fourier *** // *** The DTF gives an unnormalized value so have to divded by the total number of pixels in Fourier ***
// Normalizing // Normalizing
...@@ -551,7 +539,6 @@ int bioem::createConvolutedProjectionMap(int iMap, int iConv, mycomplex_t* lproj ...@@ -551,7 +539,6 @@ int bioem::createConvolutedProjectionMap(int iMap, int iConv, mycomplex_t* lproj
sumsquareC = sumsquareC / norm4; sumsquareC = sumsquareC / norm4;
// **** Freeing fftw_complex created (dont know if omp critical is necessary) **** // **** Freeing fftw_complex created (dont know if omp critical is necessary) ****
myfftw_free(localconvFFT);
myfftw_free(tmp); myfftw_free(tmp);
return(0); return(0);
......
...@@ -275,10 +275,12 @@ int bioem_param::CalculateRefCTF() ...@@ -275,10 +275,12 @@ int bioem_param::CalculateRefCTF()
myfloat_t amp, env, phase, ctf, radsq; myfloat_t amp, env, phase, ctf, radsq;
myfloat_t* localCTF; myfloat_t* localCTF;
mycomplex_t* localout;
int nctfmax = param_device.NumberPixels / 2; int nctfmax = param_device.NumberPixels / 2;
int n = 0; int n = 0;
localCTF = (myfloat_t *) myfftw_malloc(sizeof(myfloat_t) * param_device.NumberPixels * param_device.NumberPixels); localCTF = (myfloat_t *) myfftw_malloc(sizeof(myfloat_t) * param_device.NumberPixels * param_device.NumberPixels);
localout = (mycomplex_t *) myfftw_malloc(sizeof(mycomplex_t) * param_device.NumberPixels * param_device.NumberFFTPixels1D);
nTotCTFs = numberGridPointsCTF_amp * numberGridPointsCTF_phase * numberGridPointsEnvelop; nTotCTFs = numberGridPointsCTF_amp * numberGridPointsCTF_phase * numberGridPointsEnvelop;
delete[] refCTF; delete[] refCTF;
...@@ -314,9 +316,6 @@ int bioem_param::CalculateRefCTF() ...@@ -314,9 +316,6 @@ int bioem_param::CalculateRefCTF()
localCTF[(param_device.NumberPixels - i - 1)*param_device.NumberPixels + param_device.NumberPixels - j - 1] = (myfloat_t) ctf; localCTF[(param_device.NumberPixels - i - 1)*param_device.NumberPixels + param_device.NumberPixels - j - 1] = (myfloat_t) ctf;
} }
} }
//Creatting FFT_Forward of Kernel to store
mycomplex_t* localout;
localout = (mycomplex_t *) myfftw_malloc(sizeof(mycomplex_t) * param_device.NumberPixels * param_device.NumberFFTPixels1D);
//Calling FFT_Forward //Calling FFT_Forward
myfftw_execute_dft_r2c(fft_plan_r2c_forward, localCTF, localout); myfftw_execute_dft_r2c(fft_plan_r2c_forward, localCTF, localout);
...@@ -331,12 +330,12 @@ int bioem_param::CalculateRefCTF() ...@@ -331,12 +330,12 @@ int bioem_param::CalculateRefCTF()
CtfParam[n].pos[1] = phase; CtfParam[n].pos[1] = phase;
CtfParam[n].pos[2] = env; CtfParam[n].pos[2] = env;
n++; n++;
myfftw_free(localout);
} }
} }
} }
myfftw_free(localCTF); myfftw_free(localCTF);
myfftw_free(localout);
if (nTotCTFs != n) if (nTotCTFs != n)
{ {
cout << "Internal error during CTF preparation\n"; cout << "Internal error during CTF preparation\n";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment