1530a2e93fcd95fcbb7332ca5cd6bbcd63db78fc
[alexxy/gromacs.git] / src / gromacs / legacyheaders / nbnxn_cuda_data_mgmt.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2012, The GROMACS development team.
6  * Copyright (c) 2012,2013, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source 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 NBNXN_CUDA_DATA_MGMT_H
39 #define NBNXN_CUDA_DATA_MGMT_H
40
41 #include "types/simple.h"
42 #include "types/interaction_const.h"
43 #include "types/nbnxn_cuda_types_ext.h"
44 #include "types/hw_info.h"
45
46 #ifdef GMX_GPU
47 #define FUNC_TERM ;
48 #define FUNC_QUALIFIER
49 #else
50 #define FUNC_TERM {}
51 #define FUNC_QUALIFIER static
52 #endif
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 /*! Initializes the data structures related to CUDA nonbonded calculations. */
59 FUNC_QUALIFIER
60 void nbnxn_cuda_init(FILE gmx_unused                 *fplog,
61                      nbnxn_cuda_ptr_t gmx_unused     *p_cu_nb,
62                      const gmx_gpu_info_t gmx_unused *gpu_info,
63                      const gmx_gpu_opt_t gmx_unused  *gpu_opt,
64                      int gmx_unused                   my_gpu_index,
65                      /* true of both local and non-local are don on GPU */
66                      gmx_bool gmx_unused              bLocalAndNonlocal) FUNC_TERM
67
68 /*! Initializes simulation constant data. */
69 FUNC_QUALIFIER
70 void nbnxn_cuda_init_const(nbnxn_cuda_ptr_t               gmx_unused  cu_nb,
71                            const interaction_const_t      gmx_unused *ic,
72                            const nonbonded_verlet_group_t gmx_unused *nbv_group) FUNC_TERM
73
74 /*! Initializes pair-list data for GPU, called at every pair search step. */
75 FUNC_QUALIFIER
76 void nbnxn_cuda_init_pairlist(nbnxn_cuda_ptr_t       gmx_unused  cu_nb,
77                               const nbnxn_pairlist_t gmx_unused *h_nblist,
78                               int                    gmx_unused  iloc) FUNC_TERM
79
80 /*! Initializes atom-data on the GPU, called at every pair search step. */
81 FUNC_QUALIFIER
82 void nbnxn_cuda_init_atomdata(nbnxn_cuda_ptr_t       gmx_unused  cu_nb,
83                               const nbnxn_atomdata_t gmx_unused *atomdata) FUNC_TERM
84
85 /*! \brief Update parameters during PP-PME load balancing. */
86 FUNC_QUALIFIER
87 void nbnxn_cuda_pme_loadbal_update_param(nbnxn_cuda_ptr_t          gmx_unused  cu_nb,
88                                          const interaction_const_t gmx_unused *ic) FUNC_TERM
89
90 /*! Uploads shift vector to the GPU if the box is dynamic (otherwise just returns). */
91 FUNC_QUALIFIER
92 void nbnxn_cuda_upload_shiftvec(nbnxn_cuda_ptr_t       gmx_unused  cu_nb,
93                                 const nbnxn_atomdata_t gmx_unused *nbatom) FUNC_TERM
94
95 /*! Clears GPU outputs: nonbonded force, shift force and energy. */
96 FUNC_QUALIFIER
97 void nbnxn_cuda_clear_outputs(nbnxn_cuda_ptr_t gmx_unused cu_nb,
98                               int              gmx_unused flags) FUNC_TERM
99
100 /*! Frees all GPU resources used for the nonbonded calculations. */
101 FUNC_QUALIFIER
102 void nbnxn_cuda_free(nbnxn_cuda_ptr_t gmx_unused  cu_nb) FUNC_TERM
103
104 /*! Returns the GPU timings structure or NULL if GPU is not used or timing is off. */
105 FUNC_QUALIFIER
106 wallclock_gpu_t * nbnxn_cuda_get_timings(nbnxn_cuda_ptr_t gmx_unused cu_nb)
107 #ifdef GMX_GPU
108 ;
109 #else
110 {
111     return NULL;
112 }
113 #endif
114
115 /*! Resets nonbonded GPU timings. */
116 FUNC_QUALIFIER
117 void nbnxn_cuda_reset_timings(nbnxn_cuda_ptr_t gmx_unused cu_nb) FUNC_TERM
118
119 /*! Calculates the minimum size of proximity lists to improve SM load balance
120     with CUDA non-bonded kernels. */
121 FUNC_QUALIFIER
122 int nbnxn_cuda_min_ci_balanced(nbnxn_cuda_ptr_t gmx_unused cu_nb)
123 #ifdef GMX_GPU
124 ;
125 #else
126 {
127     return -1;
128 }
129 #endif
130
131 /*! Returns if analytical Ewald CUDA kernels are used. */
132 FUNC_QUALIFIER
133 gmx_bool nbnxn_cuda_is_kernel_ewald_analytical(const nbnxn_cuda_ptr_t gmx_unused cu_nb)
134 #ifdef GMX_GPU
135 ;
136 #else
137 {
138     return FALSE;
139 }
140 #endif
141
142 #ifdef __cplusplus
143 }
144 #endif
145
146 #undef FUNC_TERM
147 #undef FUNC_QUALIFIER
148
149 #endif /* NBNXN_CUDA_DATA_MGMT_H */