2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2016,2017,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.
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.
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.
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.
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.
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.
35 #ifndef GMX_HARDWARE_HWINFO_H
36 #define GMX_HARDWARE_HWINFO_H
42 #include "gromacs/hardware/gpu_hw_info.h"
43 #include "gromacs/utility/basedefinitions.h"
48 class HardwareTopology;
51 /* Hardware information structure with CPU and GPU information.
52 * It is initialized by gmx_detect_hardware().
53 * NOTE: this structure may only contain structures that are
54 * valid over the whole process (i.e. must be able to
55 * be shared among all threads) */
58 gmx_hw_info_t(std::unique_ptr<gmx::CpuInfo> cpuInfo,
59 std::unique_ptr<gmx::HardwareTopology> hardwareTopology);
62 /* Data for our local physical node */
63 //! Information about GPUs detected on this physical node
64 gmx_gpu_info_t gpu_info;
66 /*! \brief Number of hardware threads available.
68 * This number is based on the number of CPUs reported as
69 * available by the OS at the time of detection. */
70 int nthreads_hw_avail;
73 std::unique_ptr<gmx::CpuInfo> cpuInfo; /* Information about CPU capabilities */
74 std::unique_ptr<gmx::HardwareTopology> hardwareTopology; /* Information about hardware topology */
77 /* Data reduced through MPI over all physical nodes */
78 int nphysicalnode; /* Number of physical nodes */
79 int ncore_tot; /* Sum of #cores over all nodes, can be 0 */
80 int ncore_min; /* Min #cores over all nodes */
81 int ncore_max; /* Max #cores over all nodes */
82 int nhwthread_tot; /* Sum of #hwthreads over all nodes */
83 int nhwthread_min; /* Min #hwthreads over all nodes */
84 int nhwthread_max; /* Max #hwthreads over all nodes */
85 int ngpu_compatible_tot; /* Sum of #GPUs over all nodes */
86 int ngpu_compatible_min; /* Min #GPUs over all nodes */
87 int ngpu_compatible_max; /* Max #GPUs over all nodes */
89 int simd_suggest_min; /* Highest SIMD instruction set supported by all ranks */
90 int simd_suggest_max; /* Highest SIMD instruction set supported by at least one rank */
92 gmx_bool bIdenticalGPUs; /* TRUE if all ranks have the same type(s) and order of GPUs */
93 bool haveAmdZen1Cpu; /* TRUE when at least one CPU in any of the nodes is AMD Zen of the first generation */
97 /* The options for the thread affinity setting, default: auto */
98 enum class ThreadAffinity
107 /*! \internal \brief Threading and GPU options, can be set automatically or by the user
109 * \todo During mdrunner(), if the user has left any of these values
110 * at their defaults (which tends to mean "choose automatically"),
111 * then those values are over-written with the result of such
112 * automation. This creates problems for the subsequent code in
113 * knowing what was done, why, and reporting correctly to the
114 * user. Find a way to improve this.
118 //! Total number of threads requested (thread-MPI + OpenMP).
119 int nthreads_tot = 0;
120 //! Number of thread-MPI threads requested.
121 int nthreads_tmpi = 0;
122 //! Number of OpenMP threads requested.
123 int nthreads_omp = 0;
124 //! Number of OpenMP threads to use on PME_only ranks.
125 int nthreads_omp_pme = 0;
126 //! Thread affinity switch, see enum above.
127 ThreadAffinity threadAffinity = ThreadAffinity::Select;
128 //! Logical core pinning stride.
129 int core_pinning_stride = 0;
130 //! Logical core pinning offset.
131 int core_pinning_offset = 0;
132 //! Empty, or a string provided by the user declaring (unique) GPU IDs available for mdrun to use.
133 std::string gpuIdsAvailable = "";
134 //! Empty, or a string provided by the user mapping GPU tasks to devices.
135 std::string userGpuTaskAssignment = "";
136 //! Tells whether mdrun is free to choose the total number of threads (by choosing the number of OpenMP and/or thread-MPI threads).
137 bool totNumThreadsIsAuto;