Merge amd-staging into amd-master 20230130
Signed-off-by: Hao Zhou <Hao.Zhou@amd.com>
Change-Id: Ia1a0eadf0e37a684badaf66a8ac61ec58ced9f40
[ROCm/amdsmi commit: e79a230f92]
This commit is contained in:
@@ -271,7 +271,7 @@ int main() {
|
||||
ret = amdsmi_get_device_bdf(device_handles[j], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_device_bdf:\n");
|
||||
printf("\tDevice[%d] BDF %04x:%02x:%02x.%d\n\n", i,
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number, bdf.bus_number, bdf.device_number,
|
||||
bdf.function_number);
|
||||
|
||||
@@ -313,7 +313,7 @@ int main() {
|
||||
power_measure.voltage_gfx);
|
||||
printf("\tAverage socket power: %d\n",
|
||||
power_measure.average_socket_power);
|
||||
printf("\tEnergy accumulator: %d\n\n",
|
||||
printf("\tEnergy accumulator: %ld\n\n",
|
||||
power_measure.energy_accumulator);
|
||||
printf("\tGPU Power limit: %d\n\n", power_measure.power_limit);
|
||||
|
||||
@@ -354,7 +354,7 @@ int main() {
|
||||
printf("Number of Microcodes: %d\n", fw_information.num_fw_info);
|
||||
for (int j = 0; j < fw_information.num_fw_info; j++) {
|
||||
getFWNameFromId(fw_information.fw_info_list[j].fw_id, ucode_name);
|
||||
printf(" %s: %d\n", ucode_name, fw_information.fw_info_list[j].fw_version);
|
||||
printf(" %s: %ld\n", ucode_name, fw_information.fw_info_list[j].fw_version);
|
||||
}
|
||||
|
||||
// Get GFX clock measurements
|
||||
@@ -399,14 +399,14 @@ int main() {
|
||||
AMDSMI_TEMP_CRITICAL, &temperature);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_dev_get_temp_metric:\n");
|
||||
printf("\tGPU VRAM temp limit: %d\n", temperature);
|
||||
printf("\tGPU VRAM temp limit: %ld\n", temperature);
|
||||
|
||||
// Get GFX temperature limit
|
||||
ret = amdsmi_dev_get_temp_metric(
|
||||
device_handles[j], TEMPERATURE_TYPE_EDGE,
|
||||
AMDSMI_TEMP_CRITICAL, &temperature);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf("\tGPU GFX temp limit: %d\n\n", temperature);
|
||||
printf("\tGPU GFX temp limit: %ld\n\n", temperature);
|
||||
|
||||
// Get temperature measurements
|
||||
// amdsmi_temperature_t edge_temp, junction_temp, vram_temp,
|
||||
@@ -423,13 +423,13 @@ int main() {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
}
|
||||
printf(" Output of amdsmi_dev_get_temp_metric:\n");
|
||||
printf("\tGPU Edge temp measurement: %d\n",
|
||||
printf("\tGPU Edge temp measurement: %ld\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_EDGE]);
|
||||
printf("\tGPU Junction temp measurement: %d\n",
|
||||
printf("\tGPU Junction temp measurement: %ld\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_JUNCTION]);
|
||||
printf("\tGPU VRAM temp measurement: %d\n",
|
||||
printf("\tGPU VRAM temp measurement: %ld\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_VRAM]);
|
||||
printf("\tGPU PLX temp measurement: %d\n\n",
|
||||
printf("\tGPU PLX temp measurement: %ld\n\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_PLX]);
|
||||
|
||||
// Get RAS features enabled
|
||||
@@ -498,15 +498,6 @@ int main() {
|
||||
: -1;
|
||||
};
|
||||
|
||||
auto sum_item = [](uint16_t *a) -> float {
|
||||
float b = 0;
|
||||
for (int iterator = 0; iterator < AMDSMI_MAX_MM_IP_COUNT;
|
||||
iterator += 1) {
|
||||
b += (float)a[iterator] / 100.0;
|
||||
}
|
||||
return b;
|
||||
};
|
||||
|
||||
// Get frequency ranges
|
||||
amdsmi_frequency_range_t freq_ranges = {};
|
||||
ret = amdsmi_get_target_frequency_range(
|
||||
@@ -533,9 +524,9 @@ int main() {
|
||||
amdsmi_proc_info_t info_list[num_process];
|
||||
amdsmi_proc_info_t process = {};
|
||||
uint64_t mem = 0, gtt_mem = 0, cpu_mem = 0, vram_mem = 0;
|
||||
float gfx = 0, comp = 0, dma = 0, enc = 0, dec = 0;
|
||||
uint64_t gfx = 0, comp = 0, dma = 0, enc = 0, dec = 0;
|
||||
char bdf_str[20];
|
||||
sprintf(bdf_str, "%04x:%02x:%02x.%d", bdf.domain_number,
|
||||
sprintf(bdf_str, "%04lx:%02x:%02x.%d", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
int num = 0;
|
||||
ret = amdsmi_get_process_list(device_handles[j], process_list,
|
||||
@@ -562,7 +553,7 @@ int main() {
|
||||
printf(
|
||||
"| pid | name | user | gpu bdf | "
|
||||
"fb usage | gtt memory | cpu memory | vram memory | "
|
||||
"ring usage (%%) |\n");
|
||||
"engine usage (ns) |\n");
|
||||
printf("| | | | "
|
||||
"| | | | "
|
||||
" | gfx comp dma enc dec |\n");
|
||||
@@ -580,49 +571,49 @@ int main() {
|
||||
pwd = getpwuid(st.st_uid);
|
||||
if (!pwd)
|
||||
printf("| %5d | %16s | %10d | %s | %7ld KiB | %7ld KiB "
|
||||
"| %7ld KiB | %7ld KiB | %6.2f %6.2f %6.2f "
|
||||
"%6.2f %6.2f |\n",
|
||||
"| %7ld KiB | %7ld KiB | %lu %lu %lu "
|
||||
"%lu %lu |\n",
|
||||
info_list[it].pid, info_list[it].name, st.st_uid,
|
||||
bdf_str, info_list[it].mem / 1024,
|
||||
info_list[it].memory_usage.gtt_mem / 1024,
|
||||
info_list[it].memory_usage.cpu_mem / 1024,
|
||||
info_list[it].memory_usage.vram_mem / 1024,
|
||||
sum_item(info_list[it].engine_usage.gfx),
|
||||
sum_item(info_list[it].engine_usage.compute),
|
||||
sum_item(info_list[it].engine_usage.sdma),
|
||||
sum_item(info_list[it].engine_usage.enc),
|
||||
sum_item(info_list[it].engine_usage.dec));
|
||||
info_list[it].engine_usage.gfx,
|
||||
info_list[it].engine_usage.compute,
|
||||
info_list[it].engine_usage.dma,
|
||||
info_list[it].engine_usage.enc,
|
||||
info_list[it].engine_usage.dec);
|
||||
else
|
||||
printf("| %5d | %16s | %10s | %s | %7ld KiB | %7ld KiB "
|
||||
"| %7ld KiB | %7ld KiB | %6.2f %6.2f %6.2f "
|
||||
"%6.2f %6.2f |\n",
|
||||
"| %7ld KiB | %7ld KiB | %lu %lu %lu "
|
||||
"%lu %lu |\n",
|
||||
info_list[it].pid, info_list[it].name,
|
||||
pwd->pw_name, bdf_str, info_list[it].mem / 1024,
|
||||
info_list[it].memory_usage.gtt_mem / 1024,
|
||||
info_list[it].memory_usage.cpu_mem / 1024,
|
||||
info_list[it].memory_usage.vram_mem / 1024,
|
||||
sum_item(info_list[it].engine_usage.gfx),
|
||||
sum_item(info_list[it].engine_usage.compute),
|
||||
sum_item(info_list[it].engine_usage.sdma),
|
||||
sum_item(info_list[it].engine_usage.enc),
|
||||
sum_item(info_list[it].engine_usage.dec));
|
||||
info_list[it].engine_usage.gfx,
|
||||
info_list[it].engine_usage.compute,
|
||||
info_list[it].engine_usage.dma,
|
||||
info_list[it].engine_usage.enc,
|
||||
info_list[it].engine_usage.dec);
|
||||
mem += info_list[it].mem / 1024;
|
||||
gtt_mem += info_list[it].memory_usage.gtt_mem / 1024;
|
||||
cpu_mem += info_list[it].memory_usage.cpu_mem / 1024;
|
||||
vram_mem += info_list[it].memory_usage.vram_mem / 1024;
|
||||
gfx += sum_item(info_list[it].engine_usage.gfx);
|
||||
comp += sum_item(info_list[it].engine_usage.compute);
|
||||
dma += sum_item(info_list[it].engine_usage.sdma);
|
||||
enc += sum_item(info_list[it].engine_usage.enc);
|
||||
dec += sum_item(info_list[it].engine_usage.dec);
|
||||
gfx = info_list[it].engine_usage.gfx;
|
||||
comp = info_list[it].engine_usage.compute;
|
||||
dma = info_list[it].engine_usage.dma;
|
||||
enc = info_list[it].engine_usage.enc;
|
||||
dec = info_list[it].engine_usage.dec;
|
||||
printf(
|
||||
"+-------+------------------+------------+-------------"
|
||||
"-+-------------+-------------+-------------+----------"
|
||||
"----+-----------------------------------------+\n");
|
||||
}
|
||||
printf("| TOTAL:| %s | %7ld "
|
||||
"KiB | %7ld KiB | %7ld KiB | %7ld KiB | %6.2f %6.2f "
|
||||
"%6.2f %6.2f %6.2f |\n",
|
||||
"KiB | %7ld KiB | %7ld KiB | %7ld KiB | %lu %lu "
|
||||
"%lu %lu %lu |\n",
|
||||
bdf_str, mem, gtt_mem, cpu_mem, vram_mem, gfx, comp, dma,
|
||||
enc, dec);
|
||||
printf("+=======+==================+============+=============="
|
||||
|
||||
@@ -122,7 +122,7 @@ int main() {
|
||||
ret = amdsmi_get_device_bdf(device_handles[j], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_device_bdf:\n");
|
||||
printf("\tDevice[%d] BDF %04x:%02x:%02x.%d\n\n", i,
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number, bdf.bus_number, bdf.device_number,
|
||||
bdf.function_number);
|
||||
|
||||
@@ -132,7 +132,7 @@ int main() {
|
||||
printf(" Output of amdsmi_get_asic_info:\n");
|
||||
printf("\tMarket Name: %s\n", asic_info.market_name);
|
||||
printf("\tFamilyID: 0x%x\n", asic_info.family);
|
||||
printf("\tDeviceID: 0x%x\n", asic_info.device_id);
|
||||
printf("\tDeviceID: 0x%lx\n", asic_info.device_id);
|
||||
printf("\tVendorID: 0x%x\n", asic_info.vendor_id);
|
||||
printf("\tRevisionID: 0x%x\n", asic_info.rev_id);
|
||||
printf("\tAsic serial: 0x%s\n\n", asic_info.asic_serial);
|
||||
@@ -233,13 +233,13 @@ int main() {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
}
|
||||
printf(" Output of amdsmi_dev_get_temp_metric:\n");
|
||||
printf("\tGPU Edge temp measurement: %d\n",
|
||||
printf("\tGPU Edge temp measurement: %ld\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_EDGE]);
|
||||
printf("\tGPU Junction temp measurement: %d\n",
|
||||
printf("\tGPU Junction temp measurement: %ld\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_JUNCTION]);
|
||||
printf("\tGPU VRAM temp measurement: %d\n",
|
||||
printf("\tGPU VRAM temp measurement: %ld\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_VRAM]);
|
||||
printf("\tGPU PLX temp measurement: %d\n\n",
|
||||
printf("\tGPU PLX temp measurement: %ld\n\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_PLX]);
|
||||
|
||||
// Get bad pages
|
||||
|
||||
@@ -388,12 +388,12 @@ typedef struct {
|
||||
amdsmi_process_handle pid;
|
||||
uint64_t mem; /** in bytes */
|
||||
struct {
|
||||
uint16_t gfx[AMDSMI_MAX_MM_IP_COUNT];
|
||||
uint16_t compute[AMDSMI_MAX_MM_IP_COUNT];
|
||||
uint16_t sdma[AMDSMI_MAX_MM_IP_COUNT];
|
||||
uint16_t enc[AMDSMI_MAX_MM_IP_COUNT];
|
||||
uint16_t dec[AMDSMI_MAX_MM_IP_COUNT];
|
||||
} engine_usage; /** percentage 0-100% times 100 */
|
||||
uint64_t gfx;
|
||||
uint64_t compute;
|
||||
uint64_t dma;
|
||||
uint64_t enc;
|
||||
uint64_t dec;
|
||||
} engine_usage; /** How much time the process spend using these engines in ns */
|
||||
struct {
|
||||
uint64_t gtt_mem;
|
||||
uint64_t cpu_mem;
|
||||
@@ -3825,6 +3825,7 @@ amdsmi_get_process_list(amdsmi_device_handle device_handle, amdsmi_process_handl
|
||||
|
||||
/**
|
||||
* @brief Returns the process information of a given process.
|
||||
* Engine usage show how much time the process spend using these engines in ns.
|
||||
*
|
||||
* @param[in] device_handle Device which to query
|
||||
*
|
||||
|
||||
@@ -518,6 +518,7 @@ Field | Description
|
||||
`average_socket_power`| average socket power
|
||||
`voltage_gfx` | voltage gfx
|
||||
`energy_accumulator` | energy accumulator
|
||||
`power_limit` | power limit
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_power_measure` function:
|
||||
* `AmdSmiLibraryException`
|
||||
@@ -536,6 +537,7 @@ try:
|
||||
print(power_measure['average_socket_power'])
|
||||
print(power_measure['voltage_gfx'])
|
||||
print(power_measure['energy_accumulator'])
|
||||
print(power_measure['power_limit'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
@@ -844,7 +846,7 @@ Field | Description
|
||||
`name` | Name of process
|
||||
`pid` | Process ID
|
||||
`mem` | Process memory usage
|
||||
`engine_usage`| <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gfx`</td><td>GFX engine usage</td></tr><tr><td>`compute`</td><td>Compute engine usage</td></tr><tr><td>`sdma`</td><td>DMA engine usage</td></tr><tr><td>`enc`</td><td>Encode engine usage</td></tr><tr><td>`dec`</td><td>Decode engine usage</td></tr></tbody></table>
|
||||
`engine_usage`| <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gfx`</td><td>GFX engine usage in ns</td></tr><tr><td>`compute`</td><td>Compute engine usage in ns</td></tr><tr><td>`dma`</td><td>DMA engine usage in ns </td></tr><tr><td>`enc`</td><td>Encode engine usage in ns</td></tr><tr><td>`dec`</td><td>Decode engine usage in ns</td></tr></tbody></table>
|
||||
`memory_usage`| <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gtt_mem`</td><td>GTT memory usage</td></tr><tr><td>`cpu_mem`</td><td>CPU memory usage</td></tr><tr><td>`vram_mem`</td><td>VRAM memory usage</td></tr> </tbody></table>
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_process_info` function:
|
||||
|
||||
@@ -839,7 +839,7 @@ def amdsmi_get_ras_block_features_enabled(
|
||||
|
||||
ras_state = amdsmi_wrapper.amdsmi_ras_err_state_t()
|
||||
ras_states = []
|
||||
for key, gpu_block in amdsmi_wrapper.amdsmi_gpu_block__enumvalues.items():
|
||||
for key, gpu_block in amdsmi_wrapper.amdsmi_gpu_block_t__enumvalues.items():
|
||||
if gpu_block == "AMDSMI_GPU_BLOCK_RESERVED":
|
||||
continue
|
||||
if gpu_block == "AMDSMI_GPU_BLOCK_LAST":
|
||||
@@ -916,11 +916,11 @@ def amdsmi_get_process_info(
|
||||
"pid": info.pid,
|
||||
"mem": info.mem,
|
||||
"engine_usage": {
|
||||
"gfx": list(info.engine_usage.gfx),
|
||||
"compute": list(info.engine_usage.compute),
|
||||
"sdma": list(info.engine_usage.sdma),
|
||||
"enc": list(info.engine_usage.enc),
|
||||
"dec": list(info.engine_usage.dec),
|
||||
"gfx": info.engine_usage.gfx,
|
||||
"compute": info.engine_usage.compute,
|
||||
"dma": info.engine_usage.dma,
|
||||
"enc": info.engine_usage.enc,
|
||||
"dec": info.engine_usage.dec,
|
||||
},
|
||||
"memory_usage": {
|
||||
"gtt_mem": info.memory_usage.gtt_mem,
|
||||
@@ -991,6 +991,7 @@ def amdsmi_get_power_measure(
|
||||
"average_socket_power": power_measure.average_socket_power,
|
||||
"voltage_gfx": power_measure.voltage_gfx,
|
||||
"energy_accumulator": power_measure.energy_accumulator,
|
||||
"power_limit" : power_measure.power_limit,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -697,6 +697,18 @@ amdsmi_process_handle = ctypes.c_uint32
|
||||
class struct_c__SA_amdsmi_proc_info_t(Structure):
|
||||
pass
|
||||
|
||||
class struct_c__SA_amdsmi_proc_info_t_0(Structure):
|
||||
pass
|
||||
|
||||
struct_c__SA_amdsmi_proc_info_t_0._pack_ = 1 # source:False
|
||||
struct_c__SA_amdsmi_proc_info_t_0._fields_ = [
|
||||
('gfx', ctypes.c_uint64),
|
||||
('compute', ctypes.c_uint64),
|
||||
('dma', ctypes.c_uint64),
|
||||
('enc', ctypes.c_uint64),
|
||||
('dec', ctypes.c_uint64),
|
||||
]
|
||||
|
||||
class struct_c__SA_amdsmi_proc_info_t_1(Structure):
|
||||
pass
|
||||
|
||||
@@ -707,18 +719,6 @@ struct_c__SA_amdsmi_proc_info_t_1._fields_ = [
|
||||
('vram_mem', ctypes.c_uint64),
|
||||
]
|
||||
|
||||
class struct_c__SA_amdsmi_proc_info_t_0(Structure):
|
||||
pass
|
||||
|
||||
struct_c__SA_amdsmi_proc_info_t_0._pack_ = 1 # source:False
|
||||
struct_c__SA_amdsmi_proc_info_t_0._fields_ = [
|
||||
('gfx', ctypes.c_uint16 * 8),
|
||||
('compute', ctypes.c_uint16 * 8),
|
||||
('sdma', ctypes.c_uint16 * 8),
|
||||
('enc', ctypes.c_uint16 * 8),
|
||||
('dec', ctypes.c_uint16 * 8),
|
||||
]
|
||||
|
||||
struct_c__SA_amdsmi_proc_info_t._pack_ = 1 # source:False
|
||||
struct_c__SA_amdsmi_proc_info_t._fields_ = [
|
||||
('name', ctypes.c_char * 32),
|
||||
|
||||
@@ -300,17 +300,20 @@ amdsmi_status_t amdsmi_get_board_info(amdsmi_device_handle device_handle, amdsmi
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
// Get from sys file
|
||||
status = smi_amdgpu_get_board_info(gpu_device, board_info);
|
||||
if (gpu_device->check_if_drm_is_supported()) {
|
||||
// Get from sys file
|
||||
status = smi_amdgpu_get_board_info(gpu_device, board_info);
|
||||
}
|
||||
else {
|
||||
// ignore the errors so that it can populate as many fields as possible.
|
||||
// call rocm-smi which search multiple places for device name
|
||||
status = rsmi_wrapper(rsmi_dev_name_get, device_handle,
|
||||
board_info->product_name, AMDSMI_PRODUCT_NAME_LENGTH);
|
||||
|
||||
// ignore the errors so that it can populate as many fields as possible.
|
||||
// call rocm-smi which search multiple places for device name
|
||||
status = rsmi_wrapper(rsmi_dev_name_get, device_handle,
|
||||
board_info->product_name, AMDSMI_PRODUCT_NAME_LENGTH);
|
||||
|
||||
if (board_info->product_serial[0] == '\0') {
|
||||
status = rsmi_wrapper(rsmi_dev_serial_number_get, device_handle,
|
||||
board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
if (board_info->product_serial[0] == '\0') {
|
||||
status = rsmi_wrapper(rsmi_dev_serial_number_get, device_handle,
|
||||
board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
@@ -588,7 +591,7 @@ amdsmi_get_asic_info(amdsmi_device_handle device_handle, amdsmi_asic_info_t *inf
|
||||
std::string path = "/sys/class/drm/" + gpu_device->get_gpu_path() + "/device/unique_id";
|
||||
FILE *fp = fopen(path.c_str(), "r");
|
||||
if (fp) {
|
||||
fscanf(fp, "%s", &info->asic_serial);
|
||||
fscanf(fp, "%s", info->asic_serial);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@@ -1079,23 +1082,26 @@ amdsmi_get_power_cap_info(amdsmi_device_handle device_handle,
|
||||
// Ignore errors to get as much as possible info.
|
||||
memset(info, 0, sizeof(amdsmi_power_cap_info_t));
|
||||
|
||||
// Get power_cap and dpm
|
||||
int power_cap = 0;
|
||||
int dpm = 0;
|
||||
status = smi_amdgpu_get_power_cap(gpudevice, &power_cap);
|
||||
if (gpudevice->check_if_drm_is_supported()) {
|
||||
// Get power_cap and dpm
|
||||
int power_cap = 0;
|
||||
int dpm = 0;
|
||||
status = smi_amdgpu_get_power_cap(gpudevice, &power_cap);
|
||||
|
||||
info->power_cap = power_cap;
|
||||
status = smi_amdgpu_get_ranges(gpudevice, CLK_TYPE_GFX,
|
||||
NULL, NULL, &dpm);
|
||||
info->dpm_cap = dpm;
|
||||
|
||||
// Get other information from rocm-smi
|
||||
auto rsmi_status = rsmi_dev_power_cap_default_get(gpudevice->get_gpu_id(),
|
||||
&(info->default_power_cap));
|
||||
rsmi_status = rsmi_dev_power_cap_range_get(gpudevice->get_gpu_id(),
|
||||
sensor_ind, &(info->max_power_cap), &(info->min_power_cap));
|
||||
rsmi_status = rsmi_dev_power_cap_get(gpudevice->get_gpu_id(),
|
||||
sensor_ind, &(info->power_cap));
|
||||
info->power_cap = power_cap;
|
||||
status = smi_amdgpu_get_ranges(gpudevice, CLK_TYPE_GFX,
|
||||
NULL, NULL, &dpm);
|
||||
info->dpm_cap = dpm;
|
||||
}
|
||||
else {
|
||||
// Get other information from rocm-smi
|
||||
auto rsmi_status = rsmi_dev_power_cap_default_get(gpudevice->get_gpu_id(),
|
||||
&(info->default_power_cap));
|
||||
rsmi_status = rsmi_dev_power_cap_range_get(gpudevice->get_gpu_id(),
|
||||
sensor_ind, &(info->max_power_cap), &(info->min_power_cap));
|
||||
rsmi_status = rsmi_dev_power_cap_get(gpudevice->get_gpu_id(),
|
||||
sensor_ind, &(info->power_cap));
|
||||
}
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1945,7 +1951,7 @@ amdsmi_status_t amdsmi_get_device_handle_from_bdf(amdsmi_bdf_t bdf,
|
||||
return status;
|
||||
}
|
||||
|
||||
for (auto idx = 0; idx < device_count; idx++) {
|
||||
for (uint32_t idx = 0; idx < device_count; idx++) {
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
status = get_gpu_device_from_handle(devs[idx], &gpu_device);
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
static const char *container_type_name[AMDSMI_MAX_CONTAINER_TYPE] = {
|
||||
[CONTAINER_LXC] = "lxc",
|
||||
[CONTAINER_DOCKER] = "docker",
|
||||
};
|
||||
|
||||
amdsmi_status_t gpuvsmi_pid_is_gpu(const std::string &path, const char *bdf)
|
||||
{
|
||||
DIR *d;
|
||||
@@ -155,85 +160,65 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
|
||||
if (it == pasids.end())
|
||||
pasids.push_back(pasid);
|
||||
} else if (line.find("gtt mem:") != std::string::npos) {
|
||||
} else if (line.find("drm-memory-gtt:") != std::string::npos) {
|
||||
unsigned long mem;
|
||||
|
||||
if (sscanf(line.c_str(), "gtt mem: %lu", &mem) != 1)
|
||||
if (sscanf(line.c_str(), "drm-memory-gtt: %lu", &mem) != 1)
|
||||
continue;
|
||||
|
||||
info.mem += mem * 1024;
|
||||
info.memory_usage.gtt_mem += mem * 1024;
|
||||
} else if (line.find("cpu mem:") != std::string::npos) {
|
||||
} else if (line.find("drm-memory-cpu:") != std::string::npos) {
|
||||
unsigned long mem;
|
||||
|
||||
if (sscanf(line.c_str(), "cpu mem: %lu", &mem) != 1)
|
||||
if (sscanf(line.c_str(), "drm-memory-cpu: %lu", &mem) != 1)
|
||||
continue;
|
||||
|
||||
info.mem += mem * 1024;
|
||||
info.memory_usage.cpu_mem += mem * 1024;
|
||||
} else if (line.find("vram mem:") != std::string::npos) {
|
||||
} else if (line.find("drm-memory-vram:") != std::string::npos) {
|
||||
unsigned long mem;
|
||||
|
||||
if (sscanf(line.c_str(), "vram mem: %lu", &mem) != 1)
|
||||
if (sscanf(line.c_str(), "drm-memory-vram: %lu", &mem) != 1)
|
||||
continue;
|
||||
|
||||
info.mem += mem * 1024;
|
||||
info.memory_usage.vram_mem += mem * 1024;
|
||||
} else if (line.find("gfx") != std::string::npos) {
|
||||
float usage;
|
||||
int ring;
|
||||
} else if (line.find("drm-engine-gfx") != std::string::npos) {
|
||||
uint64_t engine_gfx;
|
||||
|
||||
if (sscanf(line.c_str(), "gfx%d: %f%%", &ring, &usage) != 2)
|
||||
if (sscanf(line.c_str(), "drm-engine-gfx: %lu", &engine_gfx) != 1)
|
||||
continue;
|
||||
|
||||
if (ring >= AMDSMI_MAX_MM_IP_COUNT)
|
||||
info.engine_usage.gfx = engine_gfx;
|
||||
} else if (line.find("drm-engine-compute") != std::string::npos) {
|
||||
uint64_t engine_compute;
|
||||
|
||||
if (sscanf(line.c_str(), "drm-engine-compute: %lu", &engine_compute) != 1)
|
||||
continue;
|
||||
|
||||
info.engine_usage.gfx[ring] += (uint16_t)(usage * 100);
|
||||
} else if (line.find("compute") != std::string::npos) {
|
||||
float usage;
|
||||
int ring;
|
||||
info.engine_usage.compute = engine_compute;
|
||||
} else if (line.find("drm-engine-dma") != std::string::npos) {
|
||||
uint64_t engine_dma;
|
||||
|
||||
if (sscanf(line.c_str(), "compute%d: %f%%", &ring, &usage) != 2)
|
||||
if (sscanf(line.c_str(), "drm-engine-dma: %lu", &engine_dma) != 1)
|
||||
continue;
|
||||
|
||||
if (ring >= AMDSMI_MAX_MM_IP_COUNT)
|
||||
info.engine_usage.dma = engine_dma;
|
||||
} else if (line.find("drm-engine-enc") != std::string::npos) {
|
||||
uint64_t engine_enc;
|
||||
|
||||
if (sscanf(line.c_str(), "drm-engine-enc: %lu", &engine_enc) != 1)
|
||||
continue;
|
||||
|
||||
info.engine_usage.compute[ring] += (uint16_t)(usage * 100);
|
||||
} else if (line.find("dma") != std::string::npos) {
|
||||
float usage;
|
||||
int ring;
|
||||
info.engine_usage.enc = engine_enc;
|
||||
} else if (line.find("drm-engine-dec") != std::string::npos) {
|
||||
uint64_t engine_dec;
|
||||
|
||||
if (sscanf(line.c_str(), "dma%d: %f%%", &ring, &usage) != 2)
|
||||
if (sscanf(line.c_str(), "drm-engine-dec: %lu", &engine_dec) != 1)
|
||||
continue;
|
||||
|
||||
if (ring >= AMDSMI_MAX_MM_IP_COUNT)
|
||||
continue;
|
||||
|
||||
info.engine_usage.sdma[ring] += (uint16_t)(usage * 100);
|
||||
} else if (line.find("enc") != std::string::npos) {
|
||||
float usage;
|
||||
int ring;
|
||||
|
||||
if (sscanf(line.c_str(), "enc%d: %f%%", &ring, &usage) != 2)
|
||||
continue;
|
||||
|
||||
if (ring >= AMDSMI_MAX_MM_IP_COUNT)
|
||||
continue;
|
||||
|
||||
info.engine_usage.enc[ring] += (uint16_t)(usage * 100);
|
||||
} else if (line.find("dec") != std::string::npos) {
|
||||
float usage;
|
||||
int ring;
|
||||
|
||||
if (sscanf(line.c_str(), "dec%d: %f%%", &ring, &usage) != 2)
|
||||
continue;
|
||||
|
||||
if (ring >= AMDSMI_MAX_MM_IP_COUNT)
|
||||
continue;
|
||||
|
||||
info.engine_usage.dec[ring] += (uint16_t)(usage * 100);
|
||||
info.engine_usage.dec = engine_dec;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,9 +241,25 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
(unsigned long) AMDSMI_NORMAL_STRING_LENGTH,
|
||||
name.length()));
|
||||
|
||||
for (int i = 0; i < AMDSMI_MAX_CONTAINER_TYPE; i++) {
|
||||
std::ifstream cgroup_info(cgroup_path.c_str());
|
||||
std::string container_id;
|
||||
for (std::string line; getline(cgroup_info, line);) {
|
||||
if (line.find(container_type_name[i]) != std::string::npos) {
|
||||
container_id = line.substr(line.find(container_type_name[i]) +
|
||||
strlen(container_type_name[i]) + 1, 16);
|
||||
strcpy(info.container_name, container_id.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strlen(info.container_name) > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
info.pid = (uint32_t)pid;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user