GCC Code Coverage Report


Directory: ./
File: src/support/types.h
Date: 2026-11-30 15:03:27
Exec Total Coverage
Lines: 5 6 83.3%
Functions: 5 6 83.3%
Branches: 0 2 0.0%

Line Branch Exec Source
1 /*********************************************************************************/
2 /* Copyright 2009-2026 Barcelona Supercomputing Center */
3 /* */
4 /* This file is part of the DLB library. */
5 /* */
6 /* DLB is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU Lesser General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* DLB is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU Lesser General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU Lesser General Public License */
17 /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */
18 /*********************************************************************************/
19
20 #ifndef TYPES_H
21 #define TYPES_H
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <inttypes.h>
28 #include <stdbool.h>
29 #include <stdint.h>
30
31 typedef uint16_t cpuid_t;
32 enum { DLB_CPUID_INVALID = UINT16_MAX };
33 #define PRICPUID PRIu16
34
35 typedef enum VerboseOptions {
36 VB_CLEAR = 0,
37 VB_API = 1 << 0,
38 VB_MICROLB = 1 << 1,
39 VB_SHMEM = 1 << 2,
40 VB_MPI_API = 1 << 3,
41 VB_MPI_INT = 1 << 4,
42 VB_STATS = 1 << 5,
43 VB_DROM = 1 << 6,
44 VB_ASYNC = 1 << 7,
45 VB_OMPT = 1 << 8,
46 VB_AFFINITY = 1 << 9,
47 VB_BARRIER = 1 << 10,
48 VB_TALP = 1 << 11,
49 VB_INSTR = 1 << 12,
50 VB_MNGO = 1 << 13,
51 VB_ALL = 0x0FFFF,
52 VB_UNDEF = 0xF0000,
53 } verbose_opts_t;
54
55 typedef enum VerboseFormat {
56 VBF_CLEAR = 0,
57 VBF_NODE = 1 << 0,
58 VBF_MPINODE = 1 << 1,
59 VBF_MPIRANK = 1 << 2,
60 VBF_SPID = 1 << 3,
61 VBF_THREAD = 1 << 4,
62 VBF_TSTAMP = 1 << 5
63 } verbose_fmt_t;
64
65 typedef enum InstrumentItems {
66 INST_NONE = 0,
67 INST_ALL = 0xFFFF,
68 INST_MPI = 1 << 0,
69 INST_LEWI = 1 << 1,
70 INST_DROM = 1 << 2,
71 INST_TALP = 1 << 3,
72 INST_BARR = 1 << 4,
73 INST_OMPT = 1 << 5,
74 INST_CPUS = 1 << 6,
75 INST_CBCK = 1 << 7,
76 INST_MNGO = 1 << 8
77 } instrument_items_t;
78
79 typedef enum DebugOptions {
80 DBG_CLEAR = 0,
81 DBG_WALL = 1 << 0,
82 DBG_WERROR = 1 << 1,
83 DBG_WARNMPI = 1 << 2,
84 DBG_RETURNSTOLEN = 1 << 3,
85 DBG_LPOSTMORTEM = 1 << 4,
86 } debug_opts_t;
87
88 typedef enum LewiAffinity {
89 LEWI_AFFINITY_AUTO,
90 LEWI_AFFINITY_NONE,
91 LEWI_AFFINITY_MASK,
92 LEWI_AFFINITY_NEARBY_FIRST,
93 LEWI_AFFINITY_NEARBY_ONLY,
94 LEWI_AFFINITY_SPREAD_IFEMPTY,
95 } lewi_affinity_t;
96
97 typedef enum TalpSummaryType {
98 SUMMARY_NONE = 0,
99 SUMMARY_ALL = 0xFFF9, // SUMMARY_POP_RAW and SUMMARY_NODE excluded
100 SUMMARY_POP_METRICS = 1 << 0,
101 SUMMARY_POP_RAW = 1 << 1, // DEPRECATED
102 SUMMARY_NODE = 1 << 2, // DEPRECATED
103 SUMMARY_PROCESS = 1 << 3,
104 } talp_summary_t;
105
106 typedef enum TalpModel {
107 TALP_MODEL_HYBRID_V1,
108 TALP_MODEL_HYBRID_V2,
109 } talp_model_t;
110
111 typedef enum TalpComponent {
112 TALP_COMPONENT_NONE = 0,
113 TALP_COMPONENT_DEFAULT = 1 << 0,
114 TALP_COMPONENT_MPI = 1 << 1,
115 TALP_COMPONENT_OPENMP = 1 << 2,
116 TALP_COMPONENT_GPU = 1 << 3,
117 TALP_COMPONENT_HWC = 1 << 4,
118 TALP_COMPONENT_ENERGY = 1 << 5,
119 } talp_component_t;
120
121 typedef enum MngoModeType {
122 MNGO_HELPER_THREAD,
123 MNGO_REGIONS,
124 } mngo_mode_t;
125
126 typedef enum PolicyType {
127 POLICY_NONE,
128 POLICY_LEWI,
129 POLICY_LEWI_ASYNC,
130 POLICY_LEWI_MASK,
131 } policy_t;
132
133 typedef enum InteractionMode {
134 MODE_POLLING,
135 MODE_ASYNC
136 } interaction_mode_t;
137
138 typedef enum MPISet {
139 MPISET_NONE,
140 MPISET_ALL,
141 MPISET_BARRIER,
142 MPISET_COLLECTIVES
143 } mpi_set_t;
144
145 typedef enum OMPTOptions {
146 OMPTOOL_OPTS_NONE = 0,
147 /* OMPTOOL_OPTS_MPI = 1 << 0, DEPRECATED */
148 OMPTOOL_OPTS_BORROW = 1 << 1,
149 OMPTOOL_OPTS_LEND = 1 << 2,
150 /* OMPTOOL_OPTS_AGGRESSIVE = 0xF DEPRECATED */
151 } omptool_opts_t;
152
153 typedef enum OMPTMVersion {
154 OMPTM_NONE,
155 OMPTM_OMP5,
156 OMPTM_FREE_AGENTS,
157 OMPTM_ROLE_SHIFT
158 } omptm_version_t;
159
160 typedef struct sync_call_flags_t {
161 bool is_mpi:1;
162 bool is_blocking:1;
163 bool is_collective:1;
164 bool is_dlb_barrier:1;
165 bool do_lewi:1;
166 } sync_call_flags_t;
167
168 87186 static inline int min_int(int a, int b) { return a < b ? a : b; }
169 235 static inline int max_int(int a, int b) { return a > b ? a : b; }
170 3 static inline int64_t min_int64(int64_t a, int64_t b) { return a < b ? a : b; }
171 62 static inline int64_t max_int64(int64_t a, int64_t b) { return a > b ? a : b; }
172 294 static inline unsigned int min_uint(unsigned int a, unsigned int b) { return a < b ? a : b; }
173 static inline double min_double(double a, double b) { return a < b ? a : b; }
174 ✗ static inline double max_double(double a, double b) { return a > b ? a : b; }
175
176 static inline double min_double_non_zero(double a, double b) {
177 if (a == 0.0 && b == 0.0) {
178 return 0.0;
179 } else if (a == 0.0) {
180 return b;
181 } else if (b == 0.0) {
182 return a;
183 } else {
184 return min_double(a, b);
185 }
186 }
187
188 int parse_bool(const char *str, bool *value);
189 bool equivalent_bool(const char *str1, const char *str2);
190
191 int parse_negated_bool(const char *str, bool *value);
192 bool equivalent_negated_bool(const char *str1, const char *str2);
193
194 int parse_int(const char *str, int *value);
195 bool equivalent_int(const char *str1, const char *str2);
196
197 /* verbose_opts_t */
198 int parse_verbose_opts(const char *str, verbose_opts_t *value);
199 const char* verbose_opts_tostr(verbose_opts_t value);
200 const char* get_verbose_opts_choices(void);
201 bool equivalent_verbose_opts(const char *str1, const char *str2);
202
203 /* verbose_fmt_t */
204 int parse_verbose_fmt(const char *str, verbose_fmt_t *value);
205 const char* verbose_fmt_tostr(verbose_fmt_t value);
206 const char* get_verbose_fmt_choices(void);
207 bool equivalent_verbose_fmt(const char *str1, const char *str2);
208
209 /* instrument_item_t */
210 int parse_instrument_items(const char *str, instrument_items_t *value);
211 const char* instrument_items_tostr(instrument_items_t value);
212 const char* get_instrument_items_choices(void);
213 bool equivalent_instrument_items(const char *str1, const char *str2);
214
215 /* debug_opts_t */
216 int parse_debug_opts(const char *str, debug_opts_t *value);
217 const char* debug_opts_tostr(debug_opts_t value);
218 const char* get_debug_opts_choices(void);
219 bool equivalent_debug_opts(const char *str1, const char *str2);
220
221 /* lewi_affinity_t */
222 int parse_lewi_affinity(const char *str, lewi_affinity_t *value);
223 const char* lewi_affinity_tostr(lewi_affinity_t value);
224 const char* get_lewi_affinity_choices(void);
225 bool equivalent_lewi_affinity(const char *str1, const char *str2);
226
227 /* policy_t */
228 int parse_policy(const char *str, policy_t *value);
229 const char* policy_tostr(policy_t policy);
230 const char* get_policy_choices(void);
231 bool equivalent_policy(const char *str1, const char *str2);
232
233 /* talp_summary_t */
234 int parse_talp_summary(const char *str, talp_summary_t *value);
235 const char* talp_summary_tostr(talp_summary_t summary);
236 const char* get_talp_summary_choices(void);
237 bool equivalent_talp_summary(const char *str1, const char *str2);
238
239 /* talp_model_t */
240 int parse_talp_model(const char *str, talp_model_t *value);
241 const char* talp_model_tostr(talp_model_t value);
242 const char* get_talp_model_choices(void);
243 bool equivalent_talp_model(const char *str1, const char *str2);
244
245 /* talp_component_t */
246 int parse_talp_component(const char *str, talp_component_t *value);
247 const char* talp_component_tostr(talp_component_t value);
248 const char* get_talp_component_choices(void);
249 bool equivalent_talp_component(const char *str1, const char *str2);
250
251 /* mngo_mode_t */
252 int parse_mngo_mode(const char *str, mngo_mode_t *option);
253 const char* mngo_mode_tostr(mngo_mode_t value);
254 const char* get_mngo_mode_choices(void);
255 bool equivalent_mngo_mode(const char *str1, const char *str2);
256
257 /* interaction_mode_t */
258 int parse_mode(const char *str, interaction_mode_t *value);
259 const char* mode_tostr(interaction_mode_t value);
260 const char* get_mode_choices(void);
261 bool equivalent_mode(const char *str1, const char *str2);
262
263 /* mpi_set_t */
264 int parse_mpiset(const char *str, mpi_set_t *value);
265 const char* mpiset_tostr(mpi_set_t value);
266 const char* get_mpiset_choices(void);
267 bool equivalent_mpiset(const char *str1, const char *str2);
268
269 /* omptool_opts_t */
270 int parse_omptool_opts(const char *str, omptool_opts_t *value);
271 const char* omptool_opts_tostr(omptool_opts_t value);
272 const char* get_omptool_opts_choices(void);
273 bool equivalent_omptool_opts(const char *str1, const char *str2);
274
275 /* omptm_version_t */
276 int parse_omptm_version(const char *str, omptm_version_t *value);
277 const char* omptm_version_tostr(omptm_version_t value);
278 const char* get_omptm_version_choices(void);
279 bool equivalent_omptm_version_opts(const char *str1, const char *str2);
280
281 #endif /* TYPES_H */
282