/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ < 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. Frankfurt Institute for Advanced Studies, Goethe University Frankfurt, Germany. Max Planck Computing and Data Facility, Garching, Germany. Released under the GNU Public License, v3. See license statement for terms of distribution. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #ifndef BIOEM_DEFS_H #define BIOEM_DEFS_H //#define BIOEM_USE_DOUBLE //#define PILAR_DEBUG #ifndef BIOEM_USE_DOUBLE typedef float myfloat_t; #define myfftw_malloc fftwf_malloc #define myfftw_free fftwf_free #define myfftw_destroy_plan fftwf_destroy_plan #define myfftw_execute fftwf_execute #define myfftw_execute_dft fftwf_execute_dft #define myfftw_execute_dft_r2c fftwf_execute_dft_r2c #define myfftw_execute_dft_c2r fftwf_execute_dft_c2r #define myfftw_plan_dft_2d fftwf_plan_dft_2d #define myfftw_plan_dft_r2c_2d fftwf_plan_dft_r2c_2d #define myfftw_plan_dft_c2r_2d fftwf_plan_dft_c2r_2d #define myfftw_plan fftwf_plan #define myfftw_cleanup fftwf_cleanup #define MY_CUFFT_C2R CUFFT_C2R #define mycufftExecC2R cufftExecC2R #define mycuComplex_t cuComplex #define MY_MPI_FLOAT MPI_FLOAT #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 #define myfftw_execute_dft fftw_execute_dft #define myfftw_execute_dft_r2c fftw_execute_dft_r2c #define myfftw_execute_dft_c2r fftw_execute_dft_c2r #define myfftw_plan_dft_2d fftw_plan_dft_2d #define myfftw_plan_dft_r2c_2d fftw_plan_dft_r2c_2d #define myfftw_plan_dft_c2r_2d fftw_plan_dft_c2r_2d #define myfftw_plan fftw_plan #define myfftw_cleanup fftw_cleanup #define mycufftExecC2R cufftExecZ2D #define mycuComplex_t cuDoubleComplex #define MY_CUFFT_C2R CUFFT_Z2D #define MY_MPI_FLOAT MPI_DOUBLE #endif typedef myfloat_t mycomplex_t[2]; #define BIOEM_FLOAT_3_PHYSICAL_SIZE 3 //Possible set to 4 for GPU struct myfloat3_t { myfloat_t pos[BIOEM_FLOAT_3_PHYSICAL_SIZE]; myfloat_t quat4; // myfloat_t prior; }; #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 #define myGridDimX gridDim.x #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 #define CUDA_FFTS_AT_ONCE 1024 //#define BIOEM_USE_NVTX /* Autotuning Autotuning algorithms: 1. AlgoSimple = 1; Testing workload values between 100 and 30, all multiples of 5. Taking the value with the best timing. 2. AlgoRatio = 2; Comparisons where GPU handles 100% or only 1% of the workload are timed, and then the optimal workload balance is computed. 3. AlgoBisection = 3; Based on bisection, multiple workload values are tested until the optimal one is found. */ #define AUTOTUNING_ALGORITHM 3 /* Recalibrate every X projections */ #define RECALIB_FACTOR 200 /* After how many comparison iterations, comparison duration becomes stable */ #define FIRST_STABLE 7 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); } #ifndef WITH_OPENMP #define omp_get_max_threads() 1 #define omp_get_thread_num() 0 #endif extern int mpi_rank; extern int mpi_size; #endif