Merge branch 'release-4-6' into master
[alexxy/gromacs.git] / src / programs / mdrun / pme_loadbal.h
1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
2  *
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  *          GROningen MAchine for Chemical Simulations
9  *
10  *                        VERSION 4.6.0
11  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13  * Copyright (c) 2001-2011, The GROMACS development team,
14  * check out http://www.gromacs.org for more information.
15
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * If you want to redistribute modifications, please consider that
22  * scientific software is very special. Version control is crucial -
23  * bugs must be traceable. We will be happy to consider code for
24  * inclusion in the official distribution, but derived work must not
25  * be called official GROMACS. Details are found in the README & COPYING
26  * files - if they are missing, get the official version at www.gromacs.org.
27  *
28  * To help us fund GROMACS development, we humbly ask that you cite
29  * the papers on the package - you can find them in the top README file.
30  *
31  * For more info, check our website at http://www.gromacs.org
32  *
33  * And Hey:
34  * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
35  */
36
37 #ifndef _pme_loadbal_h
38 #define _pme_loadbal_h
39
40 typedef struct pme_load_balancing *pme_load_balancing_t;
41
42 /* Initialze the PP-PME load balacing data and infrastructure */
43 void pme_loadbal_init(pme_load_balancing_t *pme_lb_p,
44                       const t_inputrec *ir, matrix box,
45                       const interaction_const_t *ic,
46                       gmx_pme_t pmedata);
47
48 /* Try to adjust the PME grid and Coulomb cut-off.
49  * The adjustment is done to generate a different non-bonded PP and PME load.
50  * With separate PME nodes (PP and PME on different processes) or with
51  * a GPU (PP on GPU, PME on CPU), PP and PME run on different resources
52  * and changing the load will affect the load balance and performance.
53  * The total time for a set of integration steps is monitored and a range
54  * of grid/cut-off setups is scanned. After calling pme_load_balance many
55  * times and acquiring enough statistics, the best performing setup is chosen.
56  * Here we try to take into account fluctuations and changes due to external
57  * factors as well as DD load balancing.
58  * Returns TRUE the load balancing continues, FALSE is the balancing is done.
59  */
60 gmx_bool pme_load_balance(pme_load_balancing_t pme_lb,
61                           t_commrec           *cr,
62                           FILE                *fp_err,
63                           FILE                *fp_log,
64                           t_inputrec          *ir,
65                           t_state             *state,
66                           double               cycles,
67                           interaction_const_t *ic,
68                           nonbonded_verlet_t  *nbv,
69                           gmx_pme_t           *pmedata,
70                           gmx_large_int_t      step);
71
72 /* Restart the PME load balancing discarding all timings gathered up till now */
73 void restart_pme_loadbal(pme_load_balancing_t pme_lb, int n);
74
75 /* Finish the PME load balancing and print the settings when fplog!=NULL */
76 void pme_loadbal_done(pme_load_balancing_t pme_lb,
77                       t_commrec *cr, FILE *fplog,
78                       gmx_bool bNonBondedOnGPU);
79
80 #endif /* _pme_loadbal_h */