bcefcac5ba39d7a4106fa1f7e96aa2848a5d43cb
[alexxy/gromacs.git] / src / gromacs / timing / gpu_timing.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2014,2015,2016,2017 by the GROMACS development team.
5  * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
6  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7  * and including many others, as listed in the AUTHORS file in the
8  * top-level source directory and at http://www.gromacs.org.
9  *
10  * GROMACS is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * GROMACS is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with GROMACS; if not, see
22  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
24  *
25  * If you want to redistribute modifications to GROMACS, please
26  * consider that scientific software is very special. Version
27  * control is crucial - bugs must be traceable. We will be happy to
28  * consider code for inclusion in the official distribution, but
29  * derived work must not be called official GROMACS. Details are found
30  * in the README & COPYING files - if they are missing, get the
31  * official version at http://www.gromacs.org.
32  *
33  * To help us fund GROMACS development, we humbly ask that you cite
34  * the research papers on the package. Check out http://www.gromacs.org.
35  */
36 /*! \libinternal \file
37  *  \brief Declares data types for GPU timing
38  *
39  *  \author Szilard Pall <pall.szilard@gmail.com>
40  *  \author Mark Abraham <mark.j.abraham@gmail.com>
41  *  \inlibraryapi
42  */
43
44 #ifndef GMX_TIMING_GPU_TIMING_H
45 #define GMX_TIMING_GPU_TIMING_H
46
47 /*! \internal \brief GPU kernel time and call count. */
48 struct gmx_kernel_timing_data_t
49 {
50     double t; /**< Accumulated lapsed time */
51     int    c; /**< Number of calls corresponding to the elapsed time */
52 };
53
54 /*! \internal \brief
55  * PME GPU stages timing events indices, corresponding to the string in PMEStageNames in wallcycle.cpp.
56  */
57 enum
58 {
59     gtPME_SPLINE = 0,
60     gtPME_SPREAD,
61     gtPME_SPLINEANDSPREAD,
62     gtPME_FFT_R2C,
63     gtPME_SOLVE,
64     gtPME_FFT_C2R,
65     gtPME_GATHER,
66     gtPME_EVENT_COUNT /* not a stage ID but a static array size */
67 };
68
69 /*! \internal \brief GPU timings for PME. */
70 struct gmx_wallclock_gpu_pme_t
71 {
72     /* A separate PME structure to avoid refactoring the NB code for gmx_wallclock_gpu_t later
73      * TODO: devise a better GPU timing data structuring.
74      */
75     /*! \brief Array of PME GPU timing data. */
76     gmx_kernel_timing_data_t timing[gtPME_EVENT_COUNT];
77 };
78
79 /*! \internal \brief GPU NB timings for kernels and H2d/D2H transfers. */
80 struct gmx_wallclock_gpu_nbnxn_t
81 {
82     gmx_kernel_timing_data_t ktime[2][2]; /**< table containing the timings of the four
83                                                    versions of the nonbonded kernels: force-only,
84                                                    force+energy, force+pruning, and force+energy+pruning */
85     gmx_kernel_timing_data_t pruneTime; /**< table containing the timings of the 1st pass prune-only kernels */
86     gmx_kernel_timing_data_t dynamicPruneTime; /**< table containing the timings of dynamic prune-only kernels */
87     double                   nb_h2d_t; /**< host to device transfer time in nb calculation  */
88     double                   nb_d2h_t; /**< device to host transfer time in nb calculation */
89     int                      nb_c;     /**< total call count of the nonbonded gpu operations */
90     double                   pl_h2d_t; /**< pair search step host to device transfer time */
91     int                      pl_h2d_c; /**< pair search step  host to device transfer call count */
92 };
93
94 #endif