GCC Code Coverage Report


Directory: src/
File: src/mngo/mngo_resources.c
Date: 2026-09-15 07:37:49
Exec Total Coverage
Lines: 14 18 77.8%
Functions: 1 1 100.0%
Branches: 13 22 59.1%

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 #include "mngo/mngo_resources.h"
21 #include "LB_comm/shmem_mngo.h"
22 #include "LB_comm/shmem_procinfo.h"
23 #include "LB_core/DLB_kernel.h"
24 #include "LB_core/spd.h"
25 #include "dlb_errors.h"
26 #include "support/debug.h"
27 #include "support/mask_utils.h"
28
29 30 int mngo_state__load(subprocess_descriptor_t *spd, mngo_state_t *state) {
30 // Make sure to stop lewi if is not available for this region
31 // (!lewi_enabled), and always enable it when its available (lewi_enabled)
32 // for that region and MNGO has decided that is useful for this region
33 // (lewi_on).
34
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
30 set_lewi_enabled(spd, spd->options.lewi && state->lewi_on);
35
36
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 14 times.
30 if (spd->options.drom) {
37 int error;
38
39 cpu_set_t current_mask;
40 16 shmem_procinfo__getprocessmask(0, &current_mask, DLB_DROM_FLAGS_NONE);
41
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 verbose(VB_MNGO, "(Loading State) Old mask: %s",
42 mu_to_str(&current_mask));
43
44 // For DROM to update the process mask correctly, we need to first free
45 // the cpus that other processes might add in their mask. For that we
46 // need to set our mask to the cpus that we have and are going to keep,
47 // this operation is the CPU_AND.
48 cpu_set_t intermediate_mask;
49
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 16 times.
272 CPU_AND(&intermediate_mask, &current_mask, &state->drom_mask);
50
51
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 verbose(VB_MNGO, "(Loading State) Int mask: %s",
52 mu_to_str(&intermediate_mask));
53 16 error = drom_setprocessmask(0, &intermediate_mask, DLB_DROM_FLAGS_NONE);
54
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (error != DLB_SUCCESS) {
55 verbose(
56 VB_MNGO,
57 "Could not free cpus by setting process intermediate mask %s",
58 mu_to_str(&intermediate_mask));
59 return DLB_NOUPDT;
60 }
61
62 // We then syncronize with all the other processes from the node to
63 // make sure that when we set the new_mask all the cpus that we'll
64 // aquire will be in the free list.
65 16 shmem_mngo_barrier_wait();
66
67
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 verbose(VB_MNGO, "(Loading State) New mask: %s",
68 mu_to_str(&(state->drom_mask)));
69 16 error = drom_setprocessmask(0, &(state->drom_mask), DLB_DROM_FLAGS_NONE);
70
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (error != DLB_SUCCESS) {
71 verbose(VB_MNGO, "Could not register new mask %s",
72 mu_to_str(&state->drom_mask));
73 return DLB_ERR_PERM;
74 }
75 }
76
77 30 return DLB_SUCCESS;
78 }
79