Commit c9754f9e authored by qon's avatar qon

Change all line endings in files to unix style

parent 27a1ff28
This diff is collapsed.
This diff is collapsed.
#ifndef BIOEM_H
#define BIOEM_H
#include <fstream>
#include <iostream>
#include <complex>
#include "defs.h"
#include "bioem.h"
#include "model.h"
#include "map.h"
#include "param.h"
class bioem
{
public:
bioem();
virtual ~bioem();
int configure(int ac, char* av[]);
int precalculate(); // Is it better to pass directly the input File names?
int dopreCalCrossCorrelation(int iRefMap, int iRefMapLocal);
int run();
int doProjections(int iMap);
int createConvolutedProjectionMap(int iOreint,int iMap, mycomplex_t* lproj,bioem_map& Mapconv);
virtual int compareRefMaps(int iProjectionOut, int iConv, const bioem_map& conv_map);
int createProjection(int iMap, mycomplex_t* map);
int calcross_cor(bioem_map& localmap,myfloat_t& sum,myfloat_t& sumsquare);
bioem_Probability* pProb;
protected:
virtual int deviceInit();
virtual int deviceStartRun();
virtual int deviceFinishRun();
bioem_param param;
bioem_model Model;
bioem_RefMap RefMap;
int nReferenceMaps; //Maps in memory at a time
int nReferenceMapsTotal; //Maps in total
int nProjectionMaps; //Maps in memory at a time
int nProjectionMapsTotal; //Maps in total
};
#endif
#ifndef BIOEM_H
#define BIOEM_H
#include <fstream>
#include <iostream>
#include <complex>
#include "defs.h"
#include "bioem.h"
#include "model.h"
#include "map.h"
#include "param.h"
class bioem
{
public:
bioem();
virtual ~bioem();
int configure(int ac, char* av[]);
int precalculate(); // Is it better to pass directly the input File names?
int dopreCalCrossCorrelation(int iRefMap, int iRefMapLocal);
int run();
int doProjections(int iMap);
int createConvolutedProjectionMap(int iOreint,int iMap, mycomplex_t* lproj,bioem_map& Mapconv);
virtual int compareRefMaps(int iProjectionOut, int iConv, const bioem_map& conv_map);
int createProjection(int iMap, mycomplex_t* map);
int calcross_cor(bioem_map& localmap,myfloat_t& sum,myfloat_t& sumsquare);
bioem_Probability* pProb;
protected:
virtual int deviceInit();
virtual int deviceStartRun();
virtual int deviceFinishRun();
bioem_param param;
bioem_model Model;
bioem_RefMap RefMap;
int nReferenceMaps; //Maps in memory at a time
int nReferenceMapsTotal; //Maps in total
int nProjectionMaps; //Maps in memory at a time
int nProjectionMapsTotal; //Maps in total
};
#endif
#ifndef BIOEM_DEFS_H
#define BIOEM_DEFS_H
typedef float myfloat_t;
typedef double mycomplex_t[2];
#define BIOEM_FLOAT_3_PHYSICAL_SIZE 3 //Possible set to 4 for GPU
#define BIOEM_MAP_SIZE_X 224
#define BIOEM_MAP_SIZE_Y 224
#define BIOEM_MODEL_SIZE 120000
#define BIOEM_MAX_MAPS 12000
#define MAX_REF_CTF 200
#define MAX_ORIENT 20000
struct myfloat3_t
{
myfloat_t pos[BIOEM_FLOAT_3_PHYSICAL_SIZE];
};
#ifdef BIOEM_GPUCODE
#define myThreadIdxX threadIdx.x
#define myThreadIdxY threadIdx.y
#define myBlockDimX blockDim.x
#define myBlockDimY blockDim.y
#define myBlockIdxX blockIdx.x
#define myBlockIdxY blockIdx.y
#else
#define __device__
#define __host__
#define myThreadIdxX 0
#define myThreadIdxY 0
#define myBlockDimX 1
#define myBlockDimY 1
#define myBlockIdxX 0
#define myBlockIdxY 0
#endif
#define CUDA_THREAD_COUNT 256
#define CUDA_BLOCK_COUNT 1024 * 16
#define CUDA_MAX_SHIFT_REDUCE 1024
#endif
#ifndef BIOEM_DEFS_H
#define BIOEM_DEFS_H
typedef float myfloat_t;
typedef double mycomplex_t[2];
#define BIOEM_FLOAT_3_PHYSICAL_SIZE 3 //Possible set to 4 for GPU
#define BIOEM_MAP_SIZE_X 224
#define BIOEM_MAP_SIZE_Y 224
#define BIOEM_MODEL_SIZE 120000
#define BIOEM_MAX_MAPS 12000
#define MAX_REF_CTF 200
#define MAX_ORIENT 20000
struct myfloat3_t
{
myfloat_t pos[BIOEM_FLOAT_3_PHYSICAL_SIZE];
};
#ifdef BIOEM_GPUCODE
#define myThreadIdxX threadIdx.x
#define myThreadIdxY threadIdx.y
#define myBlockDimX blockDim.x
#define myBlockDimY blockDim.y
#define myBlockIdxX blockIdx.x
#define myBlockIdxY blockIdx.y
#else
#define __device__
#define __host__
#define myThreadIdxX 0
#define myThreadIdxY 0
#define myBlockDimX 1
#define myBlockDimY 1
#define myBlockIdxX 0
#define myBlockIdxY 0
#endif
#define CUDA_THREAD_COUNT 256
#define CUDA_BLOCK_COUNT 1024 * 16
#define CUDA_MAX_SHIFT_REDUCE 1024
#endif
#ifndef BIOEM_MAP_H
#define BIOEM_MAP_H
#include "defs.h"
#include <complex>
#include <math.h>
class bioem_param;
class bioem_map
{
public:
myfloat_t points[BIOEM_MAP_SIZE_X][BIOEM_MAP_SIZE_Y];
};
class bioem_map_forFFT
{
public:
mycomplex_t cpoints[2*BIOEM_MAP_SIZE_X*2*BIOEM_MAP_SIZE_Y];
};
class bioem_RefMap
{
public:
int readRefMaps();
const char* filemap;
int ntotRefMap;
bioem_map Ref[BIOEM_MAX_MAPS];
myfloat_t sum_RefMap[BIOEM_MAX_MAPS];
myfloat_t sumsquare_RefMap[BIOEM_MAX_MAPS];
myfloat_t ForLogProbfromRef[BIOEM_MAX_MAPS];
bool dumpMap, loadMap;
__host__ __device__ inline myfloat_t get(int map, int x, int y) const {return(Ref[map].points[x][y]);}
__host__ __device__ inline const myfloat_t* getp(int map, int x, int y) const {return(&Ref[map].points[x][y]);}
};
class bioem_RefMap_Mod
{
public:
const char* filemap;
int ntotRefMap;
myfloat_t Ref[BIOEM_MAP_SIZE_X][BIOEM_MAP_SIZE_Y][BIOEM_MAX_MAPS];
myfloat_t sum_RefMap[BIOEM_MAX_MAPS];
myfloat_t sumsquare_RefMap[BIOEM_MAX_MAPS];
myfloat_t ForLogProbfromRef[BIOEM_MAX_MAPS];
__host__ __device__ inline myfloat_t get(int map, int x, int y) const {return(Ref[x][y][map]);}
bioem_RefMap_Mod() {ntotRefMap = 0;}
bioem_RefMap_Mod(const bioem_RefMap& map)
{
ntotRefMap = map.ntotRefMap;
memcpy(sum_RefMap, map.sum_RefMap, sizeof(sum_RefMap));
memcpy(sumsquare_RefMap, map.sumsquare_RefMap, sizeof(sumsquare_RefMap));
memcpy(ForLogProbfromRef, map.ForLogProbfromRef, sizeof(ForLogProbfromRef));
#pragma omp parallel for
for (int i = 0;i < ntotRefMap;i++)
{
for (int j = 0;j < BIOEM_MAP_SIZE_X;j++)
{
for (int k = 0;k < BIOEM_MAP_SIZE_Y;k++)
{
Ref[j][k][i] = map.get(i, j, k);
}
}
}
}
};
class bioem_Probability
{
public:
myfloat_t forAngles[MAX_ORIENT];
myfloat_t Total;
myfloat_t Constoadd;
myfloat_t ConstAngle[MAX_ORIENT];
myfloat_t max_prob;
int max_prob_cent_x, max_prob_cent_y, max_prob_orient, max_prob_conv;
};
#endif
#ifndef BIOEM_MAP_H
#define BIOEM_MAP_H
#include "defs.h"
#include <complex>
#include <math.h>
class bioem_param;
class bioem_map
{
public:
myfloat_t points[BIOEM_MAP_SIZE_X][BIOEM_MAP_SIZE_Y];
};
class bioem_map_forFFT
{
public:
mycomplex_t cpoints[2*BIOEM_MAP_SIZE_X*2*BIOEM_MAP_SIZE_Y];
};
class bioem_RefMap
{
public:
int readRefMaps();
const char* filemap;
int ntotRefMap;
bioem_map Ref[BIOEM_MAX_MAPS];
myfloat_t sum_RefMap[BIOEM_MAX_MAPS];
myfloat_t sumsquare_RefMap[BIOEM_MAX_MAPS];
myfloat_t ForLogProbfromRef[BIOEM_MAX_MAPS];
bool dumpMap, loadMap;
__host__ __device__ inline myfloat_t get(int map, int x, int y) const {return(Ref[map].points[x][y]);}
__host__ __device__ inline const myfloat_t* getp(int map, int x, int y) const {return(&Ref[map].points[x][y]);}
};
class bioem_RefMap_Mod
{
public:
const char* filemap;
int ntotRefMap;
myfloat_t Ref[BIOEM_MAP_SIZE_X][BIOEM_MAP_SIZE_Y][BIOEM_MAX_MAPS];
myfloat_t sum_RefMap[BIOEM_MAX_MAPS];
myfloat_t sumsquare_RefMap[BIOEM_MAX_MAPS];
myfloat_t ForLogProbfromRef[BIOEM_MAX_MAPS];
__host__ __device__ inline myfloat_t get(int map, int x, int y) const {return(Ref[x][y][map]);}
bioem_RefMap_Mod() {ntotRefMap = 0;}
bioem_RefMap_Mod(const bioem_RefMap& map)
{
ntotRefMap = map.ntotRefMap;
memcpy(sum_RefMap, map.sum_RefMap, sizeof(sum_RefMap));
memcpy(sumsquare_RefMap, map.sumsquare_RefMap, sizeof(sumsquare_RefMap));
memcpy(ForLogProbfromRef, map.ForLogProbfromRef, sizeof(ForLogProbfromRef));
#pragma omp parallel for
for (int i = 0;i < ntotRefMap;i++)
{
for (int j = 0;j < BIOEM_MAP_SIZE_X;j++)
{
for (int k = 0;k < BIOEM_MAP_SIZE_Y;k++)
{
Ref[j][k][i] = map.get(i, j, k);
}
}
}
}
};
class bioem_Probability
{
public:
myfloat_t forAngles[MAX_ORIENT];
myfloat_t Total;
myfloat_t Constoadd;
myfloat_t ConstAngle[MAX_ORIENT];
myfloat_t max_prob;
int max_prob_cent_x, max_prob_cent_y, max_prob_orient, max_prob_conv;
};
#endif
#ifndef BIOEM_MODEL_H
#define BIOEM_MODEL_H
#include "defs.h"
class bioem_model
{
public:
//bioem_model();
//~bioem_model();
int readModel();
bool readPDB;
myfloat_t getAminoAcidRad(char *name);
myfloat_t getAminoAcidDensity(char *name);
const char* filemodel;
int nPointsModel;
myfloat3_t PointsModel[BIOEM_MODEL_SIZE];
myfloat_t radiusPointsModel[BIOEM_MODEL_SIZE];
myfloat_t densityPointsModel[BIOEM_MODEL_SIZE];
};
#endif
#ifndef BIOEM_MODEL_H
#define BIOEM_MODEL_H
#include "defs.h"
class bioem_model
{
public:
//bioem_model();
//~bioem_model();
int readModel();
bool readPDB;
myfloat_t getAminoAcidRad(char *name);
myfloat_t getAminoAcidDensity(char *name);
const char* filemodel;
int nPointsModel;
myfloat3_t PointsModel[BIOEM_MODEL_SIZE];
myfloat_t radiusPointsModel[BIOEM_MODEL_SIZE];
myfloat_t densityPointsModel[BIOEM_MODEL_SIZE];
};
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
#include <time.h>
#include <fenv.h>
#ifdef _WIN32
#include <Windows.h>
#include <WinBase.h>
#endif
#include <iostream>
#include <algorithm>
#include <iterator>
#include "bioem.h"
#include "bioem_cuda.h"
#include <omp.h>
#include "cmodules/timer.h"
int main(int argc, char* argv[])
{
/**************************************************************************************/
/********************************* Main BioEM code **********************************/
/************************************************************************************/
#pragma omp parallel
{
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); //Flush denormals to zero in all OpenMP threads
}
HighResTimer timer;
bioem* bio;
if (getenv("GPU") && atoi(getenv("GPU")))
{
bio = bioem_cuda_create();
}
else
{
bio = new bioem;
}
/************ Configuration and Pre-calculating necessary objects *****************/
printf("Configuring\n");
bio->configure(argc,argv);
/******************************* Run BioEM routine ******************************/
printf("Running\n");
timer.Start();
bio->run();
timer.Stop();
/************************************ End **********************************/
printf ("The code ran for %f seconds.\n", timer.GetElapsedTime());
delete bio;
return(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
#include <time.h>
#include <fenv.h>
#ifdef _WIN32
#include <Windows.h>
#include <WinBase.h>
#endif
#include <iostream>
#include <algorithm>
#include <iterator>
#include "bioem.h"
#include "bioem_cuda.h"
#include <omp.h>
#include "cmodules/timer.h"
int main(int argc, char* argv[])
{
/**************************************************************************************/
/********************************* Main BioEM code **********************************/
/************************************************************************************/
#pragma omp parallel
{
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); //Flush denormals to zero in all OpenMP threads
}
HighResTimer timer;
bioem* bio;
if (getenv("GPU") && atoi(getenv("GPU")))
{
bio = bioem_cuda_create();
}
else
{
bio = new bioem;
}
/************ Configuration and Pre-calculating necessary objects *****************/
printf("Configuring\n");
bio->configure(argc,argv);
/******************************* Run BioEM routine ******************************/
printf("Running\n");
timer.Start();
bio->run();
timer.Stop();
/************************************ End **********************************/
printf ("The code ran for %f seconds.\n", timer.GetElapsedTime());
delete bio;
return(0);
}
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include "map.h"
using namespace std;
int bioem_RefMap::readRefMaps()
{
/**************************************************************************************/
/***********************Reading reference Particle Maps************************/
/**************************************************************************************/
if (loadMap)
{
FILE* fp = fopen("maps.dump", "rb");
if (fp == NULL)
{
cout << "Error opening dump file\n";
exit(1);
}
fread(&ntotRefMap, sizeof(ntotRefMap), 1, fp);
if (ntotRefMap > BIOEM_MAX_MAPS)
{
cout << "BIOEM_MAX_MAPS too small\n";
exit(1);
}
fread(&Ref[0], sizeof(Ref[0]), ntotRefMap, fp);
fclose(fp);
cout << "Particle Maps read from Map Dump \nTotal Number of particles: " << ntotRefMap ;
cout << "\n+++++++++++++++++++++++++++++++++++++++++ \n";
}
else
{
int nummap=-1;
ifstream input(filemap);
if (!input.good())
{
cout << "Particle Maps Failed to open file" << endl ;
exit(1);
}
char line[512] = {' '};
char tmpLine[512] = {' '};
while (!input.eof())
{
input.getline(line,512);
strncpy(tmpLine,line,strlen(line));
char *token = strtok(tmpLine," ");
if (strcmp(token,"PARTICLE")==0) // to count the number of maps
{
nummap++;
if (nummap % 128 == 0)
{
cout << "..." << nummap << "\n";
}
if (nummap == BIOEM_MAX_MAPS)
{
cout << "BIOEM_MAX_MAPS too small\n";
exit(1);
}
}
else
{
int i,j;
myfloat_t z;
char tmpVals[36] = {' '};
strncpy (tmpVals,line,8);
sscanf (tmpVals,"%d",&i);
strncpy (tmpVals,line+8,8);
sscanf (tmpVals,"%d",&j);
strncpy (tmpVals,line+16,12);
sscanf (tmpVals,"%f",&z);
//checking for Map limits
if(i>0 && i-1 <BIOEM_MAP_SIZE_X&& j>0 && j-1<BIOEM_MAP_SIZE_Y && nummap < BIOEM_MAX_MAPS)
{
Ref[nummap].points[i-1][j-1]=z;
}
else
{
cout << "PROBLEM READING MAP (Map number " << nummap << ", i " << i << ", j " << j << ")" << "\n";
exit(1);
}
}
}
cout << ".";
ntotRefMap=nummap+1;
cout << "Particle Maps read from Standard File \nTotal Number of particles: " << ntotRefMap ;
cout << "\n+++++++++++++++++++++++++++++++++++++++++ \n";
if (dumpMap)
{
FILE* fp = fopen("maps.dump", "w+b");
if (fp == NULL)
{
cout << "Error opening dump file\n";
exit(1);
}
fwrite(&ntotRefMap, sizeof(ntotRefMap), 1, fp);
fwrite(&Ref[0], sizeof(Ref[0]), ntotRefMap, fp);
fclose(fp);
}
}
return(0);
}
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include "map.h"