Merge amd-staging into amd-master 20230907
Signed-off-by: Hao Zhou <Hao.Zhou@amd.com> Change-Id: I834fb22c825182a745e1ea83071e5b481825270d
This commit is contained in:
@@ -40,18 +40,20 @@
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "amd_smi/amdsmi.h"
|
||||
#include <bitset>
|
||||
#include <iostream>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <bitset>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "amd_smi/amdsmi.h"
|
||||
|
||||
|
||||
#define CHK_AMDSMI_RET(RET) \
|
||||
{ \
|
||||
@@ -272,8 +274,10 @@ int main() {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_gpu_device_bdf:\n");
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number, bdf.bus_number, bdf.device_number,
|
||||
bdf.function_number);
|
||||
bdf.fields.domain_number,
|
||||
bdf.fields.bus_number,
|
||||
bdf.fields.device_number,
|
||||
bdf.fields.function_number);
|
||||
|
||||
// Get handle from BDF
|
||||
amdsmi_processor_handle dev_handle;
|
||||
@@ -407,7 +411,7 @@ int main() {
|
||||
// Get temperature measurements
|
||||
// amdsmi_temperature_t edge_temp, junction_temp, vram_temp,
|
||||
// plx_temp;
|
||||
int64_t temp_measurements[4];
|
||||
int64_t temp_measurements[TEMPERATURE_TYPE__MAX + 1];
|
||||
amdsmi_temperature_type_t temp_types[4] = {
|
||||
TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_JUNCTION,
|
||||
TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_PLX};
|
||||
@@ -507,8 +511,11 @@ int main() {
|
||||
uint64_t mem = 0, gtt_mem = 0, cpu_mem = 0, vram_mem = 0;
|
||||
uint64_t gfx = 0, enc = 0;
|
||||
char bdf_str[20];
|
||||
sprintf(bdf_str, "%04lx:%02x:%02x.%d", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
sprintf(bdf_str, "%04lx:%02x:%02x.%d",
|
||||
bdf.fields.domain_number,
|
||||
bdf.fields.bus_number,
|
||||
bdf.fields.device_number,
|
||||
bdf.fields.function_number);
|
||||
int num = 0;
|
||||
ret = amdsmi_get_gpu_process_list(processor_handles[j], &num_process,
|
||||
process_list);
|
||||
@@ -543,7 +550,7 @@ int main() {
|
||||
"==+=========================================+\n");
|
||||
for (int it = 0; it < num; it++) {
|
||||
char command[30];
|
||||
struct passwd *pwd = NULL;
|
||||
struct passwd *pwd = nullptr;
|
||||
struct stat st;
|
||||
|
||||
sprintf(command, "/proc/%d", info_list[it].pid);
|
||||
|
||||
@@ -40,17 +40,21 @@
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "amd_smi/amdsmi.h"
|
||||
#include <bitset>
|
||||
#include <iostream>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <bitset>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "amd_smi/amdsmi.h"
|
||||
|
||||
#define CHK_AMDSMI_RET(RET) \
|
||||
{ \
|
||||
if (RET != AMDSMI_STATUS_SUCCESS) { \
|
||||
@@ -123,8 +127,10 @@ int main() {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_gpu_device_bdf:\n");
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number, bdf.bus_number, bdf.device_number,
|
||||
bdf.function_number);
|
||||
bdf.fields.domain_number,
|
||||
bdf.fields.bus_number,
|
||||
bdf.fields.device_number,
|
||||
bdf.fields.function_number);
|
||||
|
||||
amdsmi_asic_info_t asic_info = {};
|
||||
ret = amdsmi_get_gpu_asic_info(processor_handles[j], &asic_info);
|
||||
@@ -219,7 +225,7 @@ int main() {
|
||||
.fw_version);
|
||||
|
||||
// Get temperature measurements
|
||||
int64_t temp_measurements[4];
|
||||
int64_t temp_measurements[TEMPERATURE_TYPE__MAX + 1];
|
||||
amdsmi_temperature_type_t temp_types[4] = {
|
||||
TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_JUNCTION,
|
||||
TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_PLX};
|
||||
@@ -275,13 +281,6 @@ int main() {
|
||||
printf("\tCorrectable errors: %lu\n", err_cnt_info.correctable_count);
|
||||
printf("\tUncorrectable errors: %lu\n\n",
|
||||
err_cnt_info.uncorrectable_count);
|
||||
// Get process list
|
||||
auto compare = [](const void *a, const void *b) -> int {
|
||||
return (*(amdsmi_proc_info_t *)a).pid >
|
||||
(*(amdsmi_proc_info_t *)b).pid
|
||||
? 1
|
||||
: -1;
|
||||
};
|
||||
|
||||
// Get device name
|
||||
amdsmi_board_info_t board_info = {};
|
||||
|
||||
@@ -59,10 +59,11 @@ using namespace std;
|
||||
{ \
|
||||
if (RET != AMDSMI_STATUS_SUCCESS) { \
|
||||
const char *err_str; \
|
||||
const char **status_str; \
|
||||
std::cout << "AMDSMI call returned " << RET << " at line " \
|
||||
<< __LINE__ << std::endl; \
|
||||
amdsmi_status_code_to_string(RET, &err_str); \
|
||||
std::cout << err_str << std::endl; \
|
||||
*status_str = amdsmi_get_esmi_err_msg(RET, &err_str); \
|
||||
std::cout << *status_str << std::endl; \
|
||||
return RET; \
|
||||
} \
|
||||
}
|
||||
@@ -113,14 +114,14 @@ int main(int argc, char **argv) {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
std::cout << "core_count=" << core_count << std::endl;
|
||||
|
||||
ret = amdsmi_get_hsmp_proto_ver(&proto_ver);
|
||||
ret = amdsmi_get_cpu_hsmp_proto_ver(sockets[i], &proto_ver);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
|
||||
cout<<"\n------------------------------------------";
|
||||
cout<<"\n| HSMP Proto Version | "<< proto_ver <<"\t\t |"<< endl;
|
||||
cout<<"------------------------------------------\n";
|
||||
|
||||
ret = amdsmi_get_smu_fw_version(&smu_fw);
|
||||
ret = amdsmi_get_cpu_smu_fw_version(sockets[i], &smu_fw);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
|
||||
cout<<"\n------------------------------------------";
|
||||
@@ -289,7 +290,46 @@ int main(int argc, char **argv) {
|
||||
cout<<" NA (Err:" <<ret<<" |";
|
||||
}
|
||||
cout<<"\n-------------------------------------------------\n";
|
||||
|
||||
uint32_t input_power;
|
||||
powermax = 0;
|
||||
cout<<"\nEnter the max power to be set:\n";
|
||||
cin>>input_power;
|
||||
ret = amdsmi_get_cpu_socket_power_cap_max(sockets[i], i, &powermax);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
if ((ret == AMDSMI_STATUS_SUCCESS) && (input_power > powermax)) {
|
||||
cout<<"Input power is more than max power limit,"
|
||||
" limiting to "<<static_cast<double>(powermax)/1000<<"Watts\n";
|
||||
input_power = powermax;
|
||||
}
|
||||
ret = amdsmi_set_cpu_socket_power_cap(sockets[i], i, input_power);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
if (!ret) {
|
||||
cout<<"Socket["<<i<<"] power_limit set to "
|
||||
<<fixed<<setprecision(3)<<static_cast<double>(input_power)/1000<<" Watts successfully\n";
|
||||
}
|
||||
cout<<"\n-------------------------------------------------\n";
|
||||
|
||||
#if 0
|
||||
uint8_t mode;
|
||||
const char *err_str;
|
||||
cout <<"Enter the power efficiency mode to be set[0, 1 or 2]:\n";
|
||||
cin>>mode;
|
||||
ret = amdsmi_set_cpu_pwr_efficiency_mode(sockets[i], i, mode);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) {
|
||||
cout<<"Failed to set power efficiency mode for socket["<<i<<"], Err["
|
||||
<<ret<<"]: "<<amdsmi_get_esmi_err_msg(ret, &err_str)<<"\n";
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
cout<<"Power efficiency profile policy is set to "<<mode<<"successfully\n";
|
||||
|
||||
cout<<"\n-------------------------------------------------\n";
|
||||
|
||||
|
||||
uint32_t svi_power;
|
||||
cout<<"\n| SVI Power Telemetry (mWatts) \t |";
|
||||
|
||||
|
||||
+42
-17
@@ -352,12 +352,12 @@ typedef struct {
|
||||
} amdsmi_frequency_range_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
struct fields_ {
|
||||
uint64_t function_number : 3;
|
||||
uint64_t device_number : 5;
|
||||
uint64_t bus_number : 8;
|
||||
uint64_t domain_number : 48;
|
||||
};
|
||||
} fields;
|
||||
uint64_t as_uint;
|
||||
} amdsmi_bdf_t;
|
||||
|
||||
@@ -380,7 +380,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint8_t num_fw_info;
|
||||
struct {
|
||||
struct fw_info_list_ {
|
||||
amdsmi_fw_block_t fw_id;
|
||||
uint64_t fw_version;
|
||||
uint64_t reserved[2];
|
||||
@@ -391,11 +391,12 @@ typedef struct {
|
||||
typedef struct {
|
||||
char market_name[AMDSMI_MAX_STRING_LENGTH];
|
||||
uint32_t vendor_id; //< Use 32 bit to be compatible with other platform.
|
||||
char vendor_name[AMDSMI_MAX_STRING_LENGTH];
|
||||
uint32_t subvendor_id; //< The subsystem vendor id
|
||||
uint64_t device_id; //< The device id of a GPU
|
||||
uint32_t rev_id;
|
||||
char asic_serial[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
uint32_t reserved[3];
|
||||
uint32_t reserved[19];
|
||||
} amdsmi_asic_info_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -439,15 +440,15 @@ typedef struct {
|
||||
typedef uint32_t amdsmi_process_handle_t;
|
||||
|
||||
typedef struct {
|
||||
char name[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
amdsmi_process_handle_t pid;
|
||||
uint64_t mem; /** in bytes */
|
||||
struct {
|
||||
uint64_t gfx;
|
||||
uint64_t enc;
|
||||
char name[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
amdsmi_process_handle_t pid;
|
||||
uint64_t mem; /** in bytes */
|
||||
struct engine_usage_ {
|
||||
uint64_t gfx;
|
||||
uint64_t enc;
|
||||
uint32_t reserved[12];
|
||||
} engine_usage; /** How much time the process spend using these engines in ns */
|
||||
struct {
|
||||
} engine_usage; /** How much time the process spend using these engines in ns */
|
||||
struct memory_usage_ {
|
||||
uint64_t gtt_mem;
|
||||
uint64_t cpu_mem;
|
||||
uint64_t vram_mem;
|
||||
@@ -3685,20 +3686,24 @@ amdsmi_status_t amdsmi_get_cpu_socket_energy(amdsmi_cpusocket_handle socket_hand
|
||||
/**
|
||||
* @brief Get SMU Firmware Version.
|
||||
*
|
||||
* @param[in] socket_handle Cpu socket which to query
|
||||
* @param[in,out] amdsmi_smu_fw - Input buffer to return the firmware version
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_smu_fw_version(amdsmi_smu_fw_version_t *amdsmi_smu_fw);
|
||||
amdsmi_status_t amdsmi_get_cpu_smu_fw_version(amdsmi_cpusocket_handle socket_handle,
|
||||
amdsmi_smu_fw_version_t *amdsmi_smu_fw);
|
||||
|
||||
/**
|
||||
* @brief Get HSMP protocol Version.
|
||||
*
|
||||
* @param[in] socket_handle Cpu socket which to query
|
||||
* @param[in,out] proto_ver - Input buffer to return the protocol version
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_hsmp_proto_ver(uint32_t *proto_ver);
|
||||
amdsmi_status_t amdsmi_get_cpu_hsmp_proto_ver(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t *proto_ver);
|
||||
|
||||
/**
|
||||
* @brief Get normalized status of the processor's PROCHOT status.
|
||||
@@ -3938,11 +3943,13 @@ amdsmi_status_t amdsmi_set_cpu_socket_boostlimit(amdsmi_cpusocket_handle socket_
|
||||
/**
|
||||
* @brief Get the DDR bandwidth data.
|
||||
*
|
||||
* @param[in] socket_handle Cpu socket which to query
|
||||
* @param[in,out] ddr_bw - Input buffer to fill ddr bandwidth data
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_ddr_bw_metrics_t *ddr_bw);
|
||||
amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_cpusocket_handle socket_handle,
|
||||
amdsmi_ddr_bw_metrics_t *ddr_bw);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -4154,12 +4161,14 @@ amdsmi_status_t amdsmi_get_cpu_current_io_bandwidth(amdsmi_cpusocket_handle sock
|
||||
/**
|
||||
* @brief Get current input output bandwidth.
|
||||
*
|
||||
* @param[in] socket_handle Cpu socket which to query
|
||||
* @param[in] link - link id and bw type to which xgmi bandwidth to be obtained
|
||||
* @param[in,out] xgmi_bw - Input buffer to fill bandwidth data
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_cpu_current_xgmi_bw(amdsmi_link_id_bw_type_t link, uint32_t *xgmi_bw);
|
||||
amdsmi_status_t amdsmi_get_cpu_current_xgmi_bw(amdsmi_cpusocket_handle socket_handle,
|
||||
amdsmi_link_id_bw_type_t link, uint32_t *xgmi_bw);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -4216,14 +4225,30 @@ amdsmi_status_t amdsmi_get_number_of_cpu_sockets(uint32_t sockets);
|
||||
/**
|
||||
* @brief Get first online core on socket.
|
||||
*
|
||||
* @param[in] socket_handle Cpu socket which to query
|
||||
* @param[in] sock_ind - socket index.
|
||||
*
|
||||
* @param[in,out] sockets - Input buffer to fill first online core on socket data
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(uint32_t sock_ind, uint32_t *pcore_ind);
|
||||
amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint32_t *pcore_ind);
|
||||
|
||||
/**
|
||||
* @brief Get a description of provided AMDSMI error status for esmi errors.
|
||||
*
|
||||
* @details Set the provided pointer to a const char *, @p status_string, to
|
||||
* a string containing a description of the provided error code @p status.
|
||||
*
|
||||
* @param[in] status - The error status for which a description is desired.
|
||||
*
|
||||
* @param[in,out] status_string - A pointer to a const char * which will be made
|
||||
* to point to a description of the provided error code
|
||||
*
|
||||
* @return const char* returned on success
|
||||
*/
|
||||
const char* amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string);
|
||||
#endif
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generate py-interface and package targets
|
||||
|
||||
# match this version to your clang
|
||||
# too new won't work, too old won't work either
|
||||
# CLANG installed must be 14.0 or above
|
||||
set(clang_ver 14.0)
|
||||
set(ctypeslib_ver 2.3.2)
|
||||
|
||||
@@ -12,7 +11,6 @@ set(PY_PACKAGE_DIR "${PY_BUILD_DIR}/amdsmi")
|
||||
set(PY_WRAPPER_INSTALL_DIR "${SHARE_INSTALL_PREFIX}" CACHE STRING "Wrapper installation directory")
|
||||
|
||||
# TODO: Figure out how python-clang and clang are related
|
||||
# Currently only a very specific combination works
|
||||
|
||||
# try to find clang of the right version
|
||||
set(GOOD_CLANG_FOUND FALSE)
|
||||
@@ -22,7 +20,7 @@ if(BUILD_WRAPPER)
|
||||
# extract clang version manually because find_package(clang) doesn't work
|
||||
execute_process(COMMAND ${clang} --version OUTPUT_VARIABLE clang_full_version_string)
|
||||
string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
|
||||
if(CLANG_VERSION_STRING VERSION_EQUAL clang_ver)
|
||||
if((CLANG_VERSION_STRING VERSION_GREATER clang_ver) OR (CLANG_VERSION_STRING VERSION_EQUAL clang_ver))
|
||||
message("GOOD CLANG VERSION: ${CLANG_VERSION_STRING}")
|
||||
set(GOOD_CLANG_FOUND TRUE)
|
||||
else()
|
||||
@@ -47,9 +45,11 @@ if(NOT GOOD_CLANG_FOUND)
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/)
|
||||
else()
|
||||
find_package(Python3 3.7 COMPONENTS Interpreter Development REQUIRED)
|
||||
# --break-system-packages is needed for python 3.11
|
||||
# see: https://peps.python.org/pep-0668/
|
||||
add_custom_target(
|
||||
python_pre_reqs
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install clang==${clang_ver} ctypeslib2==${ctypeslib_ver})
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install --break-system-packages clang==${clang_ver} ctypeslib2==${ctypeslib_ver})
|
||||
# generate new wrapper
|
||||
configure_file(${PROJECT_SOURCE_DIR}/tools/generator.py generator.py @ONLY COPYONLY)
|
||||
add_custom_command(
|
||||
|
||||
@@ -445,10 +445,10 @@ def _format_bdf(amdsmi_bdf: amdsmi_wrapper.amdsmi_bdf_t) -> str:
|
||||
Returns:
|
||||
`str`: String containing BDF data in a readable format.
|
||||
"""
|
||||
domain = hex(amdsmi_bdf.c__UA_amdsmi_bdf_t_0.domain_number)[2:].zfill(4)
|
||||
bus = hex(amdsmi_bdf.c__UA_amdsmi_bdf_t_0.bus_number)[2:].zfill(2)
|
||||
device = hex(amdsmi_bdf.c__UA_amdsmi_bdf_t_0.device_number)[2:].zfill(2)
|
||||
function = hex(amdsmi_bdf.c__UA_amdsmi_bdf_t_0.function_number)[2:]
|
||||
domain = hex(amdsmi_bdf.fields.domain_number)[2:].zfill(4)
|
||||
bus = hex(amdsmi_bdf.fields.bus_number)[2:].zfill(2)
|
||||
device = hex(amdsmi_bdf.fields.device_number)[2:].zfill(2)
|
||||
function = hex(amdsmi_bdf.fields.function_number)[2:]
|
||||
|
||||
return domain + ":" + bus + ":" + device + "." + function
|
||||
|
||||
@@ -495,10 +495,10 @@ def _make_amdsmi_bdf_from_list(bdf):
|
||||
if len(bdf) != 4:
|
||||
return None
|
||||
amdsmi_bdf = amdsmi_wrapper.amdsmi_bdf_t()
|
||||
amdsmi_bdf.c__UA_amdsmi_bdf_t_0.function_number = bdf[3]
|
||||
amdsmi_bdf.c__UA_amdsmi_bdf_t_0.device_number = bdf[2]
|
||||
amdsmi_bdf.c__UA_amdsmi_bdf_t_0.bus_number = bdf[1]
|
||||
amdsmi_bdf.c__UA_amdsmi_bdf_t_0.domain_number = bdf[0]
|
||||
amdsmi_bdf.fields.function_number = bdf[3]
|
||||
amdsmi_bdf.fields.device_number = bdf[2]
|
||||
amdsmi_bdf.fields.bus_number = bdf[1]
|
||||
amdsmi_bdf.fields.domain_number = bdf[0]
|
||||
return amdsmi_bdf
|
||||
|
||||
|
||||
@@ -1422,32 +1422,6 @@ def amdsmi_set_gpu_perf_level(
|
||||
processor_handle, perf_level))
|
||||
|
||||
|
||||
def amdsmi_get_gpu_power_profile_presets(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, sensor_idx: int
|
||||
) -> Dict[str, Any]:
|
||||
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
|
||||
raise AmdSmiParameterException(
|
||||
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
||||
)
|
||||
if not isinstance(sensor_idx, int):
|
||||
raise AmdSmiParameterException(sensor_idx, int)
|
||||
|
||||
sensor_idx = ctypes.c_uint32(sensor_idx)
|
||||
status = amdsmi_wrapper.amdsmi_power_profile_status_t()
|
||||
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_gpu_power_profile_presets(
|
||||
processor_handle, sensor_idx, ctypes.byref(status)
|
||||
)
|
||||
)
|
||||
|
||||
return {
|
||||
"available_profiles": status.available_profiles,
|
||||
"current": status.current,
|
||||
"num_profiles": status.num_profiles,
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_reset_gpu(processor_handle: amdsmi_wrapper.amdsmi_processor_handle):
|
||||
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
|
||||
raise AmdSmiParameterException(
|
||||
@@ -1457,23 +1431,6 @@ def amdsmi_reset_gpu(processor_handle: amdsmi_wrapper.amdsmi_processor_handle):
|
||||
_check_res(amdsmi_wrapper.amdsmi_reset_gpu(processor_handle))
|
||||
|
||||
|
||||
def amdsmi_set_gpu_perf_determinism_mode(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, clock_value: int
|
||||
):
|
||||
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
|
||||
raise AmdSmiParameterException(
|
||||
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
||||
)
|
||||
if not isinstance(clock_value, int):
|
||||
raise AmdSmiParameterException(clock_value, int)
|
||||
clock_value = ctypes.c_uint64(clock_value)
|
||||
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_set_gpu_perf_determinism_mode(
|
||||
processor_handle, clock_value)
|
||||
)
|
||||
|
||||
|
||||
def amdsmi_set_gpu_fan_speed(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, sensor_idx: int, fan_speed: int
|
||||
):
|
||||
@@ -1998,7 +1955,7 @@ def amdsmi_get_utilization_count(
|
||||
|
||||
result = [{"timestamp": timestamp.value}]
|
||||
for idx in range(count.value):
|
||||
counter_type = amdsmi_wrapper.c__EA_AMDSMI_UTILIZATION_COUNTER_TYPE__enumvalues[
|
||||
counter_type = amdsmi_wrapper.AMDSMI_UTILIZATION_COUNTER_TYPE__enumvalues[
|
||||
util_counter_list[idx].type
|
||||
]
|
||||
if counter_type == "AMDSMI_UTILIZATION_COUNTER_LAST":
|
||||
@@ -2024,7 +1981,7 @@ def amdsmi_get_gpu_perf_level(
|
||||
processor_handle, ctypes.byref(perf))
|
||||
)
|
||||
|
||||
result = amdsmi_wrapper.c__EA_amdsmi_dev_perf_level_t__enumvalues[perf.value]
|
||||
result = amdsmi_wrapper.amdsmi_dev_perf_level_t__enumvalues[perf.value]
|
||||
if result == "AMDSMI_DEV_PERF_LEVEL_FIRST":
|
||||
result = "AMDSMI_DEV_PERF_LEVEL_AUTO"
|
||||
if result == "AMDSMI_DEV_PERF_LEVEL_LAST":
|
||||
|
||||
+394
-453
File diff suppressed because it is too large
Load Diff
@@ -722,6 +722,11 @@ int main() {
|
||||
CHK_RSMI_RET_I(ret)
|
||||
std::cout << "\t**Dev.Rev.ID: 0x" << std::hex << val_ui16 << std::endl;
|
||||
|
||||
char pcie_vendor_name[256];
|
||||
ret = rsmi_dev_pcie_vendor_name_get(i, pcie_vendor_name, 256);
|
||||
CHK_RSMI_RET_I(ret)
|
||||
std::cout << "\t**PCIe vendor name: " << pcie_vendor_name << std::endl;
|
||||
|
||||
char current_compute_partition[256];
|
||||
current_compute_partition[0] = '\0';
|
||||
ret = rsmi_dev_compute_partition_get(i, current_compute_partition, 256);
|
||||
|
||||
@@ -1155,6 +1155,43 @@ rsmi_status_t rsmi_dev_sku_get(uint32_t dv_ind, uint16_t *sku);
|
||||
*/
|
||||
rsmi_status_t rsmi_dev_vendor_id_get(uint32_t dv_ind, uint16_t *id);
|
||||
|
||||
/**
|
||||
* @brief Get the name string for a give PCIe vendor ID
|
||||
*
|
||||
* @details Given a device index @p dv_ind, a pointer to a caller provided
|
||||
* char buffer @p name, and a length of this buffer @p len, this function will
|
||||
* write the name of the PCIe vendor (up to @p len characters) buffer @p name.
|
||||
*
|
||||
* If the integer ID associated with the PCIe vendor is not found in one of the
|
||||
* system files containing device name information (e.g.
|
||||
* /usr/share/misc/pci.ids), then this function will return RSMI_STATUS_NOT_FOUND.
|
||||
* Updating the system name files can be accompplished with
|
||||
* "sudo update-pciids".
|
||||
*
|
||||
* @param[in] dv_ind a device index
|
||||
*
|
||||
* @param[inout] name a pointer to a caller provided char buffer to which the
|
||||
* name will be written
|
||||
* If this parameter is nullptr, this function will return
|
||||
* ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided,
|
||||
* arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the
|
||||
* provided arguments.
|
||||
*
|
||||
* @param[in] len the length of the caller provided buffer @p name.
|
||||
*
|
||||
* @retval ::RSMI_STATUS_SUCCESS call was successful
|
||||
* @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not
|
||||
* support this function with the given arguments
|
||||
* @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid
|
||||
* @retval ::RSMI_STATUS_NOT_FOUND the vnedor name are not found
|
||||
* @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not
|
||||
* large enough to hold the entire name. In this case, only @p len bytes will
|
||||
* be written.
|
||||
*
|
||||
*/
|
||||
rsmi_status_t rsmi_dev_pcie_vendor_name_get(uint32_t dv_ind, char *name,
|
||||
size_t len);
|
||||
|
||||
/**
|
||||
* @brief Get the name string of a gpu device.
|
||||
*
|
||||
|
||||
@@ -167,7 +167,12 @@ enum DevInfoTypes {
|
||||
kDevGpuReset,
|
||||
kDevAvailableComputePartition,
|
||||
kDevComputePartition,
|
||||
kDevMemoryPartition
|
||||
kDevMemoryPartition,
|
||||
|
||||
// The information read from pci core sysfs
|
||||
kDevPCieTypeStart = 1000,
|
||||
kDevPCieVendorID = kDevPCieTypeStart,
|
||||
kDevPCieTypeEND = 2000,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -103,6 +103,7 @@ std::tuple<bool, std::string, std::string, std::string, std::string,
|
||||
getSystemDetails(void);
|
||||
void logSystemDetails(void);
|
||||
rsmi_status_t getBDFString(uint64_t bdf_id, std::string& bfd_str);
|
||||
rsmi_status_t getBDFWithDomain(uint64_t bdf_id, std::string& bfd_str);
|
||||
void logHexDump(const char *desc, const void *addr, const size_t len,
|
||||
size_t perLine);
|
||||
bool isSystemBigEndian();
|
||||
|
||||
@@ -1979,6 +1979,28 @@ static rsmi_status_t get_dev_name_from_file(uint32_t dv_ind, char *name,
|
||||
return RSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// return empty if cannot find it in pci.ids
|
||||
static std::string get_vendor_name_from_id(uint16_t vendor_id) {
|
||||
for (auto fl : pci_name_files) {
|
||||
std::ifstream id_file_strm(fl);
|
||||
std::string ln;
|
||||
|
||||
while (std::getline(id_file_strm, ln)) {
|
||||
// parse line
|
||||
if (ln == "" || ln[0] == '#' || ln[0] == '\t') {
|
||||
continue;
|
||||
}
|
||||
std::istringstream ln_str(ln);
|
||||
std::string val_str = get_id_name_str_from_line(vendor_id, ln, &ln_str);
|
||||
|
||||
if (val_str != "") {
|
||||
return val_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Parse pci.ids files. Comment lines have # in first column. Otherwise,
|
||||
// Syntax:
|
||||
// vendor vendor_name
|
||||
@@ -2157,6 +2179,35 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) {
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_dev_pcie_vendor_name_get(uint32_t dv_ind, char *name, size_t len) {
|
||||
rsmi_status_t ret;
|
||||
|
||||
TRY
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << "| ======= start =======";
|
||||
LOG_TRACE(ss);
|
||||
CHK_SUPPORT_NAME_ONLY(name)
|
||||
|
||||
if (len == 0) {
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
DEVICE_MUTEX
|
||||
uint16_t id = 0;
|
||||
ret = get_id(dv_ind, amd::smi::kDevPCieVendorID, &id);
|
||||
if (ret != RSMI_STATUS_SUCCESS) return ret;
|
||||
std::string vendor_name = get_vendor_name_from_id(id);
|
||||
|
||||
if (vendor_name == "") {
|
||||
return RSMI_STATUS_NOT_FOUND;
|
||||
}
|
||||
memset(name, 0, len);
|
||||
strncpy(name, vendor_name.c_str(), len-1);
|
||||
return ret;
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len) {
|
||||
TRY
|
||||
|
||||
@@ -81,6 +81,9 @@ static const char *kPathDebugRootFName = "/sys/kernel/debug/dri/";
|
||||
// Device debugfs file names
|
||||
static const char *kDevGpuResetFName = "amdgpu_gpu_recover";
|
||||
|
||||
// PCI sysfs file names
|
||||
static const char *kDevPCieVendorIDFName = "vendor";
|
||||
|
||||
// Device sysfs file names
|
||||
static const char *kDevPerfLevelFName = "power_dpm_force_performance_level";
|
||||
static const char *kDevDevProdNameFName = "product_name";
|
||||
@@ -242,6 +245,7 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
|
||||
{kDevDevID, kDevDevIDFName},
|
||||
{kDevDevRevID, kDevDevRevIDFName},
|
||||
{kDevVendorID, kDevVendorIDFName},
|
||||
{kDevPCieVendorID, kDevPCieVendorIDFName},
|
||||
{kDevSubSysDevID, kDevSubSysDevIDFName},
|
||||
{kDevSubSysVendorID, kDevSubSysVendorIDFName},
|
||||
{kDevGPUMClk, kDevGPUMClkFName},
|
||||
@@ -589,6 +593,20 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
sysfs_path += "/device/";
|
||||
sysfs_path += kDevAttribNameMap.at(type);
|
||||
|
||||
// For the file under PCI sysfs
|
||||
if (type >= kDevPCieTypeStart && type <= kDevPCieTypeEND) {
|
||||
sysfs_path = "/sys/bus/pci/devices/";
|
||||
std::string bdf_str;
|
||||
if (getBDFWithDomain(bdfid_, bdf_str) != RSMI_STATUS_SUCCESS) {
|
||||
ss << "Fail to craft the bdf string";
|
||||
LOG_ERROR(ss);
|
||||
return 1;
|
||||
}
|
||||
sysfs_path += bdf_str;
|
||||
sysfs_path += "/";
|
||||
sysfs_path += kDevAttribNameMap.at(type);
|
||||
}
|
||||
|
||||
DBG_FILE_ERROR(sysfs_path, str);
|
||||
bool reg_file;
|
||||
|
||||
@@ -611,7 +629,7 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
|
||||
fs->open(sysfs_path);
|
||||
|
||||
if (!fs->is_open()) {
|
||||
if (!fs) {
|
||||
ss << "Could not open - SYSFS file (" << sysfs_path << ") for "
|
||||
<< "DevInfoInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << "), "
|
||||
<< ", returning " << std::to_string(errno) << " ("
|
||||
@@ -901,6 +919,7 @@ int Device::readDevInfo(DevInfoTypes type, uint64_t *val) {
|
||||
case kDevSubSysDevID:
|
||||
case kDevSubSysVendorID:
|
||||
case kDevVendorID:
|
||||
case kDevPCieVendorID:
|
||||
case kDevErrCntFeatures:
|
||||
ret = readDevInfoStr(type, &tempStr);
|
||||
RET_IF_NONZERO(ret);
|
||||
@@ -1038,6 +1057,7 @@ int Device::readDevInfo(DevInfoTypes type, std::string *val) {
|
||||
case kDevSubSysDevID:
|
||||
case kDevSubSysVendorID:
|
||||
case kDevVendorID:
|
||||
case kDevPCieVendorID:
|
||||
case kDevVramVendor:
|
||||
case kDevVBiosVer:
|
||||
case kDevPCIEThruPut:
|
||||
|
||||
@@ -150,7 +150,8 @@ amd::smi::RocmSMI::devInfoTypesStrings = {
|
||||
{amd::smi::kDevAvailableComputePartition, amdSMI +
|
||||
"kDevAvailableComputePartition"},
|
||||
{amd::smi::kDevComputePartition, amdSMI + "kDevComputePartition"},
|
||||
{amd::smi::kDevMemoryPartition, amdSMI + "kDevMemoryPartition"}
|
||||
{amd::smi::kDevMemoryPartition, amdSMI + "kDevMemoryPartition"},
|
||||
{amd::smi::kDevPCieVendorID, amdSMI + "kDevPCieVendorID"},
|
||||
};
|
||||
|
||||
namespace amd {
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <cstdint>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@@ -792,6 +793,29 @@ bool isSystemBigEndian() {
|
||||
return isBigEndian;
|
||||
}
|
||||
|
||||
rsmi_status_t getBDFWithDomain(uint64_t bdf_id, std::string& bfd_str)
|
||||
{
|
||||
auto result = rsmi_status_t::RSMI_STATUS_SUCCESS;
|
||||
auto domain_id = static_cast<uint32_t>(bdf_id >> 32);
|
||||
auto bus_id = static_cast<uint8_t>((bdf_id & 0x0000FF00) >> 8);
|
||||
auto dev_id = static_cast<uint8_t>((bdf_id & 0x000000F8) >> 3);
|
||||
auto func_id = static_cast<uint8_t>(bdf_id & 0x00000003);
|
||||
|
||||
bfd_str = std::string();
|
||||
if (!(bus_id > 0)) {
|
||||
result = rsmi_status_t::RSMI_STATUS_NO_DATA;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::stringstream bdf_sstream;
|
||||
bdf_sstream << std::hex << std::setfill('0') << std::setw(4) << +domain_id << ":";
|
||||
bdf_sstream << std::hex << std::setfill('0') << std::setw(2) << +bus_id << ":";
|
||||
bdf_sstream << std::hex << std::setfill('0') << std::setw(2) << +dev_id << ".";
|
||||
bdf_sstream << std::hex << std::setfill('0') << +func_id;
|
||||
bfd_str = bdf_sstream.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
rsmi_status_t getBDFString(uint64_t bdf_id, std::string& bfd_str)
|
||||
{
|
||||
auto result = rsmi_status_t::RSMI_STATUS_SUCCESS;
|
||||
|
||||
+535
-10
@@ -671,11 +671,10 @@ amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_i
|
||||
info->rev_id = dev_info.pci_rev;
|
||||
info->vendor_id = gpu_device->get_vendor_id();
|
||||
}
|
||||
// For other sysfs related information, get from rocm-smi
|
||||
else {
|
||||
uint64_t dv_uid = 0;
|
||||
status = rsmi_wrapper(rsmi_dev_unique_id_get, processor_handle, &dv_uid);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) snprintf(info->asic_serial, sizeof(info->asic_serial), "%d", dv_uid);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) snprintf(info->asic_serial, sizeof(info->asic_serial), "%lu", dv_uid);
|
||||
|
||||
status = rsmi_wrapper(rsmi_dev_brand_get, processor_handle,
|
||||
info->market_name, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
@@ -688,6 +687,9 @@ amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_i
|
||||
&subvendor_id);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) info->subvendor_id = subvendor_id;
|
||||
}
|
||||
// For other sysfs related information, get from rocm-smi
|
||||
status = rsmi_wrapper(rsmi_dev_pcie_vendor_name_get, processor_handle,
|
||||
info->vendor_name, AMDSMI_MAX_STRING_LENGTH);
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1847,10 +1849,10 @@ amdsmi_status_t amdsmi_get_processor_handle_from_bdf(amdsmi_bdf_t bdf,
|
||||
return status;
|
||||
}
|
||||
amdsmi_bdf_t found_bdf = gpu_device->get_bdf();
|
||||
if (bdf.bus_number == found_bdf.bus_number &&
|
||||
bdf.device_number == found_bdf.device_number &&
|
||||
bdf.domain_number == found_bdf.domain_number &&
|
||||
bdf.function_number == found_bdf.function_number) {
|
||||
if ((bdf.fields.bus_number == found_bdf.fields.bus_number) &&
|
||||
(bdf.fields.device_number == found_bdf.fields.device_number) &&
|
||||
(bdf.fields.domain_number == found_bdf.fields.domain_number) &&
|
||||
(bdf.fields.function_number == found_bdf.fields.function_number)) {
|
||||
*processor_handle = devs[idx];
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1861,14 +1863,20 @@ amdsmi_status_t amdsmi_get_processor_handle_from_bdf(amdsmi_bdf_t bdf,
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
amdsmi_status_t amdsmi_get_hsmp_proto_ver(uint32_t *proto_ver)
|
||||
amdsmi_status_t amdsmi_get_cpu_hsmp_proto_ver(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t *proto_ver)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t hsmp_proto_ver;
|
||||
|
||||
if (proto_ver == nullptr)
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_hsmp_proto_ver_get(&hsmp_proto_ver));
|
||||
*proto_ver = hsmp_proto_ver;
|
||||
|
||||
@@ -1878,14 +1886,20 @@ amdsmi_status_t amdsmi_get_hsmp_proto_ver(uint32_t *proto_ver)
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_smu_fw_version(amdsmi_smu_fw_version_t *amdsmi_smu_fw)
|
||||
amdsmi_status_t amdsmi_get_cpu_smu_fw_version(amdsmi_cpusocket_handle socket_handle,
|
||||
amdsmi_smu_fw_version_t *amdsmi_smu_fw)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
struct smu_fw_version smu_fw;
|
||||
|
||||
if (amdsmi_smu_fw == nullptr)
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_smu_fw_version_get(&smu_fw));
|
||||
|
||||
amdsmi_smu_fw->major = smu_fw.major;
|
||||
@@ -2179,6 +2193,483 @@ amdsmi_status_t amdsmi_get_cpu_pwr_svi_telemetry_all_rails(amdsmi_cpusocket_hand
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_socket_power_cap(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint32_t pcap)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_socket_power_cap_set(sock_ind, pcap));
|
||||
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_pwr_efficiency_mode(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t mode)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_pwr_efficiency_mode_set(sock_ind, mode));
|
||||
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_core_boostlimit(amdsmi_processor_handle processor_handle,
|
||||
uint32_t core_ind, uint32_t *pboostlimit)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t boostlimit;
|
||||
|
||||
if (processor_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuCore* core = nullptr;
|
||||
amdsmi_status_t r = get_cpu_core_from_handle(processor_handle, &core);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_core_boostlimit_get(core_ind, &boostlimit));
|
||||
*pboostlimit = boostlimit;
|
||||
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_socket_c0_residency(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint32_t *pc0_residency)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t res;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_socket_c0_residency_get(sock_ind, &res));
|
||||
*pc0_residency = res;
|
||||
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_core_boostlimit(amdsmi_processor_handle processor_handle,
|
||||
uint32_t core_ind, uint32_t boostlimit)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (processor_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuCore* core = nullptr;
|
||||
amdsmi_status_t r = get_cpu_core_from_handle(processor_handle, &core);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_core_boostlimit_set(core_ind, boostlimit));
|
||||
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_socket_boostlimit(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint32_t boostlimit)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_socket_boostlimit_set(sock_ind, boostlimit));
|
||||
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_cpusocket_handle socket_handle,
|
||||
amdsmi_ddr_bw_metrics_t *ddr_bw)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
struct ddr_bw_metrics ddr;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_ddr_bw_get(&ddr));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
ddr_bw->max_bw = ddr.max_bw;
|
||||
ddr_bw->utilized_bw = ddr.utilized_bw;
|
||||
ddr_bw->utilized_pct = ddr.utilized_pct;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_socket_temperature(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint32_t *ptmon)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t tmon;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_socket_temperature_get(sock_ind, &tmon));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
*ptmon = tmon;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(
|
||||
amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t dimm_addr, amdsmi_temp_range_refresh_rate_t *rate)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
struct temp_range_refresh_rate dimm_rate;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_dimm_temp_range_and_refresh_rate_get(
|
||||
sock_ind, dimm_addr, &dimm_rate));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
rate->range = dimm_rate.range;
|
||||
rate->ref_rate = dimm_rate.ref_rate;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_dimm_power_consumption(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t dimm_addr, amdsmi_dimm_power_t *dimm_pow)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
struct dimm_power d_power;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_dimm_power_consumption_get(sock_ind,
|
||||
dimm_addr, &d_power));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
dimm_pow->power = d_power.power;
|
||||
dimm_pow->update_rate = d_power.update_rate;
|
||||
dimm_pow->dimm_addr = d_power.dimm_addr;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_dimm_thermal_sensor(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t dimm_addr, amdsmi_dimm_thermal_t *dimm_temp)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
struct dimm_thermal d_sensor;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_dimm_thermal_sensor_get(sock_ind,
|
||||
dimm_addr, &d_sensor));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
dimm_temp->temp = d_sensor.temp;
|
||||
dimm_temp->update_rate = d_sensor.update_rate;
|
||||
dimm_temp->dimm_addr = d_sensor.dimm_addr;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_xgmi_width(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t min, uint8_t max)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_xgmi_width_set(min, max));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_gmi3_link_width_range(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t min_link_width, uint8_t max_link_width)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_gmi3_link_width_range_set(sock_ind,
|
||||
min_link_width, max_link_width));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_cpu_apb_enable(amdsmi_cpusocket_handle socket_handle, uint32_t sock_ind)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_apb_enable(sock_ind));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_cpu_apb_disable(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint8_t pstate)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_apb_disable(sock_ind, pstate));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_socket_lclk_dpm_level(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint8_t nbio_id, uint8_t min, uint8_t max)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_socket_lclk_dpm_level_set(sock_ind,
|
||||
nbio_id, min, max));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_socket_lclk_dpm_level(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t nbio_id, amdsmi_dpm_level_t *nbio)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
struct dpm_level nb;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_socket_lclk_dpm_level_get(sock_ind,
|
||||
nbio_id, &nb));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
nbio->min_dpm_level = nb.min_dpm_level;
|
||||
nbio->max_dpm_level = nb.max_dpm_level;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_pcie_link_rate(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t rate_ctrl, uint8_t *prev_mode)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_pcie_link_rate_set(sock_ind,
|
||||
rate_ctrl, prev_mode));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_set_cpu_df_pstate_range(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, uint8_t max_pstate, uint8_t min_pstate)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_df_pstate_range_set(sock_ind,
|
||||
max_pstate, min_pstate));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_current_io_bandwidth(amdsmi_cpusocket_handle socket_handle,
|
||||
uint8_t sock_ind, amdsmi_link_id_bw_type_t link, uint32_t *io_bw)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t bw;
|
||||
struct link_id_bw_type io_link;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_current_io_bandwidth_get(sock_ind,
|
||||
io_link, &bw));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
link.link_name = io_link.link_name;
|
||||
link.bw_type= io_link.bw_type;
|
||||
*io_bw = bw;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_cpu_current_xgmi_bw(amdsmi_cpusocket_handle socket_handle,
|
||||
amdsmi_link_id_bw_type_t link, uint32_t *xgmi_bw)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t bw;
|
||||
struct link_id_bw_type io_link;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_current_xgmi_bw_get(io_link, &bw));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
link.link_name = io_link.link_name;
|
||||
link.bw_type= io_link.bw_type;
|
||||
*xgmi_bw = bw;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_number_of_cpu_sockets(uint32_t sockets)
|
||||
{
|
||||
amdsmi_status_t status = amd::smi::AMDSmiSystem::getInstance().get_cpu_sockets(sockets);
|
||||
@@ -2223,4 +2714,38 @@ amdsmi_status_t amdsmi_get_cpu_model(uint32_t model)
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(amdsmi_cpusocket_handle socket_handle,
|
||||
uint32_t sock_ind, uint32_t *pcore_ind)
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint32_t online_core;
|
||||
|
||||
if (socket_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
amd::smi::AMDSmiCpuSocket* socket = nullptr;
|
||||
amdsmi_status_t r = get_cpu_socket_from_handle(socket_handle, &socket);
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_first_online_core_on_socket(sock_ind, &online_core));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
*pcore_ind = online_core;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
const char* amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string)
|
||||
{
|
||||
for (auto& iter : amd::smi::esmi_status_map) {
|
||||
if (iter.first == status) {
|
||||
*status_string = esmi_get_err_msg(static_cast<esmi_status_t>(iter.first));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return *status_string;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -171,10 +171,10 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
continue;
|
||||
}
|
||||
|
||||
bdf.function_number = device->businfo.pci->func;
|
||||
bdf.device_number = device->businfo.pci->dev;
|
||||
bdf.bus_number = device->businfo.pci->bus;
|
||||
bdf.domain_number = device->businfo.pci->domain;
|
||||
bdf.fields.function_number = device->businfo.pci->func;
|
||||
bdf.fields.device_number = device->businfo.pci->dev;
|
||||
bdf.fields.bus_number = device->businfo.pci->bus;
|
||||
bdf.fields.domain_number = device->businfo.pci->domain;
|
||||
|
||||
vendor_id = device->deviceinfo.pci->vendor_id;
|
||||
|
||||
|
||||
+10
-8
@@ -73,10 +73,11 @@ amdsmi_status_t gpuvsmi_get_pids(const amdsmi_bdf_t &bdf, std::vector<long int>
|
||||
struct dirent *dir;
|
||||
|
||||
/* 0000:00:00.0 */
|
||||
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d", bdf.domain_number & 0xffff,
|
||||
bdf.bus_number & 0xff,
|
||||
bdf.device_number & 0x1f,
|
||||
bdf.function_number & 0x7);
|
||||
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d",
|
||||
bdf.fields.domain_number & 0xffff,
|
||||
bdf.fields.bus_number & 0xff,
|
||||
bdf.fields.device_number & 0x1f,
|
||||
bdf.fields.function_number & 0x7);
|
||||
|
||||
d = opendir("/proc");
|
||||
if (!d)
|
||||
@@ -121,10 +122,11 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
struct dirent *dir;
|
||||
|
||||
/* 0000:00:00.0 */
|
||||
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d", bdf.domain_number & 0xffff,
|
||||
bdf.bus_number & 0xff,
|
||||
bdf.device_number & 0x1f,
|
||||
bdf.function_number & 0x7);
|
||||
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d",
|
||||
bdf.fields.domain_number & 0xffff,
|
||||
bdf.fields.bus_number & 0xff,
|
||||
bdf.fields.device_number & 0x1f,
|
||||
bdf.fields.function_number & 0x7);
|
||||
|
||||
|
||||
std::string path = "/proc/" + std::to_string(pid) + "/fdinfo/";
|
||||
|
||||
@@ -163,11 +163,8 @@ void TestSysInfoRead::Run(void) {
|
||||
} else {
|
||||
if (err == AMDSMI_STATUS_SUCCESS) {
|
||||
IF_VERB(STANDARD) {
|
||||
// TODO(bliu): read unique_id
|
||||
/*
|
||||
std::cout << "\t**GPU Unique ID : " << std::hex << asci_info.unique_id <<
|
||||
std::endl;
|
||||
*/
|
||||
std:: cout << "\t**GPU PCIe Vendor : "
|
||||
<< asci_info.vendor_name << std::endl;
|
||||
}
|
||||
// Verify api support checking functionality is working
|
||||
err = amdsmi_get_gpu_asic_info(processor_handles_[i], nullptr);
|
||||
|
||||
Reference in New Issue
Block a user