Add rsmi_dev_busy_percent_get()
Also: correct some comments, ifdef out unused code
This commit is contained in:
1 orang tua
59a952666f
melakukan
861c2c2e33
6 files changed
+81
-34
No files matched your search
+21
-1
@@ -102,7 +102,8 @@ static rsmi_status_t errno_to_rsmi_status(uint32_t err) {
|
||||
case 0: return RSMI_STATUS_SUCCESS;
|
||||
case EACCES: return RSMI_STATUS_PERMISSION;
|
||||
case EPERM: return RSMI_STATUS_NOT_SUPPORTED;
|
||||
case ENOENT: return RSMI_STATUS_FILE_ERROR;
|
||||
case ENOENT:
|
||||
case EISDIR: return RSMI_STATUS_FILE_ERROR;
|
||||
default: return RSMI_STATUS_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -1026,3 +1027,22 @@ rsmi_status_string(rsmi_status_t status, const char **status_string) {
|
||||
return RSMI_STATUS_SUCCESS;
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent) {
|
||||
TRY
|
||||
std::string val_str;
|
||||
rsmi_status_t ret = get_dev_value_str(amd::smi::kDevUsage, dv_ind,
|
||||
&val_str);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
*busy_percent = strtoul(val_str.c_str(), nullptr, 10);
|
||||
assert(errno == 0);
|
||||
|
||||
return RSMI_STATUS_SUCCESS;
|
||||
|
||||
CATCH
|
||||
}
|
||||
@@ -64,7 +64,9 @@ static const char *kDevDevIDFName = "device";
|
||||
static const char *kDevOverDriveLevelFName = "pp_sclk_od";
|
||||
static const char *kDevGPUSClkFName = "pp_dpm_sclk";
|
||||
static const char *kDevGPUMClkFName = "pp_dpm_mclk";
|
||||
static const char *kDevPowerProfileModeName = "pp_power_profile_mode";
|
||||
static const char *kDevPowerProfileModeFName = "pp_power_profile_mode";
|
||||
static const char *kDevUsageFName = "gpu_busy_percent";
|
||||
|
||||
static const char *kDevPerfLevelAutoStr = "auto";
|
||||
static const char *kDevPerfLevelLowStr = "low";
|
||||
static const char *kDevPerfLevelHighStr = "high";
|
||||
@@ -81,7 +83,8 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
|
||||
{kDevDevID, kDevDevIDFName},
|
||||
{kDevGPUMClk, kDevGPUMClkFName},
|
||||
{kDevGPUSClk, kDevGPUSClkFName},
|
||||
{kDevPowerProfileMode, kDevPowerProfileModeName},
|
||||
{kDevPowerProfileMode, kDevPowerProfileModeFName},
|
||||
{kDevUsage, kDevUsageFName},
|
||||
};
|
||||
|
||||
static const std::map<rsmi_dev_perf_level, const char *> kDevPerfLvlMap = {
|
||||
@@ -114,7 +117,6 @@ Device::Device(std::string p, RocmSMI_env_vars const *e) : path_(p), env_(e) {
|
||||
Device:: ~Device() {
|
||||
}
|
||||
|
||||
// TODO(cfreehil): cache values that are constant
|
||||
int Device::readDevInfoStr(DevInfoTypes type, std::string *retStr) {
|
||||
auto tempPath = path_;
|
||||
|
||||
@@ -242,12 +244,12 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int Device::readDevInfo(DevInfoTypes type, uint32_t *val) {
|
||||
assert(val != nullptr);
|
||||
|
||||
std::string tempStr;
|
||||
int ret;
|
||||
|
||||
switch (type) {
|
||||
case kDevDevID:
|
||||
ret = readDevInfoStr(type, &tempStr);
|
||||
@@ -255,6 +257,7 @@ int Device::readDevInfo(DevInfoTypes type, uint32_t *val) {
|
||||
*val = std::stoi(tempStr, 0, 16);
|
||||
break;
|
||||
|
||||
case kDevUsage:
|
||||
case kDevOverDriveLevel:
|
||||
ret = readDevInfoStr(type, &tempStr);
|
||||
RET_IF_NONZERO(ret);
|
||||
@@ -266,7 +269,7 @@ int Device::readDevInfo(DevInfoTypes type, uint32_t *val) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
int Device::readDevInfo(DevInfoTypes type, std::vector<std::string> *val) {
|
||||
assert(val != nullptr);
|
||||
|
||||
@@ -289,6 +292,7 @@ int Device::readDevInfo(DevInfoTypes type, std::string *val) {
|
||||
|
||||
switch (type) {
|
||||
case kDevPerfLevel:
|
||||
case kDevUsage:
|
||||
case kDevOverDriveLevel:
|
||||
case kDevDevID:
|
||||
return readDevInfoStr(type, val);
|
||||
|
||||
Reference in new issue
Block a user