GCC Code Coverage Report


Directory: src/
File: src/LB_core/DLB_kernel.c
Date: 2026-09-15 07:37:49
Exec Total Coverage
Lines: 318 400 79.5%
Functions: 33 35 94.3%
Branches: 212 290 73.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 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include "LB_core/DLB_kernel.h"
25
26 #include "LB_core/fork_handler.h"
27 #include "LB_core/node_barrier.h"
28 #include "LB_core/spd.h"
29 #include "LB_core/thread_ctx.h"
30 #include "LB_numThreads/numThreads.h"
31 #include "LB_numThreads/omptool.h"
32 #include "LB_comm/shmem_async.h"
33 #include "LB_comm/shmem_barrier.h"
34 #include "LB_comm/shmem_cpuinfo.h"
35 #include "LB_comm/shmem_procinfo.h"
36 #include "LB_comm/shmem_talp.h"
37 #include "LB_comm/shmem_mngo.h"
38 #include "apis/dlb_errors.h"
39 #include "apis/dlb_talp.h"
40 #include "support/debug.h"
41 #include "support/mytime.h"
42 #include "support/tracing.h"
43 #include "support/options.h"
44 #include "support/mask_utils.h"
45 #include "talp/backend_manager.h"
46 #include "talp/talp.h"
47 #include "talp/talp_mpi.h"
48 #include "mngo/mngo.h"
49 #ifdef MPI_LIB
50 #include "mpi/mpi_core.h"
51 #endif
52
53 #include <limits.h>
54 #include <sched.h>
55 #include <string.h>
56
57
58 /* Status */
59
60 117 int Initialize(subprocess_descriptor_t *spd, pid_t id, int ncpus,
61 const cpu_set_t *mask, const char *lb_args) {
62
63 117 int error = DLB_SUCCESS;
64
65 117 thread_ctx_set_main(THREAD_MAIN_SEQUENTIAL);
66
67 // Initialize common modules (spd->id and instrumentation module ASAP)
68 117 *spd = (const subprocess_descriptor_t) {
69 .id = id,
70 117 .pid = getpid(),
71 117 .dlb_initialized = spd->dlb_initialized,
72 117 .dlb_preinitialized = spd->dlb_preinitialized,
73 117 .dlb_initialized_via_ompt = spd->dlb_initialized_via_ompt,
74 };
75 117 options_init(&spd->options, lb_args);
76 117 debug_init(&spd->options);
77 init_tracing(&spd->options);
78 instrument_event(RUNTIME_EVENT, EVENT_INIT, EVENT_BEGIN);
79 117 mu_init();
80 117 timer_init();
81 117 fork_handler_init();
82
83 // Infer LeWI mode
84 117 spd->lb_policy =
85
4/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 3 times.
179 !spd->options.lewi ? POLICY_NONE :
86
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 30 times.
62 spd->options.lewi_affinity == LEWI_AFFINITY_NONE ? POLICY_LEWI :
87
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 spd->options.lewi_affinity != LEWI_AFFINITY_AUTO ? POLICY_LEWI_MASK :
88
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
32 spd->dlb_initialized_via_ompt ? POLICY_LEWI_MASK :
89
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
14 spd->options.mngo ? POLICY_LEWI_MASK :
90
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 spd->options.preinit_pid ? POLICY_LEWI_MASK :
91 mask ? POLICY_LEWI_MASK :
92 POLICY_LEWI;
93
94
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 84 times.
117 if (spd->lb_policy == POLICY_LEWI
95
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 28 times.
33 && spd->options.mode == MODE_ASYNC) {
96 5 spd->lb_policy = POLICY_LEWI_ASYNC;
97 }
98
99 // Check if real process mask is needed and possible incompatibilities
100 // (Basically, always except if classic LeWI)
101 117 bool mask_is_needed = (
102 117 spd->lb_policy == POLICY_LEWI_MASK
103
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 27 times.
88 || spd->options.drom
104
4/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 56 times.
205 || spd->options.preinit_pid);
105
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 56 times.
117 if (mask_is_needed &&
106
2/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
61 (spd->lb_policy == POLICY_LEWI || spd->lb_policy == POLICY_LEWI_ASYNC)) {
107 warning("Classic LeWI support with no cpuset binding is not compatible"
108 " with newer DLB modules. DLB_Init cannot continue.");
109 return DLB_ERR_NOCOMP;
110 }
111
112 // Initialize the rest of the subprocess descriptor
113 117 pm_init(&spd->pm);
114 117 set_lb_funcs(&spd->lb_funcs, spd->lb_policy);
115
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 46 times.
117 if (mask) {
116 // Preferred case, mask is provided by the user
117 71 memcpy(&spd->process_mask, mask, sizeof(cpu_set_t));
118 } else {
119 // Best effort querying the system
120 // (it may be late if DLB_Init is called after other RT sets this thread's affinity)
121 46 sched_getaffinity(0, sizeof(cpu_set_t), &spd->process_mask);
122 }
123
124 // ncpus is only used for classic LeWI
125
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 28 times.
117 if (spd->lb_policy == POLICY_LEWI
126
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 84 times.
89 || spd->lb_policy == POLICY_LEWI_ASYNC) {
127
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 4 times.
33 spd->lewi_ncpus = ncpus > 0 ? ncpus : pm_get_num_threads();
128 }
129
130 // Initialize shared memories
131
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 56 times.
117 if (mask_is_needed) {
132 // Initialize procinfo
133
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (spd->options.lewi_color == 0) {
134 cpu_set_t new_process_mask;
135 61 error = shmem_procinfo__init(spd->id, spd->options.preinit_pid,
136 61 &spd->process_mask, &new_process_mask, spd->options.shm_key,
137 spd->options.shm_size_multiplier);
138
139 // If the process has been pre-initialized (error=DLB_NOTED),
140 // the mask provided by shmem_procinfo__init must overwrite the process mask
141
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 45 times.
61 if (error == DLB_NOTED) {
142 16 set_process_mask(&spd->pm, &new_process_mask);
143 16 memcpy(&spd->process_mask, &new_process_mask, sizeof(cpu_set_t));
144 16 error = DLB_SUCCESS;
145 }
146 } else {
147 // If using --lewi-color, we also need to initialize procinfo with cpu sharing
148 error = shmem_procinfo__init_with_cpu_sharing(spd->id, spd->options.preinit_pid,
149 &spd->process_mask, spd->options.shm_key, spd->options.shm_size_multiplier);
150 }
151
152
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 59 times.
61 if (error != DLB_SUCCESS) return error;
153
154 // Initialize cpuinfo
155 59 error = shmem_cpuinfo__init(spd->id, spd->options.preinit_pid,
156 59 &spd->process_mask, spd->options.shm_key, spd->options.lewi_color);
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if (error != DLB_SUCCESS) return error;
158
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 44 times.
56 } else if (spd->options.talp) {
159 // If mask is not needed but TALP is enabled, we still need to
160 // initialize shmem_procinfo but allowing CPU sharing
161 12 error = shmem_procinfo__init_with_cpu_sharing(spd->id, spd->options.preinit_pid,
162 12 &spd->process_mask, spd->options.shm_key, spd->options.shm_size_multiplier);
163 }
164
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 if (spd->options.barrier) {
165 112 shmem_barrier__init(spd->options.shm_key, spd->options.shm_size_multiplier);
166 112 node_barrier_init(spd);
167 }
168
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 104 times.
115 if (spd->options.mode == MODE_ASYNC) {
169 11 error = shmem_async_init(spd->id, &spd->pm, &spd->process_mask,
170 11 spd->options.shm_key, spd->options.shm_size_multiplier);
171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (error != DLB_SUCCESS) return error;
172 }
173
174 // Initialise LeWI
175 115 error = spd->lb_funcs.init(spd);
176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if (error != DLB_SUCCESS) return error;
177 115 spd->lewi_enabled = true;
178
179 /**
180 * If MNGO is enabled with LeWI support we want to start the execution with
181 * LeWI dormant.
182 */
183
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
115 if (spd->options.mngo && spd->options.lewi) {
184 4 spd->lewi_enabled = false;
185 4 spd->lb_funcs.disable(spd);
186 }
187
188 // Initialize TALP
189
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if (spd->options.talp) {
190 28 talp_init(spd);
191 } else {
192 87 spd->talp_info = NULL;
193 }
194
195 // Print initialization summary
196 115 info0("%s %s", PACKAGE, VERSION);
197
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 53 times.
115 if (spd->lb_policy != POLICY_NONE) {
198 62 info0("Balancing policy: %s", policy_tostr(spd->lb_policy));
199 62 options_print_lewi_flags(&spd->options);
200 }
201 instrument_print_flags();
202
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_API, "Enabled verbose mode for DLB API");
203
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_MPI_API, "Enabled verbose mode for MPI API");
204
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_MPI_INT, "Enabled verbose mode for MPI Interception");
205
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_SHMEM, "Enabled verbose mode for Shared Memory");
206
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_DROM, "Enabled verbose mode for DROM");
207
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_STATS, "Enabled verbose mode for STATS");
208
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_MICROLB, "Enabled verbose mode for microLB policies");
209
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_ASYNC, "Enabled verbose mode for Asynchronous thread");
210
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose0(VB_OMPT, "Enabled verbose mode for OMPT experimental features");
211
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 107 times.
115 verbose(VB_MNGO, "Enabled verbose mode for MNGO");
212
213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if (spd->options.verbose & VB_AFFINITY) {
214 print_buffer_t buffer;
215 mu_get_system_description(&buffer);
216 verbose0(VB_AFFINITY, "System affinity\n%s", buffer.addr);
217 printbuffer_destroy(&buffer);
218 }
219
220 // Print number of cpus or mask
221
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 56 times.
115 if (mask_is_needed) {
222 59 info("Process CPU affinity mask: %s", mu_to_str(&spd->process_mask));
223 }
224
225 instrument_event(RUNTIME_EVENT, EVENT_INIT, EVENT_END);
226 115 if (spd->lewi_enabled) {
227 instrument_event(DLB_MODE_EVENT, EVENT_ENABLED, EVENT_BEGIN);
228 }
229
230 115 return error;
231 }
232
233 115 int Finish(subprocess_descriptor_t *spd) {
234
235 /* Protect finalization if spd does not match with current process */
236
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
115 if (spd->pid != getpid()) {
237 return DLB_NOUPDT;
238 }
239
240 115 int error = DLB_SUCCESS;
241 instrument_event(RUNTIME_EVENT, EVENT_FINALIZE, EVENT_BEGIN);
242
243 #if MPI_LIB
244 /* If DLB_Finalize is called preemptively, we need to finalize also the MPI
245 * module */
246 mpi_core_finalize();
247 #endif
248
249 115 spd->lewi_enabled = false;
250
251 115 pm_finalize(&spd->pm);
252
253
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if (spd->options.talp) {
254 28 talp_finalize(spd);
255 }
256
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (spd->lb_funcs.finalize) {
257 115 spd->lb_funcs.finalize(spd);
258 115 spd->lb_funcs.finalize = NULL;
259 }
260
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 if (spd->options.barrier) {
261 112 node_barrier_finalize(spd);
262 112 shmem_barrier__finalize(spd->options.shm_key, spd->options.shm_size_multiplier);
263 }
264
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 29 times.
115 if (spd->lb_policy == POLICY_LEWI_MASK
265
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 25 times.
86 || spd->options.drom
266
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 12 times.
61 || spd->options.talp
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 || spd->options.ompt
268 || spd->options.preinit_pid) {
269 115 shmem_cpuinfo__finalize(spd->id, spd->options.shm_key, spd->options.lewi_color);
270 115 shmem_procinfo__finalize(spd->id, spd->options.debug_opts & DBG_RETURNSTOLEN,
271 115 spd->options.shm_key, spd->options.shm_size_multiplier);
272 }
273
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 104 times.
115 if (spd->options.mode == MODE_ASYNC) {
274 11 shmem_async_finalize(spd->id);
275 }
276 115 timer_finalize();
277 instrument_event(RUNTIME_EVENT, EVENT_FINALIZE, EVENT_END);
278 instrument_finalize();
279 115 options_finalize(&spd->options);
280 115 return error;
281 }
282
283 7 int PreInitialize(subprocess_descriptor_t *spd, const cpu_set_t *mask,
284 const char *lb_args) {
285 // Initialize options
286 7 options_init(&spd->options, lb_args);
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (spd->options.preinit_pid == 0) return DLB_ERR_INIT;
288
289 7 debug_init(&spd->options);
290
291 // Initialize subprocess descriptor
292 7 spd->lb_policy = POLICY_NONE;
293 7 pm_init(&spd->pm);
294 7 set_lb_funcs(&spd->lb_funcs, spd->lb_policy);
295 7 spd->id = spd->options.preinit_pid;
296 7 memcpy(&spd->process_mask, mask, sizeof(cpu_set_t));
297
298 // Initialize modules
299 7 int error = DLB_SUCCESS;
300
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 error = error ? error : shmem_cpuinfo_ext__init(spd->options.shm_key, spd->options.lewi_color);
301
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 error = error ? error : shmem_procinfo_ext__init(spd->options.shm_key,
302 spd->options.shm_size_multiplier);
303
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 error = error ? error : shmem_procinfo_ext__preinit(spd->id, mask, DLB_DROM_FLAGS_NONE);
304
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 error = error ? error : shmem_cpuinfo_ext__preinit(spd->id, mask, DLB_DROM_FLAGS_NONE);
305 // Close shmems even if there was an error
306 7 int cpuinfo_finalize_err = shmem_cpuinfo_ext__finalize();
307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 error = error ? error : cpuinfo_finalize_err;
308 7 int procinfo_finalize_err = shmem_procinfo_ext__finalize();
309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 error = error ? error : procinfo_finalize_err;
310 7 return error;
311 }
312
313 48 int set_lewi_enabled(subprocess_descriptor_t *spd, bool enabled) {
314 48 int error = DLB_SUCCESS;
315
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 22 times.
48 if (__sync_bool_compare_and_swap(&spd->lewi_enabled, !enabled, enabled)) {
316
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15 times.
26 if (enabled) {
317 11 spd->lb_funcs.enable(spd);
318 instrument_event(DLB_MODE_EVENT, EVENT_ENABLED, EVENT_BEGIN);
319 } else {
320 15 spd->lb_funcs.disable(spd);
321 instrument_event(DLB_MODE_EVENT, EVENT_DISABLED, EVENT_BEGIN);
322 }
323 } else {
324 22 error = DLB_NOUPDT;
325 }
326 48 return error;
327 }
328
329 5 int set_max_parallelism(subprocess_descriptor_t *spd, int max) {
330 int error;
331
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!spd->options.lewi) {
332 3 error = DLB_ERR_NOLEWI;
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (!spd->lewi_enabled) {
334 error = DLB_ERR_DISBLD;
335 } else {
336 instrument_event(RUNTIME_EVENT, EVENT_MAX_PARALLELISM, EVENT_BEGIN);
337 instrument_event(MAX_PAR_EVENT, 0, EVENT_END);
338 instrument_event(MAX_PAR_EVENT, max, EVENT_BEGIN);
339 2 error = spd->lb_funcs.set_max_parallelism(spd, max);
340 instrument_event(RUNTIME_EVENT, EVENT_MAX_PARALLELISM, EVENT_END);
341 }
342 5 return error;
343 }
344
345 3 int unset_max_parallelism(subprocess_descriptor_t *spd) {
346 int error;
347
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (!spd->options.lewi) {
348 1 error = DLB_ERR_NOLEWI;
349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (!spd->lewi_enabled) {
350 error = DLB_ERR_DISBLD;
351 } else {
352 instrument_event(RUNTIME_EVENT, EVENT_MAX_PARALLELISM, EVENT_BEGIN);
353 instrument_event(MAX_PAR_EVENT, 0, EVENT_END);
354 2 error = spd->lb_funcs.unset_max_parallelism(spd);
355 instrument_event(RUNTIME_EVENT, EVENT_MAX_PARALLELISM, EVENT_END);
356 }
357 3 return error;
358 }
359
360
361 /* Sync-call specific (MPI, DLB_Barrier, etc.) */
362
363 40 void into_sync_call(sync_call_flags_t flags) {
364 /* Observer threads do not trigger LeWI nor TALP on sync calls */
365
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 38 times.
40 if (unlikely(thread_is_observer())) return;
366
367 38 const subprocess_descriptor_t *spd = thread_spd;
368
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 36 times.
38 if (unlikely(spd == NULL)) return;
369
370
6/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 5 times.
36 if (flags.do_lewi && spd->options.lewi && spd->lewi_enabled) {
371 18 spd->lb_funcs.into_blocking_call(spd);
372 18 omptool__into_blocking_call();
373 }
374
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 if(spd->options.talp) {
375 14 talp_into_sync_call(spd, flags);
376 }
377 }
378
379 40 void out_of_sync_call(sync_call_flags_t flags) {
380 /* Observer threads do not trigger LeWI nor TALP on MPI calls */
381
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 38 times.
40 if (unlikely(thread_is_observer())) return;
382
383 38 const subprocess_descriptor_t *spd = thread_spd;
384
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 36 times.
38 if (unlikely(spd == NULL)) return;
385
386
6/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 6 times.
36 if (spd->options.lewi && spd->lewi_enabled && flags.do_lewi) {
387 18 spd->lb_funcs.out_of_blocking_call(spd);
388 18 omptool__outof_blocking_call();
389 }
390
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 if(spd->options.talp) {
391 14 talp_out_of_sync_call(spd, flags);
392 }
393 }
394
395
396 /* Lend */
397
398 8 int lend(const subprocess_descriptor_t *spd) {
399 int error;
400
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if (!spd->options.lewi) {
401 6 error = DLB_ERR_NOLEWI;
402
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 } else if (!spd->lewi_enabled) {
403 2 error = DLB_ERR_DISBLD;
404 } else {
405 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_BEGIN);
406 instrument_event(GIVE_CPUS_EVENT, CPU_SETSIZE, EVENT_BEGIN);
407 omptool__lend_from_api();
408 error = spd->lb_funcs.lend(spd);
409 instrument_event(GIVE_CPUS_EVENT, 0, EVENT_END);
410 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_END);
411 }
412 8 return error;
413 }
414
415 40 int lend_cpu(const subprocess_descriptor_t *spd, int cpuid) {
416 int error;
417
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 37 times.
40 if (!spd->options.lewi) {
418 3 error = DLB_ERR_NOLEWI;
419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 } else if (!spd->lewi_enabled) {
420 error = DLB_ERR_DISBLD;
421 } else {
422 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_BEGIN);
423 instrument_event(GIVE_CPUS_EVENT, 1, EVENT_BEGIN);
424 37 error = spd->lb_funcs.lend_cpu(spd, cpuid);
425 instrument_event(GIVE_CPUS_EVENT, 0, EVENT_END);
426 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_END);
427 }
428 40 return error;
429 }
430
431 6 int lend_cpus(const subprocess_descriptor_t *spd, int ncpus) {
432 int error;
433
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (!spd->options.lewi) {
434 3 error = DLB_ERR_NOLEWI;
435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } else if (!spd->lewi_enabled) {
436 error = DLB_ERR_DISBLD;
437 } else {
438 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_BEGIN);
439 instrument_event(GIVE_CPUS_EVENT, ncpus, EVENT_BEGIN);
440 3 error = spd->lb_funcs.lend_cpus(spd, ncpus);
441 instrument_event(GIVE_CPUS_EVENT, 0, EVENT_END);
442 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_END);
443 }
444 6 return error;
445 }
446
447 18 int lend_cpu_mask(const subprocess_descriptor_t *spd, const cpu_set_t *mask) {
448 int error;
449
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 15 times.
18 if (!spd->options.lewi) {
450 3 error = DLB_ERR_NOLEWI;
451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 } else if (!spd->lewi_enabled) {
452 error = DLB_ERR_DISBLD;
453 } else {
454 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_BEGIN);
455 instrument_event(GIVE_CPUS_EVENT, CPU_COUNT(mask), EVENT_BEGIN);
456 15 error = spd->lb_funcs.lend_cpu_mask(spd, mask);
457 instrument_event(GIVE_CPUS_EVENT, 0, EVENT_END);
458 instrument_event(RUNTIME_EVENT, EVENT_LEND, EVENT_END);
459 }
460 18 return error;
461 }
462
463
464 /* Reclaim */
465
466 6 int reclaim(const subprocess_descriptor_t *spd) {
467 int error;
468
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (!spd->options.lewi) {
469 3 error = DLB_ERR_NOLEWI;
470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } else if (!spd->lewi_enabled) {
471 error = DLB_ERR_DISBLD;
472 } else {
473 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_BEGIN);
474 instrument_event(WANT_CPUS_EVENT, CPU_SETSIZE, EVENT_BEGIN);
475 3 error = spd->lb_funcs.reclaim(spd);
476 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
477 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_END);
478 }
479 6 return error;
480 }
481
482 5 int reclaim_cpu(const subprocess_descriptor_t *spd, int cpuid) {
483 int error;
484
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!spd->options.lewi) {
485 3 error = DLB_ERR_NOLEWI;
486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (!spd->lewi_enabled) {
487 error = DLB_ERR_DISBLD;
488 } else {
489 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_BEGIN);
490 instrument_event(WANT_CPUS_EVENT, 1, EVENT_BEGIN);
491 2 error = spd->lb_funcs.reclaim_cpu(spd, cpuid);
492 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
493 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_END);
494 }
495 5 return error;
496 }
497
498 3 int reclaim_cpus(const subprocess_descriptor_t *spd, int ncpus) {
499 int error;
500
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!spd->options.lewi) {
501 3 error = DLB_ERR_NOLEWI;
502 } else if (!spd->lewi_enabled) {
503 error = DLB_ERR_DISBLD;
504 } else {
505 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_BEGIN);
506 instrument_event(WANT_CPUS_EVENT, ncpus, EVENT_BEGIN);
507 error = spd->lb_funcs.reclaim_cpus(spd, ncpus);
508 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
509 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_END);
510 }
511 3 return error;
512 }
513
514 8 int reclaim_cpu_mask(const subprocess_descriptor_t *spd, const cpu_set_t *mask) {
515 int error;
516
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 if (!spd->options.lewi) {
517 3 error = DLB_ERR_NOLEWI;
518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 } else if (!spd->lewi_enabled) {
519 error = DLB_ERR_DISBLD;
520 } else {
521 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_BEGIN);
522 instrument_event(WANT_CPUS_EVENT, CPU_COUNT(mask), EVENT_BEGIN);
523 5 error = spd->lb_funcs.reclaim_cpu_mask(spd, mask);
524 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
525 instrument_event(RUNTIME_EVENT, EVENT_RECLAIM, EVENT_END);
526 }
527 8 return error;
528 }
529
530
531 /* Acquire */
532
533 13 int acquire_cpu(const subprocess_descriptor_t *spd, int cpuid) {
534 int error;
535
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 10 times.
13 if (!spd->options.lewi) {
536 3 error = DLB_ERR_NOLEWI;
537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 } else if (!spd->lewi_enabled) {
538 error = DLB_ERR_DISBLD;
539 } else {
540 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_BEGIN);
541 instrument_event(WANT_CPUS_EVENT, 1, EVENT_BEGIN);
542 10 error = spd->lb_funcs.acquire_cpu(spd, cpuid);
543 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
544 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_END);
545 }
546 13 return error;
547 }
548
549 61 int acquire_cpus(const subprocess_descriptor_t *spd, int ncpus) {
550 int error;
551
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 58 times.
61 if (!spd->options.lewi) {
552 3 error = DLB_ERR_NOLEWI;
553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 } else if (!spd->lewi_enabled) {
554 error = DLB_ERR_DISBLD;
555 } else {
556 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_BEGIN);
557 instrument_event(WANT_CPUS_EVENT, ncpus, EVENT_BEGIN);
558 58 error = spd->lb_funcs.acquire_cpus(spd, ncpus);
559 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
560 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_END);
561 }
562 61 return error;
563 }
564
565 12 int acquire_cpu_mask(const subprocess_descriptor_t *spd, const cpu_set_t *mask) {
566 int error;
567
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
12 if (!spd->options.lewi) {
568 3 error = DLB_ERR_NOLEWI;
569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 } else if (!spd->lewi_enabled) {
570 error = DLB_ERR_DISBLD;
571 } else {
572 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_BEGIN);
573 instrument_event(WANT_CPUS_EVENT, CPU_COUNT(mask), EVENT_BEGIN);
574 9 error = spd->lb_funcs.acquire_cpu_mask(spd, mask);
575 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
576 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_END);
577 }
578 12 return error;
579 }
580
581 14 int acquire_cpus_in_mask(const subprocess_descriptor_t *spd, int ncpus, const cpu_set_t *mask) {
582 int error;
583
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 if (!spd->options.lewi) {
584 3 error = DLB_ERR_NOLEWI;
585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 } else if (!spd->lewi_enabled) {
586 error = DLB_ERR_DISBLD;
587 } else {
588 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_BEGIN);
589 instrument_event(WANT_CPUS_EVENT, ncpus, EVENT_BEGIN);
590 11 error = spd->lb_funcs.acquire_cpus_in_mask(spd, ncpus, mask);
591 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
592 instrument_event(RUNTIME_EVENT, EVENT_ACQUIRE, EVENT_END);
593 }
594 14 return error;
595 }
596
597
598 /* Borrow */
599
600 7 int borrow(const subprocess_descriptor_t *spd) {
601 int error;
602
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (!spd->options.lewi) {
603 3 error = DLB_ERR_NOLEWI;
604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 } else if (!spd->lewi_enabled) {
605 error = DLB_ERR_DISBLD;
606 } else {
607 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_BEGIN);
608 instrument_event(WANT_CPUS_EVENT, CPU_SETSIZE, EVENT_BEGIN);
609 4 error = spd->lb_funcs.borrow(spd);
610 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
611 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_END);
612 }
613 7 return error;
614 }
615
616 3 int borrow_cpu(const subprocess_descriptor_t *spd, int cpuid) {
617 int error;
618
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!spd->options.lewi) {
619 3 error = DLB_ERR_NOLEWI;
620 } else if (!spd->lewi_enabled) {
621 error = DLB_ERR_DISBLD;
622 } else {
623 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_BEGIN);
624 instrument_event(WANT_CPUS_EVENT, 1, EVENT_BEGIN);
625 error = spd->lb_funcs.borrow_cpu(spd, cpuid);
626 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
627 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_END);
628 }
629 3 return error;
630 }
631
632 3 int borrow_cpus(const subprocess_descriptor_t *spd, int ncpus) {
633 int error;
634
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!spd->options.lewi) {
635 3 error = DLB_ERR_NOLEWI;
636 } else if (!spd->lewi_enabled) {
637 error = DLB_ERR_DISBLD;
638 } else {
639 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_BEGIN);
640 instrument_event(WANT_CPUS_EVENT, ncpus, EVENT_BEGIN);
641 error = spd->lb_funcs.borrow_cpus(spd, ncpus);
642 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
643 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_END);
644 }
645 3 return error;
646 }
647
648 3 int borrow_cpu_mask(const subprocess_descriptor_t *spd, const cpu_set_t *mask) {
649 int error;
650
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!spd->options.lewi) {
651 3 error = DLB_ERR_NOLEWI;
652 } else if (!spd->lewi_enabled) {
653 error = DLB_ERR_DISBLD;
654 } else {
655 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_BEGIN);
656 instrument_event(WANT_CPUS_EVENT, CPU_COUNT(mask), EVENT_BEGIN);
657 error = spd->lb_funcs.borrow_cpu_mask(spd, mask);
658 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
659 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_END);
660 }
661 3 return error;
662 }
663
664 7 int borrow_cpus_in_mask(const subprocess_descriptor_t *spd, int ncpus, const cpu_set_t *mask) {
665 int error;
666
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (!spd->options.lewi) {
667 3 error = DLB_ERR_NOLEWI;
668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 } else if (!spd->lewi_enabled) {
669 error = DLB_ERR_DISBLD;
670 } else {
671 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_BEGIN);
672 instrument_event(WANT_CPUS_EVENT, ncpus, EVENT_BEGIN);
673 4 error = spd->lb_funcs.borrow_cpus_in_mask(spd, ncpus, mask);
674 instrument_event(WANT_CPUS_EVENT, 0, EVENT_END);
675 instrument_event(RUNTIME_EVENT, EVENT_BORROW, EVENT_END);
676 }
677 7 return error;
678 }
679
680 /* Return */
681
682 3 int return_all(const subprocess_descriptor_t *spd) {
683 int error;
684
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!spd->options.lewi) {
685 3 error = DLB_ERR_NOLEWI;
686 } else if (!spd->lewi_enabled) {
687 error = DLB_ERR_DISBLD;
688 } else {
689 instrument_event(RUNTIME_EVENT, EVENT_RETURN, EVENT_BEGIN);
690 error = spd->lb_funcs.return_all(spd);
691 instrument_event(RUNTIME_EVENT, EVENT_RETURN, EVENT_END);
692 }
693 3 return error;
694 }
695
696 19 int return_cpu(const subprocess_descriptor_t *spd, int cpuid) {
697 int error;
698
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 16 times.
19 if (!spd->options.lewi) {
699 3 error = DLB_ERR_NOLEWI;
700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 } else if (!spd->lewi_enabled) {
701 error = DLB_ERR_DISBLD;
702 } else {
703 instrument_event(RUNTIME_EVENT, EVENT_RETURN, EVENT_BEGIN);
704 16 error = spd->lb_funcs.return_cpu(spd, cpuid);
705 instrument_event(RUNTIME_EVENT, EVENT_RETURN, EVENT_END);
706 }
707 19 return error;
708 }
709
710 3 int return_cpu_mask(const subprocess_descriptor_t *spd, const cpu_set_t *mask) {
711 int error;
712
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!spd->options.lewi) {
713 3 error = DLB_ERR_NOLEWI;
714 } else if (!spd->lewi_enabled) {
715 error = DLB_ERR_DISBLD;
716 } else {
717 instrument_event(RUNTIME_EVENT, EVENT_RETURN, EVENT_BEGIN);
718 error = spd->lb_funcs.return_cpu_mask(spd, mask);
719 instrument_event(RUNTIME_EVENT, EVENT_RETURN, EVENT_END);
720 }
721 3 return error;
722 }
723
724
725 /* Drom Responsive */
726
727 20 int poll_drom(const subprocess_descriptor_t *spd, int *new_cpus, cpu_set_t *new_mask) {
728 int error;
729
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 18 times.
20 if (!spd->options.drom) {
730 2 error = DLB_ERR_NOCOMP;
731 } else {
732 instrument_event(RUNTIME_EVENT, EVENT_POLLDROM, EVENT_BEGIN);
733 // Use a local mask if new_mask was not provided
734 cpu_set_t local_mask;
735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 cpu_set_t *mask = new_mask ? new_mask : &local_mask;
736
737 18 error = shmem_procinfo__polldrom(spd->id, new_cpus, mask);
738
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 15 times.
18 if (error == DLB_SUCCESS) {
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (spd->options.lewi) {
740 /* If LeWI, resolve reclaimed CPUs */
741 spd->lb_funcs.update_ownership(spd, mask);
742 } else {
743 /* Otherwise, udate owner and guest data */
744 3 shmem_cpuinfo__update_ownership(spd->id, mask, NULL);
745 }
746 }
747 instrument_event(RUNTIME_EVENT, EVENT_POLLDROM, EVENT_END);
748 }
749 20 return error;
750 }
751
752 15 int poll_drom_update(const subprocess_descriptor_t *spd) {
753 cpu_set_t new_mask;
754 15 int error = poll_drom(spd, NULL, &new_mask);
755
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
15 if (error == DLB_SUCCESS) {
756 2 set_process_mask(&spd->pm, &new_mask);
757 }
758 15 return error;
759 }
760
761 46 int drom_setprocessmask(int pid, const_dlb_cpu_set_t mask, dlb_drom_flags_t flags) {
762 cpu_set_t free_cpu_mask;
763 46 int error = shmem_procinfo__setprocessmask(pid, mask, flags, &free_cpu_mask);
764
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 8 times.
46 if (error == DLB_SUCCESS
765
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 35 times.
38 && thread_spd->dlb_initialized
766
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
3 && (pid == 0 || pid == thread_spd->id)
767
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 && !(flags & DLB_NO_SYNC)) {
768 /* Mask has been successfully set by own process, do like a poll_drom_update */
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (thread_spd->options.lewi) {
770 /* If LeWI, resolve reclaimed CPUs */
771 thread_spd->lb_funcs.update_ownership(thread_spd, mask);
772 } else {
773 /* Otherwise, udate owner and guest data */
774 2 shmem_cpuinfo__update_ownership(thread_spd->id, mask, NULL);
775 }
776 2 set_process_mask(&thread_spd->pm, mask);
777 }
778
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
46 if (error == DLB_SUCCESS && (flags & DLB_FREE_CPUS_SLURM)) {
779 // Slurm freeing
780 char *mask_str = mu_parse_to_slurm_format(&free_cpu_mask);
781 if (mask_str == NULL) {
782 warning("error parsing mask %s to Slurm format", mu_to_str(&free_cpu_mask));
783 return DLB_ERR_UNKNOWN;
784 }
785 if (!secure_getenv("SLURM_JOBID")) {
786 warning("SLURM_JOBID is mandatory");
787 return DLB_ERR_UNKNOWN;
788 }
789 char hostname[HOST_NAME_MAX];
790 gethostname(hostname, HOST_NAME_MAX);
791 char *args[5];
792 asprintf(&args[0], "scontrol");
793 asprintf(&args[1], "update");
794 asprintf(&args[2], "jobid=%s", secure_getenv("SLURM_JOBID"));
795 asprintf(&args[3], "dealloc=%s:%s", hostname, mask_str);
796 args[4] = NULL;
797
798 int res_pid = fork();
799 if (res_pid < 0) {
800 warning("fork error while invoking scontrol");
801 return DLB_ERR_UNKNOWN;
802 } else if (res_pid == 0) {
803 verbose(VB_DROM, "%s %s %s %s", args[0], args[1], args[2], args[3]);
804 execvp("scontrol", args);
805 }
806
807 for (int i = 0; i < 5; ++i) {
808 free(args[i]);
809 }
810 free(mask_str);
811 }
812
813 46 return error;
814 }
815
816
817 /* Misc */
818
819 24 int check_cpu_availability(const subprocess_descriptor_t *spd, int cpuid) {
820 24 int error = DLB_SUCCESS;
821
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23 times.
24 if (!spd->options.lewi) {
822 1 error = DLB_ERR_NOLEWI;
823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 } else if (!spd->lewi_enabled) {
824 error = DLB_ERR_DISBLD;
825 } else {
826 23 error = spd->lb_funcs.check_cpu_availability(spd, cpuid);
827 }
828 24 return error;
829 }
830
831 5 int print_shmem(subprocess_descriptor_t *spd, int num_columns,
832 dlb_printshmem_flags_t print_flags) {
833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!spd->dlb_initialized) {
834 options_init(&spd->options, NULL);
835 debug_init(&spd->options);
836 }
837
838 5 shmem_cpuinfo__print_info(spd->options.shm_key, spd->options.lewi_color,
839 num_columns, print_flags);
840 5 shmem_procinfo__print_info(spd->options.shm_key, spd->options.shm_size_multiplier);
841 5 shmem_barrier__print_info(spd->options.shm_key, spd->options.shm_size_multiplier);
842 5 shmem_talp__print_info(spd->options.shm_key, spd->options.shm_size_multiplier);
843 5 shmem_mngo__print_info(spd->options.shm_key);
844
845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!spd->dlb_initialized) {
846 options_finalize(&spd->options);
847 }
848
849 5 return DLB_SUCCESS;
850 }
851
852 int get_gpu_affinity(char *buffer, size_t buffer_size, bool full_uuid) {
853 return talp_backend_manager_get_gpu_affinity(buffer, buffer_size, full_uuid);
854 }
855
856 void print_dlb_variables(subprocess_descriptor_t *spd, bool print_extended) {
857
858 options_t options;
859 options_init(&options, NULL);
860
861 /* dlb is not intialized, this step is needed to print the correct host:pid */
862 if (spd->id == 0) {
863 spd->id = getpid();
864 }
865 debug_init(&options);
866
867 options_print_variables(&options, print_extended);
868
869 options_finalize(&options);
870 }
871