fftw++.cc
Go to the documentation of this file.
1 #include <cstring>
2 #include <sstream>
3 #include "fftw++.h"
4 
5 using namespace std;
6 
7 namespace fftwpp {
8 
9 const double fftw::twopi=2.0*acos(-1.0);
10 
11 // User settings:
12 unsigned int fftw::effort=FFTW_MEASURE;
13 const char *fftw::WisdomName="wisdom3.txt";
14 unsigned int fftw::maxthreads=1;
15 double fftw::testseconds=0.2; // Time limit for threading efficiency tests
16 
17 fftw_plan (*fftw::planner)(fftw *f, Complex *in, Complex *out)=Planner;
18 
19 const char *fftw::oddshift="Shift is not implemented for odd nx";
20 const char *inout=
21  "constructor and call must be both in place or both out of place";
22 
23 fft1d::Table fft1d::threadtable;
24 mfft1d::Table mfft1d::threadtable;
25 rcfft1d::Table rcfft1d::threadtable;
26 crfft1d::Table crfft1d::threadtable;
27 mrcfft1d::Table mrcfft1d::threadtable;
28 mcrfft1d::Table mcrfft1d::threadtable;
29 fft2d::Table fft2d::threadtable;
30 
31 void LoadWisdom()
32 {
33  static bool Wise=false;
34  if(!Wise) {
35  ifstream ifWisdom;
36  ifWisdom.open(fftw::WisdomName);
37  ostringstream wisdom;
38  wisdom << ifWisdom.rdbuf();
39  ifWisdom.close();
40  const string& s=wisdom.str();
41  fftw_import_wisdom_from_string(s.c_str());
42  Wise=true;
43  }
44 }
45 
46 void SaveWisdom()
47 {
48  ofstream ofWisdom;
49  ofWisdom.open(fftw::WisdomName);
50  char *wisdom=fftw_export_wisdom_to_string();
51  ofWisdom << wisdom;
52  fftw_free(wisdom);
53  ofWisdom.close();
54 }
55 
56 fftw_plan Planner(fftw *F, Complex *in, Complex *out)
57 {
58  LoadWisdom();
59  fftw::effort |= FFTW_WISDOM_ONLY;
60  fftw_plan plan=F->Plan(in,out);
61  //fftw::effort &= !FFTW_WISDOM_ONLY; // I think this should be binary not. LN.
62  fftw::effort &= ~FFTW_WISDOM_ONLY;
63  if(!plan) {
64  plan=F->Plan(in,out);
65  SaveWisdom();
66  }
67  return plan;
68 }
69 
70 ThreadBase::ThreadBase() {threads=fftw::maxthreads;}
71 
72 }
73 
74 namespace utils {
75 unsigned int defaultmpithreads=1;
76 }
void LoadWisdom()
Definition: fftw++.cc:31
vector< t2list > out
output of the algorithm: a list of clusters
Definition: XbAlgo.cc:32
const char * inout
Definition: fftw++.cc:20
void SaveWisdom()
Definition: fftw++.cc:46
virtual fftw_plan Plan(Complex *, Complex *)
Definition: fftw++.h:279
std::complex< double > Complex
Definition: fftw++.h:83
constexpr double s
Definition: AugerUnits.h:163
fftw_plan Planner(fftw *F, Complex *in, Complex *out)
Definition: fftw++.cc:56
std::map< keytype1, threaddata, keyless1 > Table
Definition: fftw++.h:642
unsigned int defaultmpithreads
Definition: fftw++.cc:75
void plan(int n)
Definition: testlib.cc:41

, generated on Tue Sep 26 2023.