Merge amd-staging into amd-master 20230113
Signed-off-by: Hao Zhou <Hao.Zhou@amd.com> Change-Id: If4c1ada5b8ef50c8cb117efa71d004057d9311cb
This commit is contained in:
@@ -315,6 +315,7 @@ int main() {
|
||||
power_measure.average_socket_power);
|
||||
printf("\tEnergy accumulator: %d\n\n",
|
||||
power_measure.energy_accumulator);
|
||||
printf("\tGPU Power limit: %d\n\n", power_measure.power_limit);
|
||||
|
||||
// Get driver version
|
||||
char version[AMDSMI_MAX_DRIVER_VERSION_LENGTH];
|
||||
@@ -356,13 +357,6 @@ int main() {
|
||||
printf(" %s: %d\n", ucode_name, fw_information.fw_info_list[j].fw_version);
|
||||
}
|
||||
|
||||
// Get GPU power limit info
|
||||
amdsmi_power_limit_t power_limit = {};
|
||||
ret = amdsmi_get_power_limit(device_handles[j], &power_limit);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_power_limit:\n");
|
||||
printf("\tGPU Power limit: %d\n\n", power_limit.limit);
|
||||
|
||||
// Get GFX clock measurements
|
||||
amdsmi_clk_measure_t gfx_clk_values = {};
|
||||
ret = amdsmi_get_clock_measure(device_handles[j], CLK_TYPE_GFX,
|
||||
@@ -399,42 +393,44 @@ int main() {
|
||||
printf("\tPCIe max speed: %d\n\n", pcie_caps_info.pcie_speed);
|
||||
|
||||
// Get VRAM temperature limit
|
||||
amdsmi_temperature_limit_t mem_temp_limit = {};
|
||||
ret = amdsmi_get_temperature_limit(
|
||||
device_handles[j], TEMPERATURE_TYPE_VRAM, &mem_temp_limit);
|
||||
int64_t temperature = 0;
|
||||
ret = amdsmi_dev_get_temp_metric(
|
||||
device_handles[j], TEMPERATURE_TYPE_VRAM,
|
||||
AMDSMI_TEMP_CRITICAL, &temperature);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_temperature_limit:\n");
|
||||
printf("\tGPU VRAM temp limit: %d\n", mem_temp_limit.limit);
|
||||
printf(" Output of amdsmi_dev_get_temp_metric:\n");
|
||||
printf("\tGPU VRAM temp limit: %d\n", temperature);
|
||||
|
||||
// Get GFX temperature limit
|
||||
amdsmi_temperature_limit_t gfx_temp_limit = {};
|
||||
ret = amdsmi_get_temperature_limit(
|
||||
device_handles[j], TEMPERATURE_TYPE_EDGE, &gfx_temp_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", gfx_temp_limit.limit);
|
||||
printf("\tGPU GFX temp limit: %d\n\n", temperature);
|
||||
|
||||
// Get temperature measurements
|
||||
// amdsmi_temperature_t edge_temp, junction_temp, vram_temp,
|
||||
// plx_temp;
|
||||
amdsmi_temperature_t temp_measurements[4];
|
||||
int64_t temp_measurements[4];
|
||||
amdsmi_temperature_type_t temp_types[4] = {
|
||||
TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_JUNCTION,
|
||||
TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_PLX};
|
||||
for (const auto &temp_type : temp_types) {
|
||||
ret = amdsmi_get_temperature_measure(
|
||||
ret = amdsmi_dev_get_temp_metric(
|
||||
device_handles[j], temp_type,
|
||||
AMDSMI_TEMP_CURRENT,
|
||||
&temp_measurements[(int)(temp_type)]);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
}
|
||||
printf(" Output of amdsmi_get_temperature_measure:\n");
|
||||
printf(" Output of amdsmi_dev_get_temp_metric:\n");
|
||||
printf("\tGPU Edge temp measurement: %d\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_EDGE].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_EDGE]);
|
||||
printf("\tGPU Junction temp measurement: %d\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_JUNCTION].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_JUNCTION]);
|
||||
printf("\tGPU VRAM temp measurement: %d\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_VRAM].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_VRAM]);
|
||||
printf("\tGPU PLX temp measurement: %d\n\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_PLX].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_PLX]);
|
||||
|
||||
// Get RAS features enabled
|
||||
char block_names[14][10] = {"UMC", "SDMA", "GFX", "MMHUB",
|
||||
|
||||
@@ -221,25 +221,26 @@ int main() {
|
||||
.fw_version);
|
||||
|
||||
// Get temperature measurements
|
||||
amdsmi_temperature_t temp_measurements[4];
|
||||
int64_t temp_measurements[4];
|
||||
amdsmi_temperature_type_t temp_types[4] = {
|
||||
TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_JUNCTION,
|
||||
TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_PLX};
|
||||
for (const auto &temp_type : temp_types) {
|
||||
ret = amdsmi_get_temperature_measure(
|
||||
ret = amdsmi_dev_get_temp_metric(
|
||||
device_handles[j], temp_type,
|
||||
AMDSMI_TEMP_CURRENT,
|
||||
&temp_measurements[(int)(temp_type)]);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
}
|
||||
printf(" Output of amdsmi_get_temperature_measure:\n");
|
||||
printf(" Output of amdsmi_dev_get_temp_metric:\n");
|
||||
printf("\tGPU Edge temp measurement: %d\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_EDGE].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_EDGE]);
|
||||
printf("\tGPU Junction temp measurement: %d\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_JUNCTION].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_JUNCTION]);
|
||||
printf("\tGPU VRAM temp measurement: %d\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_VRAM].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_VRAM]);
|
||||
printf("\tGPU PLX temp measurement: %d\n\n",
|
||||
temp_measurements[TEMPERATURE_TYPE_PLX].cur_temp);
|
||||
temp_measurements[TEMPERATURE_TYPE_PLX]);
|
||||
|
||||
// Get bad pages
|
||||
char bad_page_status_names[3][15] = {"RESERVED", "PENDING",
|
||||
|
||||
@@ -358,28 +358,14 @@ typedef struct amdsmi_board_info {
|
||||
char manufacturer_name[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
} amdsmi_board_info_t;
|
||||
|
||||
typedef struct amdsmi_temperature {
|
||||
uint32_t cur_temp;
|
||||
uint32_t reserved[7];
|
||||
} amdsmi_temperature_t;
|
||||
|
||||
typedef struct amdsmi_temperature_limit {
|
||||
uint32_t limit;
|
||||
uint32_t reserved[7];
|
||||
} amdsmi_temperature_limit_t;
|
||||
|
||||
typedef struct amdsmi_power_limit {
|
||||
uint32_t limit;
|
||||
uint32_t reserved[7];
|
||||
} amdsmi_power_limit_t;
|
||||
|
||||
typedef struct amdsmi_power_measure {
|
||||
uint32_t average_socket_power;
|
||||
uint64_t energy_accumulator; // v1 mod. (32->64)
|
||||
uint32_t voltage_gfx; // GFX voltage measurement in mV
|
||||
uint32_t voltage_soc; // SOC voltage measurement in mV
|
||||
uint32_t voltage_mem; // MEM voltage measurement in mV
|
||||
uint32_t reserved[10];
|
||||
uint32_t power_limit; // The power limit;
|
||||
uint32_t reserved[9];
|
||||
} amdsmi_power_measure_t;
|
||||
|
||||
typedef struct amdsmi_clk_measure {
|
||||
@@ -3812,52 +3798,6 @@ amdsmi_get_power_measure(amdsmi_device_handle device_handle, amdsmi_power_measur
|
||||
amdsmi_status_t
|
||||
amdsmi_get_clock_measure(amdsmi_device_handle device_handle, amdsmi_clk_type_t clk_type, amdsmi_clk_measure_t *info);
|
||||
|
||||
/**
|
||||
* @brief Returns temperature measurements of the GPU.
|
||||
* The results are in °C.
|
||||
*
|
||||
* @param[in] device_handle Device which to query
|
||||
*
|
||||
* @param[in] temp_type Enum representing the temperature type to query.
|
||||
*
|
||||
* @param[out] info Reference to the temperature measured.
|
||||
* Must be allocated by user.
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_temperature_measure(amdsmi_device_handle device_handle, amdsmi_temperature_type_t temp_type, amdsmi_temperature_t *info);
|
||||
|
||||
/**
|
||||
* @brief Returns temperature limit of the GPU.
|
||||
* The results are in °C.
|
||||
*
|
||||
* @param[in] device_handle Device which to query
|
||||
*
|
||||
* @param[in] temp_type Enum representing the temperature type to query.
|
||||
*
|
||||
* @param[out] limit Reference to the temperature limit.
|
||||
* Must be allocated by user.
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_temperature_limit(amdsmi_device_handle device_handle, amdsmi_temperature_type_t temp_type, amdsmi_temperature_limit_t *limit);
|
||||
|
||||
/**
|
||||
* @brief Returns power limit of the GPU.
|
||||
* The results are in W.
|
||||
*
|
||||
* @param[in] device_handle Device which to query
|
||||
*
|
||||
* @param[out] limit Reference to the power limit.
|
||||
* Must be allocated by user.
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_power_limit(amdsmi_device_handle device_handle, amdsmi_power_limit_t *power);
|
||||
|
||||
/**
|
||||
* @brief Returns the VRAM usage (both total and used memory)
|
||||
* in MegaBytes.
|
||||
|
||||
@@ -65,6 +65,8 @@ class AMDSmiDrm {
|
||||
std::vector<std::string>& get_drm_paths();
|
||||
bool check_if_drm_is_supported();
|
||||
|
||||
uint32_t get_vendor_id();
|
||||
|
||||
amdsmi_status_t amdgpu_query_info(int fd, unsigned info_id,
|
||||
unsigned size, void *value);
|
||||
amdsmi_status_t amdgpu_query_fw(int fd, unsigned info_id, unsigned fw_type,
|
||||
@@ -78,6 +80,7 @@ class AMDSmiDrm {
|
||||
std::vector<int> drm_fds_; // drm file descriptor by gpu_index
|
||||
std::vector<std::string> drm_paths_; // drm path (renderD128 for example)
|
||||
std::vector<amdsmi_bdf_t> drm_bdfs_; // bdf
|
||||
uint32_t vendor_id;
|
||||
|
||||
AMDSmiLibraryLoader lib_loader_; // lazy load libdrm
|
||||
DrmCmdWriteFunc drm_cmd_write_; // drmCommandWrite
|
||||
|
||||
@@ -72,6 +72,7 @@ class AMDSmiGPUDevice: public AMDSmiDevice {
|
||||
std::string& get_gpu_path();
|
||||
amdsmi_bdf_t get_bdf();
|
||||
bool check_if_drm_is_supported() { return drm_.check_if_drm_is_supported(); }
|
||||
uint32_t get_vendor_id();
|
||||
|
||||
amdsmi_status_t amdgpu_query_info(unsigned info_id,
|
||||
unsigned size, void *value) const;
|
||||
@@ -85,6 +86,7 @@ class AMDSmiGPUDevice: public AMDSmiDevice {
|
||||
uint32_t fd_;
|
||||
std::string path_;
|
||||
amdsmi_bdf_t bdf_;
|
||||
uint32_t vendor_id_;
|
||||
AMDSmiDrm& drm_;
|
||||
shared_mutex_t mutex_;
|
||||
};
|
||||
|
||||
+5
-167
@@ -448,51 +448,7 @@ Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`FW_ID_SMU` | SMU info
|
||||
`FW_ID_CP_CE` | CP_CE info
|
||||
`FW_ID_CP_PFP` | CP_PFP info
|
||||
`FW_ID_CP_ME` | CP_ME info
|
||||
`FW_ID_CP_MEC_JT1` | CP_MEC_JT1 info
|
||||
`FW_ID_CP_MEC_JT2` | CP_MEC_JT2 info
|
||||
`FW_ID_CP_MEC1` | CP_MEC1 info
|
||||
`FW_ID_CP_MEC2` | CP_MEC2 info
|
||||
`FW_ID_RLC` | RLC info
|
||||
`FW_ID_SDMA0` | SDMA0 info
|
||||
`FW_ID_SDMA1` | SDMA1 info
|
||||
`FW_ID_SDMA2` | SDMA2 info
|
||||
`FW_ID_SDMA3` | SDMA3 info
|
||||
`FW_ID_SDMA4` | SDMA4 info
|
||||
`FW_ID_SDMA5` | SDMA5 info
|
||||
`FW_ID_SDMA6` | SDMA6 info
|
||||
`FW_ID_SDMA7` | SDMA7 info
|
||||
`FW_ID_VCN` | VCN info
|
||||
`FW_ID_UVD` | UVD info
|
||||
`FW_ID_VCE` | VCE info
|
||||
`FW_ID_ISP` | ISP info
|
||||
`FW_ID_DMCU_ERAM` | DMCU_ERAM info
|
||||
`FW_ID_DMCU_ISR` | DMCU_ISR info
|
||||
`FW_ID_RLC_RESTORE_LIST_GPM_MEM` | RLC_RESTORE_LIST_GPM_MEM info
|
||||
`FW_ID_RLC_RESTORE_LIST_SRM_MEM` | RLC_RESTORE_LIST_SRM_MEM info
|
||||
`FW_ID_RLC_RESTORE_LIST_CNTL` | RLC_RESTORE_LIST_CNTL info
|
||||
`FW_ID_RLC_V` | RLC_V info
|
||||
`FW_ID_MMSCH` | MMSCH info
|
||||
`FW_ID_PSP_SYSDRV` | PSP_SYSDRV info
|
||||
`FW_ID_PSP_SOSDRV` | PSP_SOSDRV info
|
||||
`FW_ID_PSP_TOC` | PSP_TOC info
|
||||
`FW_ID_PSP_KEYDB` | PSP_KEYDB info
|
||||
`FW_ID_DFC` | DFC info
|
||||
`FW_ID_PSP_SPL` | PSP_SPL info
|
||||
`FW_ID_DRV_CAP` | DRV_CAP info
|
||||
`FW_ID_MC` | MC info
|
||||
`FW_ID_PSP_BL` | PSP_BL info
|
||||
`FW_ID_CP_PM4` | CP_PM4 info
|
||||
`FW_ID_ASD` | ASD info
|
||||
`FW_ID_TA_RAS` | TA_RAS info
|
||||
`FW_ID_XGMI` | XGMI info
|
||||
`FW_ID_RLC_SRLG` | RLC_SRLG info
|
||||
`FW_ID_RLC_SRLS` | RLC_SRLS info
|
||||
`FW_ID_SMC` | SMC info
|
||||
`FW_ID_DMCU` | DMCU info
|
||||
`fw_list`| List of dictionaries that contain information about a certain firmware block
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_fw_info` function:
|
||||
* `AmdSmiLibraryException`
|
||||
@@ -507,10 +463,10 @@ try:
|
||||
print("No GPUs on machine")
|
||||
else:
|
||||
for device in devices:
|
||||
fw_info = amdsmi_get_fw_info(device)
|
||||
for block_name, block_value in fw_info.items():
|
||||
print(block_name, str(block_value))
|
||||
|
||||
firmware_list = amdsmi_get_fw_info(device)['fw_list']
|
||||
for firmware_block in firmware_list:
|
||||
print(firmware_block['fw_name'])
|
||||
print(firmware_block['fw_version'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
@@ -615,49 +571,6 @@ try:
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
## amdsmi_get_temperature_measure
|
||||
Description: Returns the measurements of temperatures for the given GPU
|
||||
|
||||
Input parameters:
|
||||
|
||||
* `device_handle` device which to query
|
||||
* `temperature_type` one of `AmdSmiTemperatureType` enum values:
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`EDGE` | edge temperature type
|
||||
`JUNCTION` | junction temperature type
|
||||
`VRAM` | vram temperature type
|
||||
`HBM_0` | HBM_0 temperature type
|
||||
`HBM_1` | HBM_1 temperature type
|
||||
`HBM_2` | HBM_2 temperature type
|
||||
`HBM_3` | HBM_3 temperature type
|
||||
`PLX` | PLX temperature type
|
||||
|
||||
Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`cur_temp`| temperature value for the given temperature type
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_temperature_measure` function:
|
||||
* `AmdSmiLibraryException`
|
||||
* `AmdSmiRetryException`
|
||||
* `AmdSmiParameterException`
|
||||
|
||||
Example:
|
||||
```python
|
||||
try:
|
||||
devices = amdsmi_get_device_handles()
|
||||
if len(devices) == 0:
|
||||
print("No GPUs on machine")
|
||||
else:
|
||||
for device in devices:
|
||||
temperature_measure = amdsmi_get_temperature_measure(device, AmdSmiTemperatureType.EDGE)
|
||||
print(temperature_measure['cur_temp'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
## amdsmi_get_clock_measure
|
||||
Description: Returns the clock measure for the given GPU
|
||||
|
||||
@@ -709,81 +622,6 @@ try:
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
## amdsmi_get_power_limit
|
||||
Description: Returns the power limit for the given GPU
|
||||
|
||||
Input parameters:
|
||||
* `device_handle` device which to query
|
||||
|
||||
Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`limit`| power limit
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_power_limit` function:
|
||||
* `AmdSmiLibraryException`
|
||||
* `AmdSmiRetryException`
|
||||
* `AmdSmiParameterException`
|
||||
|
||||
Example:
|
||||
```python
|
||||
try:
|
||||
devices = amdsmi_get_device_handles()
|
||||
if len(devices) == 0:
|
||||
print("No GPUs on machine")
|
||||
else:
|
||||
for device in devices:
|
||||
power_limit = amdsmi_get_power_limit(device)
|
||||
print(power_limit['limit'])
|
||||
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
## amdsmi_get_temperature_limit
|
||||
Description: Returns the temperature limits for the given GPU
|
||||
|
||||
Input parameters:
|
||||
|
||||
* `device_handle` device which to query
|
||||
* `temperature_type` one of `AmdSmiTemperatureType` enum values:
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`EDGE` | edge temperature type
|
||||
`JUNCTION` | junction temperature type
|
||||
`VRAM` | vram temperature type
|
||||
`HBM_0` | HBM_0 temperature type
|
||||
`HBM_1` | HBM_1 temperature type
|
||||
`HBM_2` | HBM_2 temperature type
|
||||
`HBM_3` | HBM_3 temperature type
|
||||
`PLX` | PLX temperature type
|
||||
|
||||
Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`limit`| temperature limit for the given thermal domain
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_temperature_limit` function:
|
||||
* `AmdSmiLibraryException`
|
||||
* `AmdSmiRetryException`
|
||||
* `AmdSmiParameterException`
|
||||
|
||||
Example:
|
||||
```python
|
||||
try:
|
||||
devices = amdsmi_get_device_handles()
|
||||
if len(devices) == 0:
|
||||
print("No GPUs on machine")
|
||||
else:
|
||||
for device in devices:
|
||||
temperature_limit = amdsmi_get_temperature_limit(device, AmdSmiTemperatureType.EDGE)
|
||||
print(temperature_limit['limit'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
## amdsmi_get_pcie_link_status
|
||||
Description: Returns the pcie link status for the given GPU
|
||||
|
||||
@@ -50,12 +50,9 @@ from .amdsmi_interface import amdsmi_get_gpu_activity
|
||||
from .amdsmi_interface import amdsmi_get_vram_usage
|
||||
from .amdsmi_interface import amdsmi_get_power_measure
|
||||
from .amdsmi_interface import amdsmi_get_clock_measure
|
||||
from .amdsmi_interface import amdsmi_get_temperature_measure
|
||||
|
||||
from .amdsmi_interface import amdsmi_get_pcie_link_status
|
||||
from .amdsmi_interface import amdsmi_get_pcie_link_caps
|
||||
from .amdsmi_interface import amdsmi_get_power_limit
|
||||
from .amdsmi_interface import amdsmi_get_temperature_limit
|
||||
from .amdsmi_interface import amdsmi_get_bad_page_info
|
||||
|
||||
# # Power Management
|
||||
@@ -185,7 +182,7 @@ from .amdsmi_interface import AmdSmiInitFlags
|
||||
from .amdsmi_interface import AmdSmiContainerTypes
|
||||
from .amdsmi_interface import AmdSmiDeviceType
|
||||
from .amdsmi_interface import AmdSmiMmIp
|
||||
from .amdsmi_interface import AmdSmiFWBlock
|
||||
from .amdsmi_interface import AmdSmiFwBlock
|
||||
from .amdsmi_interface import AmdSmiClkType
|
||||
from .amdsmi_interface import AmdSmiTemperatureType
|
||||
from .amdsmi_interface import AmdSmiDevPerfLevel
|
||||
|
||||
@@ -56,7 +56,7 @@ class AmdSmiMmIp(IntEnum):
|
||||
VCN = amdsmi_wrapper.AMDSMI_MM_VCN
|
||||
|
||||
|
||||
class AmdSmiFWBlock(IntEnum):
|
||||
class AmdSmiFwBlock(IntEnum):
|
||||
FW_ID_SMU = amdsmi_wrapper.FW_ID_SMU
|
||||
FW_ID_CP_CE = amdsmi_wrapper.FW_ID_CP_CE
|
||||
FW_ID_CP_PFP = amdsmi_wrapper.FW_ID_CP_PFP
|
||||
@@ -376,38 +376,6 @@ _AMDSMI_GPU_UUID_SIZE = 38
|
||||
_AMDSMI_STRING_LENGTH = 80
|
||||
|
||||
|
||||
def _parse_fw_info(fw_info: amdsmi_wrapper.amdsmi_fw_info_t) -> Dict[str, Any]:
|
||||
"""
|
||||
Format firmware info extracted.
|
||||
|
||||
Parameters:
|
||||
fw_info(`amdsmi_fw_info_t`): Struct containing the extracted info to be
|
||||
formatted.
|
||||
|
||||
Returns:
|
||||
`dict`: All of the firmware info formatted into a dictionary.
|
||||
"""
|
||||
if not isinstance(fw_info, amdsmi_wrapper.amdsmi_fw_info_t):
|
||||
raise AmdSmiParameterException(
|
||||
fw_info, amdsmi_wrapper.amdsmi_fw_info_t)
|
||||
formatted_fw_info = dict()
|
||||
formatted_fw_info = {"num_fw_info": fw_info.num_fw_info}
|
||||
|
||||
|
||||
for i in range(0, fw_info.num_fw_info):
|
||||
index = fw_info.fw_info_list[i].fw_id
|
||||
value = amdsmi_wrapper.amdsmi_fw_block__enumvalues.get(index)
|
||||
if value == "FW_ID_FIRST":
|
||||
value = "FW_ID_SMU"
|
||||
if value == "FW_ID__MAX":
|
||||
continue
|
||||
|
||||
formatted_fw_info.update(
|
||||
{value: fw_info.fw_info_list[i].fw_version})
|
||||
|
||||
return formatted_fw_info
|
||||
|
||||
|
||||
def _format_bad_page_info(bad_page_info, bad_page_count: ctypes.c_uint32) -> List[Dict]:
|
||||
"""
|
||||
Format bad page info data retrieved.
|
||||
@@ -766,69 +734,6 @@ def amdsmi_get_clock_measure(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_get_temperature_measure(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
temperature_type: amdsmi_wrapper.amdsmi_temperature_type_t,
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
raise AmdSmiParameterException(
|
||||
device_handle, amdsmi_wrapper.amdsmi_device_handle
|
||||
)
|
||||
if not isinstance(temperature_type, AmdSmiTemperatureType):
|
||||
raise AmdSmiParameterException(temperature_type, AmdSmiTemperatureType)
|
||||
|
||||
temperature_measure = amdsmi_wrapper.amdsmi_temperature_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_temperature_measure(
|
||||
device_handle,
|
||||
amdsmi_wrapper.amdsmi_temperature_type_t(temperature_type),
|
||||
ctypes.byref(temperature_measure),
|
||||
)
|
||||
)
|
||||
|
||||
return {"cur_temp": temperature_measure.cur_temp}
|
||||
|
||||
|
||||
def amdsmi_get_power_limit(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
raise AmdSmiParameterException(
|
||||
device_handle, amdsmi_wrapper.amdsmi_device_handle
|
||||
)
|
||||
|
||||
power_limit = amdsmi_wrapper.amdsmi_power_limit_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_power_limit(
|
||||
device_handle, ctypes.byref(power_limit))
|
||||
)
|
||||
|
||||
return {"limit": power_limit.limit}
|
||||
|
||||
|
||||
def amdsmi_get_temperature_limit(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
temperature_type: amdsmi_wrapper.amdsmi_temperature_type_t,
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
raise AmdSmiParameterException(
|
||||
device_handle, amdsmi_wrapper.amdsmi_device_handle
|
||||
)
|
||||
if not isinstance(temperature_type, AmdSmiTemperatureType):
|
||||
raise AmdSmiParameterException(temperature_type, AmdSmiTemperatureType)
|
||||
|
||||
temperature_limit = amdsmi_wrapper.amdsmi_temperature_limit_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_temperature_limit(
|
||||
device_handle,
|
||||
amdsmi_wrapper.amdsmi_temperature_type_t(temperature_type),
|
||||
ctypes.byref(temperature_limit),
|
||||
)
|
||||
)
|
||||
|
||||
return {"limit": temperature_limit.limit}
|
||||
|
||||
|
||||
def amdsmi_get_bad_page_info(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
) -> Union[list, str]:
|
||||
@@ -1090,18 +995,23 @@ def amdsmi_get_power_measure(
|
||||
|
||||
|
||||
def amdsmi_get_fw_info(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
) -> Dict[str, Any]:
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle
|
||||
) -> List[Dict[str, Any]]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
raise AmdSmiParameterException(
|
||||
device_handle, amdsmi_wrapper.amdsmi_device_handle
|
||||
)
|
||||
|
||||
device_handle, amdsmi_wrapper.amdsmi_device_handle)
|
||||
fw_info = amdsmi_wrapper.amdsmi_fw_info_t()
|
||||
_check_res(amdsmi_wrapper.amdsmi_get_fw_info(
|
||||
device_handle, ctypes.byref(fw_info)))
|
||||
|
||||
return _parse_fw_info(fw_info)
|
||||
firmwares = list()
|
||||
for i in range(0, fw_info.num_fw_info):
|
||||
firmwares.append({
|
||||
'fw_name': AmdSmiFwBlock(fw_info.fw_info_list[i].fw_id),
|
||||
'fw_version': fw_info.fw_info_list[i].fw_version,
|
||||
})
|
||||
return {
|
||||
'fw_list': firmwares
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_get_vram_usage(
|
||||
@@ -1342,7 +1252,7 @@ def amdsmi_topo_get_link_weight(
|
||||
return weight.value
|
||||
|
||||
|
||||
def amdsmi_get_minmax_bandwidth(
|
||||
def amdsmi_get_minmax_bandwidth(
|
||||
device_handle_src: amdsmi_wrapper.amdsmi_device_handle,
|
||||
device_handle_dst: amdsmi_wrapper.amdsmi_device_handle,
|
||||
):
|
||||
@@ -1392,7 +1302,8 @@ def amdsmi_topo_get_link_type(
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_topo_get_link_type(
|
||||
#device_handle_src, device_handle_dst, ctypes.byref(hops), type
|
||||
device_handle_src, device_handle_dst, ctypes.byref(hops), ctypes.byref(type)
|
||||
device_handle_src, device_handle_dst, ctypes.byref(
|
||||
hops), ctypes.byref(type)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1529,7 +1440,7 @@ def amdsmi_read_counter(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_counter_get_available_counters(
|
||||
def amdsmi_counter_get_available_counters(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
event_group: AmdSmiEventGroup,
|
||||
) -> int:
|
||||
@@ -1550,7 +1461,7 @@ def amdsmi_counter_get_available_counters(
|
||||
return available.value
|
||||
|
||||
|
||||
def amdsmi_dev_set_perf_level(
|
||||
def amdsmi_dev_set_perf_level(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
perf_level: AmdSmiDevPerfLevel,
|
||||
):
|
||||
@@ -1565,7 +1476,7 @@ def amdsmi_dev_set_perf_level(
|
||||
device_handle, perf_level))
|
||||
|
||||
|
||||
def amdsmi_dev_get_power_profile_presets(
|
||||
def amdsmi_dev_get_power_profile_presets(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, sensor_idx: int
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -1651,7 +1562,7 @@ def amdsmi_dev_reset_fan(
|
||||
_check_res(amdsmi_wrapper.amdsmi_dev_reset_fan(device_handle, sensor_idx))
|
||||
|
||||
|
||||
def amdsmi_dev_set_clk_freq(
|
||||
def amdsmi_dev_set_clk_freq(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
clk_type: AmdSmiClkType,
|
||||
freq_bitmask: int,
|
||||
@@ -1672,7 +1583,7 @@ def amdsmi_dev_set_clk_freq(
|
||||
)
|
||||
|
||||
|
||||
def amdsmi_dev_set_overdrive_level_v1(
|
||||
def amdsmi_dev_set_overdrive_level_v1(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, overdrive_value: int
|
||||
):
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -1689,7 +1600,7 @@ def amdsmi_dev_set_overdrive_level_v1(
|
||||
)
|
||||
|
||||
|
||||
def amdsmi_dev_set_overdrive_level(
|
||||
def amdsmi_dev_set_overdrive_level(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, overdrive_value: int
|
||||
):
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -1814,7 +1725,7 @@ def amdsmi_get_func_iter_value(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_set_pci_bandwidth(
|
||||
def amdsmi_dev_set_pci_bandwidth(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, bitmask: int
|
||||
) -> None:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -1883,7 +1794,7 @@ def amdsmi_dev_get_pci_throughput(device_handle: amdsmi_wrapper.amdsmi_device_ha
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_get_pci_replay_counter(device_handle: amdsmi_wrapper.amdsmi_device_handle):
|
||||
def amdsmi_dev_get_pci_replay_counter(device_handle: amdsmi_wrapper.amdsmi_device_handle):
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
raise AmdSmiParameterException(
|
||||
device_handle, amdsmi_wrapper.amdsmi_device_handle
|
||||
@@ -1915,7 +1826,7 @@ def amdsmi_topo_get_numa_affinity(device_handle: amdsmi_wrapper.amdsmi_device_ha
|
||||
return numa_node.value
|
||||
|
||||
|
||||
def amdsmi_dev_set_power_cap(
|
||||
def amdsmi_dev_set_power_cap(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, sensor_ind: int, cap: int
|
||||
) -> None:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -1952,7 +1863,7 @@ def amdsmi_dev_get_power_ave(device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
return power.value
|
||||
|
||||
|
||||
def amdsmi_dev_set_power_profile(
|
||||
def amdsmi_dev_set_power_profile(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
reserved: int,
|
||||
profile: AmdSmiPowerProfilePresetMasks,
|
||||
@@ -2048,7 +1959,7 @@ def amdsmi_dev_get_memory_total(device_handle: amdsmi_wrapper.amdsmi_device_hand
|
||||
return total.value
|
||||
|
||||
|
||||
def amdsmi_dev_set_od_clk_info(
|
||||
def amdsmi_dev_set_od_clk_info(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
level: AmdSmiFreqInd,
|
||||
value: int,
|
||||
@@ -2096,7 +2007,7 @@ def amdsmi_dev_get_memory_usage(device_handle: amdsmi_wrapper.amdsmi_device_hand
|
||||
return used.value
|
||||
|
||||
|
||||
def amdsmi_dev_set_od_volt_info(
|
||||
def amdsmi_dev_set_od_volt_info(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
vpoint: int,
|
||||
clk_value: int,
|
||||
@@ -2142,7 +2053,7 @@ def amdsmi_dev_get_memory_busy_percent(device_handle: amdsmi_wrapper.amdsmi_devi
|
||||
return busy_percent.value
|
||||
|
||||
|
||||
def amdsmi_dev_set_perf_level_v1(
|
||||
def amdsmi_dev_set_perf_level_v1(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
perf_lvl: AmdSmiDevPerfLevel,
|
||||
) -> None:
|
||||
@@ -2215,7 +2126,7 @@ def amdsmi_dev_get_fan_speed_max(
|
||||
return fan_speed.value
|
||||
|
||||
|
||||
def amdsmi_dev_get_temp_metric(
|
||||
def amdsmi_dev_get_temp_metric(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
sensor_type: AmdSmiTemperatureType,
|
||||
metric: AmdSmiTemperatureMetric,
|
||||
@@ -2239,7 +2150,7 @@ def amdsmi_dev_get_temp_metric(
|
||||
return temp_value.value
|
||||
|
||||
|
||||
def amdsmi_dev_get_volt_metric(
|
||||
def amdsmi_dev_get_volt_metric(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
sensor_type: AmdSmiVoltageType,
|
||||
metric: AmdSmiVoltageMetric,
|
||||
@@ -2383,7 +2294,7 @@ def amdsmi_dev_get_overdrive_level(
|
||||
return od_level.value
|
||||
|
||||
|
||||
def amdsmi_dev_get_gpu_clk_freq(
|
||||
def amdsmi_dev_get_gpu_clk_freq(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, clk_type: AmdSmiClkType
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2407,7 +2318,7 @@ def amdsmi_dev_get_gpu_clk_freq(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_get_od_volt_info(
|
||||
def amdsmi_dev_get_od_volt_info(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2444,7 +2355,7 @@ def amdsmi_dev_get_od_volt_info(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_get_gpu_metrics_info(
|
||||
def amdsmi_dev_get_gpu_metrics_info(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2497,7 +2408,7 @@ def amdsmi_dev_get_gpu_metrics_info(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_get_od_volt_curve_regions(
|
||||
def amdsmi_dev_get_od_volt_curve_regions(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, num_regions: int
|
||||
) -> List[Dict[str, Any]]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2536,7 +2447,7 @@ def amdsmi_dev_get_od_volt_curve_regions(
|
||||
return result
|
||||
|
||||
|
||||
def amdsmi_dev_get_power_profile_presets(
|
||||
def amdsmi_dev_get_power_profile_presets(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, sensor_idx: int
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2560,7 +2471,7 @@ def amdsmi_dev_get_power_profile_presets(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_get_ecc_count(
|
||||
def amdsmi_dev_get_ecc_count(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, block: AmdSmiGpuBlock
|
||||
) -> Dict[str, int]:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2583,7 +2494,7 @@ def amdsmi_dev_get_ecc_count(
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_dev_get_ecc_enabled(
|
||||
def amdsmi_dev_get_ecc_enabled(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle,
|
||||
) -> int:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
@@ -2600,7 +2511,7 @@ def amdsmi_dev_get_ecc_enabled(
|
||||
return blocks.value
|
||||
|
||||
|
||||
def amdsmi_dev_get_ecc_status(
|
||||
def amdsmi_dev_get_ecc_status(
|
||||
device_handle: amdsmi_wrapper.amdsmi_device_handle, block: AmdSmiGpuBlock
|
||||
) -> AmdSmiRasErrState:
|
||||
if not isinstance(device_handle, amdsmi_wrapper.amdsmi_device_handle):
|
||||
|
||||
@@ -653,33 +653,6 @@ amdsmi_board_info_t = struct_amdsmi_board_info
|
||||
class struct_amdsmi_temperature(Structure):
|
||||
pass
|
||||
|
||||
struct_amdsmi_temperature._pack_ = 1 # source:False
|
||||
struct_amdsmi_temperature._fields_ = [
|
||||
('cur_temp', ctypes.c_uint32),
|
||||
('reserved', ctypes.c_uint32 * 7),
|
||||
]
|
||||
|
||||
amdsmi_temperature_t = struct_amdsmi_temperature
|
||||
class struct_amdsmi_temperature_limit(Structure):
|
||||
pass
|
||||
|
||||
struct_amdsmi_temperature_limit._pack_ = 1 # source:False
|
||||
struct_amdsmi_temperature_limit._fields_ = [
|
||||
('limit', ctypes.c_uint32),
|
||||
('reserved', ctypes.c_uint32 * 7),
|
||||
]
|
||||
|
||||
amdsmi_temperature_limit_t = struct_amdsmi_temperature_limit
|
||||
class struct_amdsmi_power_limit(Structure):
|
||||
pass
|
||||
|
||||
struct_amdsmi_power_limit._pack_ = 1 # source:False
|
||||
struct_amdsmi_power_limit._fields_ = [
|
||||
('limit', ctypes.c_uint32),
|
||||
('reserved', ctypes.c_uint32 * 7),
|
||||
]
|
||||
|
||||
amdsmi_power_limit_t = struct_amdsmi_power_limit
|
||||
class struct_amdsmi_power_measure(Structure):
|
||||
pass
|
||||
|
||||
@@ -691,7 +664,8 @@ struct_amdsmi_power_measure._fields_ = [
|
||||
('voltage_gfx', ctypes.c_uint32),
|
||||
('voltage_soc', ctypes.c_uint32),
|
||||
('voltage_mem', ctypes.c_uint32),
|
||||
('reserved', ctypes.c_uint32 * 10),
|
||||
('power_limit', ctypes.c_uint32),
|
||||
('reserved', ctypes.c_uint32 * 9),
|
||||
('PADDING_1', ctypes.c_ubyte * 4),
|
||||
]
|
||||
|
||||
@@ -1733,15 +1707,6 @@ amdsmi_get_power_measure.argtypes = [amdsmi_device_handle, ctypes.POINTER(struct
|
||||
amdsmi_get_clock_measure = _libraries['libamd_smi.so'].amdsmi_get_clock_measure
|
||||
amdsmi_get_clock_measure.restype = amdsmi_status_t
|
||||
amdsmi_get_clock_measure.argtypes = [amdsmi_device_handle, amdsmi_clk_type_t, ctypes.POINTER(struct_amdsmi_clk_measure)]
|
||||
amdsmi_get_temperature_measure = _libraries['libamd_smi.so'].amdsmi_get_temperature_measure
|
||||
amdsmi_get_temperature_measure.restype = amdsmi_status_t
|
||||
amdsmi_get_temperature_measure.argtypes = [amdsmi_device_handle, amdsmi_temperature_type_t, ctypes.POINTER(struct_amdsmi_temperature)]
|
||||
amdsmi_get_temperature_limit = _libraries['libamd_smi.so'].amdsmi_get_temperature_limit
|
||||
amdsmi_get_temperature_limit.restype = amdsmi_status_t
|
||||
amdsmi_get_temperature_limit.argtypes = [amdsmi_device_handle, amdsmi_temperature_type_t, ctypes.POINTER(struct_amdsmi_temperature_limit)]
|
||||
amdsmi_get_power_limit = _libraries['libamd_smi.so'].amdsmi_get_power_limit
|
||||
amdsmi_get_power_limit.restype = amdsmi_status_t
|
||||
amdsmi_get_power_limit.argtypes = [amdsmi_device_handle, ctypes.POINTER(struct_amdsmi_power_limit)]
|
||||
amdsmi_get_vram_usage = _libraries['libamd_smi.so'].amdsmi_get_vram_usage
|
||||
amdsmi_get_vram_usage.restype = amdsmi_status_t
|
||||
amdsmi_get_vram_usage.argtypes = [amdsmi_device_handle, ctypes.POINTER(struct_amdsmi_vram_info)]
|
||||
@@ -1949,12 +1914,11 @@ __all__ = \
|
||||
'amdsmi_get_fw_info', 'amdsmi_get_gpu_activity',
|
||||
'amdsmi_get_minmax_bandwidth', 'amdsmi_get_pcie_link_caps',
|
||||
'amdsmi_get_pcie_link_status', 'amdsmi_get_power_cap_info',
|
||||
'amdsmi_get_power_limit', 'amdsmi_get_power_measure',
|
||||
'amdsmi_get_power_measure',
|
||||
'amdsmi_get_process_info', 'amdsmi_get_process_list',
|
||||
'amdsmi_get_ras_block_features_enabled',
|
||||
'amdsmi_get_socket_handles', 'amdsmi_get_socket_info',
|
||||
'amdsmi_get_target_frequency_range',
|
||||
'amdsmi_get_temperature_limit', 'amdsmi_get_temperature_measure',
|
||||
'amdsmi_get_utilization_count', 'amdsmi_get_vbios_info',
|
||||
'amdsmi_get_version', 'amdsmi_get_version_str',
|
||||
'amdsmi_get_vram_usage', 'amdsmi_get_xgmi_info',
|
||||
@@ -1972,7 +1936,7 @@ __all__ = \
|
||||
'amdsmi_od_volt_curve_t', 'amdsmi_od_volt_freq_data',
|
||||
'amdsmi_od_volt_freq_data_t', 'amdsmi_pcie_bandwidth',
|
||||
'amdsmi_pcie_bandwidth_t', 'amdsmi_pcie_info_t',
|
||||
'amdsmi_power_cap_info_t', 'amdsmi_power_limit_t',
|
||||
'amdsmi_power_cap_info_t',
|
||||
'amdsmi_power_measure_t', 'amdsmi_power_profile_preset_masks',
|
||||
'amdsmi_power_profile_preset_masks__enumvalues',
|
||||
'amdsmi_power_profile_preset_masks_t',
|
||||
@@ -1986,11 +1950,10 @@ __all__ = \
|
||||
'amdsmi_set_perf_determinism_mode', 'amdsmi_shut_down',
|
||||
'amdsmi_socket_handle', 'amdsmi_status_string', 'amdsmi_status_t',
|
||||
'amdsmi_stop_event_notification', 'amdsmi_sw_component_t',
|
||||
'amdsmi_sw_component_t__enumvalues', 'amdsmi_temperature_limit_t',
|
||||
'amdsmi_temperature_metric',
|
||||
'amdsmi_temperature_metric__enumvalues',
|
||||
'amdsmi_temperature_metric_t',
|
||||
'amdsmi_temperature_metric_t__enumvalues', 'amdsmi_temperature_t',
|
||||
'amdsmi_temperature_metric_t__enumvalues',
|
||||
'amdsmi_temperature_type', 'amdsmi_temperature_type_t',
|
||||
'amdsmi_temperature_type_t__enumvalues',
|
||||
'amdsmi_topo_get_link_type', 'amdsmi_topo_get_link_weight',
|
||||
@@ -2025,7 +1988,7 @@ __all__ = \
|
||||
'struct_amdsmi_power_limit', 'struct_amdsmi_power_measure',
|
||||
'struct_amdsmi_process_info', 'struct_amdsmi_process_info_0',
|
||||
'struct_amdsmi_process_info_1', 'struct_amdsmi_temperature',
|
||||
'struct_amdsmi_temperature_limit', 'struct_amdsmi_vbios_info',
|
||||
'struct_amdsmi_vbios_info',
|
||||
'struct_amdsmi_vram_info', 'struct_amdsmi_xgmi_info',
|
||||
'struct_c__SA_amdsmi_counter_value_t',
|
||||
'struct_c__SA_amdsmi_error_count_t',
|
||||
|
||||
+22
-146
@@ -555,7 +555,6 @@ amdsmi_status_t amdsmi_get_fw_info(amdsmi_device_handle device_handle,
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO(bliu) : add other asic info
|
||||
amdsmi_status_t
|
||||
amdsmi_get_asic_info(amdsmi_device_handle device_handle, amdsmi_asic_info_t *info) {
|
||||
|
||||
@@ -569,6 +568,8 @@ amdsmi_get_asic_info(amdsmi_device_handle device_handle, amdsmi_asic_info_t *inf
|
||||
struct drm_amdgpu_info_vbios vbios = {};
|
||||
char* name;
|
||||
char *tmp;
|
||||
uint16_t vendor_id = 0;
|
||||
uint16_t subvendor_id = 0;
|
||||
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
amdsmi_status_t r = get_gpu_device_from_handle(device_handle, &gpu_device);
|
||||
@@ -598,24 +599,24 @@ amdsmi_get_asic_info(amdsmi_device_handle device_handle, amdsmi_asic_info_t *inf
|
||||
info->device_id = dev_info.device_id;
|
||||
info->family = dev_info.family;
|
||||
info->rev_id = dev_info.pci_rev;
|
||||
info->vendor_id = gpu_device->get_vendor_id();
|
||||
}
|
||||
// For other sysfs related information, get from rocm-smi
|
||||
uint16_t vendor_id = 0;
|
||||
else {
|
||||
status = rsmi_wrapper(rsmi_dev_serial_number_get, device_handle,
|
||||
info->asic_serial, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
|
||||
status = rsmi_wrapper(rsmi_dev_serial_number_get, device_handle,
|
||||
info->asic_serial, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
status = rsmi_wrapper(rsmi_dev_brand_get, device_handle,
|
||||
info->market_name, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
|
||||
status = rsmi_wrapper(rsmi_dev_brand_get, device_handle,
|
||||
info->market_name, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
status = rsmi_wrapper(rsmi_dev_vendor_id_get, device_handle,
|
||||
&vendor_id);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) info->vendor_id = vendor_id;
|
||||
|
||||
status = rsmi_wrapper(rsmi_dev_vendor_id_get, device_handle,
|
||||
&vendor_id);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) info->vendor_id = vendor_id;
|
||||
|
||||
vendor_id = 0;
|
||||
status = rsmi_wrapper(rsmi_dev_subsystem_vendor_id_get, device_handle,
|
||||
&vendor_id);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) info->subvendor_id = vendor_id;
|
||||
status = rsmi_wrapper(rsmi_dev_subsystem_vendor_id_get, device_handle,
|
||||
&subvendor_id);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) info->subvendor_id = subvendor_id;
|
||||
}
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1467,29 +1468,6 @@ amdsmi_get_gpu_activity(amdsmi_device_handle device_handle, amdsmi_engine_usage_
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_power_limit(amdsmi_device_handle device_handle, amdsmi_power_limit_t *power) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (power == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
amdsmi_status_t r = get_gpu_device_from_handle(device_handle, &gpu_device);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
amdsmi_status_t status;
|
||||
int power_limit;
|
||||
status = smi_amdgpu_get_power_cap(gpu_device, &power_limit);
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
power->limit = (uint16_t)(power_limit);
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_clock_measure(amdsmi_device_handle device_handle, amdsmi_clk_type_t clk_type, amdsmi_clk_measure_t *info) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
@@ -1545,115 +1523,6 @@ amdsmi_get_clock_measure(amdsmi_device_handle device_handle, amdsmi_clk_type_t c
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_temperature_limit(amdsmi_device_handle device_handle, amdsmi_temperature_type_t temp_type, amdsmi_temperature_limit_t *temp) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (temp == nullptr || temp_type > TEMPERATURE_TYPE__MAX) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
amdsmi_status_t r = get_gpu_device_from_handle(device_handle, &gpu_device);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
amdsmi_status_t status;
|
||||
std::string name;
|
||||
std::string path;
|
||||
switch (temp_type) {
|
||||
case TEMPERATURE_TYPE_EDGE:
|
||||
name = "edge";
|
||||
break;
|
||||
case TEMPERATURE_TYPE_JUNCTION:
|
||||
name = "junction";
|
||||
break;
|
||||
case TEMPERATURE_TYPE_VRAM:
|
||||
name = "mem";
|
||||
break;
|
||||
default:
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
status = smi_amdgpu_find_hwmon_dir(gpu_device, &path);
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
SMIGPUDEVICE_MUTEX(gpu_device->get_mutex())
|
||||
|
||||
for (int count = 1; ; count++) {
|
||||
std::string local_path = path + "/temp" +
|
||||
std::to_string(count);
|
||||
std::string local_temp = local_path + "_label";
|
||||
char f_name[10];
|
||||
std::ifstream file(local_temp.c_str(), std::ifstream::in);
|
||||
|
||||
if (!file.is_open()) {
|
||||
printf("Failed to open file: %s \n", local_temp.c_str());
|
||||
return AMDSMI_STATUS_API_FAILED;
|
||||
}
|
||||
|
||||
file.getline(f_name, 10);
|
||||
|
||||
if (!strstr(name.c_str(), f_name)) {
|
||||
int readTemp = 0;
|
||||
local_temp = local_path + "_crit";
|
||||
std::ifstream file2(local_temp.c_str(), std::ifstream::in);
|
||||
|
||||
if (!file2.is_open()) {
|
||||
printf("Failed to open file: %s \n", local_temp.c_str());
|
||||
return AMDSMI_STATUS_API_FAILED;
|
||||
}
|
||||
|
||||
file2.getline(f_name, 10);
|
||||
if (!sscanf(f_name, "%d", &readTemp)) {
|
||||
return AMDSMI_STATUS_API_FAILED;
|
||||
}
|
||||
temp->limit = (uint16_t)(readTemp / 1000);
|
||||
break;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
amdsmi_status_t
|
||||
amdsmi_get_temperature_measure(amdsmi_device_handle device_handle, amdsmi_temperature_type_t temp_type, amdsmi_temperature_t *info) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (info == nullptr || temp_type > TEMPERATURE_TYPE__MAX) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
amdsmi_gpu_metrics_t metrics;
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
amdsmi_status_t r = get_gpu_device_from_handle(device_handle, &gpu_device);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
amdsmi_status_t status;
|
||||
status = amdsmi_dev_get_gpu_metrics_info(device_handle, &metrics);
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
switch (temp_type) {
|
||||
case TEMPERATURE_TYPE_EDGE:
|
||||
info->cur_temp = metrics.temperature_edge;
|
||||
break;
|
||||
case TEMPERATURE_TYPE_JUNCTION:
|
||||
info->cur_temp = metrics.temperature_hotspot;
|
||||
break;
|
||||
case TEMPERATURE_TYPE_VRAM:
|
||||
info->cur_temp = metrics.temperature_mem;
|
||||
break;
|
||||
case TEMPERATURE_TYPE_PLX:
|
||||
info->cur_temp = metrics.temperature_vrsoc;
|
||||
break;
|
||||
default:
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_ras_block_features_enabled(amdsmi_device_handle device_handle, amdsmi_gpu_block block, amdsmi_ras_err_state_t *state) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
@@ -1833,6 +1702,13 @@ amdsmi_get_power_measure(amdsmi_device_handle device_handle, amdsmi_power_measur
|
||||
return status;
|
||||
}
|
||||
|
||||
int power_limit = 0;
|
||||
status = smi_amdgpu_get_power_cap(gpu_device, &power_limit);
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
info->power_limit = power_limit;
|
||||
|
||||
info->voltage_gfx = voltage_read;
|
||||
|
||||
info->average_socket_power = metrics.average_socket_power;
|
||||
|
||||
@@ -142,6 +142,8 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
bdf.bus_number = device->businfo.pci->bus;
|
||||
bdf.domain_number = device->businfo.pci->domain;
|
||||
|
||||
vendor_id = device->deviceinfo.pci->vendor_id;
|
||||
|
||||
drm_bdfs_.push_back(bdf);
|
||||
drm_free_device(&device);
|
||||
}
|
||||
@@ -261,6 +263,10 @@ std::vector<amdsmi_bdf_t> AMDSmiDrm::get_bdfs() {
|
||||
return drm_bdfs_;
|
||||
}
|
||||
|
||||
uint32_t AMDSmiDrm::get_vendor_id() {
|
||||
return vendor_id;
|
||||
}
|
||||
|
||||
} // namespace smi
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -63,6 +63,11 @@ std::string& AMDSmiGPUDevice::get_gpu_path() {
|
||||
amdsmi_bdf_t AMDSmiGPUDevice::get_bdf() {
|
||||
return bdf_;
|
||||
}
|
||||
|
||||
uint32_t AMDSmiGPUDevice::get_vendor_id() {
|
||||
return vendor_id_;
|
||||
}
|
||||
|
||||
amdsmi_status_t AMDSmiGPUDevice::get_drm_data() {
|
||||
amdsmi_status_t ret;
|
||||
uint32_t fd = 0;
|
||||
@@ -81,6 +86,7 @@ amdsmi_status_t AMDSmiGPUDevice::get_drm_data() {
|
||||
return AMDSMI_STATUS_INIT_ERROR;
|
||||
}
|
||||
bdf_ = bdf, path_ = path, fd_ = fd;
|
||||
vendor_id_ = drm_.get_vendor_id();
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user