Add rsmi_dev_memory_busy_percent_get()
Change-Id: Ide683b6c72870af547331f4502c5bb8c445d61b5
[ROCm/rocm_smi_lib commit: 1c5e090507]
This commit is contained in:
Binary file not shown.
@@ -1118,6 +1118,24 @@ rsmi_status_t
|
||||
rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type,
|
||||
uint64_t *used);
|
||||
|
||||
/**
|
||||
* @brief Get percentage of time any device memory is being used
|
||||
*
|
||||
* @details Given a device index @p dv_ind, this function returns the
|
||||
* percentage of time that any device memory is being used for the specified
|
||||
* device.
|
||||
*
|
||||
* @param[in] dv_ind a device index
|
||||
*
|
||||
* @param[inout] busy_percent a pointer to the uint32_t to which the busy
|
||||
* percent will be written
|
||||
*
|
||||
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call
|
||||
*
|
||||
*/
|
||||
rsmi_status_t
|
||||
rsmi_dev_memory_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent);
|
||||
|
||||
/** @} */ // end of MemQuer
|
||||
|
||||
/** @defgroup PhysQuer Physical State Queries
|
||||
|
||||
@@ -95,6 +95,7 @@ enum DevInfoTypes {
|
||||
kDevPCIEReplayCount,
|
||||
kDevUniqueId,
|
||||
kDevDFCountersAvailable,
|
||||
kDevMemBusyPercent,
|
||||
};
|
||||
|
||||
class Device {
|
||||
|
||||
@@ -1904,6 +1904,25 @@ rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type,
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_dev_memory_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent) {
|
||||
TRY
|
||||
rsmi_status_t ret;
|
||||
|
||||
if (busy_percent == nullptr) {
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
uint64_t tmp_util = 0;
|
||||
|
||||
DEVICE_MUTEX
|
||||
ret = get_dev_value_int(amd::smi::kDevMemBusyPercent, dv_ind, &tmp_util);
|
||||
|
||||
*busy_percent = static_cast<uint32_t>(tmp_util);
|
||||
return ret;
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_status_string(rsmi_status_t status, const char **status_string) {
|
||||
TRY
|
||||
|
||||
@@ -99,6 +99,7 @@ static const char *kDevMemUsedVRAMFName = "mem_info_vram_used";
|
||||
static const char *kDevPCIEReplayCountFName = "pcie_replay_count";
|
||||
static const char *kDevUniqueIdFName = "unique_id";
|
||||
static const char *kDevDFCountersAvailableFName = "df_cntr_avail";
|
||||
static const char *kDevMemBusyPercentFName = "mem_busy_percent";
|
||||
|
||||
// Strings that are found within sysfs files
|
||||
static const char *kDevPerfLevelAutoStr = "auto";
|
||||
@@ -135,6 +136,7 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
|
||||
{kDevErrCntFeatures, kDevErrCntFeaturesFName},
|
||||
{kDevMemTotGTT, kDevMemTotGTTFName},
|
||||
{kDevMemTotVisVRAM, kDevMemTotVisVRAMFName},
|
||||
{kDevMemBusyPercent, kDevMemBusyPercentFName},
|
||||
{kDevMemTotVRAM, kDevMemTotVRAMFName},
|
||||
{kDevMemUsedGTT, kDevMemUsedGTTFName},
|
||||
{kDevMemUsedVisVRAM, kDevMemUsedVisVRAMFName},
|
||||
@@ -390,6 +392,7 @@ int Device::readDevInfo(DevInfoTypes type, uint64_t *val) {
|
||||
case kDevMemUsedVRAM:
|
||||
case kDevPCIEReplayCount:
|
||||
case kDevDFCountersAvailable:
|
||||
case kDevMemBusyPercent:
|
||||
ret = readDevInfoStr(type, &tempStr);
|
||||
RET_IF_NONZERO(ret);
|
||||
*val = std::stoul(tempStr, 0);
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
TestMemUtilRead::TestMemUtilRead() : TestBase() {
|
||||
set_title("Memory Utilization Read Test");
|
||||
set_description("The Memory Utilization Read tests verifies that "
|
||||
"memory utilization can be read properly.");
|
||||
"memory busy percent, size and amount used can be read properly.");
|
||||
}
|
||||
|
||||
TestMemUtilRead::~TestMemUtilRead(void) {
|
||||
@@ -94,6 +94,7 @@ void TestMemUtilRead::Run(void) {
|
||||
rsmi_status_t err;
|
||||
uint64_t total;
|
||||
uint64_t usage;
|
||||
uint32_t mem_busy_percent;
|
||||
|
||||
TestBase::Run();
|
||||
|
||||
@@ -113,6 +114,17 @@ void TestMemUtilRead::Run(void) {
|
||||
for (uint32_t i = 0; i < num_monitor_devs(); ++i) {
|
||||
PrintDeviceHeader(i);
|
||||
|
||||
#if 0
|
||||
err = rsmi_dev_memory_busy_percent_get(i, &mem_busy_percent);
|
||||
err_chk("rsmi_dev_memory_busy_percent_get()");
|
||||
if (err != RSMI_STATUS_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**" << "GPU Memory Busy %: " << mem_busy_percent <<
|
||||
std::endl;
|
||||
}
|
||||
#endif
|
||||
for (uint32_t mem_type = RSMI_MEM_TYPE_FIRST;
|
||||
mem_type <= RSMI_MEM_TYPE_LAST; ++mem_type) {
|
||||
err = rsmi_dev_memory_total_get(i,
|
||||
@@ -132,8 +144,8 @@ void TestMemUtilRead::Run(void) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**" <<
|
||||
kDevMemoryTypeNameMap.at(static_cast<rsmi_memory_type_t>(mem_type)) <<
|
||||
" Utilization: " << (static_cast<float>(usage)*100)/total << "% ("<<
|
||||
usage << "/" << total << ")" << std::endl;
|
||||
" Calculated Utilization: " << (static_cast<float>(usage)*100)/total
|
||||
<< "% ("<< usage << "/" << total << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ TEST(rsmitstReadOnly, TestIdInfoRead) {
|
||||
TestIdInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstreadWrite,TestPerfCntrReadWrite) {
|
||||
TEST(rsmitstreadWrite, TestPerfCntrReadWrite) {
|
||||
TestPerfCntrReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class TestBase {
|
||||
std::string title_; ///< Displayed title of test
|
||||
uint32_t verbosity_; ///< How much additional output to produce
|
||||
bool dont_fail_; ///< Don't quit test on individual failure if true
|
||||
uint64_t init_options_; ///< rsmi initialization options
|
||||
uint64_t init_options_; ///< rsmi initialization options
|
||||
};
|
||||
|
||||
#define IF_VERB(VB) if (verbosity() && verbosity() >= (TestBase::VERBOSE_##VB))
|
||||
|
||||
@@ -72,8 +72,8 @@ static const char * kRasErrStateStrings[] = {
|
||||
"Poison" // RSMI_RAS_ERR_STATE_POISON
|
||||
};
|
||||
static_assert(
|
||||
sizeof(kRasErrStateStrings)/sizeof(char *) == (RSMI_RAS_ERR_STATE_LAST + 1),
|
||||
"kErrStateNameMap needs to be updated");
|
||||
sizeof(kRasErrStateStrings)/sizeof(char *) == (RSMI_RAS_ERR_STATE_LAST + 1),
|
||||
"kErrStateNameMap needs to be updated");
|
||||
|
||||
|
||||
static const std::map<rsmi_ras_err_state_t, const char *> kErrStateNameMap = {
|
||||
|
||||
Referens i nytt ärende
Block a user