[SWDEV-335697] Add RSMI_STATUS_SETTING_UNAVAILABLE for dynamic partition
Updates:
* Added RSMI_STATUS_SETTING_UNAVAILABLE for
rsmi_dev_compute_partition_set - gives users
better error output when attempting to set
compute partition to values not listed in
available_compute_partition SYSFS
* Updated python --setcomputepartition to
provide better output when receiving
RSMI_STATUS_SETTING_UNAVAILABLE
* Updated all test & example files to check for
RSMI_STATUS_SETTING_UNAVAILABLE when doing
rsmi_dev_compute_partition_set
Change-Id: Ida5d54880d9b9b6e4a0468cdb962fdc0c18d6257
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
[ROCm/amdsmi commit: 0d3558945b]
This commit is contained in:
@@ -2865,6 +2865,11 @@ rsmi_status_string(rsmi_status_t status, const char **status_string) {
|
||||
"counter exceeded INT32_MAX";
|
||||
break;
|
||||
|
||||
case RSMI_STATUS_SETTING_UNAVAILABLE:
|
||||
*status_string = "RSMI_STATUS_SETTING_UNAVAILABLE: Requested setting is "
|
||||
"unavailable for the current device";
|
||||
break;
|
||||
|
||||
case RSMI_STATUS_AMDGPU_RESTART_ERR:
|
||||
*status_string = "RSMI_STATUS_AMDGPU_RESTART_ERR: Could not successfully "
|
||||
"restart the amdgpu driver";
|
||||
@@ -3751,17 +3756,16 @@ static rsmi_status_t
|
||||
get_compute_partition(uint32_t dv_ind, std::string &compute_partition) {
|
||||
TRY
|
||||
CHK_SUPPORT_NAME_ONLY(compute_partition.c_str())
|
||||
std::string val_str;
|
||||
std::string compute_partition_str;
|
||||
|
||||
DEVICE_MUTEX
|
||||
rsmi_status_t ret = get_dev_value_str(amd::smi::kDevComputePartition,
|
||||
dv_ind, &val_str);
|
||||
|
||||
dv_ind, &compute_partition_str);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (mapStringToRSMIComputePartitionTypes[val_str]) {
|
||||
switch (mapStringToRSMIComputePartitionTypes[compute_partition_str]) {
|
||||
case RSMI_COMPUTE_PARTITION_INVALID:
|
||||
// Retrieved an unknown compute partition
|
||||
return RSMI_STATUS_UNEXPECTED_DATA;
|
||||
@@ -3779,7 +3783,7 @@ get_compute_partition(uint32_t dv_ind, std::string &compute_partition) {
|
||||
// Retrieved an unknown compute partition
|
||||
return RSMI_STATUS_UNEXPECTED_DATA;
|
||||
}
|
||||
compute_partition = val_str;
|
||||
compute_partition = compute_partition_str;
|
||||
return RSMI_STATUS_SUCCESS;
|
||||
CATCH
|
||||
}
|
||||
@@ -3809,13 +3813,33 @@ rsmi_dev_compute_partition_get(uint32_t dv_ind, char *compute_partition,
|
||||
CATCH
|
||||
}
|
||||
|
||||
static rsmi_status_t
|
||||
is_available_compute_partition(uint32_t dv_ind,
|
||||
std::string new_compute_partition) {
|
||||
TRY
|
||||
DEVICE_MUTEX
|
||||
std::string availableComputePartitions;
|
||||
rsmi_status_t ret =
|
||||
get_dev_value_line(amd::smi::kDevAvailableComputePartition,
|
||||
dv_ind, &availableComputePartitions);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isComputePartitionAvailable =
|
||||
amd::smi::containsString(availableComputePartitions,
|
||||
new_compute_partition);
|
||||
return (isComputePartitionAvailable) ? RSMI_STATUS_SUCCESS :
|
||||
RSMI_STATUS_SETTING_UNAVAILABLE;
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_dev_compute_partition_set(uint32_t dv_ind,
|
||||
rsmi_compute_partition_type_t compute_partition) {
|
||||
TRY
|
||||
REQUIRE_ROOT_ACCESS
|
||||
DEVICE_MUTEX
|
||||
|
||||
std::string newComputePartitionStr
|
||||
= mapRSMIToStringComputePartitionTypes[compute_partition];
|
||||
std::string currentComputePartition;
|
||||
@@ -3838,6 +3862,14 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind,
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
// Confirm what we are trying to set is available, otherwise provide
|
||||
// RSMI_STATUS_SETTING_UNAVAILABLE
|
||||
rsmi_status_t available_ret =
|
||||
is_available_compute_partition(dv_ind, newComputePartitionStr);
|
||||
if (available_ret != RSMI_STATUS_SUCCESS) {
|
||||
return available_ret;
|
||||
}
|
||||
|
||||
// do nothing if compute_partition is the current compute partition
|
||||
rsmi_status_t ret_get = get_compute_partition(dv_ind, currentComputePartition);
|
||||
// we can try to set, even if we get unexpected data
|
||||
|
||||
@@ -122,6 +122,8 @@ static const char *kDevXGMIErrorFName = "xgmi_error";
|
||||
static const char *kDevSerialNumberFName = "serial_number";
|
||||
static const char *kDevNumaNodeFName = "numa_node";
|
||||
static const char *kDevGpuMetricsFName = "gpu_metrics";
|
||||
static const char *kDevAvailableComputePartitionFName =
|
||||
"available_compute_partition";
|
||||
static const char *kDevComputePartitionFName = "current_compute_partition";
|
||||
static const char *kDevMemoryPartitionFName = "current_memory_partition";
|
||||
|
||||
@@ -293,6 +295,7 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
|
||||
{kDevNumaNode, kDevNumaNodeFName},
|
||||
{kDevGpuMetrics, kDevGpuMetricsFName},
|
||||
{kDevGpuReset, kDevGpuResetFName},
|
||||
{kDevAvailableComputePartition, kDevAvailableComputePartitionFName},
|
||||
{kDevComputePartition, kDevComputePartitionFName},
|
||||
{kDevMemoryPartition, kDevMemoryPartitionFName},
|
||||
};
|
||||
@@ -930,6 +933,7 @@ int Device::readDevInfo(DevInfoTypes type, std::string *val) {
|
||||
case kDevVBiosVer:
|
||||
case kDevPCIEThruPut:
|
||||
case kDevSerialNumber:
|
||||
case kDevAvailableComputePartition:
|
||||
case kDevComputePartition:
|
||||
case kDevMemoryPartition:
|
||||
return readDevInfoStr(type, val);
|
||||
|
||||
@@ -75,7 +75,8 @@ static const char *kDeviceNamePrefix = "card";
|
||||
static const char *kAMDMonitorTypes[] = {"radeon", "amdgpu", ""};
|
||||
|
||||
static const std::string amdSMI = "amd::smi::";
|
||||
const std::map<amd::smi::DevInfoTypes, std::string> amd::smi::RocmSMI::devInfoTypesStrings = {
|
||||
const std::map<amd::smi::DevInfoTypes, std::string>
|
||||
amd::smi::RocmSMI::devInfoTypesStrings = {
|
||||
{amd::smi::kDevPerfLevel, amdSMI + "kDevPerfLevel"},
|
||||
{amd::smi::kDevOverDriveLevel, amdSMI + "kDevOverDriveLevel"},
|
||||
{amd::smi::kDevMemOverDriveLevel, amdSMI + "kDevMemOverDriveLevel"},
|
||||
@@ -142,6 +143,8 @@ const std::map<amd::smi::DevInfoTypes, std::string> amd::smi::RocmSMI::devInfoTy
|
||||
{amd::smi::kDevNumaNode, amdSMI + "kDevNumaNode"},
|
||||
{amd::smi::kDevGpuMetrics, amdSMI + "kDevGpuMetrics"},
|
||||
{amd::smi::kDevGpuReset, amdSMI + "kDevGpuReset"},
|
||||
{amd::smi::kDevAvailableComputePartition, amdSMI +
|
||||
"kDevAvailableComputePartition"},
|
||||
{amd::smi::kDevComputePartition, amdSMI + "kDevComputePartition"},
|
||||
{amd::smi::kDevMemoryPartition, amdSMI + "kDevMemoryPartition"}
|
||||
};
|
||||
|
||||
@@ -390,7 +390,7 @@ std::string readTemporaryFile(std::string path) {
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
// Used to debug application temporary files (idenified by kTmpFilePrefix)
|
||||
// Used to debug application temporary files (identified by kTmpFilePrefix)
|
||||
// and their content
|
||||
void displayAppTmpFilesContent() {
|
||||
std::vector<std::string> tmpFiles = getListOfAppTmpFiles();
|
||||
|
||||
Reference in New Issue
Block a user