(git:e70887f)
Loading...
Searching...
No Matches
fft_lib.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* CP2K: A general program to perform molecular dynamics simulations */
3/* Copyright 2000-2026 CP2K developers group <https://cp2k.org> */
4/* */
5/* SPDX-License-Identifier: BSD-3-Clause */
6/*----------------------------------------------------------------------------*/
7#ifndef FFT_LIB_H
8#define FFT_LIB_H
9
10#include "../mpiwrap/cp_mpi.h"
11#include "fft_lib_fftw.h"
12
13#include <complex.h>
14#include <stdbool.h>
15
17
18/*******************************************************************************
19 * \brief Initialize the FFT library (if not done externally).
20 * \author Frederick Stein
21 ******************************************************************************/
22int fft_init_lib(const fft_lib lib, const int fftw_planning_flag,
23 const bool use_guru_interface, const char *wisdom_file);
24
25/*******************************************************************************
26 * \brief Finalize the FFT library (if not done externally).
27 * \author Frederick Stein
28 ******************************************************************************/
29void fft_finalize_lib(const char *wisdom_file);
30
31/*******************************************************************************
32 * \brief Get the default library (GPU if offloading was enabled, else FFTW3).
33 * \author Frederick Stein
34 ******************************************************************************/
36
37/*******************************************************************************
38 * \brief Inquire the library backend in use.
39 * \author Frederick Stein
40 ******************************************************************************/
42
43/*******************************************************************************
44 * \brief Whether compound MPI implementations are available.
45 * \author Frederick Stein
46 ******************************************************************************/
48
49/*******************************************************************************
50 * \brief Allocate buffer of type double.
51 * \author Frederick Stein
52 ******************************************************************************/
53void fft_allocate_double(const int length, double **buffer);
54
55/*******************************************************************************
56 * \brief Allocate buffer of type double complex.
57 * \author Frederick Stein
58 ******************************************************************************/
59void fft_allocate_complex(const int length, double complex **buffer);
60
61/*******************************************************************************
62 * \brief Allocate buffer of type double.
63 * \author Frederick Stein
64 ******************************************************************************/
65void fft_free_double(double *buffer);
66
67/*******************************************************************************
68 * \brief Allocate buffer of type double complex.
69 * \author Frederick Stein
70 ******************************************************************************/
71void fft_free_complex(double complex *buffer);
72
73/*******************************************************************************
74 * \brief Register a local 1D C2C FFT.
75 * \author Frederick Stein
76 ******************************************************************************/
77void fft_register_1d_local(const bool dir, const int fft_size,
78 const int number_of_ffts, const bool transpose_rs,
79 const bool transpose_gs,
80 const int leading_dimension_rs,
81 const int leading_dimension_gs,
82 double complex *grid_in, double complex *grid_out);
83
84/*******************************************************************************
85 * \brief Register a local 1D R2C FFT.
86 * \author Frederick Stein
87 ******************************************************************************/
88void fft_register_1d_r2c_local(const int fft_size, const int number_of_ffts,
89 const bool transpose_rs, const bool transpose_gs,
90 const int leading_dimension_rs,
91 const int leading_dimension_gs, double *grid_in,
92 double complex *grid_out);
93
94/*******************************************************************************
95 * \brief Register a local 1D C2R FFT.
96 * \author Frederick Stein
97 ******************************************************************************/
98void fft_register_1d_c2r_local(const int fft_size, const int number_of_ffts,
99 const bool transpose_rs, const bool transpose_gs,
100 const int leading_dimension_rs,
101 const int leading_dimension_gs,
102 double complex *grid_in, double *grid_out);
103
104/*******************************************************************************
105 * \brief Register a local 2D FFT.
106 * \author Frederick Stein
107 ******************************************************************************/
108void fft_register_2d_local(const bool dir, const int fft_size[2],
109 const int number_of_ffts, const bool transpose_rs,
110 const bool transpose_gs, double complex *grid_in,
111 double complex *grid_out);
112
113/*******************************************************************************
114 * \brief Register a local 2D R2C FFT.
115 * \author Frederick Stein
116 ******************************************************************************/
117void fft_register_2d_r2c_local(const int fft_size[2], const int number_of_ffts,
118 const bool transpose_rs, const bool transpose_gs,
119 double *grid_in, double complex *grid_out);
120
121/*******************************************************************************
122 * \brief Register a local 2D C2R FFT.
123 * \author Frederick Stein
124 ******************************************************************************/
125void fft_register_2d_c2r_local(const int fft_size[2], const int number_of_ffts,
126 const bool transpose_rs, const bool transpose_gs,
127 double complex *grid_in, double *grid_out);
128
129/*******************************************************************************
130 * \brief Register a local 3D FFT.
131 * \author Frederick Stein
132 ******************************************************************************/
133void fft_register_3d_local(const bool dir, const int fft_size[3],
134 const int number_of_ffts, const bool transpose_in,
135 const bool transpose_out, double complex *grid_in,
136 double complex *grid_out);
137
138/*******************************************************************************
139 * \brief Register a local 3D R2C FFT.
140 * \author Frederick Stein
141 ******************************************************************************/
142void fft_register_3d_r2c_local(const int fft_size[3], const int number_of_ffts,
143 const bool transpose_in,
144 const bool transpose_out, double *grid_in,
145 double complex *grid_out);
146
147/*******************************************************************************
148 * \brief Register a local 3D C2R FFT.
149 * \author Frederick Stein
150 ******************************************************************************/
151void fft_register_3d_c2r_local(const int fft_size[3], const int number_of_ffts,
152 const bool transpose_in,
153 const bool transpose_out,
154 double complex *grid_in, double *grid_out);
155
156/*******************************************************************************
157 * \brief Perform a local 1D FFT.
158 * \author Frederick Stein
159 ******************************************************************************/
160void fft_1d_local(const bool dir, const int fft_size, const int number_of_ffts,
161 const bool transpose_rs, const bool transpose_gs,
162 const int leading_dimension_rs,
163 const int leading_dimension_gs, double complex *grid_in,
164 double complex *grid_out);
165
166/*******************************************************************************
167 * \brief Perform a local 1D R2C FFT.
168 * \author Frederick Stein
169 ******************************************************************************/
170void fft_1d_r2c_local(const int fft_size, const int number_of_ffts,
171 const bool transpose_rs, const bool transpose_gs,
172 const int leading_dimension_rs,
173 const int leading_dimension_gs, double *grid_in,
174 double complex *grid_out);
175
176/*******************************************************************************
177 * \brief Perform a local 1D C2R FFT.
178 * \author Frederick Stein
179 ******************************************************************************/
180void fft_1d_c2r_local(const int fft_size, const int number_of_ffts,
181 const bool transpose_rs, const bool transpose_gs,
182 const int leading_dimension_rs,
183 const int leading_dimension_gs, double complex *grid_in,
184 double *grid_out);
185
186/*******************************************************************************
187 * \brief Perform a local 2D FFT.
188 * \author Frederick Stein
189 ******************************************************************************/
190void fft_2d_local(const bool dir, const int fft_size[2],
191 const int number_of_ffts, const bool transpose_rs,
192 const bool transpose_gs, double complex *grid_in,
193 double complex *grid_out);
194
195/*******************************************************************************
196 * \brief Perform a local 2D R2C FFT.
197 * \author Frederick Stein
198 ******************************************************************************/
199void fft_2d_r2c_local(const int fft_size[2], const int number_of_ffts,
200 const bool transpose_rs, const bool transpose_gs,
201 double *grid_in, double complex *grid_out);
202
203/*******************************************************************************
204 * \brief Perform a local 2D C2R FFT.
205 * \author Frederick Stein
206 ******************************************************************************/
207void fft_2d_c2r_local(const int fft_size[2], const int number_of_ffts,
208 const bool transpose_rs, const bool transpose_gs,
209 double complex *grid_in, double *grid_out);
210
211/*******************************************************************************
212 * \brief Perform a local 3D FFT.
213 * \author Frederick Stein
214 ******************************************************************************/
215void fft_3d_local(const bool dir, const int fft_size[3],
216 const int number_of_ffts, const bool transpose_in,
217 const bool transpose_out, double complex *grid_in,
218 double complex *grid_out);
219
220/*******************************************************************************
221 * \brief Perform a local 3D R2C FFT.
222 * \author Frederick Stein
223 ******************************************************************************/
224void fft_3d_r2c_local(const int fft_size[3], const int number_of_ffts,
225 const bool transpose_in, const bool transpose_out,
226 double *grid_in, double complex *grid_out);
227
228/*******************************************************************************
229 * \brief Perform a local 3D C2R FFT.
230 * \author Frederick Stein
231 ******************************************************************************/
232void fft_3d_c2r_local(const int fft_size[3], const int number_of_ffts,
233 const bool transpose_in, const bool transpose_out,
234 double complex *grid_in, double *grid_out);
235
236#endif /* FFT_LIB_H */
237
238// EOF
int fft_lib_default_library()
Get the default library (GPU if offloading was enabled, else FFTW3).
Definition fft_lib.c:144
void fft_register_1d_r2c_local(const int fft_size, const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, const int leading_dimension_rs, const int leading_dimension_gs, double *grid_in, double complex *grid_out)
Register a local 1D R2C FFT.
Definition fft_lib.c:266
void fft_register_2d_r2c_local(const int fft_size[2], const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, double *grid_in, double complex *grid_out)
Register a local 2D R2C FFT.
Definition fft_lib.c:361
void fft_3d_r2c_local(const int fft_size[3], const int number_of_ffts, const bool transpose_in, const bool transpose_out, double *grid_in, double complex *grid_out)
Perform a local 3D R2C FFT.
Definition fft_lib.c:712
void fft_register_2d_local(const bool dir, const int fft_size[2], const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, double complex *grid_in, double complex *grid_out)
Register a local 2D FFT.
Definition fft_lib.c:333
void fft_2d_local(const bool dir, const int fft_size[2], const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, double complex *grid_in, double complex *grid_out)
Perform a local 2D FFT.
Definition fft_lib.c:603
fft_lib
Definition fft_lib.h:16
@ FFT_LIB_FFTW
Definition fft_lib.h:16
@ FFT_LIB_GPU
Definition fft_lib.h:16
@ FFT_LIB_DEFAULT
Definition fft_lib.h:16
void fft_1d_r2c_local(const int fft_size, const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, const int leading_dimension_rs, const int leading_dimension_gs, double *grid_in, double complex *grid_out)
Perform a local 1D R2C FFT.
Definition fft_lib.c:538
void fft_2d_r2c_local(const int fft_size[2], const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, double *grid_in, double complex *grid_out)
Perform a local 2D R2C FFT.
Definition fft_lib.c:630
void fft_finalize_lib(const char *wisdom_file)
Finalize the FFT library (if not done externally).
Definition fft_lib.c:134
void fft_free_complex(double complex *buffer)
Allocate buffer of type double complex.
Definition fft_lib.c:210
void fft_1d_c2r_local(const int fft_size, const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, const int leading_dimension_rs, const int leading_dimension_gs, double complex *grid_in, double *grid_out)
Perform a local 1D C2R FFT.
Definition fft_lib.c:571
bool fft_lib_has_guru_interface()
Whether compound MPI implementations are available.
Definition fft_lib.c:156
int fft_init_lib(const fft_lib lib, const int fftw_planning_flag, const bool use_guru_interface, const char *wisdom_file)
Initialize the FFT library (if not done externally).
Definition fft_lib.c:84
int fft_lib_backend_in_use()
Inquire the library backend in use.
Definition fft_lib.c:150
void fft_1d_local(const bool dir, const int fft_size, const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, const int leading_dimension_rs, const int leading_dimension_gs, double complex *grid_in, double complex *grid_out)
Perform a local 1D FFT.
Definition fft_lib.c:506
void fft_free_double(double *buffer)
Allocate buffer of type double.
Definition fft_lib.c:195
void fft_3d_c2r_local(const int fft_size[3], const int number_of_ffts, const bool transpose_in, const bool transpose_out, double complex *grid_in, double *grid_out)
Perform a local 3D C2R FFT.
Definition fft_lib.c:739
void fft_register_1d_local(const bool dir, const int fft_size, const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, const int leading_dimension_rs, const int leading_dimension_gs, double complex *grid_in, double complex *grid_out)
Register a local 1D C2C FFT.
Definition fft_lib.c:233
void fft_allocate_double(const int length, double **buffer)
Allocate buffer of type double.
Definition fft_lib.c:174
void fft_register_2d_c2r_local(const int fft_size[2], const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, double complex *grid_in, double *grid_out)
Register a local 2D C2R FFT.
Definition fft_lib.c:389
void fft_register_3d_local(const bool dir, const int fft_size[3], const int number_of_ffts, const bool transpose_in, const bool transpose_out, double complex *grid_in, double complex *grid_out)
Register a local 3D FFT.
Definition fft_lib.c:420
void fft_3d_local(const bool dir, const int fft_size[3], const int number_of_ffts, const bool transpose_in, const bool transpose_out, double complex *grid_in, double complex *grid_out)
Perform a local 3D FFT.
Definition fft_lib.c:685
void fft_2d_c2r_local(const int fft_size[2], const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, double complex *grid_in, double *grid_out)
Perform a local 2D C2R FFT.
Definition fft_lib.c:657
void fft_register_3d_c2r_local(const int fft_size[3], const int number_of_ffts, const bool transpose_in, const bool transpose_out, double complex *grid_in, double *grid_out)
Register a local 3D C2R FFT.
Definition fft_lib.c:475
void fft_register_3d_r2c_local(const int fft_size[3], const int number_of_ffts, const bool transpose_in, const bool transpose_out, double *grid_in, double complex *grid_out)
Register a local 3D R2C FFT.
Definition fft_lib.c:447
void fft_allocate_complex(const int length, double complex **buffer)
Allocate buffer of type double complex.
Definition fft_lib.c:185
void fft_register_1d_c2r_local(const int fft_size, const int number_of_ffts, const bool transpose_rs, const bool transpose_gs, const int leading_dimension_rs, const int leading_dimension_gs, double complex *grid_in, double *grid_out)
Register a local 1D C2R FFT.
Definition fft_lib.c:300