Restructure the load balancing timing
[gromacs.git] / src / gromacs / mdlib / force.h
blob7874e723ad970fd05b46d3b69a262c88516954ab
1 /*
2 * This file is part of the GROMACS molecular simulation package.
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,2016,2017, 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.
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.
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.
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.
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.
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.
37 #ifndef GMX_MDLIB_FORCE_H
38 #define GMX_MDLIB_FORCE_H
40 #include "gromacs/domdec/dlbtiming.h"
41 #include "gromacs/mdlib/force_flags.h"
42 #include "gromacs/mdlib/vsite.h"
43 #include "gromacs/mdtypes/fcdata.h"
44 #include "gromacs/mdtypes/forcerec.h"
45 #include "gromacs/timing/wallcycle.h"
46 #include "gromacs/utility/arrayref.h"
48 struct gmx_edsam;
49 struct gmx_gpu_info_t;
50 struct gmx_groups_t;
51 struct gmx_vsite_t;
52 class history_t;
53 struct nonbonded_verlet_t;
54 struct t_blocka;
55 struct t_commrec;
56 struct t_fcdata;
57 struct t_graph;
58 struct t_grpopts;
59 struct t_inputrec;
60 struct t_lambda;
61 struct t_mdatoms;
62 struct t_nrnb;
63 struct t_pbc;
65 namespace gmx
67 class MDLogger;
70 void calc_vir(int nxf, rvec x[], rvec f[], tensor vir,
71 gmx_bool bScrewPBC, matrix box);
72 /* Calculate virial for nxf atoms, and add it to vir */
74 void f_calc_vir(int i0, int i1, rvec x[], rvec f[], tensor vir,
75 t_graph *g, rvec shift_vec[]);
76 /* Calculate virial taking periodicity into account */
78 real RF_excl_correction(const t_forcerec *fr, t_graph *g,
79 const t_mdatoms *mdatoms, const t_blocka *excl,
80 rvec x[], rvec f[], rvec *fshift, const t_pbc *pbc,
81 real lambda, real *dvdlambda);
82 /* Calculate the reaction-field energy correction for this node:
83 * epsfac q_i q_j (k_rf r_ij^2 - c_rf)
84 * and force correction for all excluded pairs, including self pairs.
87 void calc_rffac(FILE *fplog, int eel, real eps_r, real eps_rf,
88 real Rc, real Temp,
89 real zsq, matrix box,
90 real *kappa, real *krf, real *crf);
91 /* Determine the reaction-field constants */
93 void init_generalized_rf(FILE *fplog,
94 const gmx_mtop_t *mtop, const t_inputrec *ir,
95 t_forcerec *fr);
96 /* Initialize the generalized reaction field parameters */
99 /* In wall.c */
100 void make_wall_tables(FILE *fplog,
101 const t_inputrec *ir, const char *tabfn,
102 const gmx_groups_t *groups,
103 t_forcerec *fr);
105 real do_walls(t_inputrec *ir, t_forcerec *fr, matrix box, t_mdatoms *md,
106 rvec x[], rvec f[], real lambda, real Vlj[], t_nrnb *nrnb);
108 gmx_bool can_use_allvsall(const t_inputrec *ir,
109 gmx_bool bPrintNote, t_commrec *cr, FILE *fp);
110 /* Returns if we can use all-vs-all loops.
111 * If bPrintNote==TRUE, prints a note, if necessary, to stderr
112 * and fp (if !=NULL) on the master node.
115 gmx_bool nbnxn_simd_supported(const gmx::MDLogger &mdlog,
116 const t_inputrec *ir);
117 /* Return if CPU SIMD support exists for the given inputrec
118 * If the return value is FALSE and fplog/cr != NULL, prints a fallback
119 * message to fplog/stderr.
122 gmx_bool uses_simple_tables(int cutoff_scheme,
123 nonbonded_verlet_t *nbv,
124 int group);
125 /* Returns whether simple tables (i.e. not for use with GPUs) are used
126 * with the type of kernel indicated.
129 void init_enerdata(int ngener, int n_lambda, gmx_enerdata_t *enerd);
130 /* Intializes the energy storage struct */
132 void destroy_enerdata(gmx_enerdata_t *enerd);
133 /* Free all memory associated with enerd */
135 void reset_foreign_enerdata(gmx_enerdata_t *enerd);
136 /* Resets only the foreign energy data */
138 void reset_enerdata(gmx_enerdata_t *enerd);
139 /* Resets the energy data */
141 void sum_epot(gmx_grppairener_t *grpp, real *epot);
142 /* Locally sum the non-bonded potential energy terms */
144 void sum_dhdl(gmx_enerdata_t *enerd, gmx::ConstArrayRef<real> lambda, t_lambda *fepvals);
145 /* Sum the free energy contributions */
147 /* Compute the average C6 and C12 params for LJ corrections */
148 void set_avcsixtwelve(FILE *fplog, t_forcerec *fr,
149 const gmx_mtop_t *mtop);
151 void do_force(FILE *log, t_commrec *cr,
152 t_inputrec *inputrec,
153 gmx_int64_t step, struct t_nrnb *nrnb, gmx_wallcycle_t wcycle,
154 gmx_localtop_t *top,
155 gmx_groups_t *groups,
156 matrix box, PaddedRVecVector *coordinates, history_t *hist,
157 PaddedRVecVector *force,
158 tensor vir_force,
159 t_mdatoms *mdatoms,
160 gmx_enerdata_t *enerd, t_fcdata *fcd,
161 gmx::ArrayRef<real> lambda, t_graph *graph,
162 t_forcerec *fr,
163 gmx_vsite_t *vsite, rvec mu_tot,
164 double t, struct gmx_edsam *ed,
165 gmx_bool bBornRadii,
166 int flags,
167 DdOpenBalanceRegionBeforeForceComputation ddOpenBalanceRegion,
168 DdCloseBalanceRegionAfterForceComputation ddCloseBalanceRegion);
170 /* Communicate coordinates (if parallel).
171 * Do neighbor searching (if necessary).
172 * Calculate forces.
173 * Communicate forces (if parallel).
174 * Spread forces for vsites (if present).
176 * f is always required.
179 void ns(FILE *fplog,
180 t_forcerec *fr,
181 matrix box,
182 gmx_groups_t *groups,
183 gmx_localtop_t *top,
184 t_mdatoms *md,
185 t_commrec *cr,
186 t_nrnb *nrnb,
187 gmx_bool bFillGrid);
188 /* Call the neighborsearcher */
190 void do_force_lowlevel(t_forcerec *fr,
191 t_inputrec *ir,
192 t_idef *idef,
193 t_commrec *cr,
194 t_nrnb *nrnb,
195 gmx_wallcycle_t wcycle,
196 t_mdatoms *md,
197 rvec x[],
198 history_t *hist,
199 rvec f_shortrange[],
200 gmx_enerdata_t *enerd,
201 t_fcdata *fcd,
202 gmx_localtop_t *top,
203 gmx_genborn_t *born,
204 gmx_bool bBornRadii,
205 matrix box,
206 t_lambda *fepvals,
207 real *lambda,
208 t_graph *graph,
209 t_blocka *excl,
210 rvec mu_tot[2],
211 int flags,
212 float *cycles_pme);
213 /* Call all the force routines */
215 void free_gpu_resources(const t_forcerec *fr,
216 const t_commrec *cr,
217 const gmx_gpu_info_t *gpu_info,
218 const gmx_gpu_opt_t *gpu_opt);
220 #endif