Tests of restrained listed potentials.
[alexxy/gromacs.git] / src / gromacs / nbnxm / gpu_data_mgmt.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2014,2015,2017,2018,2019, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \libinternal \file
36  *  \brief Declare interface for GPU data transfer for NBNXN module
37  *
38  *  \author Szilard Pall <pall.szilard@gmail.com>
39  *  \author Mark Abraham <mark.j.abraham@gmail.com>
40  *  \ingroup module_nbnxm
41  *  \inlibraryapi
42  */
43
44 #ifndef GMX_NBNXN_GPU_DATA_MGMT_H
45 #define GMX_NBNXN_GPU_DATA_MGMT_H
46
47 #include "gromacs/gpu_utils/gpu_macros.h"
48 #include "gromacs/mdtypes/interaction_const.h"
49
50 #include "gpu_types.h"
51
52 struct nonbonded_verlet_group_t;
53 struct NbnxnPairlistGpu;
54 struct nbnxn_atomdata_t;
55 struct NbnxnListParameters;
56 struct gmx_wallclock_gpu_nbnxn_t;
57 struct gmx_gpu_info_t;
58 struct gmx_device_info_t;
59
60 /** Initializes the data structures related to GPU nonbonded calculations. */
61 GPU_FUNC_QUALIFIER
62 void nbnxn_gpu_init(gmx_nbnxn_gpu_t gmx_unused            **p_nb,
63                     const gmx_device_info_t gmx_unused     *deviceInfo,
64                     const interaction_const_t gmx_unused   *ic,
65                     const NbnxnListParameters gmx_unused   *listParams,
66                     const nbnxn_atomdata_t gmx_unused      *nbat,
67                     int gmx_unused                          rank,
68                     /* true if both local and non-local are done on GPU */
69                     gmx_bool gmx_unused                     bLocalAndNonlocal) GPU_FUNC_TERM
70
71 /** Initializes pair-list data for GPU, called at every pair search step. */
72 GPU_FUNC_QUALIFIER
73 void nbnxn_gpu_init_pairlist(gmx_nbnxn_gpu_t gmx_unused               *nb,
74                              const struct NbnxnPairlistGpu gmx_unused *h_nblist,
75                              int                    gmx_unused         iloc) GPU_FUNC_TERM
76
77 /** Initializes atom-data on the GPU, called at every pair search step. */
78 GPU_FUNC_QUALIFIER
79 void nbnxn_gpu_init_atomdata(gmx_nbnxn_gpu_t gmx_unused               *nb,
80                              const nbnxn_atomdata_t gmx_unused        *nbat) GPU_FUNC_TERM
81
82 /*! \brief Re-generate the GPU Ewald force table, resets rlist, and update the
83  *  electrostatic type switching to twin cut-off (or back) if needed.
84  */
85 GPU_FUNC_QUALIFIER
86 void nbnxn_gpu_pme_loadbal_update_param(const struct nonbonded_verlet_t gmx_unused *nbv,
87                                         const interaction_const_t gmx_unused       *ic,
88                                         const NbnxnListParameters gmx_unused       *listParams) GPU_FUNC_TERM
89
90 /** Uploads shift vector to the GPU if the box is dynamic (otherwise just returns). */
91 GPU_FUNC_QUALIFIER
92 void nbnxn_gpu_upload_shiftvec(gmx_nbnxn_gpu_t gmx_unused               *nb,
93                                const nbnxn_atomdata_t gmx_unused        *nbatom) GPU_FUNC_TERM
94
95 /** Clears GPU outputs: nonbonded force, shift force and energy. */
96 GPU_FUNC_QUALIFIER
97 void nbnxn_gpu_clear_outputs(gmx_nbnxn_gpu_t gmx_unused *nb,
98                              int              gmx_unused flags) GPU_FUNC_TERM
99
100 /** Frees all GPU resources used for the nonbonded calculations. */
101 GPU_FUNC_QUALIFIER
102 void nbnxn_gpu_free(gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM
103
104 /** Returns the GPU timings structure or NULL if GPU is not used or timing is off. */
105 GPU_FUNC_QUALIFIER
106 struct gmx_wallclock_gpu_nbnxn_t *nbnxn_gpu_get_timings(gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM_WITH_RETURN(nullptr)
107
108 /** Resets nonbonded GPU timings. */
109 GPU_FUNC_QUALIFIER
110 void nbnxn_gpu_reset_timings(struct nonbonded_verlet_t gmx_unused *nbv) GPU_FUNC_TERM
111
112 /** Calculates the minimum size of proximity lists to improve SM load balance
113  *  with GPU non-bonded kernels. */
114 GPU_FUNC_QUALIFIER
115 int nbnxn_gpu_min_ci_balanced(gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM_WITH_RETURN(-1)
116
117 /** Returns if analytical Ewald GPU kernels are used. */
118 GPU_FUNC_QUALIFIER
119 gmx_bool nbnxn_gpu_is_kernel_ewald_analytical(const gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM_WITH_RETURN(FALSE)
120
121 /** Returns an opaque pointer to the GPU command stream
122  *  Note: CUDA only.
123  */
124 CUDA_FUNC_QUALIFIER
125 void *nbnxn_gpu_get_command_stream(gmx_nbnxn_gpu_t gmx_unused *nb,
126                                    int gmx_unused              iloc) CUDA_FUNC_TERM_WITH_RETURN(nullptr)
127
128 /** Returns an opaque pointer to the GPU coordinate+charge array
129  *  Note: CUDA only.
130  */
131 CUDA_FUNC_QUALIFIER
132 void *nbnxn_gpu_get_xq(gmx_nbnxn_gpu_t gmx_unused *nb) CUDA_FUNC_TERM_WITH_RETURN(nullptr)
133
134 /** Returns an opaque pointer to the GPU force array
135  *  Note: CUDA only.
136  */
137 CUDA_FUNC_QUALIFIER
138 void *nbnxn_gpu_get_f(gmx_nbnxn_gpu_t gmx_unused *nb) CUDA_FUNC_TERM_WITH_RETURN(nullptr)
139
140 /** Returns an opaque pointer to the GPU shift force array
141  *  Note: CUDA only.
142  */
143 CUDA_FUNC_QUALIFIER
144 rvec *nbnxn_gpu_get_fshift(gmx_nbnxn_gpu_t gmx_unused *nb) CUDA_FUNC_TERM_WITH_RETURN(nullptr)
145
146 #endif