Modernize t_nrnb
[alexxy/gromacs.git] / src / gromacs / gmxlib / nrnb.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-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
7  * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
8  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9  * and including many others, as listed in the AUTHORS file in the
10  * top-level source directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38
39 #ifndef GMX_GMXLIB_NRNB_H
40 #define GMX_GMXLIB_NRNB_H
41
42 #include <array>
43 #include <cstdint>
44 #include <cstdio>
45
46 enum
47 {
48     eNR_NBKERNEL_VDW_VF,
49     eNR_NBKERNEL_VDW_F,
50     eNR_NBKERNEL_ELEC_VF,
51     eNR_NBKERNEL_ELEC_F,
52     eNR_NBKERNEL_ELEC_W3_VF,
53     eNR_NBKERNEL_ELEC_W3_F,
54     eNR_NBKERNEL_ELEC_W3W3_VF,
55     eNR_NBKERNEL_ELEC_W3W3_F,
56     eNR_NBKERNEL_ELEC_W4_VF,
57     eNR_NBKERNEL_ELEC_W4_F,
58     eNR_NBKERNEL_ELEC_W4W4_VF,
59     eNR_NBKERNEL_ELEC_W4W4_F,
60     eNR_NBKERNEL_ELEC_VDW_VF,
61     eNR_NBKERNEL_ELEC_VDW_F,
62     eNR_NBKERNEL_ELEC_VDW_W3_VF,
63     eNR_NBKERNEL_ELEC_VDW_W3_F,
64     eNR_NBKERNEL_ELEC_VDW_W3W3_VF,
65     eNR_NBKERNEL_ELEC_VDW_W3W3_F,
66     eNR_NBKERNEL_ELEC_VDW_W4_VF,
67     eNR_NBKERNEL_ELEC_VDW_W4_F,
68     eNR_NBKERNEL_ELEC_VDW_W4W4_VF,
69     eNR_NBKERNEL_ELEC_VDW_W4W4_F,
70
71     eNR_NBKERNEL_NR, /* Total number of interaction-specific kernel entries */
72
73     eNR_NBKERNEL_GENERIC = eNR_NBKERNEL_NR, /* Reuse number; KERNEL_NR is not an entry itself */
74     eNR_NBKERNEL_GENERIC_CG,
75     eNR_NBKERNEL_FREE_ENERGY, /* Add other generic kernels _before_ the free energy one */
76
77     eNR_NBKERNEL_TOTAL_NR,
78
79     eNR_NBNXN_DIST2 = eNR_NBKERNEL_TOTAL_NR, // Reuse the symbolic constant that indicates the last kernel
80     eNR_NBNXN_LJ_RF,
81     eNR_NBNXN_LJ_RF_E,
82     eNR_NBNXN_LJ_TAB,
83     eNR_NBNXN_LJ_TAB_E,
84     eNR_NBNXN_LJ_EWALD,
85     eNR_NBNXN_LJ_EWALD_E,
86     eNR_NBNXN_LJ,
87     eNR_NBNXN_LJ_E,
88     eNR_NBNXN_RF,
89     eNR_NBNXN_RF_E,
90     eNR_NBNXN_TAB,
91     eNR_NBNXN_TAB_E,
92     eNR_NBNXN_EWALD,
93     eNR_NBNXN_EWALD_E,
94     eNR_NBNXN_ADD_LJ_FSW,
95     eNR_NBNXN_ADD_LJ_FSW_E,
96     eNR_NBNXN_ADD_LJ_PSW,
97     eNR_NBNXN_ADD_LJ_PSW_E,
98     eNR_NBNXN_ADD_LJ_EWALD,
99     eNR_NBNXN_ADD_LJ_EWALD_E,
100     eNR_NB14,
101     eNR_WEIGHTS,
102     eNR_SPREAD,
103     eNR_SPREADBSP,
104     eNR_GATHERF,
105     eNR_GATHERFBSP,
106     eNR_FFT,
107     eNR_CONV,
108     eNR_SOLVEPME,
109     eNR_NS,
110     eNR_RESETX,
111     eNR_SHIFTX,
112     eNR_CGCM,
113     eNR_FSUM,
114     eNR_BONDS,
115     eNR_G96BONDS,
116     eNR_FENEBONDS,
117     eNR_TABBONDS,
118     eNR_RESTRBONDS,
119     eNR_LINEAR_ANGLES,
120     eNR_ANGLES,
121     eNR_G96ANGLES,
122     eNR_QANGLES,
123     eNR_TABANGLES,
124     eNR_PROPER,
125     eNR_IMPROPER,
126     eNR_RB,
127     eNR_FOURDIH,
128     eNR_TABDIHS,
129     eNR_DISRES,
130     eNR_ORIRES,
131     eNR_DIHRES,
132     eNR_POSRES,
133     eNR_FBPOSRES,
134     eNR_ANGRES,
135     eNR_ANGRESZ,
136     eNR_MORSE,
137     eNR_CUBICBONDS,
138     eNR_WALLS,
139     eNR_POLARIZE,
140     eNR_ANHARM_POL,
141     eNR_WPOL,
142     eNR_THOLE,
143     eNR_VIRIAL,
144     eNR_UPDATE,
145     eNR_EXTUPDATE,
146     eNR_STOPCM,
147     eNR_PCOUPL,
148     eNR_EKIN,
149     eNR_LINCS,
150     eNR_LINCSMAT,
151     eNR_SHAKE,
152     eNR_CONSTR_V,
153     eNR_SHAKE_RIJ,
154     eNR_CONSTR_VIR,
155     eNR_SETTLE,
156     eNR_VSITE1,
157     eNR_VSITE2,
158     eNR_VSITE2FD,
159     eNR_VSITE3,
160     eNR_VSITE3FD,
161     eNR_VSITE3FAD,
162     eNR_VSITE3OUT,
163     eNR_VSITE4FD,
164     eNR_VSITE4FDN,
165     eNR_VSITEN,
166     eNR_CMAP,
167     eNR_UREY_BRADLEY,
168     eNR_CROSS_BOND_BOND,
169     eNR_CROSS_BOND_ANGLE,
170     eNRNB
171 };
172
173
174 struct t_nrnb
175 {
176     std::array<double, eNRNB> n = { 0 };
177 };
178
179 void clear_nrnb(t_nrnb* nrnb);
180
181 void print_nrnb(FILE* out, t_nrnb* nrnb);
182
183 /*! \brief Increment the nonbonded kernel flop counters
184  *
185  * \param nrnb The nonbonded kernel flop counters.
186  * \param index Which counter to incrememnt.
187  * \param increment How much to increment the counter by.
188  */
189 static inline void inc_nrnb(t_nrnb* nrnb, int index, int increment)
190 {
191     nrnb->n[index] += increment;
192 }
193
194 /*! \brief Atomic increment of nonbonded kernel flop counters
195  *
196  * \param nrnb The nonbonded kernel flop counters.
197  * \param index Which counter to incrememnt.
198  * \param increment How much to increment the counter by.
199  *
200  * Same as inc_nrnb but includes omp atomic pragma
201  */
202 void atomicNrnbIncrement(t_nrnb* nrnb, int index, int increment);
203
204 void print_flop(FILE* out, t_nrnb* nrnb, double* nbfs, double* mflop);
205 /* Calculates the non-bonded forces and flop count.
206  * When out!=NULL also prints the full count table.
207  */
208
209 void print_perf(FILE* out, double nodetime, double realtime, int64_t nsteps, double delta_t, double nbfs, double mflop);
210 /* Prints the performance, nbfs and mflop come from print_flop */
211
212 int cost_nrnb(int enr);
213 /* Cost in i860 cycles of this component of MD */
214
215 const char* nrnb_str(int enr);
216 /* Name of this component */
217
218 #endif /* GMX_GMXLIB_NRNB_H */