C++ main module for emicrom Package  1.0
fftw_types.h
Go to the documentation of this file.
1 #ifndef FFTW_TYPES
2 #define FFTW_TYPES
3 
4 
5 
6 //include fftw3 library
7 #include "fftw3.h"
8 
9 
10 
11 #if defined (USE_FFTW_FLOAT)
12 //===========================
13 //use the float fftw library
14 //===========================
15 
16 //complex & real definition
17 #define tFFTWComplex fftwf_complex
18 #define tFFTWReal float
19 //memory managment
20 #define FFTW_ALLOC(C,N) (C*) fftwf_malloc(sizeof(C) * (N+1))
21 #define FFTW_FREE fftwf_free
22 #define FFTW_CLEANUP fftwf_cleanup
23 
24 //DFT
25 #define FFTW_PLAN fftwf_plan
26 #define FFTW_PLAN_DFT_1D fftwf_plan_dft_1d
27 #define FFTW_DESTROY_PLAN fftwf_destroy_plan
28 #define FFTW_RUN fftwf_execute
29 
30 //THREADS
31 #define FFTW_INIT_THREADS() fftwf_init_threads()
32 #define FFTW_PLAN_WITH_NTHREADS(A) fftwf_plan_with_nthreads(A)
33 #define FFTW_CLEANUP_THREADS() fftwf_cleanup_threads()
34 
35 #elif defined(USE_FFTW_LONG)
36 //=================================
37 //use the long double fftw library
38 //==================================
39 
40 //complex & real definition
41 #define tFFTWComplex fftwl_complex
42 #define tFFTWReal long double
43 //memory managment
44 #define FFTW_ALLOC(C,N) (C*) fftwl_malloc(sizeof(C) * (N+1))
45 #define FFTW_FREE fftwl_free
46 #define FFTW_CLEANUP fftwl_cleanup
47 
48 //DFT
49 #define FFTW_PLAN fftwl_plan
50 #define FFTW_PLAN_DFT_1D fftwl_plan_dft_1d
51 #define FFTW_DESTROY_PLAN fftwl_destroy_plan
52 #define FFTW_RUN fftwl_execute
53 
54 //THREADS
55 #define FFTW_INIT_THREADS() fftwl_init_threads()
56 #define FFTW_PLAN_WITH_NTHREADS(A) fftwl_plan_with_nthreads(A)
57 #define FFTW_CLEANUP_THREADS() fftwl_cleanup_threads()
58 
59 #else
60 //=================================
61 //use the double fftw library
62 //==================================
63 
64 //complex & real definition
65 #define tFFTWComplex fftw_complex
66 #define tFFTWReal double
67 
68 //memory managment
69 #define FFTW_ALLOC(C,N) (C*) fftw_malloc(sizeof(C) * (N+1))
70 #define FFTW_FREE fftw_free
71 #define FFTW_CLEANUP fftw_cleanup
72 
73 //DFT
74 #define FFTW_PLAN fftw_plan
75 #define FFTW_PLAN_DFT_1D fftw_plan_dft_1d
76 #define FFTW_DESTROY_PLAN fftw_destroy_plan
77 #define FFTW_RUN fftw_execute
78 
79 //THREADS
80 #define FFTW_INIT_THREADS() fftw_init_threads()
81 #define FFTW_PLAN_WITH_NTHREADS(A) fftw_plan_with_nthreads(A)
82 #define FFTW_CLEANUP_THREADS() fftw_cleanup_threads()
83 
84 
85 #endif
86 
87 
88 //OPENMP
89 //=====
90 #ifdef _OPENMP
91 
92 #define OMP_FFTW_INIT_THREADS() FFTW_INIT_THREADS()
93 #define OMP_FFTW_PLAN_WITH_NTHREADS(A) FFTW_PLAN_WITH_NTHREADS(A)
94 #define OMP_FFTW_CLEANUP_THREADS() FFTW_CLEANUP_THREADS()
95 
96 #else
97 
98 #define OMP_FFTW_INIT_THREADS()
99 #define OMP_FFTW_PLAN_WITH_NTHREADS(A)
100 #define OMP_FFTW_CLEANUP_THREADS();
101 
102 #endif
103 
104 //intel compiler
105 //================
106 #if defined (__INTEL_COMPILER)
107 #undefine FFTW_ALLOC(C,A)
108 #undefine FFTW_FREE
109 
110 #define FFTW_ALLOC(C,N) (C*) _mm_malloc(sizeof(C) * (N+1), 64)
111 #define FFTW_FREE _mm_free
112 #endif
113 
114 
115 //end FFTW types definition
116 #endif
117 
118