Generative Fast Fourier Transforms (GFFT)  0.3
gfftpolicy.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2009-2014 by Vladimir Mirnyy *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  ***************************************************************************/
14 
15 #ifndef __gfftpolicy_h
16 #define __gfftpolicy_h
17 
22 #include "Typelist.h"
23 
24 #include <complex>
25 
26 #include <omp.h>
27 
28 #include "sint.h"
29 
30 namespace GFFT {
31 
32 typedef unsigned int id_t;
33 
41 template<typename T>
43 public:
44  virtual void fft(T*) = 0;
45  virtual ~AbstractFFT_inp() {}
46 };
47 
48 template<typename T>
49 class AbstractFFT_oop {
50 public:
51  virtual void fft(const T*, T*) = 0;
52  virtual ~AbstractFFT_oop() {}
53 };
54 
62 class Empty { };
63 
64 
73 struct DOUBLE {
74  static const id_t ID = 0;
75  typedef double ValueType;
76 #ifdef __x86_64
77  static const int Accuracy = 2;
78 #else
79  static const int Accuracy = 4;
80 #endif
81 };
82 
86 struct FLOAT {
87  static const id_t ID = 1;
88  typedef float ValueType;
89 #ifdef __x86_64
90  static const int Accuracy = 1;
91 #else
92  static const int Accuracy = 2;
93 #endif
94 };
95 
100  static const id_t ID = 2;
101  typedef std::complex<double> ValueType;
102 #ifdef __x86_64
103  static const int Accuracy = 2;
104 #else
105  static const int Accuracy = 4;
106 #endif
107 };
108 
113  static const id_t ID = 3;
114  typedef std::complex<float> ValueType;
115 #ifdef __x86_64
116  static const int Accuracy = 1;
117 #else
118  static const int Accuracy = 2;
119 #endif
120 };
121 
125 struct INTIME {
126  static const id_t ID = 0;
127  template<int_t N, typename NFact, typename T,
128  class Swap, class Direction, short_t NT, class W1>
129  class List {
130 // typedef InTime<N,NFact,T,Direction::Sign,W1> InT;
132  public:
133  typedef TYPELIST_3(Swap,InT,Direction) Result;
134  };
135 };
136 
137 struct INTIME_OOP {
138  static const id_t ID = 0;
139  template<int_t N, typename NFact, typename T,
140  class Swap, class Direction, short_t NT, class W1>
141  class List {
142 // typedef InTimeOOP<N,NFact,T,Direction::Sign,W1> InT;
143  typedef InTimeOOP_OMP<NT,N,NFact,T,Direction::Sign,W1> InT;
144  public:
145  typedef TYPELIST_3(Swap,InT,Direction) Result;
146  };
147 };
148 
152 struct INFREQ {
153  static const id_t ID = 1;
154  template<int_t N, typename NFact, typename T,
155  class Swap, class Direction, short_t NT, class W1>
156  class List {
157 // typedef InFreq<N,NFact,T,Direction::Sign,W1> InF;
159  public:
160  typedef TYPELIST_3(InF,Swap,Direction) Result;
161  };
162 };
163 
167 struct IN_PLACE {
168  static const id_t ID = 0;
169  template<class T>
170  struct Interface {
171  typedef AbstractFFT_inp<T> Result;
172  };
173  template<int_t N, typename NFact, typename T,
174  class Swap, class Direction, short_t NT, class W1>
175  struct List {
176  typedef typename INTIME::template List<N,NFact,T,Swap,Direction,NT,W1>::Result Result;
177  };
178 };
179 
183 struct OUT_OF_PLACE {
184  static const id_t ID = 1;
185  template<class T>
186  struct Interface {
187  typedef AbstractFFT_oop<T> Result;
188  };
189  template<int_t N, typename NFact, typename T,
190  class Swap, class Direction, short_t NT, class W1>
191  struct List {
192  typedef typename INTIME_OOP::template List<N,NFact,T,Swap,Direction,NT,W1>::Result Result;
193  };
194 };
195 
196 struct IDFT;
197 struct IRDFT;
198 
202 struct DFT {
203  static const id_t ID = 0;
204  typedef IDFT Inverse;
205 
206  template<unsigned long N, typename T>
207  struct Direction : public Forward<N,T> {};
208 
209  template<class TList, class Separator>
210  struct Algorithm {
211  typedef TList Result;
212  };
213 };
214 
218 struct IDFT {
219  static const id_t ID = 1;
220  typedef DFT Inverse;
221 
222  template<unsigned long N, typename T>
223  struct Direction : public Backward<N,T> {};
224 
225  template<class TList, class Separator>
226  struct Algorithm {
227  typedef TList Result;
228  };
229 };
230 
234 struct RDFT {
235  static const id_t ID = 2;
236  typedef IRDFT Inverse;
237 
238  template<unsigned long N, typename T>
239  struct Direction : public Forward<N,T> {};
240 
241  template<class TList, class Separator>
242  struct Algorithm {
243  typedef typename Loki::TL::Append<TList,Separator>::Result Result;
244  };
245 };
246 
250 struct IRDFT {
251  static const id_t ID = 3;
252  typedef RDFT Inverse;
253 
254  template<unsigned long N, typename T>
255  struct Direction : public Backward<N,T> {};
256 
257  template<class TList, class Separator>
258  struct Algorithm {
259  typedef Loki::Typelist<Separator,TList> Result;
260  };
261 };
262 
263 
268 struct Serial {
269  static const id_t ID = 0;
270  static const uint_t NParProc = 1;
271 
272  template<uint_t M, uint_t P, class T>
273  struct Swap {
274  typedef GFFTswap2<M,P,T> Result;
275  };
276 
277  template<typename T>
278  void apply(T*) { }
279 
280  template<typename T>
281  void apply(const T*, T*) { }
282 };
283 
289 template<unsigned int NT>
290 struct OpenMP {
291  static const id_t ID = NT-1;
292  static const uint_t NParProc = NT;
293 
294  template<uint_t M, uint_t P, class T>
295  struct Swap {
296  typedef GFFTswap2<M,P,T> Result;
297 // typedef GFFTswap2OMP<NT,M,P,T> Result;
298  };
299 
300  template<typename T>
301  void apply(T*) {
302  //omp_set_dynamic(0);
303  //omp_set_num_threads(NT);
304  omp_set_nested(true);
305  }
306 
307  template<typename T>
308  void apply(const T*, T* d) { apply(d); }
309 };
310 
311 template<>
312 struct OpenMP<0>:public Serial { };
313 
314 template<>
315 struct OpenMP<1>:public Serial { };
316 
317 
318 } //namespace GFFT
319 
320 #endif /*__gfftpolicy_h*/

Generated on Mon Feb 10 2014 for Generative Fast Fourier Transforms (GFFT) by DoxyGen 1.8.3.1