Update copyright statements and change license to LGPL
[alexxy/gromacs.git] / include / gmx_parallel_3dfft.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2005
5  * David van der Spoel, Erik Lindahl, University of Groningen.
6  * Copyright (c) 2012, by the GROMACS development team, led by
7  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
8  * others, as listed in the AUTHORS file in the top-level source
9  * directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37
38 #ifndef _gmx_parallel_3dfft_h_
39 #define _gmx_parallel_3dfft_h_
40
41
42 #include "types/simple.h"
43 #include "types/commrec.h"
44 #include "gmxcomplex.h"
45 #include "gmx_fft.h"
46
47 typedef struct gmx_parallel_3dfft *
48 gmx_parallel_3dfft_t;
49
50
51
52 /*! \brief Initialize parallel MPI-based 3D-FFT.
53  *
54  *  This routine performs real-to-complex and complex-to-real parallel 3D FFTs,
55  *  but not complex-to-complex.
56  *
57  *  The routine is optimized for small-to-medium size FFTs used for PME and
58  *  PPPM algorithms, and do allocate extra workspace whenever it might improve
59  *  performance. 
60  *
61  *  \param pfft_setup     Pointer to parallel 3dfft setup structure, previously
62  *                        allocated or with automatic storage.
63  *  \param ngridx         Global number of grid cells in the x direction. Must be
64  *                        divisible by the number of nodes.
65  *  \param ngridy         Global number of grid cells in the y direction. Must be
66  *                        divisible by the number of nodes.
67  *  \param ngridz         Global number of grid cells in the z direction.
68  *  \param node2slab      Node id to slab index array, can be NULL.
69  *  \param slab2grid_x    Slab index to grid_x array (nnodes+1), can be NULL.
70  *  \param comm           MPI communicator, must have been initialized. 
71  *  \param bReproducible  Try to avoid FFT timing optimizations and other stuff
72  *                        that could make results differ for two runs with
73  *                        identical input (reproducibility for debugging).
74  *  \param nthreads       Run in parallel using n threads
75  *    
76  *  \return 0 or a standard error code.
77  */
78 int
79 gmx_parallel_3dfft_init   (gmx_parallel_3dfft_t *    pfft_setup,
80                            ivec                      ndata,
81                            real **                   real_data,
82                            t_complex **              complex_data,
83                            MPI_Comm                  comm[2],
84                            int *                     slab2index_major,
85                            int *                     slab2index_minor,
86                            gmx_bool                  bReproducible,
87                            int                       nthreads);
88
89
90
91
92
93 /*! \brief Get direct space grid index limits
94  */
95 int
96 gmx_parallel_3dfft_real_limits(gmx_parallel_3dfft_t      pfft_setup,
97                                ivec                      local_ndata,
98                                ivec                      local_offset,
99                                ivec                      local_size);
100
101
102 /*! \brief Get reciprocal space grid index limits
103  */
104 int
105 gmx_parallel_3dfft_complex_limits(gmx_parallel_3dfft_t      pfft_setup,
106                                   ivec                      complex_order,
107                                   ivec                      local_ndata,
108                                   ivec                      local_offset,
109                                   ivec                      local_size);
110
111
112 int
113 gmx_parallel_3dfft_execute(gmx_parallel_3dfft_t    pfft_setup,
114                            enum gmx_fft_direction  dir,
115                            void *                  in_data,
116                            void *                  out_data,
117                            int                     thread,
118                            gmx_wallcycle_t         wcycle);
119
120
121 /*! \brief Release all data in parallel fft setup
122  *
123  *  All temporary storage and FFT plans are released. The structure itself
124  *  is not released, but the contents is invalid after this call.
125  *
126  *  \param pfft_setup Parallel 3dfft setup.
127  *  \param in_data    Input data.
128  *  \param out_data   Output data.
129  *  \param thread     Thread index of the calling thread, i.e. index to the part
130  *                    of the data operated on last by the calling thread. This
131  *                    is needed to start the FFT without an OpenMP barrier.
132  *  \param wcycle     Wall cycle counters.
133  *
134  *  \return 0 or a standard error code.
135  */
136 int
137 gmx_parallel_3dfft_destroy(gmx_parallel_3dfft_t    pfft_setup);
138
139
140
141
142 #endif /* _gmx_parallel_3dfft_h_ */
143