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

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

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

14 15 16
#ifndef BIOEM_DEFS_H
#define BIOEM_DEFS_H

David Rohr's avatar
David Rohr committed
17
//#define BIOEM_USE_DOUBLE
18

Pilar Cossio's avatar
Pilar Cossio committed
19 20
//#define PILAR_DEBUG

21
#ifndef BIOEM_USE_DOUBLE
22
typedef float myfloat_t;
23 24 25 26
#define myfftw_malloc fftwf_malloc
#define myfftw_free fftwf_free
#define myfftw_destroy_plan fftwf_destroy_plan
#define myfftw_execute fftwf_execute
27
#define myfftw_execute_dft fftwf_execute_dft
28 29
#define myfftw_execute_dft_r2c fftwf_execute_dft_r2c
#define myfftw_execute_dft_c2r fftwf_execute_dft_c2r
30
#define myfftw_plan_dft_2d fftwf_plan_dft_2d
31 32
#define myfftw_plan_dft_r2c_2d fftwf_plan_dft_r2c_2d
#define myfftw_plan_dft_c2r_2d fftwf_plan_dft_c2r_2d
33
#define myfftw_plan fftwf_plan
34
#define myfftw_cleanup fftwf_cleanup
David Rohr's avatar
David Rohr committed
35
#define MY_CUFFT_C2R CUFFT_C2R
36 37
#define mycufftExecC2R cufftExecC2R
#define mycuComplex_t cuComplex
David Rohr's avatar
David Rohr committed
38
#define MY_MPI_FLOAT MPI_FLOAT
39 40 41 42 43 44
#else
typedef double myfloat_t;
#define myfftw_malloc fftw_malloc
#define myfftw_free fftw_free
#define myfftw_destroy_plan fftw_destroy_plan
#define myfftw_execute fftw_execute
45
#define myfftw_execute_dft fftw_execute_dft
46 47
#define myfftw_execute_dft_r2c fftw_execute_dft_r2c
#define myfftw_execute_dft_c2r fftw_execute_dft_c2r
48
#define myfftw_plan_dft_2d fftw_plan_dft_2d
49 50
#define myfftw_plan_dft_r2c_2d fftw_plan_dft_r2c_2d
#define myfftw_plan_dft_c2r_2d fftw_plan_dft_c2r_2d
51
#define myfftw_plan fftw_plan
52
#define myfftw_cleanup fftw_cleanup
53 54
#define mycufftExecC2R cufftExecZ2D
#define mycuComplex_t cuDoubleComplex
David Rohr's avatar
David Rohr committed
55
#define MY_CUFFT_C2R CUFFT_Z2D
David Rohr's avatar
David Rohr committed
56
#define MY_MPI_FLOAT MPI_DOUBLE
57 58
#endif
typedef myfloat_t mycomplex_t[2];
59 60 61 62 63

#define BIOEM_FLOAT_3_PHYSICAL_SIZE 3	//Possible set to 4 for GPU

struct myfloat3_t
{
64
	myfloat_t pos[BIOEM_FLOAT_3_PHYSICAL_SIZE];
65
        myfloat_t quat4;
66
   //     myfloat_t prior;
67 68 69 70 71 72 73 74 75
};

#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
76
#define myGridDimX gridDim.x
77 78 79 80 81 82 83 84 85 86 87 88 89 90
#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
91
#define CUDA_FFTS_AT_ONCE 1024
92
//#define BIOEM_USE_NVTX
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
static inline void* mallocchk(size_t size)
{
	void* ptr = malloc(size);
	if (ptr == 0)
	{
		std::cout << "Memory allocation error\n";
		exit(1);
	}
	return(ptr);
}

static inline void* reallocchk(void* oldptr, size_t size)
{
	void* ptr = realloc(oldptr, size);
	if (ptr == 0)
	{
		std::cout << "Memory allocation error\n";
		exit(1);
	}
	return(ptr);
}

116 117 118 119 120
#ifndef WITH_OPENMP
#define omp_get_max_threads() 1
#define omp_get_thread_num() 0
#endif

121 122 123
extern int mpi_rank;
extern int mpi_size;

124
#endif