ls1-MarDyn
ls1-MarDyn molecular dynamics code
FakedOptFFT.h
1/*
2 * FakeOptFFT.h
3 *
4 * Created on: Mar 06, 2015
5 * Author: gallardjm
6 */
7
8#ifndef FAKEOPTFFT_H_
9#define FAKEOPTFFT_H_
10
11#include "WrapOpenMP.h"
12
13#include "bhfmm/fft/tools/optimizedFFT/optFFT_API.h"
14#include "bhfmm/fft/tools/FFTW_API.h"
15#include "bhfmm/fft/tools/fft_utils.h"
16
17#include <map>
18#include <iostream>
19
20using namespace std;
21
22//struct storing a int[2] for the map
23struct pos {
24 int x, y;
25};
26
27//comparator of pos (=int[2])
28struct pos_comp {
29 bool operator()(const pos &l, const pos &r) const {
30 return (l.x < r.x || (l.x == r.x && l.y < r.y));
31 }
32};
33
39class FakedOptFFT: public optFFT_API {
40
41public:
42
43 FakedOptFFT() {
44 } //cout << "Using faked opt FFT (see bhfmm/fft/tools/optimizedFFT)" << endl;}
45 ~~FakedOptFFT() { //free all entry of the map and the map
46 auto itr = _fftw_api_map.begin();
47 while (itr != _fftw_api_map.end()) {
48 for (int i = 0; i < mardyn_get_max_threads(); ++i) {
49 delete ((*itr).second[i]);
50 }
51 delete ((*itr).second);
52 _fftw_api_map.erase(itr++);
53 }
54 _fftw_api_map.clear();
55 }
56
57 void optimizedFFT(FFT_precision** & Real, FFT_precision** & Imag,
58 const int size_x, const int size_y);
59 void optimizedIFFT(FFT_precision** & Real, FFT_precision** & Imag,
60 const int size_x, const int size_y);
61
62private:
63 map<pos, FFTW_API**, pos_comp> _fftw_api_map; //storage of the various FFTW_API required
64
65 FFTW_API* getFFTW_API(const int size_x, const int size_y); //memoized function using the map
66};
67
68#endif
Definition: FFTW_API.h:25
Definition: FakedOptFFT.h:39
void optimizedIFFT(FFT_precision **&Real, FFT_precision **&Imag, const int size_x, const int size_y)
Definition: FakedOptFFT.cpp:135
void optimizedFFT(FFT_precision **&Real, FFT_precision **&Imag, const int size_x, const int size_y)
Definition: FakedOptFFT.cpp:72
Definition: optFFT_API.h:18
Definition: FakedOptFFT.h:28
Definition: FakedOptFFT.h:23