Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / nbnxm / benchmark / bench_setup.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2019, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35
36 /*! \libinternal \file
37  * \brief
38  * This file declares functions for setting up kernel benchmarks
39  *
40  * \author Berk Hess <hess@kth.se>
41  *
42  * \inlibraryapi
43  * \ingroup module_nbnxm
44  */
45
46 #ifndef GMX_NBNXN_BENCH_SETUP_H
47 #define GMX_NBNXN_BENCH_SETUP_H
48
49 #include "gromacs/utility/real.h"
50
51 namespace Nbnxm
52 {
53
54 //! Enum for selecting the SIMD kernel type for benchmarks
55 enum class BenchMarkKernels : int
56 {
57     SimdAuto,
58     SimdNo,
59     Simd4XM,
60     Simd2XMM,
61     Count
62 };
63
64 //! Enum for selecting the combination rule for kernel benchmarks
65 enum class BenchMarkCombRule : int
66 {
67     RuleGeom,
68     RuleLB,
69     RuleNone,
70     Count
71 };
72
73 //! Enum for selecting coulomb type for kernel benchmarks
74 enum class BenchMarkCoulomb : int
75 {
76     Pme,
77     ReactionField,
78     Count
79 };
80
81 /*! \internal \brief
82  * The options for the kernel benchmarks
83  */
84 struct KernelBenchOptions
85 {
86     //! Whether to use a GPU, currently GPUs are not supported
87     bool useGpu = false;
88     //! The number of OpenMP threads to use
89     int numThreads = 1;
90     //! The SIMD type for the kernel
91     BenchMarkKernels nbnxmSimd = BenchMarkKernels::SimdAuto;
92     //! The LJ combination rule
93     BenchMarkCombRule ljCombinationRule = BenchMarkCombRule::RuleGeom;
94     //! Use i-cluster half-LJ optimization for clusters with <= half LJ
95     bool useHalfLJOptimization = false;
96     //! The pairlist and interaction cut-off
97     real pairlistCutoff = 1.0;
98     //! The Coulomb Ewald coefficient
99     real ewaldcoeff_q = 0;
100     //! Whether to compute energies (shift forces for virial are always computed on CPU)
101     bool computeVirialAndEnergy = false;
102     //! The Coulomb interaction function
103     BenchMarkCoulomb coulombType = BenchMarkCoulomb::Pme;
104     //! Whether to use tabulated PME grid correction instead of analytical, not applicable with simd=no
105     bool useTabulatedEwaldCorr = false;
106     //! Whether to run all combinations of Coulomb type, combination rule and SIMD
107     bool doAll = false;
108     //! Number of iterations to run before running each kernel benchmark, currently always 1
109     int numPreIterations = 1;
110     //! The number of iterations for each kernel
111     int numIterations = 100;
112     //! The number of (untimed) iterations to run at startup to warm up the CPU
113     int numWarmupIterations = 0;
114     //! Print cycles/pair instead of pairs/cycle
115     bool cyclesPerPair = false;
116 };
117
118 /*! \brief
119  * Sets up and runs one or more Nbnxm kernel benchmarks
120  *
121  * The simulated system is a box of 1000 SPC/E water molecules scaled
122  * by the factor \p sizeFactor, which has to be a power of 2.
123  * One or more benchmarks are run, as specified by \p options.
124  * Benchmark settings and timings are printed to stdout.
125  *
126  * \param[in] sizeFactor How much should the system size be increased.
127  * \param[in] options How the benchmark will be run.
128  */
129 void bench(int sizeFactor, const KernelBenchOptions& options);
130
131 } // namespace Nbnxm
132
133 #endif