GCC Code Coverage Report


Directory: src/
File: src/support/options.c
Date: 2026-11-25 09:48:53
Exec Total Coverage
Lines: 418 509 82.1%
Functions: 14 14 100.0%
Branches: 221 294 75.2%

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 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include "support/options.h"
25
26 #include "apis/dlb_types.h"
27 #include "apis/dlb_errors.h"
28 #include "support/types.h"
29 #include "support/mask_utils.h"
30 #include "support/debug.h"
31 #include "LB_core/spd.h"
32
33 #include <stdio.h>
34 #include <string.h>
35 #include <stddef.h>
36 #include <ctype.h>
37 #include <stdint.h>
38 #include <limits.h>
39
40 typedef enum OptionFlags {
41 OPT_CLEAR = 0,
42 OPT_READONLY = 1 << 0,
43 OPT_OPTIONAL = 1 << 1,
44 OPT_DEPRECATED = 1 << 2,
45 OPT_ADVANCED = 1 << 3,
46 OPT_HIDDEN = 1 << 4,
47 OPT_UNUSED = 1 << 5,
48 } option_flags_t;
49
50 typedef enum OptionTypes {
51 OPT_BOOL_T,
52 OPT_NEG_BOOL_T,
53 OPT_INT_T,
54 OPT_STR_T,
55 OPT_PTR_PATH_T, // pointer to char[PATH_MAX]
56 OPT_VB_T, // verbose_opts_t
57 OPT_VBFMT_T, // verbose_fmt_t
58 OPT_INST_T, // instrument_items_t
59 OPT_DBG_T, // debug_opts_t
60 OPT_LEWI_AFF_T, // lewi_affinity_t
61 OPT_MASK_T, // cpu_set_t
62 OPT_MODE_T, // interaction_mode_t
63 OPT_MPISET_T, // mpi_set_t
64 OPT_OMPTOPTS_T, // omptool_opts_t
65 OPT_TLPSUM_T, // talp_summary_t
66 OPT_TLPMOD_T, // talp_model_t
67 OPT_TLPCOM_T, // talp_component_t
68 OPT_MNGO_MODE_T,// mngo_mode_t
69 OPT_OMPTM_T // omptm_version_t
70 } option_type_t;
71
72 typedef struct {
73 char var_name[MAX_OPTION_LENGTH]; // LB_OPTION
74 char arg_name[MAX_OPTION_LENGTH]; // --option
75 char default_value[MAX_OPTION_LENGTH];
76 char description[MAX_DESCRIPTION];
77 size_t offset;
78 option_type_t type;
79 option_flags_t flags;
80 } opts_dict_t;
81
82 /* Description is displaced 4 spaces */
83 #define OFFSET " "
84 static const opts_dict_t options_dictionary[] = {
85 // general options
86 {
87 .var_name = "LB_LEWI",
88 .arg_name = "--lewi",
89 .default_value = "no",
90 .description = OFFSET"Enable Lend When Idle. Processes using this mode can use LeWI\n"
91 OFFSET"API to lend and borrow resources.",
92 .offset = offsetof(options_t, lewi),
93 .type = OPT_BOOL_T,
94 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
95 }, {
96 .var_name = "LB_DROM",
97 .arg_name = "--drom",
98 .default_value = "no",
99 .description = OFFSET"Enable the Dynamic Resource Ownership Manager Module. Processes\n"
100 OFFSET"using this mode can receive requests from other processes to\n"
101 OFFSET"change its own process mask.",
102 .offset = offsetof(options_t, drom),
103 .type = OPT_BOOL_T,
104 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
105 }, {
106 .var_name = "LB_TALP",
107 .arg_name = "--talp",
108 .default_value = "none",
109 .description = OFFSET"Enable the TALP (Tracking Application Live Performance) profiler.\n"
110 OFFSET"\n"
111 OFFSET"The option accepts a comma-separated list of profiling components:\n"
112 OFFSET" default Enable profiling for all available components\n"
113 OFFSET" mpi MPI activity\n"
114 OFFSET" openmp OpenMP activity\n"
115 OFFSET" gpu GPU activity\n"
116 OFFSET" hwc Hardware counters\n"
117 OFFSET" energy Energy measurements\n"
118 OFFSET" none Disable TALP\n"
119 OFFSET"\n"
120 OFFSET"If the option is specified without value (i.e., --talp), it is\n"
121 OFFSET"equivalent to --talp=default.\n"
122 OFFSET"\n"
123 OFFSET"Expected usage is one of:\n"
124 OFFSET" --talp=none\n"
125 OFFSET" --talp or --talp=default\n"
126 OFFSET" --talp=<component>[,<component>...]\n"
127 OFFSET"\n"
128 OFFSET"Examples:\n"
129 OFFSET" --talp\n"
130 OFFSET" Enable profiling for all available components\n"
131 OFFSET" (auto-detected).\n"
132 OFFSET"\n"
133 OFFSET" --talp=gpu\n"
134 OFFSET" Enable GPU profiling.\n"
135 OFFSET"\n"
136 OFFSET" --talp=mpi,openmp\n"
137 OFFSET" Enable profiling of MPI and OpenMP activity.",
138 .offset = offsetof(options_t, talp),
139 .type = OPT_TLPCOM_T,
140 .flags = (option_flags_t)(OPT_OPTIONAL)
141 }, {
142 .var_name = "LB_MNGO",
143 .arg_name = "--mngo",
144 .default_value = "no",
145 .description = OFFSET"Enables the MNGO module. Processes using\n"
146 OFFSET"this module use TALP metrics to enable the usage of other modules\n"
147 OFFSET"like LeWI, and DROM depending on the live performance.",
148 .offset = offsetof(options_t, mngo),
149 .type = OPT_BOOL_T,
150 .flags = (option_flags_t)(OPT_OPTIONAL)
151 }, {
152 .var_name = "LB_BARRIER",
153 .arg_name = "--barrier",
154 .default_value = "yes",
155 .description = OFFSET"Enable the Shared Memory Barrier. Processes can perform\n"
156 OFFSET"intra-node barriers.",
157 .offset = offsetof(options_t, barrier),
158 .type = OPT_BOOL_T,
159 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
160 }, {
161 .var_name = "LB_NULL",
162 .arg_name = "--ompt",
163 .default_value = "yes",
164 .description = OFFSET"Enable OpenMP performance tool. If running with an OMPT capable\n"
165 OFFSET"runtime, DLB can register itself as OpenMP Tool and perform\n"
166 OFFSET"some tasks, like thread pinning reallocation when the process\n"
167 OFFSET"mask changes or some LeWI features if enabled.",
168 .offset = offsetof(options_t, ompt),
169 .type = OPT_BOOL_T,
170 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
171 }, {
172 .var_name = "LB_MODE",
173 .arg_name = "--mode",
174 .default_value = "polling",
175 .description = OFFSET"Set interaction mode between DLB and the application. In polling\n"
176 OFFSET"mode, each process needs to poll DLB to acquire resources. In\n"
177 OFFSET"async mode, DLB creates a helper thread to call back the\n"
178 OFFSET"application when resources become available.",
179 .offset = offsetof(options_t, mode),
180 .type = OPT_MODE_T,
181 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
182 },
183 // verbose
184 {
185 .var_name = "LB_NULL",
186 .arg_name = "--quiet",
187 .default_value = "no",
188 .description = OFFSET"Suppress VERBOSE and INFO messages from DLB, still shows\n"
189 OFFSET"WARNING and PANIC messages.",
190 .offset = offsetof(options_t, quiet),
191 .type = OPT_BOOL_T,
192 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
193 }, {
194 .var_name = "LB_NULL",
195 .arg_name = "--silent",
196 .default_value = "no",
197 .description = OFFSET"Suppress all output from DLB, even error messages.",
198 .offset = offsetof(options_t, silent),
199 .type = OPT_BOOL_T,
200 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
201 }, {
202 .var_name = "LB_VERBOSE",
203 .arg_name = "--verbose",
204 .default_value = "no",
205 .description = OFFSET"Select which verbose components will be printed. Multiple\n"
206 OFFSET"components may be selected.",
207 .offset = offsetof(options_t, verbose),
208 .type = OPT_VB_T,
209 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
210 }, {
211 .var_name = "LB_VERBOSE_FORMAT",
212 .arg_name = "--verbose-format",
213 .default_value = "node:spid",
214 .description = OFFSET"Set the verbose format for the verbose messages. Multiple\n"
215 OFFSET"components may be selected but the order is predefined as\n"
216 OFFSET"shown in the possible values.",
217 .offset = offsetof(options_t, verbose_fmt),
218 .type = OPT_VBFMT_T,
219 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
220 },
221 // instrument
222 {
223 .var_name = "LB_NULL",
224 .arg_name = "--instrument",
225 .default_value = "all",
226 .description = OFFSET"Enable Extrae instrumentation. This option requires the\n"
227 OFFSET"instrumented DLB library and the Extrae library. If both\n"
228 OFFSET"conditions are met, DLB will emit events such as the DLB\n"
229 OFFSET"calls, DLB modes, etc.",
230 .offset = offsetof(options_t, instrument),
231 .type = OPT_INST_T,
232 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
233 }, {
234 .var_name = "LB_NULL",
235 .arg_name = "--instrument-counters",
236 .default_value = "no",
237 .description = OFFSET"Enable counters on DLB events. If this option is enabled, DLB\n"
238 OFFSET"will emit events to Extrae with hardware counters information.\n"
239 OFFSET"This may significantly increase the size of the tracefile.",
240 .offset = offsetof(options_t, instrument_counters),
241 .type = OPT_BOOL_T,
242 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
243 }, {
244 .var_name = "LB_NULL",
245 .arg_name = "--instrument-extrae-nthreads",
246 .default_value = "0",
247 .description = OFFSET"Invoke Extrae_change_num_threads with the provided parameter\n"
248 OFFSET"at the start of the execution to pre-allocate a buffer per\n"
249 OFFSET"thread.",
250 .offset = offsetof(options_t, instrument_extrae_nthreads),
251 .type = OPT_INT_T,
252 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
253 },
254 // LeWI
255 {
256 .var_name = "LB_NULL",
257 .arg_name = "--lewi-keep-one-cpu",
258 .default_value = "no",
259 .description = OFFSET"Whether the CPU of the thread that encounters a blocking call\n"
260 OFFSET"(MPI blocking call or DLB_Barrier) is also lent in the LeWI policy.\n"
261 OFFSET"This flag replaces the option --lewi-mpi, although negated.",
262 .offset = offsetof(options_t, lewi_keep_cpu_on_blocking_call),
263 .type = OPT_BOOL_T,
264 .flags = (option_flags_t)(OPT_OPTIONAL)
265 }, {
266 .var_name = "LB_NULL",
267 .arg_name = "--lewi-respect-cpuset",
268 .default_value = "yes",
269 .description = OFFSET"Whether to respect the set of CPUs registered in DLB to\n"
270 OFFSET"use with LeWI. If disabled, all unknown CPUs are available\n"
271 OFFSET"for any process to borrow.",
272 .offset = offsetof(options_t, lewi_respect_cpuset),
273 .type = OPT_BOOL_T,
274 .flags = (option_flags_t)(OPT_OPTIONAL)
275 }, {
276 .var_name = "LB_NULL",
277 .arg_name = "--lewi-respect-mask",
278 .default_value = "yes",
279 .description = OFFSET"Deprecated in favor of --lewi-respect-cpuset.\n",
280 .offset = SIZE_MAX,
281 .type = OPT_BOOL_T,
282 .flags = (option_flags_t)(OPT_OPTIONAL | OPT_DEPRECATED | OPT_UNUSED)
283 }, {
284 /* This is a deprecated option that overlaps with --lewi-keep-one-cpu.
285 * It must be defined afterwards so that the default value of the
286 * previous option does not overwrite this one */
287 .var_name = "LB_NULL",
288 .arg_name = "--lewi-mpi",
289 .default_value = "no",
290 .description = OFFSET"This option is now deprecated, but its previous behavior is now\n"
291 OFFSET"enabled by default.\n"
292 OFFSET"If you want to lend a CPU when in a blocking call, you may safely\n"
293 OFFSET"remove this option.\n"
294 OFFSET"If you want to keep this CPU, use --lewi-keep-one-cpu instead.",
295 .offset = SIZE_MAX,
296 .type = OPT_NEG_BOOL_T,
297 .flags = (option_flags_t)(OPT_OPTIONAL | OPT_DEPRECATED | OPT_UNUSED)
298 }, {
299 .var_name = "LB_NULL",
300 .arg_name = "--lewi-mpi-calls",
301 .default_value = "all",
302 .description = OFFSET"Select which type of MPI calls will make LeWI to lend their\n"
303 OFFSET"CPUs. If set to all, LeWI will act on all blocking MPI calls,\n"
304 OFFSET"If set to other values, only those types will trigger LeWI.",
305 .offset = offsetof(options_t, lewi_mpi_calls),
306 .type = OPT_MPISET_T,
307 .flags = (option_flags_t)(OPT_OPTIONAL)
308 }, {
309 .var_name = "LB_NULL",
310 .arg_name = "--lewi-barrier",
311 .default_value = "yes",
312 .description = OFFSET"Select whether DLB_Barrier calls (unnamed barriers only) will\n"
313 OFFSET"activate LeWI and lend their CPUs. Named barriers can be\n"
314 OFFSET"configured individually in the source code, or using the\n"
315 OFFSET"--lewi-barrier-select.",
316 .offset = offsetof(options_t, lewi_barrier),
317 .type = OPT_BOOL_T,
318 .flags = (option_flags_t)(OPT_OPTIONAL | OPT_READONLY)
319 }, {
320 .var_name = "LB_NULL",
321 .arg_name = "--lewi-barrier-select",
322 .default_value = "",
323 .description = OFFSET"Comma separated values of barrier names that will activate\n"
324 OFFSET"LeWI. Warning: by setting this option to any non-blank value,\n"
325 OFFSET"the option --lewi-barrier is ignored. Use 'default' to also\n"
326 OFFSET"control the default unnamed barrier.\n"
327 OFFSET"e.g.: --lewi-barrier-select=default,barrier3",
328 .offset = offsetof(options_t, lewi_barrier_select),
329 .type = OPT_STR_T,
330 .flags = (option_flags_t)(OPT_OPTIONAL | OPT_READONLY | OPT_ADVANCED)
331 }, {
332 .var_name = "LB_NULL",
333 .arg_name = "--lewi-affinity",
334 .default_value = "auto",
335 .description = OFFSET"Select which affinity policy to use.\n"
336 OFFSET"With 'auto', DLB will infer the LeWI policy for either classic\n"
337 OFFSET"(no mask support) or LeWI_mask depending on a number of factors.\n"
338 OFFSET"To override the automatic detection, use either 'none' or 'mask'\n"
339 OFFSET"to select the respective policy.\n"
340 OFFSET"The tokens 'nearby-first', 'nearby-only', and 'spread-ifempty'\n"
341 OFFSET"also enforce mask support with extended policies.\n"
342 OFFSET"'nearby-first' is the default policy when LeWI has mask support\n"
343 OFFSET"and will instruct LeWI to assign resources that share the same\n"
344 OFFSET"socket or NUMA node with the current process first, then the\n"
345 OFFSET"rest.\n"
346 OFFSET"'nearby-only' will make LeWI assign only those resources that\n"
347 OFFSET"are near the process.\n"
348 OFFSET"'spread-ifempty' will also prioritise nearby resources, but the\n"
349 OFFSET"rest will only be considered if all CPUs in that socket or NUMA\n"
350 OFFSET"node has been lent to DLB.",
351 .offset = offsetof(options_t, lewi_affinity),
352 .type = OPT_LEWI_AFF_T,
353 .flags = (option_flags_t)(OPT_OPTIONAL)
354 }, {
355 .var_name = "LB_NULL",
356 .arg_name = "--lewi-ompt",
357 .default_value = "borrow",
358 .description = OFFSET"OMPT option flags for LeWI. If OMPT mode is enabled, set when\n"
359 OFFSET"DLB can automatically invoke LeWI functions to lend or borrow\n"
360 OFFSET"CPUs. If 'none' is set, LeWI will not be invoked automatically.\n"
361 OFFSET"If 'borrow' is set, DLB will try to borrow CPUs in certain\n"
362 OFFSET"situations; typically, before non nested parallel constructs if\n"
363 OFFSET"the OMPT thread manager is omp5 and on each task creation and\n"
364 OFFSET"task switch in other thread managers. (This option is the default\n"
365 OFFSET"and should be enough in most of the cases). If the flag 'lend'\n"
366 OFFSET"is set, DLB will lend all non used CPUs after each non nested\n"
367 OFFSET"parallel construct and task completion on external threads.\n"
368 OFFSET"Multiple flags can be selected at the same time.",
369 .offset = offsetof(options_t, lewi_ompt),
370 .type = OPT_OMPTOPTS_T,
371 .flags = (option_flags_t)(OPT_OPTIONAL)
372 }, {
373 .var_name = "LB_NULL",
374 .arg_name = "--lewi-greedy",
375 .default_value = "no",
376 .description = OFFSET"Greedy option for LeWI policy.",
377 .offset = offsetof(options_t, lewi_greedy),
378 .type = OPT_BOOL_T,
379 .flags = (option_flags_t)(OPT_OPTIONAL)
380 }, {
381 .var_name = "LB_NULL",
382 .arg_name = "--lewi-warmup",
383 .default_value = "no",
384 .description = OFFSET"Create as many threads as necessary during the process startup.",
385 .offset = offsetof(options_t, lewi_warmup),
386 .type = OPT_BOOL_T,
387 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
388 }, {
389 .var_name = "LB_NULL",
390 .arg_name = "--lewi-max-parallelism",
391 .default_value = "0",
392 .description = OFFSET"Set the maximum level of parallelism for the LeWI algorithm.",
393 .offset = offsetof(options_t, lewi_max_parallelism),
394 .type = OPT_INT_T,
395 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
396 }, {
397 .var_name = "LB_NULL",
398 .arg_name = "--lewi-color",
399 .default_value = "0",
400 .description = OFFSET"Set the LeWI color of the process, allowing the creation of\n"
401 OFFSET"different disjoint subgroups for resource sharing. Processes\n"
402 OFFSET"will only share resources with other processes of the same color.",
403 .offset = offsetof(options_t, lewi_color),
404 .type = OPT_INT_T,
405 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
406 },
407 // talp
408 {
409 .var_name = "LB_NULL",
410 .arg_name = "--talp-openmp",
411 .default_value = "no",
412 .description = OFFSET"Select whether to measure OpenMP metrics.\n"
413 OFFSET"Deprecated: use --talp=openmp instead.",
414 .offset = offsetof(options_t, deprecated_talp_openmp),
415 .type = OPT_BOOL_T,
416 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_DEPRECATED)
417 },
418 {
419 .var_name = "LB_NULL",
420 .arg_name = "--talp-papi",
421 .default_value = "no",
422 .description = OFFSET"Select whether to collect PAPI counters.\n"
423 OFFSET"Deprecated: use --talp=hwc instead.",
424 .offset = offsetof(options_t, deprecated_talp_papi),
425 .type = OPT_BOOL_T,
426 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_DEPRECATED)
427 },
428 {
429 .var_name = "LB_TALP_SUMM",
430 .arg_name = "--talp-summary",
431 .default_value = "pop-metrics",
432 .description = OFFSET"Report TALP metrics at the end of the execution. If\n"
433 OFFSET"'--talp-output-file' is not specified, a short summary is\n"
434 OFFSET"printed. Otherwise, a more verbose file will be generated\n"
435 OFFSET"with all the metrics collected by TALP, depending on the list\n"
436 OFFSET"of requested summaries, separated by ':':\n"
437 OFFSET"'pop-metrics', the default option, will report a subset of\n"
438 OFFSET"the POP metrics.\n"
439 OFFSET"'process' will report the measurements of each process for\n"
440 OFFSET"each registered region.\n"
441 OFFSET"\n"
442 OFFSET"Deprecated options:\n"
443 OFFSET"'pop-raw' will be removed in the next release. The output \n"
444 OFFSET"will be available using the 'pop-metrics' summary.\n"
445 OFFSET"'node' will be removed in the next release. Its data may\n"
446 OFFSET"be derived from the 'process' report.",
447 .offset = offsetof(options_t, talp_summary),
448 .type = OPT_TLPSUM_T,
449 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
450 },
451 {
452 .var_name = "LB_NULL",
453 .arg_name = "--talp-output-file",
454 .default_value = "",
455 .description = OFFSET"Write extended TALP metrics to a file. If omitted, output is\n"
456 OFFSET"written to stderr.\n"
457 OFFSET"\n"
458 OFFSET"The output format is determined by the file extension:\n"
459 OFFSET" *.json JSON (file is overwritten)\n"
460 OFFSET" *.csv CSV (rows are appended)\n"
461 OFFSET" other Plain text\n"
462 OFFSET"\n"
463 OFFSET"The filename may contain replacement tokens:\n"
464 OFFSET" %h Hostname\n"
465 OFFSET" %p Process ID (PID)\n"
466 OFFSET" %j Job ID from the environment (e.g., Slurm, Flux)\n"
467 OFFSET" %% Literal '%'\n"
468 OFFSET"\n"
469 OFFSET"Deprecated:\n"
470 OFFSET" *.xml XML output format",
471 .offset = offsetof(options_t, talp_output_file),
472 .type = OPT_PTR_PATH_T,
473 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
474 },
475 {
476 .var_name = "LB_NULL",
477 .arg_name = "--talp-partial-output",
478 .default_value = "no",
479 .description = OFFSET"Write one profiling output file per process instead of a single\n"
480 OFFSET"merged file. Only supported when the output format is JSON.",
481 .offset = offsetof(options_t, talp_partial_output),
482 .type = OPT_BOOL_T,
483 .flags = (option_flags_t)(OPT_OPTIONAL)
484 },
485 {
486 /* In the future, consider using an interval update timer instead of a boolean */
487 .var_name = "LB_NULL",
488 .arg_name = "--talp-external-profiler",
489 .default_value = "no",
490 .description = OFFSET"Enable live metrics update to the shared memory. This flag\n"
491 OFFSET"is only needed if there is an external program monitoring\n"
492 OFFSET"the application.",
493 .offset = offsetof(options_t, talp_external_profiler),
494 .type = OPT_BOOL_T,
495 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
496 },
497 {
498 .var_name = "LB_NULL",
499 .arg_name = "--talp-regions-per-proc",
500 .default_value = "100",
501 .description = OFFSET"Number of TALP regions per process to allocate in the shared\n"
502 OFFSET"memory.\n"
503 OFFSET"Deprecated: use --shmem-size-multiplier instead.\n",
504 .offset = SIZE_MAX,
505 .type = OPT_INT_T,
506 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_DEPRECATED | OPT_UNUSED)
507 },
508 {
509 .var_name = "LB_NULL",
510 .arg_name = "--talp-region-select",
511 .default_value = "",
512 .description = OFFSET"Select TALP regions to enable. This option follows the format:\n"
513 OFFSET" --talp-region-select=[(include|exclude):]<region-list>\n"
514 OFFSET"\n"
515 OFFSET"The modifiers 'include:' and 'exclude:' are optional, but only\n"
516 OFFSET"one modifier can be used at a time. If neither is specified,\n"
517 OFFSET"'include:' is assumed by default.\n"
518 OFFSET"\n"
519 OFFSET"The '<region-list>' can be a comma-separated list of regions\n"
520 OFFSET"or a special token 'all' to refer to all regions. The global\n"
521 OFFSET"monitoring region may be specified with the special token\n"
522 OFFSET"'global'. If the modifier 'include:' is used, only the listed\n"
523 OFFSET"regions will be enabled. If 'exclude:' is used, all regions\n"
524 OFFSET"will be enabled except for the ones specified.\n"
525 OFFSET"\n"
526 OFFSET"Note that when using this feature, listed regions must not have\n"
527 OFFSET"spaces in their names.\n"
528 OFFSET"\n"
529 OFFSET"e.g.: --talp-region-select=all (default)\n"
530 OFFSET" --talp-region-select=exclude:all\n"
531 OFFSET" --talp-region-select=include:global,region3\n"
532 OFFSET" --talp-region-select=exclude:region4",
533 .offset = offsetof(options_t, talp_region_select),
534 .type = OPT_STR_T,
535 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
536 },
537 {
538 .var_name = "LB_NULL",
539 .arg_name = "--talp-gpu-backend",
540 .default_value = "",
541 .description = OFFSET"Specifies the GPU backend plugin used by TALP.\n"
542 OFFSET"If unset (default), DLB automatically attempts to load a GPU\n"
543 OFFSET"backend in the following order:\n"
544 OFFSET"'cupti', 'rocprofiler-sdk', and 'rocprofilerv2'.",
545 .offset = offsetof(options_t, talp_gpu_backend),
546 .type = OPT_STR_T,
547 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
548 },
549 {
550 .var_name = "LB_NULL",
551 .arg_name = "--talp-hwc-backend",
552 .default_value = "",
553 .description = OFFSET"Specifies the hardware counter backend plugin used by TALP.\n"
554 OFFSET"If unset (default), DLB automatically attempts to load an HWC\n"
555 OFFSET"backend in the following order:\n"
556 OFFSET"'papi' and 'perf'.",
557 .offset = offsetof(options_t, talp_hwc_backend),
558 .type = OPT_STR_T,
559 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
560 },
561 {
562 .var_name = "LB_NULL",
563 .arg_name = "--talp-energy-backend",
564 .default_value = "",
565 .description = OFFSET"Specifies the energy backend plugin used by TALP.\n"
566 OFFSET"If unset (default), DLB automatically attempts to load an energy\n"
567 OFFSET"backend in the following order: 'ear' and 'seanerbus'.",
568 .offset = offsetof(options_t, talp_energy_backend),
569 .type = OPT_STR_T,
570 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
571 },
572 {
573 .var_name = "LB_NULL",
574 .arg_name = "--talp-model",
575 .default_value = "hybrid-v2",
576 .description = OFFSET"For development use only.\n"
577 OFFSET"Select which version of POP metrics to compute.",
578 .offset = offsetof(options_t, talp_model),
579 .type = OPT_TLPMOD_T,
580 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
581 },
582 // MNGO
583 {
584 .var_name = "LB_NULL",
585 .arg_name = "--mngo-mode",
586 .default_value = "regions",
587 .description = OFFSET"The method used to call the mngo manager.",
588 .offset = offsetof(options_t, mngo_mode),
589 .type = OPT_MNGO_MODE_T,
590 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
591 },
592 {
593 .var_name = "LB_NULL",
594 .arg_name = "--mngo-helper-thread-interval",
595 .default_value = "30",
596 .description = OFFSET"The number of seconds MNGO waits between each event.",
597 .offset = offsetof(options_t, mngo_interval_time),
598 .type = OPT_INT_T,
599 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
600 },
601 {
602 .var_name = "LB_NULL",
603 .arg_name = "--mngo-lb-in-threshold",
604 .default_value = "10",
605 .description = OFFSET"The percentage difference between a process useful computation\n"
606 OFFSET"and its node average useful computation to consider that the\n"
607 OFFSET"process is contributing to load imbalance within the node.\n"
608 OFFSET"\n"
609 OFFSET"Note: This will affect when MNGO redistributes resources inside\n"
610 OFFSET" the node (either with DROM or with LeWI).\n",
611 .offset = offsetof(options_t, mngo_lb_in_threshold),
612 .type = OPT_INT_T,
613 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
614
615 },
616 {
617 .var_name = "LB_NULL",
618 .arg_name = "--mngo-lb-out-threshold",
619 .default_value = "5",
620 .description = OFFSET"The percentage difference between a process useful computation\n"
621 OFFSET"and the global average useful computation to consider that the\n"
622 OFFSET"process is contributing to the imbalance of other nodes.\n"
623 OFFSET"\n"
624 OFFSET"Note: This will change when DROM is used balance nodes across nodes.",
625 .offset = offsetof(options_t, mngo_lb_out_threshold),
626 .type = OPT_INT_T,
627 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL)
628
629 },
630 // barrier
631 {
632 .var_name = "LB_NULL",
633 .arg_name = "--barrier-id",
634 .default_value = "0",
635 .description = OFFSET"Barrier ID. Use different barrier id numbers for different\n"
636 OFFSET"processes to avoid unwanted synchronization.",
637 .offset = offsetof(options_t, barrier_id),
638 .type = OPT_INT_T,
639 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
640 },
641 // misc
642 {
643 .var_name = "LB_SHM_KEY",
644 .arg_name = "--shm-key",
645 .default_value = "",
646 .description = OFFSET"Shared Memory key. By default, if key is empty, all processes\n"
647 OFFSET"will use a shared memory based on the user ID. If different\n"
648 OFFSET"processes start their execution with different keys, they will\n"
649 OFFSET"use different shared memories and they will not share resources.",
650 .offset = offsetof(options_t, shm_key),
651 .type = OPT_STR_T,
652 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
653 }, {
654 .var_name = "LB_NULL",
655 .arg_name = "--shm-size-multiplier",
656 .default_value = "1",
657 .description = OFFSET"DLB allocates its shared memory at the start of execution, with\n"
658 OFFSET"its size based on the number of CPUs in the node. If you\n"
659 OFFSET"encounter a DLB_ERR_NOMEM error, you can adjust the multiplier\n"
660 OFFSET"to increase the shared memory size. As a reference, with the\n"
661 OFFSET"default multiplier, the typical shared memory size on HPC\n"
662 OFFSET"machines is under 10 megabytes, so keep that in mind if you\n"
663 OFFSET"increase its size to allocate more running processes or TALP\n"
664 OFFSET"regions.",
665 .offset = offsetof(options_t, shm_size_multiplier),
666 .type = OPT_INT_T,
667 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_ADVANCED)
668 }, {
669 .var_name = "LB_PREINIT_PID",
670 .arg_name = "--preinit-pid",
671 .default_value = "0",
672 .description = OFFSET"Process ID that pre-initializes the DLB process for DROM.",
673 .offset = offsetof(options_t, preinit_pid),
674 .type = OPT_INT_T,
675 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_HIDDEN)
676 }, {
677 .var_name = "LB_NULL",
678 .arg_name = "--ompt-thread-manager",
679 .default_value = "omp5",
680 .description = OFFSET"OMPT Thread Manager version.",
681 .offset = offsetof(options_t, omptm_version),
682 .type = OPT_OMPTM_T,
683 .flags = (option_flags_t)(OPT_OPTIONAL)
684 }, {
685 .var_name = "LB_NULL",
686 .arg_name = "--plugin",
687 .default_value = "",
688 .description = OFFSET"Select plugin to enable.\n"
689 OFFSET"Available options: 'cupti', 'rocprofiler-sdk', or 'rocprofilerv2'.\n"
690 OFFSET"Deprecated: use --talp=gpu or --talp-gpu-backend.",
691 .offset = offsetof(options_t, deprecated_plugins),
692 .type = OPT_STR_T,
693 .flags = (option_flags_t)(OPT_READONLY | OPT_OPTIONAL | OPT_DEPRECATED)
694 }, {
695 .var_name = "LB_DEBUG_OPTS",
696 .arg_name = "--debug-opts",
697 .default_value = "",
698 .description = OFFSET"Debug options.",
699 .offset = offsetof(options_t, debug_opts),
700 .type = OPT_DBG_T,
701 .flags = (option_flags_t)(OPT_OPTIONAL | OPT_ADVANCED)
702 }
703 };
704 #undef OFFSET
705
706 enum { NUM_OPTIONS = sizeof(options_dictionary)/sizeof(opts_dict_t) };
707
708
709 570 static const opts_dict_t* get_entry_by_name(const char *name) {
710 int i;
711
2/2
✓ Branch 0 taken 10650 times.
✓ Branch 1 taken 2 times.
10652 for (i=0; i<NUM_OPTIONS; ++i) {
712 10650 const opts_dict_t *entry = &options_dictionary[i];
713
1/2
✓ Branch 0 taken 10650 times.
✗ Branch 1 not taken.
10650 if (strcasecmp(entry->var_name, name) == 0
714
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 10082 times.
10650 || strcasecmp(entry->arg_name, name) == 0) {
715 568 return entry;
716 }
717 }
718 2 return NULL;
719 }
720
721 222 static int set_ptr_path_value(void *option, const char *str_value) {
722 222 int path_len = snprintf(NULL, 0, "%s", str_value) + 1;
723
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 221 times.
222 if (path_len > 1) {
724 1 *(char**)option = malloc(sizeof(char) * path_len);
725 1 snprintf(*(char**)option, path_len, "%s", str_value);
726 } else {
727 221 *(char**)option = NULL;
728 }
729 222 return DLB_SUCCESS;
730 }
731
732 10722 static int set_value(option_type_t type, void *option, const char *str_value) {
733
18/20
✓ Branch 0 taken 3915 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2047 times.
✓ Branch 3 taken 1579 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 283 times.
✓ Branch 6 taken 223 times.
✓ Branch 7 taken 223 times.
✓ Branch 8 taken 224 times.
✓ Branch 9 taken 223 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 223 times.
✓ Branch 12 taken 224 times.
✓ Branch 13 taken 223 times.
✓ Branch 14 taken 223 times.
✓ Branch 15 taken 223 times.
✓ Branch 16 taken 222 times.
✓ Branch 17 taken 222 times.
✓ Branch 18 taken 222 times.
✗ Branch 19 not taken.
10722 switch(type) {
734 3915 case OPT_BOOL_T:
735 3915 return parse_bool(str_value, (bool*)option);
736 1 case OPT_NEG_BOOL_T:
737 1 return parse_negated_bool(str_value, (bool*)option);
738 2047 case OPT_INT_T:
739 2047 return parse_int(str_value, (int*)option);
740 1579 case OPT_STR_T:
741 1579 snprintf(option, MAX_OPTION_LENGTH, "%s", str_value);
742 1579 return DLB_SUCCESS;
743 222 case OPT_PTR_PATH_T:
744 222 return set_ptr_path_value(option, str_value);
745 283 case OPT_VB_T:
746 283 return parse_verbose_opts(str_value, (verbose_opts_t*)option);
747 223 case OPT_VBFMT_T:
748 223 return parse_verbose_fmt(str_value, (verbose_fmt_t*)option);
749 223 case OPT_INST_T:
750 223 return parse_instrument_items(str_value, (instrument_items_t*)option);
751 224 case OPT_DBG_T:
752 224 return parse_debug_opts(str_value, (debug_opts_t*)option);
753 223 case OPT_LEWI_AFF_T:
754 223 return parse_lewi_affinity(str_value, (lewi_affinity_t*)option);
755 ✗ case OPT_MASK_T:
756 ✗ mu_parse_mask(str_value, (cpu_set_t*)option);
757 ✗ return DLB_SUCCESS;
758 223 case OPT_MODE_T:
759 223 return parse_mode(str_value, (interaction_mode_t*)option);
760 224 case OPT_MPISET_T:
761 224 return parse_mpiset(str_value, (mpi_set_t*)option);
762 223 case OPT_OMPTOPTS_T:
763 223 return parse_omptool_opts(str_value, (omptool_opts_t*)option);
764 223 case OPT_TLPSUM_T:
765 223 return parse_talp_summary(str_value, (talp_summary_t*)option);
766 223 case OPT_TLPMOD_T:
767 223 return parse_talp_model(str_value, (talp_model_t*)option);
768 222 case OPT_TLPCOM_T:
769 222 return parse_talp_component(str_value, (talp_component_t*)option);
770 222 case OPT_MNGO_MODE_T:
771 222 return parse_mngo_mode(str_value, (mngo_mode_t*)option);
772 222 case OPT_OMPTM_T:
773 222 return parse_omptm_version(str_value, (omptm_version_t*)option);
774 }
775 ✗ return DLB_ERR_NOENT;
776 }
777
778 155 static const char * get_value(option_type_t type, const void *option) {
779 static char int_value[8];
780
17/20
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 5 times.
✓ Branch 17 taken 4 times.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
155 switch(type) {
781 65 case OPT_BOOL_T:
782
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 48 times.
65 return *(bool*)option ? "yes" : "no";
783 ✗ case OPT_NEG_BOOL_T:
784 ✗ return *(bool*)option ? "no" : "yes";
785 23 case OPT_INT_T:
786 23 sprintf(int_value, "%d", *(int*)option);
787 23 return int_value;
788 10 case OPT_STR_T:
789 10 return (char*)option;
790 4 case OPT_PTR_PATH_T:
791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 return *(const char**)option ? *(const char**)option : "";
792 4 case OPT_VB_T:
793 4 return verbose_opts_tostr(*(verbose_opts_t*)option);
794 4 case OPT_VBFMT_T:
795 4 return verbose_fmt_tostr(*(verbose_fmt_t*)option);
796 4 case OPT_INST_T:
797 4 return instrument_items_tostr(*(instrument_items_t*)option);
798 1 case OPT_DBG_T:
799 1 return debug_opts_tostr(*(debug_opts_t*)option);
800 4 case OPT_LEWI_AFF_T:
801 4 return lewi_affinity_tostr(*(lewi_affinity_t*)option);
802 ✗ case OPT_MASK_T:
803 ✗ return mu_to_str((cpu_set_t*)option);
804 8 case OPT_MODE_T:
805 8 return mode_tostr(*(interaction_mode_t*)option);
806 6 case OPT_MPISET_T:
807 6 return mpiset_tostr(*(mpi_set_t*)option);
808 4 case OPT_OMPTOPTS_T:
809 4 return omptool_opts_tostr(*(omptool_opts_t*)option);
810 4 case OPT_TLPSUM_T:
811 4 return talp_summary_tostr(*(talp_summary_t*)option);
812 1 case OPT_TLPMOD_T:
813 1 return talp_model_tostr(*(talp_model_t*)option);
814 5 case OPT_TLPCOM_T:
815 5 return talp_component_tostr(*(talp_component_t*)option);
816 4 case OPT_MNGO_MODE_T:
817 4 return mngo_mode_tostr(*(mngo_mode_t*)option);
818 4 case OPT_OMPTM_T:
819 4 return omptm_version_tostr(*(omptm_version_t*)option);
820 }
821 ✗ return "unknown";
822 }
823
824 5 static bool values_are_equivalent(option_type_t type, const char *value1, const char *value2) {
825
1/20
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
5 switch(type) {
826 5 case OPT_BOOL_T:
827 5 return equivalent_bool(value1, value2);
828 ✗ case OPT_NEG_BOOL_T:
829 ✗ return equivalent_negated_bool(value1, value2);
830 ✗ case OPT_INT_T:
831 ✗ return equivalent_int(value1, value2);
832 ✗ case OPT_STR_T:
833 ✗ return strcmp(value1, value2) == 0;
834 ✗ case OPT_PTR_PATH_T:
835 ✗ return *(const char**)value1 && *(const char**)value2
836 ✗ && strcmp(*(const char**)value1, *(const char**)value2) == 0;
837 ✗ case OPT_VB_T:
838 ✗ return equivalent_verbose_opts(value1, value2);
839 ✗ case OPT_VBFMT_T:
840 ✗ return equivalent_verbose_fmt(value1, value2);
841 ✗ case OPT_INST_T:
842 ✗ return equivalent_instrument_items(value1, value2);
843 ✗ case OPT_DBG_T:
844 ✗ return equivalent_debug_opts(value1, value2);
845 ✗ case OPT_LEWI_AFF_T:
846 ✗ return equivalent_lewi_affinity(value1, value2);
847 ✗ case OPT_MASK_T:
848 ✗ return mu_equivalent_masks(value1, value2);
849 ✗ case OPT_MODE_T:
850 ✗ return equivalent_mode(value1, value2);
851 ✗ case OPT_MPISET_T:
852 ✗ return equivalent_mpiset(value1, value2);
853 ✗ case OPT_OMPTOPTS_T:
854 ✗ return equivalent_omptool_opts(value1, value2);
855 ✗ case OPT_TLPSUM_T:
856 ✗ return equivalent_talp_summary(value1, value2);
857 ✗ case OPT_TLPMOD_T:
858 ✗ return equivalent_talp_model(value1, value2);
859 ✗ case OPT_TLPCOM_T:
860 ✗ return equivalent_talp_component(value1, value2);
861 ✗ case OPT_MNGO_MODE_T:
862 ✗ return equivalent_mngo_mode(value1, value2);
863 ✗ case OPT_OMPTM_T:
864 ✗ return equivalent_omptm_version_opts(value1, value2);
865 }
866 ✗ return false;
867 }
868
869 16 static void copy_value(option_type_t type, void *dest, const char *src) {
870
13/20
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
16 switch(type) {
871 1 case OPT_BOOL_T:
872 1 memcpy(dest, src, sizeof(bool));
873 1 break;
874 1 case OPT_NEG_BOOL_T:
875 1 memcpy(dest, src, sizeof(bool));
876 1 break;
877 3 case OPT_INT_T:
878 3 memcpy(dest, src, sizeof(int));
879 3 break;
880 2 case OPT_STR_T:
881 2 memcpy(dest, src, sizeof(char)*MAX_OPTION_LENGTH);
882 2 break;
883 ✗ case OPT_PTR_PATH_T:
884 ✗ fatal("copy_value of type OPT_PTR_PATH_T not supported");
885 break;
886 1 case OPT_VB_T:
887 1 memcpy(dest, src, sizeof(verbose_opts_t));
888 1 break;
889 1 case OPT_VBFMT_T:
890 1 memcpy(dest, src, sizeof(verbose_fmt_t));
891 1 break;
892 1 case OPT_INST_T:
893 1 memcpy(dest, src, sizeof(instrument_items_t));
894 1 break;
895 ✗ case OPT_DBG_T:
896 ✗ memcpy(dest, src, sizeof(debug_opts_t));
897 ✗ break;
898 1 case OPT_LEWI_AFF_T:
899 1 memcpy(dest, src, sizeof(lewi_affinity_t));
900 1 break;
901 ✗ case OPT_MASK_T:
902 ✗ memcpy(dest, src, sizeof(cpu_set_t));
903 ✗ break;
904 1 case OPT_MODE_T:
905 1 memcpy(dest, src, sizeof(interaction_mode_t));
906 1 break;
907 1 case OPT_MPISET_T:
908 1 memcpy(dest, src, sizeof(mpi_set_t));
909 1 break;
910 1 case OPT_OMPTOPTS_T:
911 1 memcpy(dest, src, sizeof(omptool_opts_t));
912 1 break;
913 1 case OPT_TLPSUM_T:
914 1 memcpy(dest, src, sizeof(talp_summary_t));
915 1 break;
916 1 case OPT_TLPMOD_T:
917 1 memcpy(dest, src, sizeof(talp_model_t));
918 1 break;
919 ✗ case OPT_TLPCOM_T:
920 ✗ memcpy(dest, src, sizeof(talp_component_t));
921 ✗ break;
922 ✗ case OPT_MNGO_MODE_T:
923 ✗ memcpy(dest, src, sizeof(mngo_mode_t));
924 ✗ break;
925 ✗ case OPT_OMPTM_T:
926 ✗ memcpy(dest, src, sizeof(omptm_version_t));
927 ✗ break;
928 }
929 16 }
930
931 /* Parse DLB_ARGS and remove argument if found */
932 18225 static void parse_dlb_args(char *dlb_args, const char *arg_name, char* arg_value, size_t arg_max_len) {
933 18225 *arg_value = 0;
934 /* Tokenize a copy of dlb_args with " "(blank) delimiter */
935 18225 char *progress = dlb_args;
936 18225 char *end_space = NULL;
937 18225 size_t len = strlen(dlb_args) + 1;
938 18225 char *dlb_args_copy = malloc(sizeof(char)*len);
939 18225 strcpy(dlb_args_copy, dlb_args);
940 18225 char *token = strtok_r(dlb_args_copy, " ", &end_space);
941
2/2
✓ Branch 0 taken 13404 times.
✓ Branch 1 taken 18225 times.
31629 while (token) {
942 /* Each token is a complete string representing an option */
943
944 13404 bool remove_token = false;
945 /* token length must be computed before tokenizing into arg=val */
946 13404 size_t token_len = strlen(token);
947 /* progress pointer must be updated each iteration to skip spaces */
948
2/2
✓ Branch 0 taken 19134 times.
✓ Branch 1 taken 13404 times.
32538 while(isspace((unsigned char)*progress)) progress++;
949
950
2/2
✓ Branch 0 taken 12175 times.
✓ Branch 1 taken 1229 times.
13404 if (strchr(token, '=')) {
951 /* Option is of the form --argument=value */
952 12175 char *end_equal = NULL;
953 12175 char *argument = strtok_r(token, "=", &end_equal);
954
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 11762 times.
12175 if (strcmp(argument, arg_name) == 0) {
955 /* Obtain value */
956 413 char *value = strtok_r(NULL, "=", &end_equal);
957
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 1 times.
413 if (value) {
958 412 snprintf(arg_value, arg_max_len, "%s", value);
959 } else {
960 1 warning("Bad format parsing of DLB_ARGS. Option %s with empty value", token);
961 }
962 413 remove_token = true;
963 }
964 } else {
965 /* Option is of the form --argument/--no-argument */
966 1229 char *argument = token;
967
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 1023 times.
1229 if (strcmp(argument, arg_name) == 0) {
968 /* Option value is 'yes' */
969 206 strcpy(arg_value, "yes");
970 206 remove_token = true;
971
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1005 times.
1023 } else if (strncmp(argument, "--no-", 5) == 0
972
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5 times.
18 && strcmp(argument+5, arg_name+2) == 0) {
973 /* Option value is 'no' */
974 13 strcpy(arg_value, "no");
975 13 remove_token = true;
976 }
977 }
978
979
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 12772 times.
13404 if (remove_token) {
980 /* Remove token from dlb_args */
981 632 char *dest = progress;
982 632 char *src = progress + token_len;
983 632 size_t n = strlen(src) + 1;
984 632 memmove(dest, src, n);
985 } else {
986 /* Token is not removed, update parsed progress pointer */
987 12772 progress += token_len;
988 }
989
990 /* next token */
991 13404 token = strtok_r(NULL, " ", &end_space);
992 }
993 18225 free(dlb_args_copy);
994 18225 }
995
996 /* Initialize options struct from either argument, or env. variable */
997 222 void options_init(options_t *options, const char *dlb_args) {
998 /* Copy dlb_args into a local buffer */
999 222 char *dlb_args_from_api = NULL;
1000
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 44 times.
222 if (dlb_args) {
1001 178 size_t len = strlen(dlb_args) + 1;
1002 178 dlb_args_from_api = malloc(sizeof(char)*len);
1003 178 strcpy(dlb_args_from_api, dlb_args);
1004 }
1005
1006 /* Copy either DLB_ARGS or LB_ARGS into a local buffer */
1007 222 char *dlb_args_from_env = NULL;
1008 222 const char *env = getenv("DLB_ARGS");
1009
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 181 times.
222 if (!env) {
1010 41 env = getenv("LB_ARGS");
1011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if (env) {
1012 ✗ warning("LB_ARGS is deprecated, please use DLB_ARGS");
1013 }
1014 }
1015
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 41 times.
222 if (env) {
1016 181 size_t len = strlen(env) + 1;
1017 181 dlb_args_from_env = malloc(sizeof(char)*len);
1018 181 strcpy(dlb_args_from_env, env);
1019 }
1020
1021 /* Preallocate two buffers large enough to save any intermediate option value */
1022 222 char *arg_value_from_api = malloc(sizeof(char)*PATH_MAX);
1023 222 char *arg_value_from_env = malloc(sizeof(char)*PATH_MAX);
1024
1025 int i;
1026
2/2
✓ Branch 0 taken 11100 times.
✓ Branch 1 taken 222 times.
11322 for (i=0; i<NUM_OPTIONS; ++i) {
1027 11100 const opts_dict_t *entry = &options_dictionary[i];
1028 11100 const char *rhs = NULL; /* pointer to rhs to be parsed */
1029
1030 /* Set-up specific argument length */
1031 size_t arg_max_len;
1032
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 10878 times.
11100 switch (entry->type) {
1033 222 case OPT_PTR_PATH_T:
1034 222 arg_max_len = PATH_MAX-1;
1035 222 break;
1036 10878 default:
1037 10878 arg_max_len = MAX_OPTION_LENGTH-1;
1038 10878 break;
1039 }
1040
1041 /* Reset intermediate buffers */
1042 11100 arg_value_from_api[0] = '\0';
1043 11100 arg_value_from_env[0] = '\0';
1044
1045 /* Parse dlb_args from API */
1046
2/2
✓ Branch 0 taken 8900 times.
✓ Branch 1 taken 2200 times.
11100 if (dlb_args_from_api) {
1047 8900 parse_dlb_args(dlb_args_from_api, entry->arg_name, arg_value_from_api, arg_max_len);
1048
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 8438 times.
8900 if (strlen(arg_value_from_api) > 0) {
1049 462 rhs = arg_value_from_api;
1050 }
1051 }
1052
1053 /* Parse DLB_ARGS from env */
1054
2/2
✓ Branch 0 taken 9050 times.
✓ Branch 1 taken 2050 times.
11100 if (dlb_args_from_env) {
1055 9050 parse_dlb_args(dlb_args_from_env, entry->arg_name, arg_value_from_env, arg_max_len);
1056
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 8926 times.
9050 if (strlen(arg_value_from_env) > 0) {
1057
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 119 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 4 times.
124 if (rhs && !values_are_equivalent(entry->type, rhs, arg_value_from_env)) {
1058 1 warning("Overwriting option %s = %s",
1059 1 entry->arg_name, arg_value_from_env);
1060 }
1061 124 rhs = arg_value_from_env;
1062 }
1063 }
1064
1065 /* Parse LB_option (to be deprecated soon) */
1066 11100 const char *arg_value = getenv(entry->var_name);
1067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11100 times.
11100 if (arg_value) {
1068 ✗ if (rhs) {
1069 ✗ warning("Ignoring option %s = %s due to DLB_ARGS precedence",
1070 ✗ entry->var_name, arg_value);
1071 } else {
1072 ✗ warning("Option %s is to be deprecated in the near future, please use DLB_ARGS",
1073 ✗ entry->var_name);
1074 ✗ rhs = arg_value;
1075 }
1076 }
1077
1078 /* Warn if option is deprecated and has rhs */
1079
4/4
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 9768 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1323 times.
11100 if (entry->flags & OPT_DEPRECATED && rhs) {
1080 9 warning("Option %s is deprecated:\n%s", entry->arg_name, entry->description);
1081 }
1082
1083 /* Skip iteration if option is not used anymore */
1084
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 10434 times.
11100 if (entry->flags & OPT_UNUSED) {
1085 666 continue;
1086 }
1087
1088 /* Check offset is valid at this point */
1089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10434 times.
10434 ensure(entry->offset < sizeof(options_t), "Offset value in options directory not valid");
1090
1091 /* Assign option = rhs, and nullify rhs if error */
1092
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 9855 times.
10434 if (rhs) {
1093 579 int error = set_value(entry->type, (char*)options+entry->offset, rhs);
1094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579 times.
579 if (error) {
1095 ✗ warning("Unrecognized %s value: %s. Setting default %s",
1096 ✗ entry->arg_name, rhs, entry->default_value);
1097 ✗ rhs = NULL;
1098 }
1099 }
1100
1101 /* Set default value if needed */
1102
2/2
✓ Branch 0 taken 9855 times.
✓ Branch 1 taken 579 times.
10434 if (rhs == NULL) {
1103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9855 times.
9855 fatal_cond(!(entry->flags & OPT_OPTIONAL),
1104 "Variable %s must be defined", entry->arg_name);
1105 9855 int error = set_value(entry->type, (char*)options+entry->offset, entry->default_value);
1106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9855 times.
9855 fatal_cond(error, "Internal error parsing default value %s=%s. Please, report bug at %s.",
1107 entry->arg_name, entry->default_value, PACKAGE_BUGREPORT);
1108 }
1109 }
1110
1111 /* Temporarily support deprecated TALP options */
1112
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 219 times.
222 if (options->deprecated_talp_openmp) {
1113 3 options->talp |= TALP_COMPONENT_OPENMP;
1114 }
1115
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 220 times.
222 if (options->deprecated_talp_papi) {
1116 2 options->talp |= TALP_COMPONENT_HWC;
1117 }
1118
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 220 times.
222 if (options->deprecated_plugins[0] != '\0' &&
1119
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 (strncmp(options->deprecated_plugins, "cupti", MAX_OPTION_LENGTH-1) == 0
1120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 || strncmp(options->deprecated_plugins, "rocprofiler-sdk", MAX_OPTION_LENGTH-1) == 0
1121 ✗ || strncmp(options->deprecated_plugins, "rocprofilerv2", MAX_OPTION_LENGTH-1) == 0)) {
1122 2 options->talp |= TALP_COMPONENT_GPU;
1123
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (options->talp_gpu_backend[0] == '\0') {
1124 2 strcpy(options->talp_gpu_backend, options->deprecated_plugins);
1125 }
1126 }
1127
1128 /* MNGO required options */
1129
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 208 times.
222 if (options->mngo){
1130
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
14 if ( (!options->lewi) && (!options->drom) ) {
1131 ✗ warning("MNGO without LeWI nor DROM won't be able to take any"
1132 " action.");
1133 }
1134
1135 // Enable the TALP MPI component in external mode
1136 14 options->talp |= TALP_COMPONENT_MPI;
1137 14 options->talp_external_profiler = true;
1138 }
1139
1140 /* Free intermediate buffers */
1141 222 free(arg_value_from_api);
1142 222 free(arg_value_from_env);
1143
1144 /* Safety checks and free local buffers */
1145
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 44 times.
222 if (dlb_args_from_api) {
1146 178 char *str = dlb_args_from_api;
1147
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 178 times.
486 while(isspace((unsigned char)*str)) str++;
1148
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 176 times.
178 if (strlen(str) > 0) {
1149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (options->debug_opts & DBG_WERROR) {
1150 ✗ fatal("Unrecognized flags from DLB_Init: %s", str);
1151 } else {
1152 2 warning("Unrecognized flags from DLB_Init: %s", str);
1153 }
1154 }
1155 178 free(dlb_args_from_api);
1156 }
1157
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 41 times.
222 if (dlb_args_from_env) {
1158 181 char *str = dlb_args_from_env;
1159
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 181 times.
461 while(isspace((unsigned char)*str)) str++;
1160
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 180 times.
181 if (strlen(str) > 0) {
1161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (options->debug_opts & DBG_WERROR) {
1162 ✗ fatal("Unrecognized flags from DLB_ARGS: %s", str);
1163 } else {
1164 1 warning("Unrecognized flags from DLB_ARGS: %s", str);
1165 }
1166 }
1167 181 free(dlb_args_from_env);
1168 }
1169 222 }
1170
1171 121 void options_finalize(options_t *options) {
1172
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 120 times.
121 if (options->talp_output_file) {
1173 1 free(options->talp_output_file);
1174 1 options->talp_output_file = NULL;
1175 }
1176 121 }
1177
1178 /* Obtain value of specific entry, either from DLB_ARGS or from thread_spd->options */
1179 300 void options_parse_entry(const char *var_name, void *option) {
1180 300 const opts_dict_t *entry = get_entry_by_name(var_name);
1181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 ensure(entry, "%s: bad variable name '%s'", __func__, var_name);
1182
1183
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 238 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 46 times.
300 if (thread_spd && thread_spd->dlb_initialized) {
1184 16 copy_value(entry->type, option, (char*)&thread_spd->options + entry->offset);
1185 } else {
1186 /* Simplified options_init just for this entry */
1187
1188 /* Copy DLB_ARGS into a local buffer */
1189 284 char *dlb_args_from_env = NULL;
1190 284 const char *env = getenv("DLB_ARGS");
1191
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 9 times.
284 if (env) {
1192 275 size_t len = strlen(env) + 1;
1193 275 dlb_args_from_env = malloc(sizeof(char)*len);
1194 275 strcpy(dlb_args_from_env, env);
1195 }
1196
1197 /* Pointer to rhs to be parsed */
1198 284 const char *rhs = NULL;
1199
1200 /* Set-up specific argument length */
1201 size_t arg_max_len;
1202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 284 times.
284 switch (entry->type) {
1203 ✗ case OPT_PTR_PATH_T:
1204 ✗ arg_max_len = PATH_MAX-1;
1205 ✗ break;
1206 284 default:
1207 284 arg_max_len = MAX_OPTION_LENGTH-1;
1208 284 break;
1209 }
1210
1211 /* Preallocate a buffer large enough to save the option value */
1212 284 char *arg_value_from_env = malloc(sizeof(char)*(arg_max_len+1));
1213 284 arg_value_from_env[0] = '\0';
1214
1215 /* Parse DLB_ARGS from env */
1216
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 9 times.
284 if (dlb_args_from_env) {
1217 275 parse_dlb_args(dlb_args_from_env, entry->arg_name, arg_value_from_env, arg_max_len);
1218
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 245 times.
275 if (strlen(arg_value_from_env) > 0) {
1219 30 rhs = arg_value_from_env;
1220 }
1221 }
1222
1223 /* Assign option = rhs, and nullify rhs if error */
1224
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 254 times.
284 if (rhs) {
1225 30 int error = set_value(entry->type, option, rhs);
1226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (error) {
1227 ✗ rhs = NULL;
1228 }
1229 }
1230
1231 /* Set default value if needed */
1232
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 30 times.
284 if (!rhs) {
1233 254 set_value(entry->type, option, entry->default_value);
1234 }
1235
1236 /* Free buffers */
1237 284 free(arg_value_from_env);
1238
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 9 times.
284 if (dlb_args_from_env) {
1239 275 free(dlb_args_from_env);
1240 }
1241 }
1242 300 }
1243
1244 /* API Setter */
1245 8 int options_set_variable(options_t *options, const char *var_name, const char *value) {
1246 int error;
1247 8 const opts_dict_t *entry = get_entry_by_name(var_name);
1248
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if (entry) {
1249
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (entry->flags & OPT_READONLY) {
1250 3 error = DLB_ERR_PERM;
1251 } else {
1252 4 error = set_value(entry->type, (char*)options+entry->offset, value);
1253 }
1254 } else {
1255 1 error = DLB_ERR_NOENT;
1256 }
1257
1258 8 return error;
1259 }
1260
1261 /* API Getter */
1262 14 int options_get_variable(const options_t *options, const char *var_name, char *value) {
1263 int error;
1264 14 const opts_dict_t *entry = get_entry_by_name(var_name);
1265
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 if (entry) {
1266 13 sprintf(value, "%s", get_value(entry->type, (char*)options+entry->offset));
1267 13 error = DLB_SUCCESS;
1268 } else {
1269 1 error = DLB_ERR_NOENT;
1270 }
1271
1272 14 return error;
1273 }
1274
1275 /* API Printer. Also, dlb -h/-hh output */
1276 4 void options_print_variables(const options_t *options, bool print_extended) {
1277
1278 /* Initialize buffer */
1279 print_buffer_t buffer;
1280 4 printbuffer_init(&buffer);
1281
1282 /* Set up intermediate buffer per entry */
1283 enum { MAX_ENTRY_LEN = 256 };
1284 char entry_buffer[MAX_ENTRY_LEN];
1285
1286 /* Header (last \n is not needed) */
1287 4 printbuffer_append(&buffer,
1288 "DLB Options:\n\n"
1289 "DLB is configured by setting these flags in the DLB_ARGS environment variable.\n"
1290 "Possible options are listed below:\n\n"
1291 "Option Current value Possible value (type) / [choice] / {val1:val2}\n"
1292 "--------------------------------------------------------------------------------------"
1293 );
1294
1295 int i;
1296
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 4 times.
204 for (i=0; i<NUM_OPTIONS; ++i) {
1297 200 const opts_dict_t *entry = &options_dictionary[i];
1298
1299 /* Skip if deprecated */
1300
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 176 times.
200 if (entry->flags & OPT_DEPRECATED) continue;
1301
1302 /* Skip if hidden */
1303
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 172 times.
176 if (entry->flags & OPT_HIDDEN) continue;
1304
1305 /* Skip if advanced (unless print_extended) */
1306
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 132 times.
172 if (entry->flags & OPT_ADVANCED
1307
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 10 times.
40 && !print_extended) continue;
1308
1309 /* Reset entry buffer */
1310 142 entry_buffer[0] = '\0';
1311 142 char *b = entry_buffer;
1312 142 size_t max_entry_len = MAX_ENTRY_LEN;
1313
1314 /* Name */
1315 142 size_t name_len = strlen(entry->arg_name) + 1;
1316
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 13 times.
142 if (name_len < 24) {
1317 /* Option + tabs until column 24 */
1318
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 24 times.
234 b += snprintf(b, max_entry_len, "%s:%s",
1319 129 entry->arg_name,
1320
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 53 times.
105 name_len < 8 ? "\t\t\t" : name_len < 16 ? "\t\t" : "\t");
1321 } else {
1322 /* Long option, break line */
1323 13 b += snprintf(b, max_entry_len, "%s:\n\t\t\t",
1324 13 entry->arg_name);
1325 }
1326
1327 /* Check if output was truncated, and update remaining entry length */
1328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 fatal_cond((b - entry_buffer) >= MAX_ENTRY_LEN,
1329 "Output truncated in in %s. Please report bug at %s",
1330 __func__, PACKAGE_BUGREPORT);
1331 142 max_entry_len = MAX_ENTRY_LEN - (b - entry_buffer);
1332
1333 /* Value */
1334 142 const char *value = get_value(entry->type, (char*)options+entry->offset);
1335 142 size_t value_len = strlen(value) + 1;
1336
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 125 times.
159 b += snprintf(b, max_entry_len, "%s %s",
1337 value,
1338
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 value_len < 8 ? "\t\t" : value_len < 16 ? "\t" : "");
1339
1340 /* Check if output was truncated, and update remaining entry length */
1341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 fatal_cond((b - entry_buffer) >= MAX_ENTRY_LEN,
1342 "Output truncated in in %s. Please report bug at %s",
1343 __func__, PACKAGE_BUGREPORT);
1344 142 max_entry_len = MAX_ENTRY_LEN - (b - entry_buffer);
1345
1346 /* Choices */
1347
17/20
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 4 times.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
142 switch(entry->type) {
1348 60 case OPT_BOOL_T:
1349 60 b += snprintf(b, max_entry_len, "(bool)");
1350 60 break;
1351 ✗ case OPT_NEG_BOOL_T:
1352 ✗ b += snprintf(b, max_entry_len, "(bool)");
1353 ✗ break;
1354 23 case OPT_INT_T:
1355 23 b += snprintf(b, max_entry_len, "(int)");
1356 23 break;
1357 9 case OPT_STR_T:
1358 9 b += snprintf(b, max_entry_len, "(string)");
1359 9 break;
1360 4 case OPT_PTR_PATH_T:
1361 4 b += snprintf(b, max_entry_len, "(path)");
1362 4 break;
1363 4 case OPT_VB_T:
1364 4 b += snprintf(b, max_entry_len, "{%s}", get_verbose_opts_choices());
1365 4 break;
1366 4 case OPT_VBFMT_T:
1367 4 b += snprintf(b, max_entry_len, "{%s}", get_verbose_fmt_choices());
1368 4 break;
1369 4 case OPT_INST_T:
1370 4 b += snprintf(b, max_entry_len, "{%s}", get_instrument_items_choices());
1371 4 break;
1372 1 case OPT_DBG_T:
1373 1 b += snprintf(b, max_entry_len, "{%s}", get_debug_opts_choices());
1374 1 break;
1375 4 case OPT_LEWI_AFF_T:
1376 4 b += snprintf(b, max_entry_len, "[%s]", get_lewi_affinity_choices());
1377 4 break;
1378 ✗ case OPT_MASK_T:
1379 ✗ b += snprintf(b, max_entry_len, "(cpuset)");
1380 ✗ break;
1381 4 case OPT_MODE_T:
1382 4 b += snprintf(b, max_entry_len, "[%s]", get_mode_choices());
1383 4 break;
1384 4 case OPT_MPISET_T:
1385 4 b += snprintf(b, max_entry_len, "[%s]", get_mpiset_choices());
1386 4 break;
1387 4 case OPT_OMPTOPTS_T:
1388 4 b += snprintf(b, max_entry_len, "[%s]", get_omptool_opts_choices());
1389 4 break;
1390 4 case OPT_TLPSUM_T:
1391 4 b += snprintf(b, max_entry_len, "{%s}", get_talp_summary_choices());
1392 4 break;
1393 1 case OPT_TLPMOD_T:
1394 1 b += snprintf(b, max_entry_len, "[%s]", get_talp_model_choices());
1395 1 break;
1396 4 case OPT_TLPCOM_T:
1397 4 b += snprintf(b, max_entry_len, "{%s}", get_talp_component_choices());
1398 4 break;
1399 4 case OPT_MNGO_MODE_T:
1400 4 b += snprintf(b, max_entry_len, "{%s}", get_mngo_mode_choices());
1401 4 break;
1402 4 case OPT_OMPTM_T:
1403 4 b += snprintf(b, max_entry_len, "[%s]", get_omptm_version_choices());
1404 4 break;
1405 }
1406
1407 /* Check if output was truncated */
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 fatal_cond((b - entry_buffer) >= MAX_ENTRY_LEN,
1409 "Buffer overflow in %s. Please report bug at %s",
1410 __func__, PACKAGE_BUGREPORT);
1411
1412 /* Append entry listing */
1413 142 printbuffer_append(&buffer, entry_buffer);
1414
1415 /* Append long description if print_extended */
1416
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 99 times.
142 if (print_extended) {
1417 43 printbuffer_append(&buffer, entry->description);
1418 43 printbuffer_append(&buffer, "");
1419 }
1420
1421 }
1422
1423 /* Footer (last \n is not needed) */
1424 4 printbuffer_append(&buffer,
1425 "\n"
1426 "Boolean options accept both standalone flags and 'yes'/'no' parameters.\n"
1427 "These are equivalent flags:\n"
1428 " export DLB_ARGS=\"--lewi --no-drom\"\n"
1429 " export DLB_ARGS=\"--lewi=yes --drom=no\"");
1430
1431 /* This function must print always and ignore options --quiet and --silent */
1432 4 info0_force_print("%s", buffer.addr);
1433
1434 4 printbuffer_destroy(&buffer);
1435 4 }
1436
1437 /* Print which LeWI flags are enabled during DLB_Init */
1438 62 void options_print_lewi_flags(const options_t *options) {
1439 const opts_dict_t *entry;
1440
1441 // --lewi-mpi
1442 bool default_lewi_keep_one_cpu;
1443 62 entry = get_entry_by_name("--lewi-keep-one-cpu");
1444 62 parse_bool(entry->default_value, &default_lewi_keep_one_cpu);
1445
1446 // --lewi-mpi-calls
1447 mpi_set_t default_lewi_mpi_calls;
1448 62 entry = get_entry_by_name("--lewi-mpi-calls");
1449 62 parse_mpiset(entry->default_value, &default_lewi_mpi_calls);
1450
1451 // --lewi-affinity
1452 lewi_affinity_t default_lewi_affinity;
1453 62 entry = get_entry_by_name("--lewi-affinity");
1454 62 parse_lewi_affinity(entry->default_value, &default_lewi_affinity);
1455
1456 // --lewi-ompt
1457 omptool_opts_t default_lewi_ompt;
1458 62 entry = get_entry_by_name("--lewi-ompt");
1459 62 parse_omptool_opts(entry->default_value, &default_lewi_ompt);
1460
1461
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if (options->lewi_keep_cpu_on_blocking_call != default_lewi_keep_one_cpu
1462
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 || options->lewi_mpi_calls != default_lewi_mpi_calls
1463
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 30 times.
62 || options->lewi_affinity != default_lewi_affinity
1464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 || options->lewi_ompt != default_lewi_ompt) {
1465 30 info0("LeWI options:");
1466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (options->lewi_keep_cpu_on_blocking_call != default_lewi_keep_one_cpu) {
1467 ✗ info0(" --lewi-keep-one-cpu");
1468 }
1469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (options->lewi_mpi_calls != default_lewi_mpi_calls) {
1470 ✗ info0(" --lewi-mpi-calls=%s", mpiset_tostr(options->lewi_mpi_calls));
1471 }
1472
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (options->lewi_affinity != default_lewi_affinity) {
1473 30 info0(" --lewi-affinity=%s", lewi_affinity_tostr(options->lewi_affinity));
1474 }
1475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (options->lewi_ompt != default_lewi_ompt) {
1476 ✗ info0(" --lewi-ompt=%s", omptool_opts_tostr(options->lewi_ompt));
1477 }
1478 }
1479 62 }
1480