Merge amd-staging into amd-master 20240201
Signed-off-by: guanyu12 <guanyu12@amd.com>
Change-Id: I285bcd292990730ccad6b663ba6943211e6a5bba
[ROCm/rocm_smi_lib commit: 23b3376398]
Этот коммит содержится в:
@@ -3169,6 +3169,29 @@ rsmi_status_t
|
||||
rsmi_dev_firmware_version_get(uint32_t dv_ind, rsmi_fw_block_t block,
|
||||
uint64_t *fw_version);
|
||||
|
||||
/**
|
||||
* @brief Get the graphics version for a GPU device
|
||||
*
|
||||
* @details Given a device ID @p dv_ind and a uint64_t pointer
|
||||
* @p gfx_version, this function will write the graphics version.
|
||||
*
|
||||
* @param[in] dv_ind a device index
|
||||
*
|
||||
* @param[inout] gfx_version The device graphics version number indicated by
|
||||
* KFD. If this parameter is nullptr, this function will return
|
||||
* ::RSMI_STATUS_INVALID_ARGS. If device does not support this value,
|
||||
* will return ::RSMI_STATUS_NOT_SUPPORTED and a maximum UINT64 value as
|
||||
* @p gfx_version.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
rsmi_status_t rsmi_dev_target_graphics_version_get(uint32_t dv_ind,
|
||||
uint64_t *gfx_version);
|
||||
|
||||
/** @} */ // end of VersQuer
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -123,6 +123,8 @@ std::string print_rsmi_od_volt_freq_regions(uint32_t num_regions,
|
||||
bool is_sudo_user();
|
||||
rsmi_status_t rsmi_get_gfx_target_version(uint32_t dv_ind,
|
||||
std::string *gfx_version);
|
||||
std::string removeString(const std::string origStr,
|
||||
const std::string &removeMe);
|
||||
template <typename T>
|
||||
std::string print_int_as_hex(T i, bool showHexNotation = true) {
|
||||
std::stringstream ss;
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <cstring>
|
||||
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rocm_smi/rocm_smi_utils.h"
|
||||
@@ -780,6 +781,7 @@ int main() {
|
||||
uint32_t num_monitor_devs = 0;
|
||||
rsmi_gpu_metrics_t gpu_metrics;
|
||||
std::string val_str;
|
||||
|
||||
RSMI_POWER_TYPE power_type = RSMI_INVALID_POWER;
|
||||
|
||||
rsmi_num_monitor_devices(&num_monitor_devs);
|
||||
@@ -791,8 +793,9 @@ int main() {
|
||||
ret = rsmi_dev_revision_get(i, &val_ui16);
|
||||
CHK_RSMI_RET_I(ret)
|
||||
std::cout << "\t**Dev.Rev.ID: 0x" << std::hex << val_ui16 << "\n";
|
||||
ret = amd::smi::rsmi_get_gfx_target_version(i , &val_str);
|
||||
std::cout << "\t**Target Graphics Version: " << val_str << "\n";
|
||||
ret = rsmi_dev_target_graphics_version_get(i, &val_ui64);
|
||||
std::cout << "\t**Target Graphics Version: " << std::dec
|
||||
<< static_cast<uint64_t>(val_ui64) << "\n";
|
||||
|
||||
char current_compute_partition[256];
|
||||
current_compute_partition[0] = '\0';
|
||||
|
||||
@@ -5087,6 +5087,36 @@ rsmi_status_t rsmi_dev_memory_partition_reset(uint32_t dv_ind) {
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t rsmi_dev_target_graphics_version_get(uint32_t dv_ind,
|
||||
uint64_t *gfx_version) {
|
||||
TRY
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << "| ======= start =======";
|
||||
rsmi_status_t ret = RSMI_STATUS_NOT_SUPPORTED;
|
||||
std::string version = "";
|
||||
const uint64_t undefined_gfx_version = std::numeric_limits<uint64_t>::max();
|
||||
LOG_TRACE(ss);
|
||||
if (gfx_version == nullptr) {
|
||||
ret = RSMI_STATUS_INVALID_ARGS;
|
||||
} else {
|
||||
*gfx_version = undefined_gfx_version;
|
||||
ret = amd::smi::rsmi_get_gfx_target_version(dv_ind , &version);
|
||||
}
|
||||
if (ret == RSMI_STATUS_SUCCESS) {
|
||||
version = amd::smi::removeString(version, "gfx");
|
||||
*gfx_version = std::stoull(version);
|
||||
}
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< " | ======= end ======= "
|
||||
<< " | Returning: " << getRSMIStatusString(ret)
|
||||
<< " | Device #: " << dv_ind
|
||||
<< " | Type: N/A"
|
||||
<< " | Data: " << ((gfx_version == nullptr) ? "nullptr": std::to_string(*gfx_version));
|
||||
LOG_TRACE(ss);
|
||||
return ret;
|
||||
CATCH
|
||||
}
|
||||
|
||||
enum iterator_handle_type {
|
||||
FUNC_ITER = 0,
|
||||
VARIANT_ITER,
|
||||
|
||||
@@ -1144,16 +1144,31 @@ bool is_sudo_user() {
|
||||
return isRunningWithSudo;
|
||||
}
|
||||
|
||||
rsmi_status_t rsmi_get_gfx_target_version(uint32_t dv_ind,
|
||||
std::string *gfx_version) {
|
||||
// string output of gfx_<version>
|
||||
rsmi_status_t rsmi_get_gfx_target_version(uint32_t dv_ind, std::string *gfx_version) {
|
||||
std::ostringstream ss;
|
||||
uint64_t kfd_gfx_version = 0;
|
||||
GET_DEV_AND_KFDNODE_FROM_INDX
|
||||
|
||||
int ret = kfd_node->get_gfx_target_version(&kfd_gfx_version);
|
||||
uint64_t orig_target_version = 0;
|
||||
uint64_t major = 0;
|
||||
uint64_t minor = 0;
|
||||
uint64_t rev = 0;
|
||||
if (ret == 0) {
|
||||
ss << "gfx" << kfd_gfx_version;
|
||||
*gfx_version = ss.str();
|
||||
orig_target_version = std::stoull(std::to_string(kfd_gfx_version));
|
||||
// separate out parts -> put back into normal graphics version format
|
||||
major = static_cast<uint64_t>((orig_target_version / 10000) * 100);
|
||||
minor = static_cast<uint64_t>((orig_target_version % 10000 / 100) * 10);
|
||||
if (minor == 0) major *= 10; // 0 as a minor is correct, but bump up by 10
|
||||
rev = static_cast<uint64_t>(orig_target_version % 100);
|
||||
*gfx_version = "gfx" + std::to_string(major + minor + rev);
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< " | " << std::dec << "kfd_target_version = " << orig_target_version
|
||||
<< "; major = " << major << "; minor = " << minor << "; rev = "
|
||||
<< rev << "\nReporting rsmi_get_gfx_target_version = " << *gfx_version
|
||||
<< "\n";
|
||||
LOG_INFO(ss);
|
||||
return RSMI_STATUS_SUCCESS;
|
||||
} else {
|
||||
*gfx_version = "Unknown";
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
@@ -202,5 +203,15 @@ void TestSysInfoRead::Run(void) {
|
||||
err = rsmi_dev_firmware_version_get(i, block, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
|
||||
}
|
||||
|
||||
err = rsmi_dev_target_graphics_version_get(i, &val_ui64);
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Graphics Target version: " << std::dec
|
||||
<< val_ui64 << "\n";
|
||||
}
|
||||
EXPECT_EQ(err, RSMI_STATUS_SUCCESS);
|
||||
EXPECT_NE(val_ui64, std::numeric_limits<uint64_t>::max());
|
||||
err = rsmi_dev_target_graphics_version_get(i, nullptr);
|
||||
EXPECT_EQ(err, RSMI_STATUS_INVALID_ARGS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,10 @@ TEST(rsmitstReadOnly, TestVersionRead) {
|
||||
TestVersionRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstReadOnly, TestSysInfoRead) {
|
||||
TestSysInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstReadOnly, FanRead) {
|
||||
TestFanRead tst;
|
||||
RunGenericTest(&tst);
|
||||
@@ -195,10 +199,6 @@ TEST(rsmitstReadWrite, TestPciReadWrite) {
|
||||
TestPciReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstReadOnly, TestSysInfoRead) {
|
||||
TestSysInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstReadOnly, TestGPUBusyRead) {
|
||||
TestGPUBusyRead tst;
|
||||
RunGenericTest(&tst);
|
||||
|
||||
Ссылка в новой задаче
Block a user