Update mdrun message to reflect that Cuda CC>=3.5 is supported.
[alexxy/gromacs.git] / src / gromacs / hardware / hw_info.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
5  * Copyright (c) 2017,2019,2020,2021, 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 #ifndef GMX_HARDWARE_HWINFO_H
37 #define GMX_HARDWARE_HWINFO_H
38
39 #include <memory>
40 #include <string>
41 #include <vector>
42
43 #include "gromacs/hardware/device_management.h"
44 #include "gromacs/utility/basedefinitions.h"
45
46 namespace gmx
47 {
48 class CpuInfo;
49 class HardwareTopology;
50 } // namespace gmx
51 struct DeviceInformation;
52
53 /* Hardware information structure with CPU and GPU information.
54  * It is initialized by gmx_detect_hardware().
55  * NOTE: this structure may only contain structures that are
56  *       valid over the whole process (i.e. must be able to
57  *       be shared among all threads) */
58 struct gmx_hw_info_t
59 {
60     gmx_hw_info_t(std::unique_ptr<gmx::CpuInfo>          cpuInfo,
61                   std::unique_ptr<gmx::HardwareTopology> hardwareTopology);
62     ~gmx_hw_info_t();
63
64     /* Data for our local physical node */
65
66     /*! \brief Number of hardware threads available.
67      *
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;
71
72
73     std::unique_ptr<gmx::CpuInfo>          cpuInfo; /* Information about CPU capabilities */
74     std::unique_ptr<gmx::HardwareTopology> hardwareTopology; /* Information about hardware topology */
75     std::vector<std::unique_ptr<DeviceInformation>> deviceInfoList; /* Information about GPUs detected on this physical node */
76
77
78     /* Data reduced through MPI over all physical nodes */
79     int nphysicalnode;       /* Number of physical nodes */
80     int ncore_tot;           /* Sum of #cores over all nodes, can be 0 */
81     int ncore_min;           /* Min #cores over all nodes */
82     int ncore_max;           /* Max #cores over all nodes */
83     int nhwthread_tot;       /* Sum of #hwthreads over all nodes */
84     int nhwthread_min;       /* Min #hwthreads over all nodes */
85     int nhwthread_max;       /* Max #hwthreads over all nodes */
86     int ngpu_compatible_tot; /* Sum of #GPUs over all nodes */
87     int ngpu_compatible_min; /* Min #GPUs over all nodes */
88     int ngpu_compatible_max; /* Max #GPUs over all nodes */
89
90     int simd_suggest_min; /* Highest SIMD instruction set supported by all ranks */
91     int simd_suggest_max; /* Highest SIMD instruction set supported by at least one rank */
92
93     gmx_bool bIdenticalGPUs; /* TRUE if all ranks have the same type(s) and order of GPUs */
94     bool     haveAmdZen1Cpu; /* TRUE when at least one CPU in any of the nodes is AMD Zen of the first generation */
95
96     //! Container of warning strings to log later when that is possible.
97     std::vector<std::string> hardwareDetectionWarnings_;
98 };
99
100
101 /* The options for the thread affinity setting, default: auto */
102 enum class ThreadAffinity
103 {
104     Select,
105     Auto,
106     On,
107     Off,
108     Count
109 };
110
111 /*! \internal \brief Threading and GPU options, can be set automatically or by the user
112  *
113  * \todo During mdrunner(), if the user has left any of these values
114  * at their defaults (which tends to mean "choose automatically"),
115  * then those values are over-written with the result of such
116  * automation. This creates problems for the subsequent code in
117  * knowing what was done, why, and reporting correctly to the
118  * user. Find a way to improve this.
119  */
120 struct gmx_hw_opt_t
121 {
122     //! Total number of threads requested (thread-MPI + OpenMP).
123     int nthreads_tot = 0;
124     //! Number of thread-MPI threads requested.
125     int nthreads_tmpi = 0;
126     //! Number of OpenMP threads requested.
127     int nthreads_omp = 0;
128     //! Number of OpenMP threads to use on PME_only ranks.
129     int nthreads_omp_pme = 0;
130     //! Thread affinity switch, see enum above.
131     ThreadAffinity threadAffinity = ThreadAffinity::Select;
132     //! Logical core pinning stride.
133     int core_pinning_stride = 0;
134     //! Logical core pinning offset.
135     int core_pinning_offset = 0;
136     //! Empty, or a string provided by the user declaring (unique) GPU IDs available for mdrun to use.
137     std::string devicesSelectedByUser;
138     //! Empty, or a string provided by the user mapping GPU tasks to devices.
139     std::string userGpuTaskAssignment;
140     //! Tells whether mdrun is free to choose the total number of threads (by choosing the number of OpenMP and/or thread-MPI threads).
141     bool totNumThreadsIsAuto;
142 };
143
144 #endif