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-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.
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.
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.
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.
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.
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.
38 #ifndef GMX_TIMING_WALLCYCLE_H
39 #define GMX_TIMING_WALLCYCLE_H
41 /* NOTE: None of the routines here are safe to call within an OpenMP
46 #include "gromacs/utility/basedefinitions.h"
48 typedef struct gmx_wallcycle* gmx_wallcycle_t;
50 static constexpr gmx_wallcycle* nullWallcycle = nullptr;
77 ewcWAIT_GPU_PME_SPREAD,
78 ewcPME_FFT_MIXED_MODE,
79 ewcPME_SOLVE_MIXED_MODE,
80 ewcWAIT_GPU_PME_GATHER,
82 ewcPME_GPU_F_REDUCTION,
85 ewcWAIT_GPU_STATE_PROPAGATOR_DATA,
112 ewcsNBS_GRID_NONLOCAL,
113 ewcsNBS_SEARCH_LOCAL,
114 ewcsNBS_SEARCH_NONLOCAL,
119 ewcsNONBONDED_PRUNING,
120 ewcsNONBONDED_KERNEL,
123 ewcsLAUNCH_GPU_NONBONDED,
124 ewcsLAUNCH_GPU_BONDED,
126 ewcsLAUNCH_STATE_PROPAGATOR_DATA,
127 ewcsEWALD_CORRECTION,
130 ewcsCLEAR_FORCE_BUFFER,
131 ewcsLAUNCH_GPU_NB_X_BUF_OPS,
132 ewcsLAUNCH_GPU_NB_F_BUF_OPS,
133 ewcsLAUNCH_GPU_MOVEX,
134 ewcsLAUNCH_GPU_MOVEF,
135 ewcsLAUNCH_GPU_UPDATE_CONSTRAIN,
140 gmx_bool wallcycle_have_counter();
141 /* Returns if cycle counting is supported */
143 gmx_wallcycle_t wallcycle_init(FILE* fplog, int resetstep, struct t_commrec* cr);
144 /* Returns the wall cycle structure.
145 * Returns NULL when cycle counting is not supported.
148 /* cleans up wallcycle structure */
149 void wallcycle_destroy(gmx_wallcycle_t wc);
151 void wallcycle_start(gmx_wallcycle_t wc, int ewc);
152 /* Starts the cycle counter (and increases the call count) */
154 void wallcycle_start_nocount(gmx_wallcycle_t wc, int ewc);
155 /* Starts the cycle counter without increasing the call count */
157 double wallcycle_stop(gmx_wallcycle_t wc, int ewc);
158 /* Stop the cycle count for ewc, returns the last cycle count */
160 void wallcycle_increment_event_count(gmx_wallcycle_t wc, int ewc);
161 /* Only increment call count for ewc by one */
163 void wallcycle_get(gmx_wallcycle_t wc, int ewc, int* n, double* c);
164 /* Returns the cumulative count and cycle count for ewc */
166 void wallcycle_reset_all(gmx_wallcycle_t wc);
167 /* Resets all cycle counters to zero */
169 void wallcycle_scale_by_num_threads(gmx_wallcycle_t wc, bool isPmeRank, int nthreads_pp, int nthreads_pme);
170 /* Scale the cycle counts to reflect how many threads run for that number of cycles */
172 int64_t wcycle_get_reset_counters(gmx_wallcycle_t wc);
173 /* Return reset_counters from wc struct */
175 void wcycle_set_reset_counters(gmx_wallcycle_t wc, int64_t reset_counters);
176 /* Set reset_counters */
178 void wallcycle_sub_start(gmx_wallcycle_t wc, int ewcs);
179 /* Set the start sub cycle count for ewcs */
181 void wallcycle_sub_start_nocount(gmx_wallcycle_t wc, int ewcs);
182 /* Set the start sub cycle count for ewcs without increasing the call count */
184 void wallcycle_sub_stop(gmx_wallcycle_t wc, int ewcs);
185 /* Stop the sub cycle count for ewcs */