[SWDEV-381630] Add reset partition functionality

Updates:
    * Added rsmi_dev_compute_partition_reset & rsmi_dev_nps_mode_reset
    * Added --resetcomputepartition and --resetnpsmode python smi calls
    * Added temp data files rocmsmi_boot_compute_partition_<device num>
      & rocmsmi_boot_nps_mode_partition_<device num>, writes UNKNOWN
      if data cannot be read or device does not support
    * Cleaned up NPS & compute API documentation
    * Added creation and reading of API temp files (used in reset
      functionality)
    * Cleaned up output of rocm_smi_example
    * Updated rocm_smi_example to check if running with sudo permission
      before executing write API calls (cleans up erroneous output)
    * Added template specialization for storing temp data, requires
      specific rsmi_type_t enums (restrics what data can be stored)
    * Added storage of temp data, if temp files do not exist
    * Updated google tests for NPS & compute to include reset API calls

Change-Id: I69895a466b97107617e6dbb355737b84499a76c9
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
This commit is contained in:
Charis Poag
2023-02-14 17:06:03 -06:00
parent 9ef376cd61
commit 77c950a4bf
12 changed files with 577 additions and 46 deletions
@@ -269,13 +269,13 @@ void TestComputePartitionReadWrite::Run(void) {
<< computePartitionString(new_computePartition)
<< " ===============" << std::endl;
}
ret = rsmi_dev_compute_partition_set(dv_ind, new_computePartition);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Attempting to set compute partition to: "
<< computePartitionString(new_computePartition) << std::endl;
}
ret = rsmi_dev_compute_partition_set(dv_ind, new_computePartition);
CHK_ERR_ASRT(ret)
ret = rsmi_dev_compute_partition_get(dv_ind, current_char_computePartition,
255);
CHK_ERR_ASRT(ret)
@@ -290,6 +290,46 @@ void TestComputePartitionReadWrite::Run(void) {
current_char_computePartition);
}
/* TEST RETURN TO BOOT COMPUTE PARTITION SETTING */
IF_VERB(STANDARD) {
std::cout << std::endl;
std::cout << "\t**"
<< "=========== TEST RETURN TO BOOT COMPUTE PARTITION SETTING "
<< "========" << std::endl;
}
std::string oldPartition = current_char_computePartition;
bool wasResetSuccess = false;
ret = rsmi_dev_compute_partition_reset(dv_ind);
ASSERT_TRUE((ret == RSMI_STATUS_SUCCESS) ||
(ret == RSMI_STATUS_NOT_SUPPORTED));
if (ret == RSMI_STATUS_SUCCESS) {
wasResetSuccess = true;
}
ret = rsmi_dev_compute_partition_get(dv_ind, current_char_computePartition,
255);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Current compute partition: " << current_char_computePartition << std::endl;
}
if (wasResetSuccess) {
ASSERT_STRNE(oldPartition.c_str(), current_char_computePartition);
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Confirmed prior partition (" << oldPartition << ") is not "
<< "equal to current partition ("
<< current_char_computePartition << ")" << std::endl;
}
} else {
ASSERT_STREQ(oldPartition.c_str(), current_char_computePartition);
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Confirmed prior partition (" << oldPartition << ") is equal"
<< " to current partition ("
<< current_char_computePartition << ")" << std::endl;
}
}
/* TEST RETURN TO ORIGINAL COMPUTE PARTITIONING SETTING */
IF_VERB(STANDARD) {
std::cout << std::endl;
@@ -221,11 +221,11 @@ void TestNPSModeReadWrite::Run(void) {
EXPECT_TRUE((err == RSMI_STATUS_INVALID_ARGS) ||
(err == RSMI_STATUS_NOT_SUPPORTED) ||
(err == RSMI_STATUS_PERMISSION));
if (err == RSMI_STATUS_INVALID_ARGS) {
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Confirmed RSMI_STATUS_INVALID_ARGS was returned."
<< std::endl;
if (err == RSMI_STATUS_INVALID_ARGS) {
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Confirmed RSMI_STATUS_INVALID_ARGS was returned."
<< std::endl;
} else if (err == RSMI_STATUS_PERMISSION) {
DISPLAY_RSMI_ERR(err)
// tests should not continue if err is a permission issue
@@ -251,13 +251,14 @@ void TestNPSModeReadWrite::Run(void) {
<< npsModeString(new_nps_mode)
<< " ===============" << std::endl;
}
ret = rsmi_dev_nps_mode_set(dv_ind, new_nps_mode);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Attempting to set nps mode to: "
<< npsModeString(new_nps_mode) << std::endl;
}
ret = rsmi_dev_nps_mode_set(dv_ind, new_nps_mode);
CHK_ERR_ASRT(ret)
ret = rsmi_dev_nps_mode_get(dv_ind, current_nps_mode, 255);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
@@ -268,6 +269,45 @@ void TestNPSModeReadWrite::Run(void) {
EXPECT_STREQ(npsModeString(new_nps_mode).c_str(), current_nps_mode);
}
/* TEST RETURN TO BOOT NPS MODE SETTING */
IF_VERB(STANDARD) {
std::cout << std::endl;
std::cout << "\t**"
<< "=========== TEST RETURN TO BOOT NPS MODE SETTING "
<< "========" << std::endl;
}
std::string oldMode = current_nps_mode;
bool wasResetSuccess = false;
ret = rsmi_dev_nps_mode_reset(dv_ind);
ASSERT_TRUE((ret == RSMI_STATUS_SUCCESS) ||
(ret == RSMI_STATUS_NOT_SUPPORTED));
if (ret == RSMI_STATUS_SUCCESS) {
wasResetSuccess = true;
}
ret = rsmi_dev_nps_mode_get(dv_ind, current_nps_mode, 255);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Current nps mode: " << current_nps_mode << std::endl;
}
if (wasResetSuccess) {
ASSERT_STRNE(oldMode.c_str(), current_nps_mode);
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Confirmed prior nps mode (" << oldMode << ") is not "
<< "equal to current nps mode ("
<< current_nps_mode << ")" << std::endl;
}
} else {
ASSERT_STREQ(oldMode.c_str(), current_nps_mode);
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "Confirmed prior nps mode (" << oldMode << ") is equal"
<< " to current nps mode ("
<< current_nps_mode << ")" << std::endl;
}
}
/* TEST RETURN TO ORIGINAL NPS MODE SETTING */
IF_VERB(STANDARD) {
std::cout << std::endl;
@@ -277,18 +317,18 @@ void TestNPSModeReadWrite::Run(void) {
}
new_nps_mode
= mapStringToRSMINpsModeTypes.at(orig_nps_mode);
ret = rsmi_dev_nps_mode_set(dv_ind, new_nps_mode);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**" << "Returning nps mode to: "
<< npsModeString(new_nps_mode) << std::endl;
}
ret = rsmi_dev_nps_mode_set(dv_ind, new_nps_mode);
CHK_ERR_ASRT(ret)
ret = rsmi_dev_nps_mode_get(dv_ind, current_nps_mode, 255);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**" << "Attempted to set nps mode: "
<< npsModeString(new_nps_mode) << std::endl
<< "\t**" << "Current compute partition: " << current_nps_mode
<< "\t**" << "Current nps mode: " << current_nps_mode
<< std::endl;
}
EXPECT_EQ(RSMI_STATUS_SUCCESS, ret);