GCC Code Coverage Report


Directory: src/
File: src/mngo/mngo_talp.c
Date: 2026-09-15 07:37:49
Exec Total Coverage
Lines: 35 35 100.0%
Functions: 4 4 100.0%
Branches: 2 2 100.0%

Line Branch Exec Source
1 /*********************************************************************************/
2 /* Copyright 2009-2026 Barcelona Supercomputing Center */
3 /* */
4 /* This file is part of the DLB library. */
5 /* */
6 /* DLB is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU Lesser General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* DLB is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU Lesser General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU Lesser General Public License */
17 /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */
18 /*********************************************************************************/
19
20 #include "mngo/mngo_talp.h"
21
22 #include "talp/regions.h"
23 #include "talp/talp.h"
24
25 // For warning0
26 #include "support/debug.h"
27 // For DLB_(errors)
28 #include "apis/dlb_errors.h"
29
30 #ifdef MPI_LIB
31 #include <mpi.h>
32 #endif
33
34 10 int mngo_talp__region_register(const subprocess_descriptor_t *spd,
35 const char *name, mngo_talp_region_t *region) {
36 10 region->monitor = region_register(spd, name);
37
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (region->monitor == NULL) {
38 1 warning0("MNGO could not create TALP monitoring region for: %s", name);
39 1 return DLB_NOUPDT;
40 }
41
42 9 region_set_internal(region->monitor, true);
43
44 9 return DLB_SUCCESS;
45 }
46
47 9 const char *mngo_talp__get_region_name(mngo_talp_region_t *region) {
48 9 return region->monitor->name;
49 }
50
51 13 static void collect_metrics(const subprocess_descriptor_t *spd,
52 mngo_talp_region_t *region,
53 mngo_talp_metrics_t *metrics) {
54 13 dlb_monitor_t *monitor = region->monitor;
55
56 #ifdef MPI_LIB
57 mngo_info_t *mngo_info = spd->mngo_info;
58 #endif
59 {
60 13 int64_t accumulated_total_time =
61 13 monitor->useful_time + monitor->mpi_time;
62
63 13 metrics->self_parallel_efficiency =
64 13 ((float)monitor->useful_time) / accumulated_total_time;
65
66 13 metrics->self_mpi_parallel_efficiency =
67 13 ((float)monitor->useful_time) / accumulated_total_time;
68
69 13 metrics->self_omp_parallel_efficiency =
70 13 ((float)accumulated_total_time) / accumulated_total_time;
71 }
72
73 {
74 dlb_node_metrics_t shared_metrics;
75 13 talp_collect_pop_node_metrics(spd, monitor, &shared_metrics);
76
77 13 int64_t shared_total_time =
78 13 shared_metrics.total_useful_time + shared_metrics.total_mpi_time;
79
80 13 metrics->shared_parallel_efficiency =
81 13 ((float)shared_metrics.total_useful_time) / shared_total_time;
82
83 13 metrics->shared_mpi_parallel_efficiency =
84 13 ((float)shared_metrics.total_useful_time) /
85 13 (shared_metrics.total_useful_time + shared_metrics.total_mpi_time);
86
87 13 metrics->shared_omp_parallel_efficiency =
88 13 ((float)shared_metrics.total_useful_time +
89 13 shared_metrics.total_mpi_time) /
90 shared_total_time;
91
92 #ifdef MPI_LIB
93 {
94 int64_t total_mpi_time;
95 PMPI_Allreduce(&monitor->mpi_time, &total_mpi_time, 1, MPI_INT64_T,
96 MPI_SUM, mngo_info->comm);
97
98 int64_t total_useful_time;
99
100 PMPI_Allreduce(&monitor->useful_time, &total_useful_time, 1,
101 MPI_INT64_T, MPI_SUM, mngo_info->comm);
102
103 int64_t total_time = total_useful_time + total_mpi_time;
104
105 metrics->global_parallel_efficiency =
106 ((float)total_useful_time) / total_time;
107
108 metrics->global_mpi_parallel_efficiency =
109 ((float)total_useful_time) /
110 (total_useful_time + total_mpi_time);
111
112 metrics->global_omp_parallel_efficiency =
113 ((float)total_useful_time + total_mpi_time) / (total_time);
114 }
115 #endif /* MPI_LIB */
116 }
117 13 }
118
119 13 void mngo_talp__take_metrics(const subprocess_descriptor_t *spd,
120 mngo_talp_region_t *region,
121 mngo_talp_metrics_t *metrics) {
122 13 collect_metrics(spd, region, metrics);
123 13 region_reset(spd, region->monitor);
124 13 }
125