Merge amd-staging into amd-master 20230710
Signed-off-by: Hao Zhou <Hao.Zhou@amd.com> Change-Id: I213f4f064b94187a9d157e51fb09c3051a26a449
This commit is contained in:
@@ -3390,16 +3390,21 @@ amdsmi_get_gpu_vram_usage(amdsmi_processor_handle processor_handle, amdsmi_vram_
|
|||||||
/**
|
/**
|
||||||
* @brief Returns the list of processes running on a given GPU including itself.
|
* @brief Returns the list of processes running on a given GPU including itself.
|
||||||
*
|
*
|
||||||
* @note The user provides a buffer to store the list and the
|
* @note The user provides a buffer to store the list and the maximum
|
||||||
* maximum number of processes that can be returned. If the user
|
* number of processes that can be returned. If the user sets
|
||||||
* sets max_processes to 0, the total number of processes will be
|
* max_processes to 0, the current total number of processes will
|
||||||
* returned.
|
* replace max_processes param. After that, the function needs to be
|
||||||
|
* called again, with updated max_processes, to successfully fill the
|
||||||
|
* process list, which was previously allocated with max_processes
|
||||||
*
|
*
|
||||||
* @param[in] processor_handle Device which to query
|
* @param[in] processor_handle Device which to query
|
||||||
*
|
*
|
||||||
* @param[in,out] max_processes Reference to the size of the list buffer in
|
* @param[in,out] max_processes Reference to the size of the list buffer in
|
||||||
* number of elements. Returns the return number of elements
|
* number of elements. Returns the return number of elements
|
||||||
* in list or the number of running processes if equal to 0.
|
* in list or the number of running processes if equal to 0,
|
||||||
|
* and if given value in param max_processes is less than
|
||||||
|
* number of processes currently running,
|
||||||
|
* AMDSMI_STATUS_OUT_OF_RESOURCES will be returned.
|
||||||
*
|
*
|
||||||
* @param[out] list Reference to a user-provided buffer where the process
|
* @param[out] list Reference to a user-provided buffer where the process
|
||||||
* list will be returned. This buffer must contain at least
|
* list will be returned. This buffer must contain at least
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ from collections.abc import Iterable
|
|||||||
from . import amdsmi_wrapper
|
from . import amdsmi_wrapper
|
||||||
from .amdsmi_exception import *
|
from .amdsmi_exception import *
|
||||||
|
|
||||||
|
MAX_NUM_PROCESSES = 1024
|
||||||
|
|
||||||
class AmdSmiInitFlags(IntEnum):
|
class AmdSmiInitFlags(IntEnum):
|
||||||
INIT_ALL_PROCESSORS = amdsmi_wrapper.AMDSMI_INIT_ALL_PROCESSORS
|
INIT_ALL_PROCESSORS = amdsmi_wrapper.AMDSMI_INIT_ALL_PROCESSORS
|
||||||
INIT_AMD_CPUS = amdsmi_wrapper.AMDSMI_INIT_AMD_CPUS
|
INIT_AMD_CPUS = amdsmi_wrapper.AMDSMI_INIT_AMD_CPUS
|
||||||
@@ -845,14 +847,7 @@ def amdsmi_get_gpu_process_list(
|
|||||||
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
||||||
)
|
)
|
||||||
|
|
||||||
max_processes = ctypes.c_uint32(0)
|
max_processes = ctypes.c_uint32(MAX_NUM_PROCESSES)
|
||||||
process_list = (amdsmi_wrapper.amdsmi_process_handle_t *
|
|
||||||
max_processes.value)()
|
|
||||||
_check_res(
|
|
||||||
amdsmi_wrapper.amdsmi_get_gpu_process_list(
|
|
||||||
processor_handle, ctypes.byref(max_processes), process_list
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
process_list = (amdsmi_wrapper.amdsmi_process_handle_t *
|
process_list = (amdsmi_wrapper.amdsmi_process_handle_t *
|
||||||
max_processes.value)()
|
max_processes.value)()
|
||||||
@@ -862,7 +857,8 @@ def amdsmi_get_gpu_process_list(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return [amdsmi_wrapper.amdsmi_process_handle_t(x) for x in list(process_list)]
|
return [amdsmi_wrapper.amdsmi_process_handle_t(process_list[x])\
|
||||||
|
for x in range(0, max_processes.value)]
|
||||||
|
|
||||||
|
|
||||||
def amdsmi_get_gpu_process_info(
|
def amdsmi_get_gpu_process_info(
|
||||||
|
|||||||
@@ -367,17 +367,19 @@ Monitor::setVoltSensorLabelMap(void) {
|
|||||||
}
|
}
|
||||||
auto add_volt_sensor_entry = [&](uint32_t file_index) {
|
auto add_volt_sensor_entry = [&](uint32_t file_index) {
|
||||||
ret = readMonitor(kMonVoltLabel, file_index, &type_str);
|
ret = readMonitor(kMonVoltLabel, file_index, &type_str);
|
||||||
rsmi_voltage_type_t t_type = kVoltSensorNameMap.at(type_str);
|
rsmi_voltage_type_t t_type;
|
||||||
|
|
||||||
// If readMonitor fails, there is no label file for the file_index.
|
// If readMonitor fails, there is no label file for the file_index.
|
||||||
// In that case, map the type to file index 0, which is not supported
|
// In that case, map the type to file index 0, which is not supported
|
||||||
// and will fail appropriately later when we check for support.
|
// and will fail appropriately later when we check for support.
|
||||||
if (ret) {
|
if (ret) {
|
||||||
volt_type_index_map_.insert({t_type, 0});
|
|
||||||
index_volt_type_map_.insert({file_index, RSMI_VOLT_TYPE_INVALID});
|
index_volt_type_map_.insert({file_index, RSMI_VOLT_TYPE_INVALID});
|
||||||
} else {
|
} else {
|
||||||
volt_type_index_map_.insert({t_type, file_index});
|
t_type = kVoltSensorNameMap.at(type_str);
|
||||||
|
volt_type_index_map_[t_type] = file_index;
|
||||||
index_volt_type_map_.insert({file_index, t_type});
|
index_volt_type_map_.insert({file_index, t_type});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -463,6 +465,8 @@ Monitor::getVoltSensorIndex(rsmi_voltage_type_t type) {
|
|||||||
|
|
||||||
rsmi_voltage_type_t
|
rsmi_voltage_type_t
|
||||||
Monitor::getVoltSensorEnum(uint64_t ind) {
|
Monitor::getVoltSensorEnum(uint64_t ind) {
|
||||||
|
// check if ind is a key or not
|
||||||
|
if (index_volt_type_map_.count(ind) == 0) return RSMI_VOLT_TYPE_INVALID;
|
||||||
return index_volt_type_map_.at(ind);
|
return index_volt_type_map_.at(ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user