| 1 |
// Copyright (C) 2024 Advanced Micro Devices. All rights reserved. |
| 2 |
// |
| 3 |
// Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 |
// this software and associated documentation files (the "Software"), to deal in |
| 5 |
// the Software without restriction, including without limitation the rights to |
| 6 |
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 7 |
// the Software, and to permit persons to whom the Software is furnished to do so, |
| 8 |
// subject to the following conditions: |
| 9 |
// |
| 10 |
// The above copyright notice and this permission notice shall be included in all |
| 11 |
// copies or substantial portions of the Software. |
| 12 |
// |
| 13 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 15 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 16 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 17 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 18 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 |
// |
| 20 |
|
| 21 |
use crate::amdsmi_collectors::AmdsmiCollectors; |
| 22 |
use crate::amdsmi_metric::*; |
| 23 |
use amdsmi::*; |
| 24 |
use prometheus_client::registry::Unit; |
| 25 |
use std::sync::Arc; |
| 26 |
pub fn collectors_create(collectors: &mut AmdsmiCollectors) { |
| 27 |
add_metric_group!( |
| 28 |
collectors, |
| 29 |
"AmdsmiEngineUsageMetrics", |
| 30 |
amdsmi_get_gpu_activity, |
| 31 |
AmdsmiEngineUsageT, |
| 32 |
( |
| 33 |
"AMDSMI_FI_GFX_ACTIVITY", |
| 34 |
"GFX Activity", |
| 35 |
Unit::Ratios, |
| 36 |
gfx_activity |
| 37 |
), |
| 38 |
( |
| 39 |
"AMDSMI_FI_UMC_ACTIVITY", |
| 40 |
"UMC Activity", |
| 41 |
Unit::Ratios, |
| 42 |
umc_activity |
| 43 |
), |
| 44 |
( |
| 45 |
"AMDSMI_FI_MM_ACTIVITY", |
| 46 |
"MM Activity", |
| 47 |
Unit::Ratios, |
| 48 |
mm_activity |
| 49 |
) |
| 50 |
); |
| 51 |
|
| 52 |
add_metric_group!( |
| 53 |
collectors, |
| 54 |
"AmdsmiPowerInfoMetrics", |
| 55 |
amdsmi_get_power_info, |
| 56 |
AmdsmiPowerInfoT, |
| 57 |
( |
| 58 |
"AMDSMI_FI_CURRENT_SOCKET_POWER", |
| 59 |
"Current Socket Power", |
| 60 |
metric_unit_other!("W"), |
| 61 |
current_socket_power |
| 62 |
), |
| 63 |
( |
| 64 |
"AMDSMI_FI_AVERAGE_SOCKET_POWER", |
| 65 |
"Average Socket Power", |
| 66 |
metric_unit_other!("W"), |
| 67 |
average_socket_power |
| 68 |
), |
| 69 |
( |
| 70 |
"AMDSMI_FI_GFX_VOLTAGE", |
| 71 |
"GFX Voltage", |
| 72 |
metric_unit_other!("mV"), |
| 73 |
gfx_voltage |
| 74 |
), |
| 75 |
( |
| 76 |
"AMDSMI_FI_SOC_VOLTAGE", |
| 77 |
"SOC Voltage", |
| 78 |
metric_unit_other!("mV"), |
| 79 |
soc_voltage |
| 80 |
), |
| 81 |
( |
| 82 |
"AMDSMI_FI_MEM_VOLTAGE", |
| 83 |
"Memory Voltage", |
| 84 |
metric_unit_other!("mV"), |
| 85 |
mem_voltage |
| 86 |
), |
| 87 |
); |
| 88 |
|
| 89 |
add_metric_group!( |
| 90 |
collectors, |
| 91 |
"AmdsmiGfxClockMetrics", |
| 92 |
amdsmi_func!(amdsmi_get_clock_info, AmdsmiClkTypeT::AmdsmiClkTypeGfx), |
| 93 |
AmdsmiClkInfoT, |
| 94 |
( |
| 95 |
"AMDSMI_FI_GFX_CLK", |
| 96 |
"GFX Clock", |
| 97 |
metric_unit_other!("MHz"), |
| 98 |
clk |
| 99 |
), |
| 100 |
( |
| 101 |
"AMDSMI_FI_GFX_MIN_CLK", |
| 102 |
"GFX Min Clock", |
| 103 |
metric_unit_other!("MHz"), |
| 104 |
min_clk |
| 105 |
), |
| 106 |
( |
| 107 |
"AMDSMI_FI_GFX_MAX_CLK", |
| 108 |
"GFX Max Clock", |
| 109 |
metric_unit_other!("MHz"), |
| 110 |
max_clk |
| 111 |
) |
| 112 |
); |
| 113 |
|
| 114 |
add_metric_group!( |
| 115 |
collectors, |
| 116 |
"AmdsmiVRAMUsageMetrics", |
| 117 |
amdsmi_get_gpu_vram_usage, |
| 118 |
AmdsmiVramUsageT, |
| 119 |
( |
| 120 |
"AMDSMI_FI_VRAM_TOTAL", |
| 121 |
"VRAM total", |
| 122 |
metric_unit_other!("MB"), |
| 123 |
vram_total |
| 124 |
), |
| 125 |
( |
| 126 |
"AMDSMI_FI_VRAM_USED", |
| 127 |
"VRAM used", |
| 128 |
metric_unit_other!("MB"), |
| 129 |
vram_used |
| 130 |
), |
| 131 |
); |
| 132 |
|
| 133 |
add_metric_group!( |
| 134 |
collectors, |
| 135 |
"AmdsmiMemClockMetrics", |
| 136 |
amdsmi_func!(amdsmi_get_clock_info, AmdsmiClkTypeT::AmdsmiClkTypeMem), |
| 137 |
AmdsmiClkInfoT, |
| 138 |
( |
| 139 |
"AMDSMI_FI_MEM_CLK", |
| 140 |
"Memory Clock", |
| 141 |
metric_unit_other!("MHz"), |
| 142 |
clk |
| 143 |
), |
| 144 |
( |
| 145 |
"AMDSMI_FI_MEM_MIN_CLK", |
| 146 |
"Memory Min Clock", |
| 147 |
metric_unit_other!("MHz"), |
| 148 |
min_clk |
| 149 |
), |
| 150 |
( |
| 151 |
"AMDSMI_FI_MEM_MAX_CLK", |
| 152 |
"Memory Max Clock", |
| 153 |
metric_unit_other!("MHz"), |
| 154 |
max_clk |
| 155 |
) |
| 156 |
); |
| 157 |
|
| 158 |
add_metric!( |
| 159 |
collectors, |
| 160 |
"AMDSMI_FI_TEMPERATURE_EDGE", |
| 161 |
"Current edge temperature", |
| 162 |
Unit::Celsius, |
| 163 |
amdsmi_func!( |
| 164 |
amdsmi_get_temp_metric, |
| 165 |
AmdsmiTemperatureTypeT::AmdsmiTemperatureTypeEdge, |
| 166 |
AmdsmiTemperatureMetricT::AmdsmiTempCurrent |
| 167 |
) |
| 168 |
); |
| 169 |
add_metric!( |
| 170 |
collectors, |
| 171 |
"AMDSMI_FI_TEMPERATURE_HOTSPOT", |
| 172 |
"Current Hotspot temperature", |
| 173 |
Unit::Celsius, |
| 174 |
amdsmi_func!( |
| 175 |
amdsmi_get_temp_metric, |
| 176 |
AmdsmiTemperatureTypeT::AmdsmiTemperatureTypeHotspot, |
| 177 |
AmdsmiTemperatureMetricT::AmdsmiTempCurrent |
| 178 |
) |
| 179 |
); |
| 180 |
add_metric!( |
| 181 |
collectors, |
| 182 |
"AMDSMI_FI_TEMPERATURE_MEM", |
| 183 |
"Current VRAM temperature", |
| 184 |
Unit::Celsius, |
| 185 |
amdsmi_func!( |
| 186 |
amdsmi_get_temp_metric, |
| 187 |
AmdsmiTemperatureTypeT::AmdsmiTemperatureTypeVram, |
| 188 |
AmdsmiTemperatureMetricT::AmdsmiTempCurrent |
| 189 |
) |
| 190 |
); |
| 191 |
} |