Implement OpenCL support
[alexxy/gromacs.git] / src / gromacs / mdlib / nbnxn_gpu_data_mgmt.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2014,2015, 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 Mark Abraham <mark.j.abraham@gmail.com>
39  *  \ingroup module_mdlib
40  *  \inlibraryapi
41  */
42
43 #ifndef NBNXN_GPU_DATA_MGMT_H
44 #define NBNXN_GPU_DATA_MGMT_H
45
46 #include "gromacs/gmxlib/gpu_utils/gpu_macros.h"
47 #include "gromacs/legacyheaders/types/hw_info.h"
48 #include "gromacs/legacyheaders/types/interaction_const.h"
49 #include "gromacs/legacyheaders/types/simple.h"
50 #include "gromacs/mdlib/nbnxn_gpu_types.h"
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 struct nonbonded_verlet_group_t;
57 struct nbnxn_pairlist_t;
58 struct nbnxn_atomdata_t;
59 struct gmx_wallclock_gpu_t;
60 struct gmx_gpu_info_t;
61
62 /** Initializes the data structures related to GPU nonbonded calculations. */
63 GPU_FUNC_QUALIFIER
64 void nbnxn_gpu_init(FILE gmx_unused                        *fplog,
65                     gmx_nbnxn_gpu_t gmx_unused            **p_nb,
66                     const struct gmx_gpu_info_t gmx_unused *gpu_info,
67                     const gmx_gpu_opt_t gmx_unused         *gpu_opt,
68                     const interaction_const_t gmx_unused   *ic,
69                     nonbonded_verlet_group_t gmx_unused    *nbv_grp,
70                     int gmx_unused                          my_gpu_index,
71                     int gmx_unused                          rank,
72                     /* true if both local and non-local are done on GPU */
73                     gmx_bool gmx_unused                     bLocalAndNonlocal) GPU_FUNC_TERM
74
75 /** Initializes pair-list data for GPU, called at every pair search step. */
76 GPU_FUNC_QUALIFIER
77 void nbnxn_gpu_init_pairlist(gmx_nbnxn_gpu_t gmx_unused               *nb,
78                              const struct nbnxn_pairlist_t gmx_unused *h_nblist,
79                              int                    gmx_unused         iloc) GPU_FUNC_TERM
80
81 /** Initializes atom-data on the GPU, called at every pair search step. */
82 GPU_FUNC_QUALIFIER
83 void nbnxn_gpu_init_atomdata(gmx_nbnxn_gpu_t gmx_unused               *nb,
84                              const struct nbnxn_atomdata_t gmx_unused *nbat) GPU_FUNC_TERM
85
86 /*! \brief Re-generate the GPU Ewald force table, resets rlist, and update the
87  *  electrostatic type switching to twin cut-off (or back) if needed.
88  */
89 GPU_FUNC_QUALIFIER
90 void nbnxn_gpu_pme_loadbal_update_param(const struct nonbonded_verlet_t gmx_unused *nbv,
91                                         const interaction_const_t gmx_unused       *ic) GPU_FUNC_TERM
92
93 /** Uploads shift vector to the GPU if the box is dynamic (otherwise just returns). */
94 GPU_FUNC_QUALIFIER
95 void nbnxn_gpu_upload_shiftvec(gmx_nbnxn_gpu_t gmx_unused               *nb,
96                                const struct nbnxn_atomdata_t gmx_unused *nbatom) GPU_FUNC_TERM
97
98 /** Clears GPU outputs: nonbonded force, shift force and energy. */
99 GPU_FUNC_QUALIFIER
100 void nbnxn_gpu_clear_outputs(gmx_nbnxn_gpu_t gmx_unused *nb,
101                              int              gmx_unused flags) GPU_FUNC_TERM
102
103 /** Frees all GPU resources used for the nonbonded calculations. */
104 GPU_FUNC_QUALIFIER
105 void nbnxn_gpu_free(gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM
106
107 /** Returns the GPU timings structure or NULL if GPU is not used or timing is off. */
108 GPU_FUNC_QUALIFIER
109 struct gmx_wallclock_gpu_t * nbnxn_gpu_get_timings(gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM_WITH_RETURN(NULL)
110
111 /** Resets nonbonded GPU timings. */
112 GPU_FUNC_QUALIFIER
113 void nbnxn_gpu_reset_timings(struct nonbonded_verlet_t gmx_unused *nbv) GPU_FUNC_TERM
114
115 /** Calculates the minimum size of proximity lists to improve SM load balance
116  *  with GPU non-bonded kernels. */
117 GPU_FUNC_QUALIFIER
118 int nbnxn_gpu_min_ci_balanced(gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM_WITH_RETURN(-1)
119
120 /** Returns if analytical Ewald GPU kernels are used. */
121 GPU_FUNC_QUALIFIER
122 gmx_bool nbnxn_gpu_is_kernel_ewald_analytical(const gmx_nbnxn_gpu_t gmx_unused *nb) GPU_FUNC_TERM_WITH_RETURN(FALSE)
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif