Commit 92a9eb72 authored by David Rohr's avatar David Rohr
Browse files

code cleanup, move fft plan creation to function, remove file name strings from param class

parent 093227f8
...@@ -205,20 +205,13 @@ int bioem::configure(int ac, char* av[]) ...@@ -205,20 +205,13 @@ int bioem::configure(int ac, char* av[])
exit(1); exit(1);
} }
// ********************* Reading Parameter Input *************************** // ********************* Reading Parameter Input ***************************
// copying inputfile to param class param.readParameters(infile.c_str());
param.fileinput = infile.c_str();
param.readParameters();
// ********************* Reading Model Input ****************************** // ********************* Reading Model Input ******************************
// copying modelfile to model class Model.readModel(modelfile.c_str());
Model.filemodel = modelfile.c_str();
Model.readModel();
// ********************* Reading Particle Maps Input ********************** // ********************* Reading Particle Maps Input **********************
// ********* HERE: PROBLEM if maps dont fit on the memory!! *************** RefMap.readRefMaps(param, mapfile.c_str());
// copying mapfile to ref map class
param.filemap = mapfile.c_str();
RefMap.readRefMaps(param);
} }
#ifdef WITH_MPI #ifdef WITH_MPI
...@@ -227,6 +220,7 @@ int bioem::configure(int ac, char* av[]) ...@@ -227,6 +220,7 @@ int bioem::configure(int ac, char* av[])
if (mpi_rank != 0) return(1); if (mpi_rank != 0) return(1);
// ****************** Precalculating Necessary Stuff ********************* // ****************** Precalculating Necessary Stuff *********************
param.PrepareFFTs();
precalculate(); precalculate();
if (getenv("BIOEM_DEBUG_BREAK")) if (getenv("BIOEM_DEBUG_BREAK"))
...@@ -382,10 +376,11 @@ int bioem::run() ...@@ -382,10 +376,11 @@ int bioem::run()
// *** Angular Probability *** // *** Angular Probability ***
// if(param.writeAngles){
ofstream angProbfile; ofstream angProbfile;
angProbfile.open ("ANG_PROB_iRefMap"); if(param.writeAngles)
// } {
angProbfile.open ("ANG_PROB");
}
ofstream outputProbFile; ofstream outputProbFile;
outputProbFile.open ("Output_Probabilities"); outputProbFile.open ("Output_Probabilities");
...@@ -423,7 +418,10 @@ int bioem::run() ...@@ -423,7 +418,10 @@ int bioem::run()
} }
} }
angProbfile.close(); if(param.writeAngles)
{
angProbfile.close();
}
outputProbFile.close(); outputProbFile.close();
return(0); return(0);
......
...@@ -343,7 +343,7 @@ int bioem_cuda::deviceInit() ...@@ -343,7 +343,7 @@ int bioem_cuda::deviceInit()
{ {
deviceExit(); deviceExit();
selectCudaDevice();
if (FFTAlgo) GPUAlgo = 2; if (FFTAlgo) GPUAlgo = 2;
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
sumsquare_RefMap = NULL; sumsquare_RefMap = NULL;
RefMapsFFT = NULL; RefMapsFFT = NULL;
} }
int readRefMaps(bioem_param& param); int readRefMaps(bioem_param& param, const char* filemap);
int precalculate(bioem_param& param, bioem& bio); int precalculate(bioem_param& param, bioem& bio);
int PreCalculateMapsFFT(bioem_param& param); int PreCalculateMapsFFT(bioem_param& param);
......
...@@ -9,7 +9,7 @@ public: ...@@ -9,7 +9,7 @@ public:
//bioem_model(); //bioem_model();
//~bioem_model(); //~bioem_model();
int readModel(); int readModel(const char* filemodel);
bool readPDB; bool readPDB;
...@@ -17,8 +17,6 @@ public: ...@@ -17,8 +17,6 @@ public:
myfloat_t getAminoAcidDensity(char *name); myfloat_t getAminoAcidDensity(char *name);
myfloat_t NormDen; myfloat_t NormDen;
const char* filemodel;
int nPointsModel; int nPointsModel;
myfloat3_t PointsModel[BIOEM_MODEL_SIZE]; myfloat3_t PointsModel[BIOEM_MODEL_SIZE];
myfloat_t radiusPointsModel[BIOEM_MODEL_SIZE]; myfloat_t radiusPointsModel[BIOEM_MODEL_SIZE];
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
class bioem_param_device class bioem_param_device
{ {
public: public:
// Grids in center assuming equidistance from 0,0
int maxDisplaceCenter; int maxDisplaceCenter;
int GridSpaceCenter; int GridSpaceCenter;
int NumberPixels; int NumberPixels;
...@@ -25,10 +26,10 @@ public: ...@@ -25,10 +26,10 @@ public:
bioem_param(); bioem_param();
~bioem_param(); ~bioem_param();
int readParameters(); int readParameters(const char* fileinput);
int CalculateGridsParam(); int CalculateGridsParam();
int CalculateRefCTF(); int CalculateRefCTF();
int InitializeArrays(); void PrepareFFTs();
bioem_param_device param_device; bioem_param_device param_device;
...@@ -37,20 +38,14 @@ public: ...@@ -37,20 +38,14 @@ public:
mycomplex_t* refCTF; mycomplex_t* refCTF;
myfloat3_t* CtfParam; myfloat3_t* CtfParam;
// File names
const char* fileinput;
char logFile;
// If to write Probabilities of Angles from Model // If to write Probabilities of Angles from Model
bool writeAngles; bool writeAngles;
//int NumberPixels; //in device class
myfloat_t pixelSize; myfloat_t pixelSize;
// Grid Points in Euler angles, assuming uniform sampling d_alpha=d_gamma (in 2pi) & cos(beta)=-1,1 // Grid Points in Euler angles, assuming uniform sampling d_alpha=d_gamma (in 2pi) & cos(beta)=-1,1
int angleGridPointsAlpha; int angleGridPointsAlpha;
int angleGridPointsBeta; int angleGridPointsBeta;
// Grids in center assuming equidistance from 0,0
//int maxDisplaceCenter; //in device class
int numberGridPointsDisplaceCenter; int numberGridPointsDisplaceCenter;
//int GridSpaceCenter; //in device class
// Grid sampling for the convolution kernel // Grid sampling for the convolution kernel
//ENVELOPE //ENVELOPE
myfloat_t startGridEnvelop; myfloat_t startGridEnvelop;
...@@ -64,16 +59,13 @@ public: ...@@ -64,16 +59,13 @@ public:
int numberGridPointsCTF_amp; int numberGridPointsCTF_amp;
myfloat_t gridCTF_amp; myfloat_t gridCTF_amp;
// Others // Others
//myfloat_t volu;//in device class
myfloat3_t* angles; myfloat3_t* angles;
int nTotGridAngles; int nTotGridAngles;
int nTotCTFs; int nTotCTFs;
//myfloat_t Ntotpi;//in device class
int fft_plans_created; int fft_plans_created;
myfftw_plan fft_plan_c2c_forward, fft_plan_c2c_backward, fft_plan_r2c_forward, fft_plan_c2r_backward; myfftw_plan fft_plan_c2c_forward, fft_plan_c2c_backward, fft_plan_r2c_forward, fft_plan_c2r_backward;
const char* filemap;
bool dumpMap, loadMap; bool dumpMap, loadMap;
private: private:
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
using namespace std; using namespace std;
int bioem_RefMap::readRefMaps(bioem_param& param) int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
{ {
numPixels = param.param_device.NumberPixels; numPixels = param.param_device.NumberPixels;
refMapSize = param.param_device.NumberPixels * param.param_device.NumberPixels; refMapSize = param.param_device.NumberPixels * param.param_device.NumberPixels;
...@@ -50,11 +50,11 @@ int bioem_RefMap::readRefMaps(bioem_param& param) ...@@ -50,11 +50,11 @@ int bioem_RefMap::readRefMaps(bioem_param& param)
if(readMultMRC) if(readMultMRC)
{ {
ifstream input(param.filemap); ifstream input(filemap);
if (!input.good()) if (!input.good())
{ {
cout << "Failed to open file contaning MRC names: " << param.filemap << "\n"; cout << "Failed to open file contaning MRC names: " << filemap << "\n";
exit(0); exit(0);
} }
...@@ -84,13 +84,13 @@ int bioem_RefMap::readRefMaps(bioem_param& param) ...@@ -84,13 +84,13 @@ int bioem_RefMap::readRefMaps(bioem_param& param)
} }
cout << "\n+++++++++++++++++++++++++++++++++++++++++++ \n"; cout << "\n+++++++++++++++++++++++++++++++++++++++++++ \n";
cout << "Particle Maps read from MULTIPLE MRC Files in: " << param.filemap << "\n" ; cout << "Particle Maps read from MULTIPLE MRC Files in: " << filemap << "\n" ;
} }
else else
{ {
read_MRC(param.filemap,param); read_MRC(filemap,param);
cout << "\n++++++++++++++++++++++++++++++++++++++++++ \n"; cout << "\n++++++++++++++++++++++++++++++++++++++++++ \n";
cout << "Particle Maps read from ONE MRC File: " << param.filemap << "\n" ; cout << "Particle Maps read from ONE MRC File: " << filemap << "\n" ;
} }
} }
else else
...@@ -98,7 +98,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param) ...@@ -98,7 +98,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param)
int nummap = -1; int nummap = -1;
int lasti = 0; int lasti = 0;
int lastj = 0; int lastj = 0;
ifstream input(param.filemap); ifstream input(filemap);
if (!input.good()) if (!input.good())
{ {
cout << "Particle Maps Failed to open file" << endl ; cout << "Particle Maps Failed to open file" << endl ;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
using namespace std; using namespace std;
int bioem_model::readModel() int bioem_model::readModel(const char* filemodel)
{ {
// ************************************************************************************** // **************************************************************************************
// ***************Reading reference Models either PDB or x,y,z,r,d format**************** // ***************Reading reference Models either PDB or x,y,z,r,d format****************
......
...@@ -45,7 +45,7 @@ bioem_param::bioem_param() ...@@ -45,7 +45,7 @@ bioem_param::bioem_param()
angles = NULL; angles = NULL;
} }
int bioem_param::readParameters() int bioem_param::readParameters(const char* fileinput)
{ {
// ************************************************************************************** // **************************************************************************************
// ***************************** Reading Input Parameters ****************************** // ***************************** Reading Input Parameters ******************************
...@@ -256,8 +256,23 @@ int bioem_param::readParameters() ...@@ -256,8 +256,23 @@ int bioem_param::readParameters()
} }
param_device.NumberFFTPixels1D = param_device.NumberPixels / 2 + 1;
FFTMapSize = param_device.NumberPixels * param_device.NumberFFTPixels1D;
//Does currently not work with custom alignment on GPU
/*if (FFTMapSize % Alignment)
{
FFTMapSize += Alignment - FFTMapSize % Alignment;
}
cout << "Using MAP Size " << FFTMapSize << " (Alignment " << Alignment << ", Unaligned Size " << param_device.NumberPixels * param_device.NumberFFTPixels1D << ")\n";*/
cout << " +++++++++++++++++++++++++++++++++++++++++ \n"; cout << " +++++++++++++++++++++++++++++++++++++++++ \n";
return(0);
}
void bioem_param::PrepareFFTs()
{
cout << "Preparing FFTs\n"; cout << "Preparing FFTs\n";
releaseFFTPlans(); releaseFFTPlans();
mycomplex_t *tmp_map, *tmp_map2; mycomplex_t *tmp_map, *tmp_map2;
...@@ -278,21 +293,7 @@ int bioem_param::readParameters() ...@@ -278,21 +293,7 @@ int bioem_param::readParameters()
myfftw_free(tmp_map); myfftw_free(tmp_map);
myfftw_free(tmp_map2); myfftw_free(tmp_map2);
fft_plans_created = 1; fft_plans_created = 1;
param_device.NumberFFTPixels1D = param_device.NumberPixels / 2 + 1;
FFTMapSize = param_device.NumberPixels * param_device.NumberFFTPixels1D;
//Does currently not work with custom alignment on GPU
/*if (FFTMapSize % Alignment)
{
FFTMapSize += Alignment - FFTMapSize % Alignment;
}
cout << "Using MAP Size " << FFTMapSize << " (Alignment " << Alignment << ", Unaligned Size " << param_device.NumberPixels * param_device.NumberFFTPixels1D << ")\n";*/
cout << " +++++++++++++++++++++++++++++++++++++++++ \n";
return(0);
} }
void bioem_param::releaseFFTPlans() void bioem_param::releaseFFTPlans()
......
Markdown is supported
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