Split lines with many copyright years
[alexxy/gromacs.git] / src / gromacs / timing / wallcycle.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-2008, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
7  * Copyright (c) 2019,2020, 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 #ifndef GMX_TIMING_WALLCYCLE_H
39 #define GMX_TIMING_WALLCYCLE_H
40
41 /* NOTE: None of the routines here are safe to call within an OpenMP
42  * region */
43
44 #include <stdio.h>
45
46 #include "gromacs/utility/basedefinitions.h"
47
48 typedef struct gmx_wallcycle* gmx_wallcycle_t;
49 struct t_commrec;
50 static constexpr gmx_wallcycle* nullWallcycle = nullptr;
51
52 enum
53 {
54     ewcRUN,
55     ewcSTEP,
56     ewcPPDURINGPME,
57     ewcDOMDEC,
58     ewcDDCOMMLOAD,
59     ewcDDCOMMBOUND,
60     ewcVSITECONSTR,
61     ewcPP_PMESENDX,
62     ewcNS,
63     ewcLAUNCH_GPU,
64     ewcMOVEX,
65     ewcFORCE,
66     ewcMOVEF,
67     ewcPMEMESH,
68     ewcPME_REDISTXF,
69     ewcPME_SPREAD,
70     ewcPME_GATHER,
71     ewcPME_FFT,
72     ewcPME_FFTCOMM,
73     ewcLJPME,
74     ewcPME_SOLVE,
75     ewcPMEWAITCOMM,
76     ewcPP_PMEWAITRECVF,
77     ewcWAIT_GPU_PME_SPREAD,
78     ewcPME_FFT_MIXED_MODE,
79     ewcPME_SOLVE_MIXED_MODE,
80     ewcWAIT_GPU_PME_GATHER,
81     ewcWAIT_GPU_BONDED,
82     ewcPME_GPU_F_REDUCTION,
83     ewcWAIT_GPU_NB_NL,
84     ewcWAIT_GPU_NB_L,
85     ewcWAIT_GPU_STATE_PROPAGATOR_DATA,
86     ewcNB_XF_BUF_OPS,
87     ewcVSITESPREAD,
88     ewcPULLPOT,
89     ewcAWH,
90     ewcTRAJ,
91     ewcUPDATE,
92     ewcCONSTR,
93     ewcMoveE,
94     ewcROT,
95     ewcROTadd,
96     ewcSWAP,
97     ewcIMD,
98     ewcTEST,
99     ewcNR
100 };
101
102 enum
103 {
104     ewcsDD_REDIST,
105     ewcsDD_GRID,
106     ewcsDD_SETUPCOMM,
107     ewcsDD_MAKETOP,
108     ewcsDD_MAKECONSTR,
109     ewcsDD_TOPOTHER,
110     ewcsNBS_GRID_LOCAL,
111     ewcsNBS_GRID_NONLOCAL,
112     ewcsNBS_SEARCH_LOCAL,
113     ewcsNBS_SEARCH_NONLOCAL,
114     ewcsLISTED,
115     ewcsLISTED_FEP,
116     ewcsRESTRAINTS,
117     ewcsLISTED_BUF_OPS,
118     ewcsNONBONDED_PRUNING,
119     ewcsNONBONDED_KERNEL,
120     ewcsNONBONDED_CLEAR,
121     ewcsNONBONDED_FEP,
122     ewcsLAUNCH_GPU_NONBONDED,
123     ewcsLAUNCH_GPU_BONDED,
124     ewcsLAUNCH_GPU_PME,
125     ewcsLAUNCH_STATE_PROPAGATOR_DATA,
126     ewcsEWALD_CORRECTION,
127     ewcsNB_X_BUF_OPS,
128     ewcsNB_F_BUF_OPS,
129     ewcsCLEAR_FORCE_BUFFER,
130     ewcsTEST,
131     ewcsNR
132 };
133
134 gmx_bool wallcycle_have_counter();
135 /* Returns if cycle counting is supported */
136
137 gmx_wallcycle_t wallcycle_init(FILE* fplog, int resetstep, struct t_commrec* cr);
138 /* Returns the wall cycle structure.
139  * Returns NULL when cycle counting is not supported.
140  */
141
142 /* cleans up wallcycle structure */
143 void wallcycle_destroy(gmx_wallcycle_t wc);
144
145 void wallcycle_start(gmx_wallcycle_t wc, int ewc);
146 /* Starts the cycle counter (and increases the call count) */
147
148 void wallcycle_start_nocount(gmx_wallcycle_t wc, int ewc);
149 /* Starts the cycle counter without increasing the call count */
150
151 double wallcycle_stop(gmx_wallcycle_t wc, int ewc);
152 /* Stop the cycle count for ewc, returns the last cycle count */
153
154 void wallcycle_increment_event_count(gmx_wallcycle_t wc, int ewc);
155 /* Only increment call count for ewc by one */
156
157 void wallcycle_get(gmx_wallcycle_t wc, int ewc, int* n, double* c);
158 /* Returns the cumulative count and cycle count for ewc */
159
160 void wallcycle_reset_all(gmx_wallcycle_t wc);
161 /* Resets all cycle counters to zero */
162
163 void wallcycle_scale_by_num_threads(gmx_wallcycle_t wc, bool isPmeRank, int nthreads_pp, int nthreads_pme);
164 /* Scale the cycle counts to reflect how many threads run for that number of cycles */
165
166 int64_t wcycle_get_reset_counters(gmx_wallcycle_t wc);
167 /* Return reset_counters from wc struct */
168
169 void wcycle_set_reset_counters(gmx_wallcycle_t wc, int64_t reset_counters);
170 /* Set reset_counters */
171
172 void wallcycle_sub_start(gmx_wallcycle_t wc, int ewcs);
173 /* Set the start sub cycle count for ewcs */
174
175 void wallcycle_sub_start_nocount(gmx_wallcycle_t wc, int ewcs);
176 /* Set the start sub cycle count for ewcs without increasing the call count */
177
178 void wallcycle_sub_stop(gmx_wallcycle_t wc, int ewcs);
179 /* Stop the sub cycle count for ewcs */
180
181 #endif