| 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_metrics.h" | ||
| 21 | |||
| 22 | #include "mngo/mngo_talp.h" | ||
| 23 | #include "support/queues.h" | ||
| 24 | |||
| 25 | 13 | void mngo_metrics__history_init(mngo_metrics_history_t *metrics_history) { | |
| 26 | 13 | metrics_history->history = | |
| 27 | 13 | queue__init(sizeof(mngo_talp_metrics_t), MNGO_HISTORY_WINDOW, NULL, | |
| 28 | QUEUE_ALLOC_OVERWRITE); | ||
| 29 | 13 | } | |
| 30 | |||
| 31 | 13 | void mngo_metrics__history_fini(mngo_metrics_history_t *metrics_history) { | |
| 32 | 13 | queue__destroy(metrics_history->history); | |
| 33 | 13 | } | |
| 34 | |||
| 35 | 1 | void mngo_metrics__history_push(mngo_metrics_history_t *metrics_history, | |
| 36 | const mngo_talp_metrics_t *metrics) { | ||
| 37 | 1 | queue__push_head(metrics_history->history, metrics); | |
| 38 | 1 | } | |
| 39 | |||
| 40 | mngo_talp_metrics_t * | ||
| 41 | 1041 | mngo_metrics__history_emplace(mngo_metrics_history_t *metrics_history) { | |
| 42 | 1041 | return queue__emplace_head(metrics_history->history); | |
| 43 | } | ||
| 44 | |||
| 45 | struct mngo_reduce_metric_history_t { | ||
| 46 | unsigned int coeficient_weight; | ||
| 47 | unsigned int coeficient_sum; | ||
| 48 | |||
| 49 | float self_mpi_parallel_efficiency; | ||
| 50 | float shared_mpi_parallel_efficiency; | ||
| 51 | float global_mpi_parallel_efficiency; | ||
| 52 | }; | ||
| 53 | |||
| 54 | 534 | static void reduce_metric_history_op(void *args, void *curr) { | |
| 55 | 534 | struct mngo_reduce_metric_history_t *acc = args; | |
| 56 | 534 | mngo_talp_metrics_t *metrics = curr; | |
| 57 | |||
| 58 | 534 | acc->self_mpi_parallel_efficiency += | |
| 59 | 534 | metrics->self_mpi_parallel_efficiency * acc->coeficient_weight; | |
| 60 | |||
| 61 | 534 | acc->shared_mpi_parallel_efficiency += | |
| 62 | 534 | metrics->shared_mpi_parallel_efficiency * acc->coeficient_weight; | |
| 63 | |||
| 64 | 534 | acc->global_mpi_parallel_efficiency += | |
| 65 | 534 | metrics->global_mpi_parallel_efficiency * acc->coeficient_weight; | |
| 66 | |||
| 67 | 534 | acc->coeficient_sum += acc->coeficient_weight; | |
| 68 | 534 | acc->coeficient_weight--; | |
| 69 | 534 | } | |
| 70 | |||
| 71 | 17 | void mngo_metrics__history_tendency( | |
| 72 | const mngo_metrics_history_t *metrics_history, | ||
| 73 | mngo_reduced_metric_t *metrics) { | ||
| 74 | 17 | struct mngo_reduce_metric_history_t historical_metrics = { | |
| 75 | 17 | .coeficient_weight = queue__get_size(metrics_history->history), | |
| 76 | .coeficient_sum = 0, | ||
| 77 | |||
| 78 | .self_mpi_parallel_efficiency = 0, | ||
| 79 | .shared_mpi_parallel_efficiency = 0, | ||
| 80 | .global_mpi_parallel_efficiency = 0, | ||
| 81 | }; | ||
| 82 | |||
| 83 | queue_iter_head2tail_t iter_metrics = | ||
| 84 | 17 | queue__into_head2tail_iter(metrics_history->history); | |
| 85 | 17 | queue_iter__foreach(&iter_metrics, reduce_metric_history_op, | |
| 86 | &historical_metrics); | ||
| 87 | |||
| 88 | 17 | historical_metrics.self_mpi_parallel_efficiency /= | |
| 89 | 17 | historical_metrics.coeficient_sum; | |
| 90 | 17 | historical_metrics.shared_mpi_parallel_efficiency /= | |
| 91 | 17 | historical_metrics.coeficient_sum; | |
| 92 | 17 | historical_metrics.global_mpi_parallel_efficiency /= | |
| 93 | 17 | historical_metrics.coeficient_sum; | |
| 94 | |||
| 95 | 17 | metrics->self_pe = historical_metrics.self_mpi_parallel_efficiency; | |
| 96 | 17 | metrics->shared_pe = historical_metrics.shared_mpi_parallel_efficiency; | |
| 97 | 17 | metrics->global_pe = historical_metrics.global_mpi_parallel_efficiency; | |
| 98 | 17 | } | |
| 99 |