clang-tidy: readability-non-const-parameter (2/2)
[alexxy/gromacs.git] / src / gromacs / fft / parallel_3dfft.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2005 David van der Spoel, Erik Lindahl, University of Groningen.
5  * Copyright (c) 2013,2014,2017,2018, by the GROMACS development team, led by
6  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7  * and including many others, as listed in the AUTHORS file in the
8  * top-level source directory and at http://www.gromacs.org.
9  *
10  * GROMACS is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * GROMACS 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 GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with GROMACS; if not, see
22  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
24  *
25  * If you want to redistribute modifications to GROMACS, please
26  * consider that scientific software is very special. Version
27  * control is crucial - bugs must be traceable. We will be happy to
28  * consider code for inclusion in the official distribution, but
29  * derived work must not be called official GROMACS. Details are found
30  * in the README & COPYING files - if they are missing, get the
31  * official version at http://www.gromacs.org.
32  *
33  * To help us fund GROMACS development, we humbly ask that you cite
34  * the research papers on the package. Check out http://www.gromacs.org.
35  */
36
37 #ifndef GMX_FFT_PARALLEL_3DFFT_H
38 #define GMX_FFT_PARALLEL_3DFFT_H
39
40 #include "gromacs/fft/fft.h"
41 #include "gromacs/gpu_utils/hostallocator.h"
42 #include "gromacs/math/gmxcomplex.h"
43 #include "gromacs/timing/wallcycle.h"
44 #include "gromacs/utility/basedefinitions.h"
45 #include "gromacs/utility/gmxmpi.h"
46 #include "gromacs/utility/real.h"
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 typedef struct gmx_parallel_3dfft *
53     gmx_parallel_3dfft_t;
54
55
56
57 /*! \brief Initialize parallel MPI-based 3D-FFT.
58  *
59  *  This routine performs real-to-complex and complex-to-real parallel 3D FFTs,
60  *  but not complex-to-complex.
61  *
62  *  The routine is optimized for small-to-medium size FFTs used for PME and
63  *  PPPM algorithms, and do allocate extra workspace whenever it might improve
64  *  performance.
65  *
66  *  \param pfft_setup     Pointer to parallel 3dfft setup structure, previously
67  *                        allocated or with automatic storage.
68  *  \param ndata          Number of grid cells in each direction
69  *  \param real_data      Real data. Input for forward and output for backward.
70  *  \param complex_data   Complex data.
71  *  \param comm           MPI communicator for both parallelization axis.
72  *                        Needs to be either initialized or MPI_NULL for
73  *                        no parallelization in that axis.
74  *  \param bReproducible  Try to avoid FFT timing optimizations and other stuff
75  *                        that could make results differ for two runs with
76  *                        identical input (reproducibility for debugging).
77  *  \param nthreads       Run in parallel using n threads
78  *  \param realGridAllocation  Whether to make real grid use allocation pinned for GPU transfers.
79  *                             Only used in PME mixed CPU+GPU mode.
80  *
81  *  \return 0 or a standard error code.
82  */
83 int
84     gmx_parallel_3dfft_init   (gmx_parallel_3dfft_t *    pfft_setup,
85                                const ivec                      ndata,
86                                real **real_data,
87                                t_complex **complex_data,
88                                MPI_Comm                  comm[2],
89                                gmx_bool                  bReproducible,
90                                int                       nthreads,
91                                gmx::PinningPolicy realGridAllocation = gmx::PinningPolicy::CannotBePinned);
92
93
94
95
96
97 /*! \brief Get direct space grid index limits
98  */
99 int
100 gmx_parallel_3dfft_real_limits(gmx_parallel_3dfft_t      pfft_setup,
101                                ivec                      local_ndata,
102                                ivec                      local_offset,
103                                ivec                      local_size);
104
105
106 /*! \brief Get reciprocal space grid index limits
107  */
108 int
109 gmx_parallel_3dfft_complex_limits(gmx_parallel_3dfft_t      pfft_setup,
110                                   ivec                      complex_order,
111                                   ivec                      local_ndata,
112                                   ivec                      local_offset,
113                                   ivec                      local_size);
114
115
116 int
117 gmx_parallel_3dfft_execute(gmx_parallel_3dfft_t    pfft_setup,
118                            enum gmx_fft_direction  dir,
119                            int                     thread,
120                            gmx_wallcycle_t         wcycle);
121
122
123 /*! \brief Release all data in parallel fft setup
124  *
125  *  All temporary storage and FFT plans are released. The structure itself
126  *  is not released, but the contents is invalid after this call.
127  *
128  *  \param pfft_setup Parallel 3dfft setup.
129  *
130  *  \return 0 or a standard error code.
131  */
132 int
133 gmx_parallel_3dfft_destroy(gmx_parallel_3dfft_t    pfft_setup);
134
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif