-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFFT.h
58 lines (47 loc) · 1.11 KB
/
FFT.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include "Constants.h"
#ifdef USE_CUDA
#include <cufftw.h>
// cuda's fft wrapper does not define certain functions, so we have to work around this
int fftw_init_threads();
void fftw_plan_with_nthreads(int nthreads);
void fftw_cleanup_threads();
enum fftw_r2r_kind
{
FFTW_RODFT00,
FFTW_REDFT00
};
#define fftwf_r2r_kind fftw_r2r_kind
#define fftwf_init_threads fftw_init_threads
#define fftwf_plan_with_nthreads fftw_plan_with_nthreads
#define fftwf_cleanup_threads fftw_cleanup_threads
#else
#include <fftw3.h>
#endif
// this should not be a bottleneck, so we do it in a fairly inefficient way
void Perform1DR2R(int size, const stratifloat* in, stratifloat* out, f3_r2r_kind kind);
void Setup();
void Cleanup();
// hackish solution to ensure mpi is initialised when we need it
class InitialiserClass
{
public:
InitialiserClass()
{
if (counter++ == 0)
{
Setup();
}
}
~InitialiserClass()
{
counter--;
if (counter==0)
{
Cleanup();
}
}
private:
static int counter;
};
static InitialiserClass initialiser;