2
0

[SWDEV-529030/SWDEV-531217] Fix tests & output for partitioned configurations (CPX, DPX, QPX, etc.)

Changes:
  - Updated AMD SMI firmware to display "N/A" for unavailable firmware in partitioned environments, improving clarity.
    Example (in DPX):
    $ amd-smi firmware
    GPU: 0
        FW_LIST:
            ...
            FW 12:
                FW_ID: PM
                FW_VERSION: 00.86.39.00
    GPU: 1
        FW_LIST: N/A
  - Fixed amd-smi partition not showing current partition information on
    asics with inablity to set memory or accelerator partitions.
    $ amd-smi partition -c -m
    CURRENT_PARTITION:
    GPU_ID  MEMORY  ACCELERATOR_TYPE  ACCELERATOR_PROFILE_INDEX  PARTITION_ID
    0       NPS1    CPX               2                          0
    1       N/A     N/A               N/A                        1
    2       N/A     N/A               N/A                        2
    3       N/A     N/A               N/A                        3
    4       N/A     N/A               N/A                        4
    5       N/A     N/A               N/A                        5
    6       NPS1    SPX               0                          0
    7       NPS1    SPX               0                          0
    8       NPS1    SPX               0                          0

    MEMORY_PARTITION:
    GPU_ID  MEMORY_PARTITION_CAPS  CURRENT_MEMORY_PARTITION
    0       N/A                    NPS1
    1       N/A                    N/A
    2       N/A                    N/A
    3       N/A                    N/A
    4       N/A                    N/A
    5       N/A                    N/A
    6       N/A                    NPS1
    7       N/A                    NPS1
    8       N/A                    NPS1

  - Refactored amd_smi_drm_example.cc:
    - Grouped partition changes and restores original partition settings.
    - Now handles partitioned environments allowing example to continue even if some APIs are not supported in partitioned configurations.
  - Modified amdsmi_asic_info_t (see amdsmi_get_gpu_asic_info()) to report OAM ID as N/A if 0xFFFFFFFF (was 0xFFFF).
    Allows for better handling of OAM IDs in partitioned environments (DNE for non-primary nodes,
    since its a physical identifier). Easier to handle in tests and example code (ie. now consistent w/ max size of the structure's value).
  - Introduced amdsmi_RAII_open_FD() (internal API) to manage file descriptors using RAII, ensuring proper closure and preventing resource leaks.
    Updated the following APIs to use this function:
      - amdsmi_get_gpu_asic_info(), amdsmi_get_gpu_vram_usage(),
        amdsmi_get_gpu_vram_info(), amdsmi_get_gpu_vbios_info(),
        amdsmi_get_gpu_driver_info(), amdsmi_get_gpu_virtualization_mode()
  - Updated AMD SMI test_base.cc/.h:
    - Improved output and handling for partitioned environments.
    - Added detailed ASIC information logging to align with structure changes.
    - Enhanced error messages for better context before ASSERT checks.
  - Resolved test failures in partitioned environments by updating
    logic and handling for partition-specific configurations.
    Fixed tests include:
      - computepartition_read_write.cc, frequencies_read_write.cc,
        gpu_metrics_read.cc, mem_util_read.cc, memorypartition_read_write.cc,
        perf_level_read.cc, perf_level_read_write.cc, power_cap_read_write.cc,
        power_read.cc, sys_info_read.cc, gpu_busy_read.cc

Change-Id: I36e903f8fddd714c74c719459c71aba8bbb77e6f
Signed-off-by: Charis Poag <Charis.Poag@amd.com>

Resetting head + adding fixes for tests ran in partitions

Change-Id: I0c1e9ac07488b50c95f3bc6d8a724e67d2c715dc
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
Este cometimento está contido em:
Charis Poag
2025-05-27 19:19:43 -05:00
cometido por Arif, Maisam
ascendente f0233eb664
cometimento 391451752b
27 ficheiros modificados com 1858 adições e 1063 eliminações
+28 -15
Ver ficheiro
@@ -273,6 +273,7 @@ static void checkPartitionIdChanges(amdsmi_processor_handle* const processor_han
"\"sudo rmmod amdgpu && sudo rmmod ast && sudo modprobe amdgpu\")."
"\n\tCPX may not enumerate properly.\n";
}
// amdsmi_wait_for_user_input(); // watch for any errors
break;
}
amdsmi_kfd_info_t kfd_info;
@@ -432,7 +433,7 @@ void TestComputePartitionReadWrite::Run(void) {
<< computePartitionString(updatePartition)
<< " ===============" << std::endl;
}
// waitForUserInput(); // watch for any errors
// amdsmi_wait_for_user_input(); // watch for any errors
auto ret_set = amdsmi_set_gpu_compute_partition(processor_handles_[dv_ind], updatePartition);
IF_VERB(STANDARD) {
@@ -463,6 +464,7 @@ void TestComputePartitionReadWrite::Run(void) {
<< "\n\t Device might be in a static partition mode. "
<< "With inability to change partition modes."
<< std::endl;
// amdsmi_wait_for_user_input(); // watch for any errors
break;
}
@@ -491,7 +493,7 @@ void TestComputePartitionReadWrite::Run(void) {
static_cast<amdsmi_compute_partition_type_t>(
mapStringToSMIComputePartitionTypes.at(
std::string(orig_char_computePartition)));
// waitForUserInput(); // watch for any errors on going back to original partition
// amdsmi_wait_for_user_input(); // watch for any errors on going back to original partition
auto ret_set = amdsmi_set_gpu_compute_partition(processor_handles_[dv_ind], updatePartition);
EXPECT_TRUE(ret_set == AMDSMI_STATUS_SETTING_UNAVAILABLE
|| ret_set== AMDSMI_STATUS_NO_PERM
@@ -510,6 +512,8 @@ void TestComputePartitionReadWrite::Run(void) {
// TEST 2: Set/Get Compute Partition (new functionality)
initial_num_devices = num_monitor_devs();
amdsmi_accelerator_partition_type_t primary_partition_type = AMDSMI_ACCELERATOR_PARTITION_INVALID;
uint32_t primary_index = 0;
for (uint32_t dv_ind = 0; dv_ind < initial_num_devices; ++dv_ind) {
if (dv_ind != 0) {
std::cout << "\n";
@@ -518,11 +522,11 @@ void TestComputePartitionReadWrite::Run(void) {
std::cout << "\n";
std::cout << "\t**======================================================================\n";
std::cout << "\t**Test #2: Get/Set Compute Partition (new functionality) ===============\n";
std::cout << "\t**DEVICE: #" << std::setw(2) << std::setfill('0') << dv_ind
std::cout << "\t**DEVICE: #" << std::dec << std::setw(2) << std::setfill('0') << dv_ind
<< " ==========================================================\n";
std::cout << "\t**======================================================================\n";
}
// waitForUserInput(); // watch for any errors
// amdsmi_wait_for_user_input(); // watch for any errors
PrintDeviceHeader(processor_handles_[dv_ind]);
amdsmi_accelerator_partition_profile_t profile = {};
uint32_t partition_id[8] = {0, 0, 0, 0, 0, 0, 0, 0};
@@ -563,6 +567,12 @@ void TestComputePartitionReadWrite::Run(void) {
profile_type_str = "CPX";
}
// save the primary partition type
if (profile.profile_type != AMDSMI_ACCELERATOR_PARTITION_INVALID) {
primary_partition_type = profile.profile_type;
primary_index = dv_ind;
}
std::string partition_id_str = "";
for (int i = 0; i < 8; i++) {
partition_id_str += std::to_string(partition_id[i]);
@@ -570,7 +580,7 @@ void TestComputePartitionReadWrite::Run(void) {
partition_id_str += ", ";
}
switch (profile.profile_type) {
switch (primary_partition_type) {
case AMDSMI_ACCELERATOR_PARTITION_SPX:
EXPECT_LT(partition_id[i], MAX_SPX_PARTITIONS);
break;
@@ -586,7 +596,7 @@ void TestComputePartitionReadWrite::Run(void) {
case AMDSMI_ACCELERATOR_PARTITION_CPX: {
uint16_t num_xcd;
uint32_t max_xcps = 0;
ret = amdsmi_get_gpu_xcd_counter(processor_handles_[dv_ind], &num_xcd);
ret = amdsmi_get_gpu_xcd_counter(processor_handles_[primary_index], &num_xcd);
if (ret == AMDSMI_STATUS_SUCCESS) {
max_xcps = static_cast<uint32_t>(num_xcd);
}
@@ -640,7 +650,7 @@ void TestComputePartitionReadWrite::Run(void) {
AcceleratorProfileConfig original_profile_config = {};
original_profile_config
= getAvailableProfileConfigs(dv_ind, profile, profile_config, isVerbose);
// waitForUserInput(); // watch for any errors
// amdsmi_wait_for_user_input(); // watch for any errors
IF_VERB(STANDARD) {
std::cout << "\t**=========================================================\n";
@@ -762,7 +772,7 @@ void TestComputePartitionReadWrite::Run(void) {
<< profile_config.profiles[config].profile_index << ")"
<< " ===============" << std::endl;
}
// waitForUserInput(); // watch for any errors
// amdsmi_wait_for_user_input(); // watch for any errors
auto ret_set = amdsmi_set_gpu_accelerator_partition_profile(
processor_handles_[dv_ind],
@@ -789,6 +799,7 @@ void TestComputePartitionReadWrite::Run(void) {
<< "\n\t Device might be in a static partition mode. "
<< "With inability to change partition modes."
<< std::endl;
// amdsmi_wait_for_user_input(); // watch for any errors
break;
}
if (ret_set == AMDSMI_STATUS_NOT_SUPPORTED) {
@@ -872,6 +883,7 @@ void TestComputePartitionReadWrite::Run(void) {
std::cout << "\t**" << "amdsmi_get_gpu_accelerator_partition_profile: "
<< "Not supported on this machine, skipping remaining tests." << std::endl;
}
// amdsmi_wait_for_user_input(); // watch for any errors
break;
}
@@ -911,7 +923,7 @@ void TestComputePartitionReadWrite::Run(void) {
std::cout << "\t**Test #3: Check fluctuating # of devices & partition IDs ==============\n";
std::cout << "\t**======================================================================\n";
}
// waitForUserInput(); // watch for any errors on going back to original partition
// amdsmi_wait_for_user_input(); // watch for any errors on going back to original partition
// ---------------------------------------------------------//
// TEST 3: Check fluctuating # of devices & partition IDs //
@@ -925,12 +937,12 @@ void TestComputePartitionReadWrite::Run(void) {
std::cout << "\n";
std::cout << "\t**======================================================================\n";
std::cout << "\t**Test #3: Check fluctuating # of devices & partition IDs ==============\n";
std::cout << "\t**DEVICE: #" << std::setw(2) << std::setfill('0') << dv_ind
std::cout << "\t**DEVICE: #" << std::dec << std::setw(2) << std::setfill('0') << dv_ind
<< " ========================================================\n";
std::cout << "\t**======================================================================\n";
}
// Leaving for debug purposes
// waitForUserInput(); // watch for any errors on going back to original partition
// amdsmi_wait_for_user_input(); // watch for any errors on going back to original partition
uint32_t device_index = 0;
amdsmi_processor_handle p_handle = {};
uint32_t current_num_devices = 0;
@@ -1013,6 +1025,7 @@ void TestComputePartitionReadWrite::Run(void) {
<< "\n\t Device might be in a static partition mode. "
<< "With inability to change partition modes."
<< std::endl;
// amdsmi_wait_for_user_input(); // watch for any errors
break;
}
@@ -1039,7 +1052,7 @@ void TestComputePartitionReadWrite::Run(void) {
EXPECT_NE(updatePartition, mapStringToSMIComputePartitionTypes.at(
std::string(current_char_computePartition)));
}
// waitForUserInput(); // watch for any errors on going back to original partition
// amdsmi_wait_for_user_input(); // watch for any errors on going back to original partition
}
uint32_t device_index3 = 0;
@@ -1055,7 +1068,7 @@ void TestComputePartitionReadWrite::Run(void) {
std::cout << "\t**ABOUT TO GO BACK TO ORIGINAL PARTITION ("
<< orig_char_computePartition << ")\n";
}
// waitForUserInput(); // watch for any errors on going back to original partition
// amdsmi_wait_for_user_input(); // watch for any errors on going back to original partition
auto ret_set = amdsmi_set_gpu_compute_partition(p_handle3, updatePartition);
checkPartitionIdChanges(processor_handles_, dv_ind, std::string(orig_char_computePartition),
isVerbose, true);
@@ -1076,8 +1089,8 @@ void TestComputePartitionReadWrite::Run(void) {
}
}
IF_VERB(STANDARD) {
std::cout << "\t**Get/Set Test #3 (dev_ind: "
<< dv_ind << "): Check fluctuating # of devices & partition IDs ===============\n";
std::cout << "\t**Get/Set Test #3 (dev_ind: " << std::dec
<< dv_ind << "): Check fluctuating # of devices & partition IDs ===============\n";
}
}
+4 -3
Ver ficheiro
@@ -120,16 +120,17 @@ void TestErrCntRead::Run(void) {
err = amdsmi_get_gpu_ecc_count(processor_handles_[i], static_cast<amdsmi_gpu_block_t>(b), &ec);
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
if (err == AMDSMI_STATUS_NOT_SUPPORTED || err == AMDSMI_STATUS_FILE_ERROR) {
IF_VERB(STANDARD) {
std::cout << "\t**Error Count for " <<
GetBlockNameStr(static_cast<amdsmi_gpu_block_t>(b)) <<
": Not supported for this device" << std::endl;
": Not supported for this device or error accessing file" << std::endl;
}
// Verify api support checking functionality is working
err = amdsmi_get_gpu_ecc_count(processor_handles_[i], static_cast<amdsmi_gpu_block_t>(b),
nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
ASSERT_TRUE(err == AMDSMI_STATUS_NOT_SUPPORTED
|| err == AMDSMI_STATUS_FILE_ERROR);
} else {
CHK_ERR_ASRT(err)
+25 -4
Ver ficheiro
@@ -31,6 +31,7 @@
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "amd_smi/impl/amd_smi_utils.h"
#include "frequencies_read_write.h"
#include "../test_common.h"
@@ -71,6 +72,19 @@ void TestFrequenciesReadWrite::Run(void) {
amdsmi_frequencies_t f;
uint32_t freq_bitmask;
amdsmi_clk_type_t amdsmi_clk;
const std::map<amdsmi_clk_type_t, std::string> clk_type_map = {
{AMDSMI_CLK_TYPE_SYS, "SYS"},
{AMDSMI_CLK_TYPE_GFX, "GFX"},
{AMDSMI_CLK_TYPE_DF, "DF"},
{AMDSMI_CLK_TYPE_DCEF, "DCEF"},
{AMDSMI_CLK_TYPE_SOC, "SOC"},
{AMDSMI_CLK_TYPE_MEM, "MEM"},
{AMDSMI_CLK_TYPE_PCIE, "PCIE"},
{AMDSMI_CLK_TYPE_VCLK0, "VCLK0"},
{AMDSMI_CLK_TYPE_VCLK1, "VCLK1"},
{AMDSMI_CLK_TYPE_DCLK0, "DCLK0"},
{AMDSMI_CLK_TYPE_DCLK1, "DCLK1"},
};
TestBase::Run();
if (setup_failed_) {
@@ -86,11 +100,18 @@ void TestFrequenciesReadWrite::Run(void) {
auto freq_read = [&]() -> bool {
// Skip AMDSMI_CLK_TYPE_PCIE, which does not supported in rocm-smi.
std::cout << amdsmi_clk << std::endl;
if (amdsmi_clk == AMDSMI_CLK_TYPE_PCIE)
return false;
if (auto it = clk_type_map.find(amdsmi_clk); it != clk_type_map.end()) {
if (amdsmi_clk == AMDSMI_CLK_TYPE_PCIE) {
return false; // Quietly skip PCIE clock
// Cannot read/write to PCIE clock in driver
}
std::cout << "amdsmi_get_clk_freq(" << it->second << ", f)";
}
ret = amdsmi_get_clk_freq(processor_handles_[dv_ind], amdsmi_clk, &f);
std::cout << ret << std::endl;
if (auto it = clk_type_map.find(amdsmi_clk); it != clk_type_map.end()) {
std::cout << ": " << smi_amdgpu_get_status_string(ret, false) << std::endl;
}
if (ret == AMDSMI_STATUS_NOT_SUPPORTED ||
ret == AMDSMI_STATUS_NOT_YET_IMPLEMENTED) {
+28 -1
Ver ficheiro
@@ -22,11 +22,11 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "gpu_busy_read.h"
#include "../test_common.h"
@@ -63,9 +63,36 @@ void TestGPUBusyRead::Close() {
void TestGPUBusyRead::Run(void) {
amdsmi_status_t err;
uint32_t val_ui32;
TestBase::Run();
if (setup_failed_) {
std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl;
return;
}
for (uint32_t x = 0; x < num_iterations(); ++x) {
for (uint32_t i = 0; i < num_monitor_devs(); ++i) {
PrintDeviceHeader(processor_handles_[i]);
err = amdsmi_get_gpu_busy_percent(processor_handles_[i], &val_ui32);
if (err != AMDSMI_STATUS_SUCCESS) {
if (err == AMDSMI_STATUS_FILE_ERROR || err == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**GPU Busy Percent: Not supported on this machine"
<< std::endl;
}
ASSERT_TRUE(err == AMDSMI_STATUS_FILE_ERROR || err == AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
}
} else {
IF_VERB(STANDARD) {
std::cout << "\t**GPU Busy Percent (Percent Idle):" << std::dec <<
val_ui32 << " (" << 100 - val_ui32 << ")" << std::endl;
}
}
}
}
}
+1 -1
Ver ficheiro
@@ -98,7 +98,7 @@ void TestGpuMetricsRead::Run(void) {
IF_VERB(STANDARD) {
std::cout << "\t**" <<
"Not supported on this machine" << std::endl;
return;
continue;
}
}
} else {
+23 -11
Ver ficheiro
@@ -22,15 +22,16 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <map>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "mem_util_read.h"
#include "../test_common.h"
#include "amd_smi/impl/amd_smi_utils.h"
TestMemUtilRead::TestMemUtilRead() : TestBase() {
set_title("Memory Utilization Read Test");
@@ -81,12 +82,14 @@ void TestMemUtilRead::Run(void) {
}
auto err_chk = [&](const char *str) {
IF_VERB(STANDARD) {
std::cout << "\t** " << str << std::endl;
}
if (err != AMDSMI_STATUS_SUCCESS) {
if (err == AMDSMI_STATUS_FILE_ERROR) {
IF_VERB(STANDARD) {
std::cout << "\t** " << str << ": Not supported on this machine"
<< std::endl;
}
if (err == AMDSMI_STATUS_FILE_ERROR ||
err == AMDSMI_STATUS_NOT_SUPPORTED) {
ASSERT_TRUE(err == AMDSMI_STATUS_NOT_SUPPORTED
|| err == AMDSMI_STATUS_FILE_ERROR);
} else {
CHK_ERR_ASRT(err)
}
@@ -101,23 +104,32 @@ void TestMemUtilRead::Run(void) {
mem_type <= AMDSMI_MEM_TYPE_LAST; ++mem_type) {
err = amdsmi_get_gpu_memory_total(processor_handles_[i],
static_cast<amdsmi_memory_type_t>(mem_type), &total);
err_chk("amdsmi_get_gpu_memory_total()");
smi_amdgpu_get_status_string(err, false);
std::string mem_type_str =
kDevMemoryTypeNameMap.at(static_cast<amdsmi_memory_type_t>(mem_type));
std::string input_str =
"amdsmi_get_gpu_memory_total(" + mem_type_str + "): "
+ smi_amdgpu_get_status_string(err, false);
err_chk(input_str.c_str());
if (err != AMDSMI_STATUS_SUCCESS) {
return;
continue;
}
err = amdsmi_get_gpu_memory_usage(processor_handles_[i],
static_cast<amdsmi_memory_type_t>(mem_type), &usage);
err_chk("amdsmi_get_gpu_memory_usage()");
input_str =
"amdsmi_get_gpu_memory_usage(" + mem_type_str + "): "
+ smi_amdgpu_get_status_string(err, false);
err_chk(input_str.c_str());
if (err != AMDSMI_STATUS_SUCCESS) {
return;
continue;
}
IF_VERB(STANDARD) {
std::cout << "\t**" <<
kDevMemoryTypeNameMap.at(static_cast<amdsmi_memory_type_t>(mem_type))
<< " Calculated Utilization: " <<
(static_cast<float>(usage)*100)/static_cast<float>(total) << "% ("<< usage <<
(static_cast<float>(usage)*100)/static_cast<float>(total) << "% (" << usage <<
"/" << total << ")" << std::endl;
}
}
+28 -7
Ver ficheiro
@@ -124,6 +124,8 @@ void TestMemoryPartitionReadWrite::Run(void) {
std::cout << "\t**=========================================================\n";
}
auto initial_num_devices = num_monitor_devs();
amdsmi_accelerator_partition_type_t primary_partition_type = AMDSMI_ACCELERATOR_PARTITION_INVALID;
uint32_t primary_index = 0;
for (uint32_t dv_ind = 0; dv_ind < initial_num_devices; ++dv_ind) {
if (dv_ind != 0) {
std::cout << "\n";
@@ -168,6 +170,12 @@ void TestMemoryPartitionReadWrite::Run(void) {
profile_type_str = "CPX";
}
// save the primary partition type
if (profile.profile_type != AMDSMI_ACCELERATOR_PARTITION_INVALID) {
primary_partition_type = profile.profile_type;
primary_index = dv_ind;
}
std::string partition_id_str = "";
for (int i = 0; i < 8; i++) {
partition_id_str += std::to_string(partition_id[i]);
@@ -175,7 +183,7 @@ void TestMemoryPartitionReadWrite::Run(void) {
partition_id_str += ", ";
}
switch (profile.profile_type) {
switch (primary_partition_type) {
case AMDSMI_ACCELERATOR_PARTITION_SPX:
EXPECT_LT(partition_id[i], MAX_SPX_PARTITIONS);
break;
@@ -191,7 +199,7 @@ void TestMemoryPartitionReadWrite::Run(void) {
case AMDSMI_ACCELERATOR_PARTITION_CPX: {
uint16_t num_xcd;
uint32_t max_xcps = 0;
ret = amdsmi_get_gpu_xcd_counter(processor_handles_[dv_ind], &num_xcd);
ret = amdsmi_get_gpu_xcd_counter(processor_handles_[primary_index], &num_xcd);
if (ret == AMDSMI_STATUS_SUCCESS) {
max_xcps = static_cast<uint32_t>(num_xcd);
}
@@ -245,7 +253,7 @@ void TestMemoryPartitionReadWrite::Run(void) {
AcceleratorProfileConfig original_profile_config =
getAvailableProfileConfigs(dv_ind, profile, profile_config, isVerbose);
orig_dev_config[dv_ind] = original_profile_config;
// waitForUserInput(); // watch for any errors
// amdsmi_wait_for_user_input(); // watch for any errors
IF_VERB(STANDARD) {
std::cout << "\t**=========================================================\n";
@@ -321,7 +329,7 @@ void TestMemoryPartitionReadWrite::Run(void) {
|| ret == AMDSMI_STATUS_NOT_SUPPORTED);
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**" << "amdsmi_get_gpu_accelerator_partition_profile_config: "
std::cout << "\t**" << "amdsmi_get_gpu_accelerator_partition_profile_config(): "
<< "Not supported on this machine" << std::endl;
}
continue;
@@ -329,6 +337,11 @@ void TestMemoryPartitionReadWrite::Run(void) {
}
// Run memory partition tests
IF_VERB(STANDARD) {
std::cout << "\t**=========================================================\n";
std::cout << "\t**Test: Memory Partition Sets =============================\n";
std::cout << "\t**=========================================================\n";
}
uint32_t current_num_devices = 0;
smi_amdgpu_get_device_count(&current_num_devices);
@@ -352,7 +365,7 @@ void TestMemoryPartitionReadWrite::Run(void) {
processor_handles_[dv_ind], orig_memory_partition, k255Len);
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**" << ": "
std::cout << "\t**" << "amdsmi_get_gpu_memory_partition(): "
<< "Not supported on this machine" << std::endl;
}
continue;
@@ -563,7 +576,7 @@ void TestMemoryPartitionReadWrite::Run(void) {
}
if (ret_set == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**" << ": "
std::cout << "\t**" << "amdsmi_set_gpu_memory_partition_mode(): "
<< "Not supported on this machine" << std::endl;
}
break;
@@ -618,7 +631,8 @@ void TestMemoryPartitionReadWrite::Run(void) {
ret = amdsmi_get_gpu_memory_partition_config(processor_handles_[dv_ind],
&current_memory_config);
CHK_ERR_ASRT(ret)
ASSERT_TRUE((ret == AMDSMI_STATUS_NOT_SUPPORTED) ||
(ret == AMDSMI_STATUS_SUCCESS));
IF_VERB(STANDARD) {
std::cout << "\t**"
<< "amdsmi_get_gpu_memory_partition_config(processor_handles_[" << dv_ind
@@ -629,6 +643,13 @@ void TestMemoryPartitionReadWrite::Run(void) {
<< memoryPartitionString(current_memory_config.mp_mode)
<< std::endl;
}
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**" << "amdsmi_get_gpu_memory_partition_config(): "
<< "Not supported on this machine... trying on other devices" << std::endl;
}
continue;
}
new_memory_partition
= mapStringToRSMIMemoryPartitionTypes.at(orig_memory_partition);
+10 -5
Ver ficheiro
@@ -22,11 +22,11 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "perf_level_read.h"
#include "../test_common.h"
@@ -76,10 +76,15 @@ void TestPerfLevelRead::Run(void) {
PrintDeviceHeader(processor_handles_[i]);
err = amdsmi_get_gpu_perf_level(processor_handles_[i], &pfl);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Performance Level:" << std::dec << (uint32_t)pfl <<
std::endl;
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout << "\t**Performance Level: Not Supported" << std::endl;
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Performance Level:" << std::dec << (uint32_t)pfl
<< std::endl;
}
}
// Verify api support checking functionality is working
err = amdsmi_get_gpu_perf_level(processor_handles_[i], nullptr);
+10 -4
Ver ficheiro
@@ -22,11 +22,11 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <map>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "perf_level_read_write.h"
#include "../test_common.h"
@@ -79,11 +79,17 @@ void TestPerfLevelReadWrite::Run(void) {
PrintDeviceHeader(processor_handles_[dv_ind]);
ret = amdsmi_get_gpu_perf_level(processor_handles_[dv_ind], &orig_pfl);
CHK_ERR_ASRT(ret)
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**amdsmi_get_gpu_perf_level(): Not supported on this machine" << std::endl;
}
ASSERT_EQ(ret, AMDSMI_STATUS_NOT_SUPPORTED);
continue;
}
IF_VERB(STANDARD) {
std::cout << "\t**Original Perf Level:" <<
GetPerfLevelStr(orig_pfl) << std::endl;
std::cout << "\t**Original Perf Level:"
<< GetPerfLevelStr(orig_pfl) << std::endl;
}
uint32_t pfl_i = static_cast<uint32_t>(AMDSMI_DEV_PERF_LEVEL_FIRST);
+33 -22
Ver ficheiro
@@ -22,13 +22,13 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "power_cap_read_write.h"
#include "../test_common.h"
@@ -83,18 +83,18 @@ void TestPowerCapReadWrite::SetCheckPowerCap(std::string msg, uint32_t dv_ind, u
start = clock();
ret = amdsmi_set_power_cap(processor_handles_[dv_ind], 0, new_cap);
end = clock();
cpu_time_used = ((double) (end - start)) * 1000000UL / CLOCKS_PER_SEC;
cpu_time_used = (static_cast<double>(end - start)) * 1000000UL / CLOCKS_PER_SEC;
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t** Not supported on this machine" << std::endl;
std::cout << "\t**amdsmi_set_power_cap(): Not supported on this machine" << std::endl;
}
return;
}
ASSERT_EQ(ret, ret_expected);
if (ret == AMDSMI_STATUS_INVAL) {
new_cap = curr_cap;
std::cout << "\t** Expected invalid result" << std::endl;
std::cout << "\t**amdsmi_set_power_cap(): Expected invalid result" << std::endl;
return;
}
@@ -134,11 +134,16 @@ void TestPowerCapReadWrite::Run(void) {
PrintDeviceHeader(processor_handles_[dv_ind]);
amdsmi_power_cap_info_t info;
ret = amdsmi_get_power_cap_info(processor_handles_[dv_ind], 0, &info);
CHK_ERR_ASRT(ret)
// Verify api support checking functionality is working
ret = amdsmi_get_power_cap_info(processor_handles_[dv_ind], 0, nullptr);
ASSERT_EQ(ret, AMDSMI_STATUS_INVAL);
ret = amdsmi_get_power_cap_info(processor_handles_[dv_ind], 0, &info);
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout << "\t**amdsmi_get_power_cap_info(): Not supported on this machine" << std::endl;
ASSERT_EQ(ret, AMDSMI_STATUS_NOT_SUPPORTED);
continue;
}
min_cap = info.min_power_cap;
max_cap = info.max_power_cap;
default_cap = info.default_power_cap;
@@ -148,15 +153,16 @@ void TestPowerCapReadWrite::Run(void) {
IF_VERB(STANDARD) {
std::cout << "[Before Set] Default Power Cap: " << default_cap << " uW" << std::endl;
std::cout << "[Before Set] Current Power Cap: " << curr_cap << " uW" << std::endl;
std::cout << "[Before Set] Power Cap Range [max to min]: " << max_cap << " uW to " << min_cap <<
" uW" << std::endl;
std::cout << "[Before Set] Power Cap Range [max to min]: "
<< max_cap << " uW to " << min_cap << " uW" << std::endl;
std::cout << "[Before Set] Setting new cap to " << new_cap << "..." << std::endl;
}
// Check if power cap is within the range
// skip the test otherwise
if (new_cap < min_cap || new_cap > max_cap) {
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) is failed to set for " << dv_ind << std::endl;
continue;
}
ret = AMDSMI_STATUS_SUCCESS;
@@ -166,17 +172,18 @@ void TestPowerCapReadWrite::Run(void) {
}
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) is failed to set for " << dv_ind << std::endl;
}
if (min_cap > 0)
{
if (min_cap > 0) {
new_cap = min_cap;
ret = AMDSMI_STATUS_SUCCESS;
SetCheckPowerCap("Setting to Min Power Cap", dv_ind, curr_cap, new_cap, ret);
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) is failed to set for " << dv_ind << std::endl;
}
new_cap = uint64_t(min_cap - 1);
@@ -185,7 +192,8 @@ void TestPowerCapReadWrite::Run(void) {
if (ret != AMDSMI_STATUS_INVAL) {
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) is failed to set for " << dv_ind << std::endl;
}
}
@@ -195,13 +203,13 @@ void TestPowerCapReadWrite::Run(void) {
if (ret != AMDSMI_STATUS_INVAL) {
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for "
<< dv_ind << std::endl;
}
}
}
else
{
std::cout << "\tPower cap requested is less than or equal to 0, skipping test for " << dv_ind << std::endl;
} else {
std::cout << "\tPower cap requested is less than or equal to 0, skipping test for device #"
<< dv_ind << std::endl;
}
new_cap = max_cap;
@@ -209,7 +217,8 @@ void TestPowerCapReadWrite::Run(void) {
SetCheckPowerCap("Setting to Max Power Cap", dv_ind, curr_cap, new_cap, ret);
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) is failed to set for " << dv_ind << std::endl;
}
new_cap = uint64_t(max_cap + 1);
@@ -218,7 +227,8 @@ void TestPowerCapReadWrite::Run(void) {
if (ret != AMDSMI_STATUS_INVAL) {
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) failed to set for " << dv_ind << std::endl;
}
}
@@ -228,7 +238,8 @@ void TestPowerCapReadWrite::Run(void) {
if (ret != AMDSMI_STATUS_INVAL) {
IF_VERB(STANDARD) {
if (!new_cap)
std::cout << "\t** Power cap requested (" << new_cap << " uW) is failed to set for " << dv_ind << std::endl;
std::cout << "\t** Power cap requested (" << new_cap
<< " uW) is failed to set for " << dv_ind << std::endl;
}
}
+7 -2
Ver ficheiro
@@ -22,11 +22,11 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "power_read.h"
#include "../test_common.h"
@@ -77,6 +77,11 @@ void TestPowerRead::Run(void) {
amdsmi_power_cap_info_t info;
err = amdsmi_get_power_cap_info(processor_handles_[i], 0, &info);
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout << "\t**Power Cap not supported on this device." << std::endl;
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
continue;
}
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Current Power Cap: " << info.power_cap << "uW" <<std::endl;
@@ -87,7 +92,7 @@ void TestPowerRead::Run(void) {
std::cout << "\t**Power Cap Range: " << info.min_power_cap << " to " <<
info.max_power_cap << " uW" << std::endl;
}
// TODO: Add current_socket_power tests
// TODO(amdsmi_team): Add current_socket_power tests
}
}
}
+12 -6
Ver ficheiro
@@ -22,12 +22,12 @@
#include <stdint.h>
#include <stddef.h>
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <limits>
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
#include "sys_info_read.h"
#include "../test_common.h"
@@ -118,16 +118,22 @@ void TestSysInfoRead::Run(void) {
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
err = amdsmi_get_gpu_topo_numa_affinity(processor_handles_[i], &val_i32);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**NUMA NODE: 0x" << std::hex << val_i32;
std::cout << " (" << std::dec << val_i32 << ")" << std::endl;
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout << "\t**amdsmi_get_gpu_topo_numa_affinity(): Not supported on this machine"
<< std::endl;
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**NUMA NODE: 0x" << std::hex << val_i32;
std::cout << " (" << std::dec << val_i32 << ")" << std::endl;
}
}
// Verify api support checking functionality is working
err = amdsmi_get_gpu_topo_numa_affinity(processor_handles_[i], nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
// vendor_id, unique_id, target_gfx_version
amdsmi_asic_info_t asic_info = {};
err = amdsmi_get_gpu_asic_info(processor_handles_[i], &asic_info);
+3 -1
Ver ficheiro
@@ -19,6 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <gtest/gtest.h>
#include <string>
#include <vector>
@@ -27,7 +28,7 @@
#include "amd_smi/amdsmi.h"
#include "rocm_smi/rocm_smi_utils.h"
#include <gtest/gtest.h>
#include "amd_smi/impl/amd_smi_utils.h"
#include "test_common.h"
#include "test_base.h"
@@ -114,6 +115,7 @@ static void RunGenericTest(TestBase *test) {
// RunGenericTest(&<test_obj>);
// }
TEST(amdsmitstReadOnly, TestVersionRead) {
// amdsmi_wait_for_user_input();
TestVersionRead tst;
RunGenericTest(&tst);
}
+76 -41
Ver ficheiro
@@ -21,8 +21,8 @@
*/
#include <gtest/gtest.h>
#include <cassert>
#include <limits>
#include "amd_smi/amdsmi.h"
#include "amd_smi/impl/amd_smi_utils.h"
@@ -171,7 +171,6 @@ void TestBase::PrintDeviceHeader(amdsmi_processor_handle dv_ind) {
amdsmi_status_t err;
uint16_t val_ui16;
uint32_t val_ui32;
amdsmi_asic_info_t info;
err = smi_amdgpu_get_device_count(&val_ui32);
CHK_ERR_ASRT(err)
@@ -189,16 +188,16 @@ void TestBase::PrintDeviceHeader(amdsmi_processor_handle dv_ind) {
std::cout << "\t**Device handle: " << dv_ind << std::endl;
}
err = amdsmi_get_gpu_id(dv_ind, &val_ui16);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device ID: 0x" << std::hex << val_ui16 << std::endl;
}
err = amdsmi_get_gpu_revision(dv_ind, &val_ui16);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device Revision ID: 0x" << std::hex <<
val_ui16 << std::endl;
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**Device ID: N/A" << std::endl;
}
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device ID: 0x" << std::hex << val_ui16 << std::endl;
}
}
amdsmi_board_info_t board_info;
@@ -206,30 +205,82 @@ void TestBase::PrintDeviceHeader(amdsmi_processor_handle dv_ind) {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device name: " << board_info.product_name << std::endl;
err = amdsmi_get_gpu_asic_info(dv_ind, &info);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device Vendor ID: 0x" << std::hex <<
info.vendor_id << std::endl;
}
}
amdsmi_asic_info_t asic_info;
err = amdsmi_get_gpu_asic_info(dv_ind, &asic_info);
CHK_ERR_ASRT(err)
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**ASIC info: " << smi_amdgpu_get_status_string(err, false) << std::endl;
}
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else if (err == AMDSMI_STATUS_FILE_ERROR) { // File error can happen for partition switches,
// if SMI is not re-initialized
IF_VERB(STANDARD) {
std::cout << "\t**ASIC info: " << smi_amdgpu_get_status_string(err, false) << std::endl;
}
ASSERT_EQ(err, AMDSMI_STATUS_FILE_ERROR);
} else {
CHK_ERR_ASRT(err)
}
// Print everything we can get from the ASIC info
IF_VERB(STANDARD) {
std::cout << "\t**Market name: " << asic_info.market_name << std::endl;
std::cout << "\t**ASIC serial: 0x" << std::hex << asic_info.asic_serial << std::endl;
std::cout << "\t**Target GFX Version: gfx" << asic_info.target_graphics_version << std::endl;
std::cout << "\t**Device ID: 0x" << std::hex << std::setfill('0') << std::setw(4)
<< asic_info.device_id << std::endl;
if (checkIfMaxValue(asic_info.num_of_compute_units)) {
std::cout << "\t**Num of Compute Units: N/A" << std::endl;
} else {
std::cout << "\t**Num of Compute Units: " << std::dec << asic_info.num_of_compute_units
<< std::endl;
}
if (checkIfMaxValue(asic_info.oam_id)) {
std::cout << "\t**OAM ID: N/A" << std::endl;
} else {
std::cout << "\t**OAM ID: " << std::dec << asic_info.oam_id << std::endl;
}
std::cout << "\t**Revision ID: 0x" << std::hex << std::setfill('0') << std::setw(2)
<< asic_info.rev_id << std::endl;
if (checkIfMaxValue(asic_info.subvendor_id)) {
std::cout << "\t**Subvendor ID: N/A" << std::endl;
} else {
std::cout << "\t**Subvendor ID: 0x" << std::hex << std::setfill('0') << std::setw(4)
<< asic_info.subvendor_id << std::endl;
}
std::cout << "\t**Vendor ID: 0x" << std::hex << std::setfill('0') << std::setw(4)
<< asic_info.vendor_id << std::endl;
std::cout << "\t**Vendor name: " << asic_info.vendor_name
<< std::endl;
}
err = amdsmi_get_gpu_revision(dv_ind, &val_ui16);
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**Device Revision ID: N/A" << std::endl;
}
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device Revision ID: 0x" << std::hex << std::setfill('0') << std::setw(2)
<< val_ui16 << std::endl;
}
}
err = amdsmi_get_gpu_subsystem_id(dv_ind, &val_ui16);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Subsystem ID: 0x" << std::hex << val_ui16 << std::endl;
std::cout << "\t**Subsystem Vendor ID: 0x" << std::hex
<< info.subvendor_id << std::endl;
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
IF_VERB(STANDARD) {
std::cout << "\t**Subsystem ID: N/A" << std::endl;
}
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Subsystem ID: 0x" << std::hex << std::setfill('0') << std::setw(4)
<< val_ui16 << std::endl;
}
}
std::cout << std::setbase(10);
@@ -349,22 +400,6 @@ TestBase::AcceleratorProfileConfig TestBase::getAvailableProfileConfigs(
return profile_config;
}
void TestBase::waitForUserInput() {
for (;;) {
std::cout << "\n\t**Press any key to continue**" << std::endl;
int input = std::cin.get();
if (input == EOF) {
std::cout << "EOF detected. Exiting." << std::endl;
return;
}
char input_char = static_cast<char>(input);
std::cout << "User entered: " << input_char << std::endl;
if (input_char == '\n') {
return;
}
}
}
uint32_t TestBase::promptNumDevicesToTest(uint32_t current_num_devices) {
uint32_t return_value = 0;
std::cout << "**How many devices would you like to test? (0 to skip): ";
+20 -3
Ver ficheiro
@@ -27,6 +27,7 @@
#include <string>
#include <vector>
#include <map>
#include <limits>
#include "amd_smi/amdsmi.h"
// The max devices can be monitored
@@ -133,12 +134,21 @@ class TestBase {
amdsmi_accelerator_partition_profile_t current_profile,
amdsmi_accelerator_partition_profile_config_t config,
bool isVerbose);
void waitForUserInput();
uint32_t promptNumDevicesToTest(uint32_t current_num_devices);
std::string getResourceType(amdsmi_accelerator_partition_resource_type_t resource_type);
template <typename T>
bool checkIfMaxValue(T value) {
T max_value = std::numeric_limits<T>::max();
if (value == max_value) {
return true;
} else {
return false;
}
}
protected:
void MakeHeaderStr(const char *inStr, std::string *outStr) const;
void PrintDeviceHeader(amdsmi_processor_handle dv_ind);
@@ -163,9 +173,16 @@ class TestBase {
// Macros to be used within TestBase classes
#define CHK_ERR_ASRT(RET) { \
if (dont_fail() && ((RET) != AMDSMI_STATUS_SUCCESS)) { \
if ((RET) != AMDSMI_STATUS_SUCCESS) { \
std::cout << std::endl << "\t===> TEST FAILURE." << std::endl; \
DISPLAY_AMDSMI_ERR(RET); \
const char *err_str; \
std::cout << "\t===> ERROR: AMDSMI call returned " << (RET) << std::endl; \
amdsmi_status_code_to_string((RET), &err_str); \
std::cout << "\t===> (" << err_str << ")" << std::endl; \
std::cout << "\t===> at " << __FILE__ << ":" << std::dec << __LINE__ << \
std::endl; \
} \
if (dont_fail() && ((RET) != AMDSMI_STATUS_SUCCESS)) { \
std::cout << \
"\t===> Abort is over-ridden due to dont_fail command line option." \
<< std::endl; \