underling  0.3.2
underling_fftw.hpp
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 // underling 0.3.1: an FFTW MPI-based library for 3D pencil decompositions
3 // https://github.com/RhysU/underling
4 //
5 // Copyright (C) 2010--2013, 2026 Rhys Ulerich
6 // Copyright (C) 2012, 2013 The PECOS Development Team
7 //
8 // This file is part of underling.
9 //
10 // underling is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // underling is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with underling. If not, see <http://www.gnu.org/licenses/>.
22 //-----------------------------------------------------------------------el-
23 // $Id$
24 
25 #ifndef UNDERLING_FFTW_HPP
26 #define UNDERLING_FFTW_HPP
27 
29 #include <underling/underling.hpp>
30 
36 namespace underling {
37 
38 namespace fftw {
39 
42 
44 namespace packed {
45 
46  enum { // Anonymous to avoid introducing an unnecessary type
47 
50 
53 
56 
59 
60  };
61 
62 }
63 
68 class plan : public noncopyable {
69 public:
70 
72  struct c2c_forward {};
73 
75  struct c2c_backward {};
76 
78  struct r2c_forward {};
79 
81  struct c2r_backward {};
82 
84  plan(const c2c_forward tag,
85  const problem &p,
86  int long_ni,
87  underling_real *in,
88  underling_real *out,
89  unsigned fftw_rigor_flags = 0,
90  unsigned packed_flags = 0)
92  p.get(), long_ni, in, out, fftw_rigor_flags, packed_flags))
93  {
94  (void) tag; // unused
95  }
96 
98  plan(const c2c_backward tag,
99  const problem &p,
100  int long_ni,
101  underling_real *in,
102  underling_real *out,
103  unsigned fftw_rigor_flags = 0,
104  unsigned packed_flags = 0)
106  p.get(), long_ni, in, out, fftw_rigor_flags, packed_flags))
107  {
108  (void) tag; // unused
109  }
110 
112  plan(const r2c_forward tag,
113  const problem &p,
114  int long_ni,
115  underling_real *in,
116  underling_real *out,
117  unsigned fftw_rigor_flags = 0,
118  unsigned packed_flags = 0)
120  p.get(), long_ni, in, out, fftw_rigor_flags, packed_flags))
121  {
122  (void) tag; // unused
123  }
124 
126  plan(const c2r_backward tag,
127  const problem &p,
128  int long_ni,
129  underling_real *in,
130  underling_real *out,
131  unsigned fftw_rigor_flags = 0,
132  unsigned packed_flags = 0)
134  p.get(), long_ni, in, out, fftw_rigor_flags, packed_flags))
135  {
136  (void) tag; // unused
137  }
138 
140  plan(const plan& plan_to_invert,
141  underling_real * in,
142  underling_real * out,
143  unsigned fftw_rigor_flags = 0)
145  plan_to_invert.get(), in, out, fftw_rigor_flags))
146  {};
147 
150 
152  underling_fftw_plan get() const { return plan_; }
153 
156  {
158  }
159 
162  {
164  }
165 
167  int local_input(int *start = NULL,
168  int *size = NULL,
169  int *stride = NULL,
170  int *order = NULL) const
171  {
172  return underling_fftw_local_input(plan_, start, size, stride, order);
173  }
174 
176  int local_output(int *start = NULL,
177  int *size = NULL,
178  int *stride = NULL,
179  int *order = NULL) const {
180  return underling_fftw_local_output(plan_, start, size, stride, order);
181  }
182 
184  operator bool () const { return plan_ != NULL; };
185 
188  underling_real *out) const
189  {
190  return underling_fftw_plan_execute(plan_, in, out);
191  }
192 
193 private:
194  underling_fftw_plan plan_;
195 };
196 
197 } // namespace fftw
198 
199 } // namespace underling
200 
210 template< typename charT, typename traits >
211 std::basic_ostream<charT,traits>& operator<<(
212  std::basic_ostream<charT,traits> &os,
213  const underling::fftw::extents &e)
214 {
215  return os << '['
216  << e.start[0] << ',' << (e.start[0] + e.size[0])
217  << ")x["
218  << e.start[1] << ',' << (e.start[1] + e.size[1])
219  << ")x["
220  << e.start[2] << ',' << (e.start[2] + e.size[2])
221  << ")x["
222  << e.start[3] << ',' << (e.start[3] + e.size[3])
223  << ")x["
224  << e.start[4] << ',' << (e.start[4] + e.size[4])
225  << ')';
226 }
227 
229 inline
231  const underling::fftw::extents &e2) {
232  return !underling_fftw_extents_cmp(&e1, &e2);
233 }
234 
235 #endif // UNDERLING_FFTW_HPP
underling::fftw::packed::long_n0
@ long_n0
Definition: underling_fftw.hpp:52
underling_fftw.h
underling_fftw_local_input
int underling_fftw_local_input(const underling_fftw_plan plan, int *start, int *size, int *stride, int *order)
Obtain the processor-local sizes, storage details, and global starting offsets for the given plan's i...
underling::fftw::plan::local_extents_output
underling_fftw_extents local_extents_output() const
Definition: underling_fftw.hpp:161
underling::fftw::packed::none
@ none
Definition: underling_fftw.hpp:58
underling::fftw::extents
underling_fftw_extents extents
Definition: underling_fftw.hpp:41
underling_fftw_local_output
int underling_fftw_local_output(const underling_fftw_plan plan, int *start, int *size, int *stride, int *order)
Obtain the processor-local sizes, storage details, and global starting offsets for the given plan's o...
underling::fftw::plan::execute
int execute(underling_real *in, underling_real *out) const
Definition: underling_fftw.hpp:187
operator==
bool operator==(const underling::fftw::extents &e1, const underling::fftw::extents &e2)
Definition: underling_fftw.hpp:230
underling::fftw::plan::get
underling_fftw_plan get() const
Definition: underling_fftw.hpp:152
underling::fftw::plan::~plan
~plan()
Definition: underling_fftw.hpp:149
underling_fftw_plan_create_inverse
underling_fftw_plan underling_fftw_plan_create_inverse(const underling_fftw_plan plan_to_invert, underling_real *in, underling_real *out, unsigned fftw_rigor_flags)
Create a plan to invert another underling_fftw_plan.
underling::fftw::plan
Provides a thin RAII wrapper for underling_fftw_plan.
Definition: underling_fftw.hpp:68
underling::fftw::plan::r2c_forward
A tag type used to indicate a real-to-complex forward transform.
Definition: underling_fftw.hpp:78
underling.hpp
underling::noncopyable
A mixin for making a subclass non-copyable via private inheritance.
Definition: underling.hpp:89
underling::problem
Provides a thin RAII wrapper for underling_problem.
Definition: underling.hpp:156
UNDERLING_FFTW_PACKED_LONG_N0
#define UNDERLING_FFTW_PACKED_LONG_N0
Flag indicating the FFT transform output and input for the "long in n0" direction is packed contiguou...
Definition: underling_fftw.h:90
underling::fftw::plan::local_output
int local_output(int *start=NULL, int *size=NULL, int *stride=NULL, int *order=NULL) const
Definition: underling_fftw.hpp:176
underling::fftw::plan::local_extents_input
underling_fftw_extents local_extents_input() const
Definition: underling_fftw.hpp:155
underling_fftw_extents::size
int size[5]
The amount of global data stored locally in directions n{0,1,2}.
Definition: underling_fftw.h:307
underling::fftw::plan::plan
plan(const c2r_backward tag, const problem &p, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags=0, unsigned packed_flags=0)
Definition: underling_fftw.hpp:126
underling_fftw_plan_create_c2c_backward
underling_fftw_plan underling_fftw_plan_create_c2c_backward(const underling_problem problem, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags, unsigned packed_flags)
Create a plan to perform a backward complex-to-complex FFT on the given data when long in the long_ni...
underling_fftw_plan_destroy
void underling_fftw_plan_destroy(underling_fftw_plan plan)
Destroy all resources associated with the given plan.
underling::fftw::packed::long_n2
@ long_n2
Definition: underling_fftw.hpp:49
underling
Provides C++ wrappers for underling's C-based API.
Definition: underling.hpp:38
underling_fftw_plan_create_c2r_backward
underling_fftw_plan underling_fftw_plan_create_c2r_backward(const underling_problem problem, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags, unsigned packed_flags)
Create a plan to perform a backward complex-to-real FFT on the given data when long in the long_nith ...
underling::fftw::plan::c2c_forward
A tag type used to indicate a complex-to-complex forward transform.
Definition: underling_fftw.hpp:72
operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &os, const underling::fftw::extents &e)
Outputs an underling_extents or underling::fftw::extents instance as a human-readable string on any s...
Definition: underling_fftw.hpp:211
underling::fftw::plan::plan
plan(const r2c_forward tag, const problem &p, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags=0, unsigned packed_flags=0)
Definition: underling_fftw.hpp:112
underling_fftw_local_extents_input
underling_fftw_extents underling_fftw_local_extents_input(const underling_fftw_plan plan)
Obtain local size, stride, and storage information for the input data to a given plan.
UNDERLING_FFTW_PACKED_NONE
#define UNDERLING_FFTW_PACKED_NONE
Flag indicating the FFT transform output for no direction is necessarily packed contiguously in memor...
Definition: underling_fftw.h:105
underling_fftw_plan_create_r2c_forward
underling_fftw_plan underling_fftw_plan_create_r2c_forward(const underling_problem problem, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags, unsigned packed_flags)
Create a plan to perform a forward real-to-complex FFT on the given data when long in the long_nith d...
underling::fftw::plan::c2r_backward
A tag type used to indicate a complex-to-real backward transform.
Definition: underling_fftw.hpp:81
underling_fftw_plan_create_c2c_forward
underling_fftw_plan underling_fftw_plan_create_c2c_forward(const underling_problem problem, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags, unsigned packed_flags)
Create a plan to perform a forward complex-to-complex FFT on the given data when long in the long_nit...
UNDERLING_FFTW_PACKED_ALL
#define UNDERLING_FFTW_PACKED_ALL
Convenience flag indicating packed transform output whenever possible.
Definition: underling_fftw.h:93
underling_fftw_extents
A transparent type storing the local sizes, strides, and storage when the data is long in a particula...
Definition: underling_fftw.h:291
underling_fftw_extents::start
int start[5]
The inclusive global data starting offset in directions n{0,1,2}.
Definition: underling_fftw.h:297
underling_fftw_extents_cmp
int underling_fftw_extents_cmp(const underling_fftw_extents *const e1, const underling_fftw_extents *const e2)
Compare two underling_fftw_extents instances using lexicographic ordering.
underling::fftw::packed::all
@ all
Definition: underling_fftw.hpp:55
underling_fftw_local_extents_output
underling_fftw_extents underling_fftw_local_extents_output(const underling_fftw_plan plan)
Obtain local size, stride, and storage information for the input data to a given plan.
underling_real
double underling_real
The real-valued scalar type used throughout the library.
Definition: underling.h:63
underling::fftw::plan::c2c_backward
A tag type used to indicate a complex-to-complex backward transform.
Definition: underling_fftw.hpp:75
underling_fftw_plan
struct underling_fftw_plan_s * underling_fftw_plan
A type encapsulating FFTW-like planning information.
Definition: underling_fftw.h:48
UNDERLING_FFTW_PACKED_LONG_N2
#define UNDERLING_FFTW_PACKED_LONG_N2
Flag indicating the FFT transform output and input for the "long in n2" direction is packed contiguou...
Definition: underling_fftw.h:69
underling::fftw::plan::plan
plan(const c2c_forward tag, const problem &p, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags=0, unsigned packed_flags=0)
Definition: underling_fftw.hpp:84
underling::fftw::plan::plan
plan(const c2c_backward tag, const problem &p, int long_ni, underling_real *in, underling_real *out, unsigned fftw_rigor_flags=0, unsigned packed_flags=0)
Definition: underling_fftw.hpp:98
underling::fftw::plan::local_input
int local_input(int *start=NULL, int *size=NULL, int *stride=NULL, int *order=NULL) const
Definition: underling_fftw.hpp:167
underling::fftw::plan::plan
plan(const plan &plan_to_invert, underling_real *in, underling_real *out, unsigned fftw_rigor_flags=0)
Definition: underling_fftw.hpp:140
underling_fftw_plan_execute
int underling_fftw_plan_execute(const underling_fftw_plan plan, underling_real *in, underling_real *out)
Perform a previously planned FFT.

Generated on Wed Jul 1 2026 13:22:57 for underling by  doxygen 1.8.17