bioem.h 3.89 KB
Newer Older
1 2
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   < BioEM software for Bayesian inference of Electron Microscopy images>
Luka Stanisic's avatar
Luka Stanisic committed
3 4
   Copyright (C) 2017 Pilar Cossio, David Rohr, Fabio Baruffa, Markus Rampp,
        Luka Stanisic, Volker Lindenstruth and Gerhard Hummer.
5
   Max Planck Institute of Biophysics, Frankfurt, Germany.
Luka Stanisic's avatar
Luka Stanisic committed
6 7 8
   Frankfurt Institute for Advanced Studies, Goethe University Frankfurt,
   Germany.
   Max Planck Computing and Data Facility, Garching, Germany.
9

Luka Stanisic's avatar
Luka Stanisic committed
10
   Released under the GNU Public License, v3.
11 12 13 14
   See license statement for terms of distribution.

   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

15 16 17 18
#ifndef BIOEM_H
#define BIOEM_H

#include "bioem.h"
Luka Stanisic's avatar
Luka Stanisic committed
19
#include "defs.h"
20
#include "map.h"
Luka Stanisic's avatar
Luka Stanisic committed
21
#include "model.h"
22 23 24 25
#include "param.h"

class bioem
{
Luka Stanisic's avatar
Luka Stanisic committed
26 27
  friend class bioem_RefMap;
  friend class bioem_Probability;
28

29
public:
Luka Stanisic's avatar
Luka Stanisic committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
  bioem();
  virtual ~bioem();

  void printOptions(myoption_t *myoptions, int myoptions_length);
  int readOptions(int ac, char *av[]);
  int configure(int ac, char *av[]);
  void cleanup(); // Cleanup everything happening during configure

  int precalculate(); // Is it better to pass directly the input File names?
  inline int needToPrintModel() { return param.printModel; }
  int printModel();
  int run();
  int doProjections(int iMap);
  int createConvolutedProjectionMap(int iOreint, int iMap, mycomplex_t *lproj,
                                    mycomplex_t *localmultFFT, myfloat_t &sumC,
                                    myfloat_t &sumsquareC);
  int createConvolutedProjectionMap_noFFT(mycomplex_t *lproj,
                                          myfloat_t *Mapconv,
                                          mycomplex_t *localmultFFT,
                                          myfloat_t &sumC,
                                          myfloat_t &sumsquareC);

  virtual int compareRefMaps(int iPipeline, int iOrient, int iConv,
                             int maxParallelConv, mycomplex_t *localmultFFT,
                             myparam5_t *comp_params, const int startMap = 0);

  virtual void *malloc_device_host(size_t size);
  virtual void free_device_host(void *ptr);
  virtual void rebalance(int workload); // Rebalance GPUWorkload
  void rebalanceWrapper(int workload);  // Rebalance wrapper

  int createProjection(int iMap, mycomplex_t *map);
  int calcross_cor(myfloat_t *localmap, myfloat_t &sum, myfloat_t &sumsquare);
  void calculateCCFFT(int iMap, mycomplex_t *localConvFFT,
                      mycomplex_t *localCCT, myfloat_t *lCC);
  void doRefMap_CPU_Parallel(int iRefMap, int iOrient, int iConv,
                             myfloat_t *lCC, myparam5_t *comp_params,
                             myblockCPU_t *comp_block);
  void doRefMap_CPU_Reduce(int iRefMap, int iOrient, int iConvStart,
                           int maxParallelConv, myparam5_t *comp_params,
                           myblockCPU_t *comp_block);

  bioem_Probability pProb;

  string OutfileName;
Pilar Cossio's avatar
Pilar Cossio committed
75

76
protected:
Luka Stanisic's avatar
Luka Stanisic committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  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

  int BioEMAlgo;          // BioEM algorithm used to do comparison (Default 1)
  int CudaThreadCount;    // Number of CUDA threads used in each block (Default
                          // depends on the BioEM algorithm)
  int DebugOutput;        // Debug Output Level (Default 0)
  int nProjectionsAtOnce; // Number of projections to do at once via OpenMP
                          // (Default number of OMP threads)
  bool Autotuning; // Do the autotuning of the load-balancing between CPUs and
  // GPUs (Default 1, if GPUs are used and GPUWORKLOAD is not specified)
99 100 101
};

#endif