| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************/ | ||
| 2 | /* Copyright 2009-2024 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 | /* Statistics API */ | ||
| 21 | |||
| 22 | #include "apis/dlb_stats.h" | ||
| 23 | |||
| 24 | #include "LB_comm/shmem_procinfo.h" | ||
| 25 | #include "LB_core/spd.h" | ||
| 26 | #include "apis/dlb_errors.h" | ||
| 27 | #include "support/dlb_common.h" | ||
| 28 | #include "support/mask_utils.h" | ||
| 29 | #include "support/options.h" | ||
| 30 | |||
| 31 | #include <stddef.h> | ||
| 32 | |||
| 33 | |||
| 34 | DLB_EXPORT_SYMBOL | ||
| 35 | ✗ | int DLB_Stats_Init(void) { | |
| 36 | char shm_key[MAX_OPTION_LENGTH]; | ||
| 37 | ✗ | options_parse_entry("--shm-key", &shm_key); | |
| 38 | int shm_size_multiplier; | ||
| 39 | ✗ | options_parse_entry("--shm-size-multiplier", &shm_size_multiplier); | |
| 40 | ✗ | shmem_procinfo_ext__init(shm_key, shm_size_multiplier); | |
| 41 | ✗ | return DLB_SUCCESS; | |
| 42 | } | ||
| 43 | |||
| 44 | DLB_EXPORT_SYMBOL | ||
| 45 | ✗ | int DLB_Stats_Finalize(void) { | |
| 46 | ✗ | shmem_procinfo_ext__finalize(); | |
| 47 | ✗ | return DLB_SUCCESS; | |
| 48 | } | ||
| 49 | |||
| 50 | DLB_EXPORT_SYMBOL | ||
| 51 | ✗ | int DLB_Stats_GetNumCpus(int *ncpus) { | |
| 52 | ✗ | *ncpus = mu_get_system_size(); | |
| 53 | ✗ | return DLB_SUCCESS; | |
| 54 | } | ||
| 55 | |||
| 56 | DLB_EXPORT_SYMBOL | ||
| 57 | ✗ | int DLB_Stats_GetPidList(int *pidlist, int *nelems, int max_len) { | |
| 58 | ✗ | shmem_procinfo__getpidlist(pidlist, nelems, max_len); | |
| 59 | ✗ | return DLB_SUCCESS; | |
| 60 | } | ||
| 61 | |||
| 62 | DLB_EXPORT_SYMBOL | ||
| 63 | ✗ | int DLB_Stats_GetCpuUsage(int pid, double *usage) { | |
| 64 | ✗ | *usage = shmem_procinfo__getcpuusage(pid); | |
| 65 | ✗ | return DLB_SUCCESS; | |
| 66 | } | ||
| 67 | |||
| 68 | DLB_EXPORT_SYMBOL | ||
| 69 | ✗ | int DLB_Stats_GetCpuAvgUsage(int pid, double *usage) { | |
| 70 | ✗ | *usage = shmem_procinfo__getcpuavgusage(pid); | |
| 71 | ✗ | return DLB_SUCCESS; | |
| 72 | } | ||
| 73 | |||
| 74 | DLB_EXPORT_SYMBOL | ||
| 75 | ✗ | int DLB_Stats_GetCpuUsageList(double *usagelist, int *nelems, int max_len) { | |
| 76 | ✗ | shmem_procinfo__getcpuusage_list(usagelist, nelems, max_len); | |
| 77 | ✗ | return DLB_SUCCESS; | |
| 78 | } | ||
| 79 | |||
| 80 | DLB_EXPORT_SYMBOL | ||
| 81 | ✗ | int DLB_Stats_GetCpuAvgUsageList(double *avgusagelist, int *nelems, int max_len) { | |
| 82 | ✗ | shmem_procinfo__getcpuavgusage_list(avgusagelist, nelems, max_len); | |
| 83 | ✗ | return DLB_SUCCESS; | |
| 84 | } | ||
| 85 | |||
| 86 | DLB_EXPORT_SYMBOL | ||
| 87 | ✗ | int DLB_Stats_GetNodeUsage(double *usage) { | |
| 88 | ✗ | *usage = shmem_procinfo__getnodeusage(); | |
| 89 | ✗ | return DLB_SUCCESS; | |
| 90 | } | ||
| 91 | |||
| 92 | DLB_EXPORT_SYMBOL | ||
| 93 | ✗ | int DLB_Stats_GetNodeAvgUsage(double *usage) { | |
| 94 | ✗ | *usage = shmem_procinfo__getnodeavgusage(); | |
| 95 | ✗ | return DLB_SUCCESS; | |
| 96 | } | ||
| 97 | |||
| 98 | DLB_EXPORT_SYMBOL | ||
| 99 | ✗ | int DLB_Stats_GetActiveCpus(int pid, int *ncpus) { | |
| 100 | ✗ | *ncpus = shmem_procinfo__getactivecpus(pid); | |
| 101 | ✗ | return DLB_SUCCESS; | |
| 102 | } | ||
| 103 | |||
| 104 | DLB_EXPORT_SYMBOL | ||
| 105 | ✗ | int DLB_Stats_GetActiveCpusList(int *cpuslist, int *nelems, int max_len) { | |
| 106 | ✗ | shmem_procinfo__getactivecpus_list(cpuslist, nelems, max_len); | |
| 107 | ✗ | return DLB_SUCCESS; | |
| 108 | } | ||
| 109 | |||
| 110 | DLB_EXPORT_SYMBOL | ||
| 111 | ✗ | int DLB_Stats_GetLoadAvg(int pid, double *load) { | |
| 112 | ✗ | return shmem_procinfo__getloadavg(pid, load); | |
| 113 | } | ||
| 114 | |||
| 115 | DLB_EXPORT_SYMBOL | ||
| 116 | ✗ | int DLB_Stats_GetCpuStateIdle(int cpu, float *percentage) { | |
| 117 | ✗ | return DLB_SUCCESS; | |
| 118 | } | ||
| 119 | |||
| 120 | DLB_EXPORT_SYMBOL | ||
| 121 | ✗ | int DLB_Stats_GetCpuStateOwned(int cpu, float *percentage) { | |
| 122 | ✗ | return DLB_SUCCESS; | |
| 123 | } | ||
| 124 | |||
| 125 | DLB_EXPORT_SYMBOL | ||
| 126 | ✗ | int DLB_Stats_GetCpuStateGuested(int cpu, float *percentage) { | |
| 127 | ✗ | return DLB_SUCCESS; | |
| 128 | } | ||
| 129 |