Hardware reporting now covers all nodes
[alexxy/gromacs.git] / src / gromacs / legacyheaders / types / hw_info.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2015, 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 #ifndef HWINFO_H
37 #define HWINFO_H
38
39 #include "gromacs/legacyheaders/gmx_cpuid.h"
40 #include "gromacs/legacyheaders/types/simple.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 #if 0
46 } /* fixes auto-indentation problems */
47 #endif
48
49 struct gmx_device_info_t;
50
51 /* Possible results of the GPU detection/check.
52  *
53  * The egpuInsane value means that during the sanity checks an error
54  * occurred that indicates malfunctioning of the device, driver, or
55  * incompatible driver/runtime. */
56 typedef enum
57 {
58     egpuCompatible = 0,  egpuNonexistent,  egpuIncompatible, egpuInsane
59 } e_gpu_detect_res_t;
60
61 /* Textual names of the GPU detection/check results (see e_gpu_detect_res_t). */
62 static const char * const gpu_detect_res_str[] =
63 {
64     "compatible", "inexistent", "incompatible", "insane"
65 };
66
67 /* GPU device information -- for now with only CUDA devices
68  * The gmx_hardware_detect module initializes it. */
69 struct gmx_gpu_info_t
70 {
71     gmx_bool                  bDetectGPUs;      /* Did we try to detect GPUs? */
72     int                       n_dev;            /* total number of GPU devices detected */
73     struct gmx_device_info_t *gpu_dev;          /* GPU devices detected in the system (per node) */
74     int                       n_dev_compatible; /* number of compatible GPUs */
75 };
76
77 /* Hardware information structure with CPU and GPU information.
78  * It is initialized by gmx_detect_hardware().
79  * NOTE: this structure may only contain structures that are globally valid
80  *       (i.e. must be able to be shared among all threads) */
81 typedef struct
82 {
83     /* Data for our local physical node */
84     struct gmx_gpu_info_t gpu_info;          /* Information about GPUs detected in the system */
85
86     gmx_cpuid_t           cpuid_info;        /* CPUID information about CPU detected;
87                                                 NOTE: this will only detect the CPU thread 0 of the
88                                                 current process runs on. */
89     int                   ncore;             /* Number of cores, will be 0 when not detected */
90     int                   nthreads_hw_avail; /* Number of hardware threads available; this number
91                                                 is based on the number of CPUs reported as available
92                                                 by the OS at the time of detection. */
93
94     /* Data reduced through MPI over all physical nodes */
95     int                 nphysicalnode;       /* Number of physical nodes */
96     int                 ncore_tot;           /* Sum of #cores over all nodes, can be 0 */
97     int                 ncore_min;           /* Min #cores over all nodes */
98     int                 ncore_max;           /* Max #cores over all nodes */
99     int                 nhwthread_tot;       /* Sum of #hwthreads over all nodes */
100     int                 nhwthread_min;       /* Min #hwthreads over all nodes */
101     int                 nhwthread_max;       /* Max #hwthreads over all nodes */
102     int                 ngpu_compatible_tot; /* Sum of #GPUs over all nodes */
103     int                 ngpu_compatible_min; /* Min #GPUs over all nodes */
104     int                 ngpu_compatible_max; /* Max #GPUs over all nodes */
105
106     /* The values below are only used for printing, so here it's not an issue
107      * that stricly speaking SIMD instruction sets can't be uniquely ordered.
108      */
109     enum gmx_cpuid_simd simd_suggest_min;    /* Highest SIMD instruction set supported by all ranks */
110     enum gmx_cpuid_simd simd_suggest_max;    /* Highest SIMD instruction set supported by at least one rank */
111
112     gmx_bool            bIdenticalGPUs;      /* TRUE if all ranks have the same type(s) and order of GPUs */
113 } gmx_hw_info_t;
114
115
116 /* The options for the thread affinity setting, default: auto */
117 enum {
118     threadaffSEL, threadaffAUTO, threadaffON, threadaffOFF, threadaffNR
119 };
120
121 /* GPU device selection information -- for now with only CUDA devices */
122 typedef struct
123 {
124     char     *gpu_id;           /* GPU id's to use, each specified as chars */
125     gmx_bool  bUserSet;         /* true if the GPUs in dev_use are manually provided by the user */
126
127     int       n_dev_compatible; /* number of compatible GPU devices that could be used */
128     int      *dev_compatible;   /* array of compatible GPU device IDs, from which automatic selection occurs */
129     int       n_dev_use;        /* number of GPU devices selected to be used, either by the user or automatically */
130     int      *dev_use;          /* array mapping from PP rank index to GPU device ID; GPU IDs can be listed multiple times when ranks share them */
131 } gmx_gpu_opt_t;
132
133 /* Threading and GPU options, can be set automatically or by the user */
134 typedef struct {
135     int           nthreads_tot;        /* Total number of threads requested (TMPI) */
136     int           nthreads_tmpi;       /* Number of TMPI threads requested         */
137     int           nthreads_omp;        /* Number of OpenMP threads requested       */
138     int           nthreads_omp_pme;    /* As nthreads_omp, but for PME only nodes  */
139     int           thread_affinity;     /* Thread affinity switch, see enum above   */
140     int           core_pinning_stride; /* Logical core pinning stride              */
141     int           core_pinning_offset; /* Logical core pinning offset              */
142
143     gmx_gpu_opt_t gpu_opt;             /* The GPU options                          */
144 } gmx_hw_opt_t;
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif /* HWINFO_H */