RVS - Use config files and make GPU aware

Change-Id: I7a5c80ed4e6122d102e494d1ae38b4b7d40c42cd
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
Этот коммит содержится в:
Galantsev, Dmitrii
2025-02-28 11:17:40 +00:00
коммит произвёл Galantsev, Dmitrii
родитель 247c8c7d5e
Коммит f5a4402ce5
63 изменённых файлов: 4673 добавлений и 148 удалений
+15 -5
Просмотреть файл
@@ -160,9 +160,13 @@ typedef enum { INTEGER = 0, DOUBLE, STRING, BLOB } rdc_field_type_t;
typedef enum {
RDC_FI_INVALID = 0, //!< Invalid field value
//!< @brief Identifier fields
RDC_FI_GPU_COUNT = 1, //!< GPU count in the system
RDC_FI_DEV_NAME, //!< Name of the device
RDC_FI_OAM_ID, //!< OAM ID of the device
RDC_FI_GPU_COUNT = 1, //!< GPU count in the system
RDC_FI_DEV_NAME, //!< Name of the device
RDC_FI_OAM_ID, //!< OAM ID of the device
RDC_FI_DEV_ID, //!< Device ID
RDC_FI_REV_ID, //!<
RDC_FI_TARGET_GRAPHICS_VERSION, //!< Target graphics version
RDC_FI_NUM_OF_COMPUTE_UNITS, //!< Number of compute units
/**
* @brief Frequency related fields
@@ -388,6 +392,9 @@ typedef uint32_t rdc_field_grp_t; //!< Field group ID type
*/
typedef struct {
char device_name[RDC_MAX_STR_LENGTH]; //!< Name of the device.
uint64_t device_id; //!< The device id of a GPU
uint32_t num_of_compute_units;
uint64_t target_graphics_version;
} rdc_device_attributes_t;
/**
@@ -533,7 +540,8 @@ typedef enum {
RDC_DIAG_RVS_MEMBW_TEST, //!< RVS bandwidth test
RDC_DIAG_RVS_H2DD2H_TEST, //!< RVS Host<->Device transfer speed test
RDC_DIAG_RVS_IET_TEST, //!< RVS IET test
RDC_DIAG_TEST_LAST = RDC_DIAG_RVS_IET_TEST
RDC_DIAG_RVS_CUSTOM, //!< RVS custom test
RDC_DIAG_TEST_LAST,
} rdc_diag_test_cases_t;
/**
@@ -547,7 +555,7 @@ typedef enum {
/**
* @brief The maximum test cases to run
*/
#define MAX_TEST_CASES (RDC_DIAG_TEST_LAST - RDC_DIAG_TEST_FIRST + 1)
#define MAX_TEST_CASES (RDC_DIAG_TEST_LAST - RDC_DIAG_TEST_FIRST)
/**
* @brief The maximum length of the diagnostic messages
@@ -1607,6 +1615,8 @@ rdc_status_t rdc_config_get(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_id,
*/
rdc_status_t rdc_config_clear(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_id);
const char* get_rocm_path(const char* search_string);
#ifdef __cplusplus
}
#endif // __cplusplus
+77 -38
Просмотреть файл
@@ -22,61 +22,96 @@ THE SOFTWARE.
#ifndef RDC_MODULES_RDC_RVS_RVSBASE_H_
#define RDC_MODULES_RDC_RVS_RVSBASE_H_
#include <amd_smi/amdsmi.h>
#include <cstddef>
#include <cstdio>
#include <filesystem>
#include <map>
#include <string>
#include <vector>
#include "rdc/rdc.h"
#include "rdc_lib/RdcLogger.h"
#include "rvs/rvs.h"
static constexpr size_t MAX_CONFIG_LENGTH = 1024;
// NOTE: There MUST be a space after :
static const std::map<rdc_diag_test_cases_t, std::string> test_to_conf = {
// derived from conf/gst_single.conf
{RDC_DIAG_RVS_GST_TEST,
"{actions: [{name: gpustress-9000-sgemm-false, device: all, "
"device_index: '0', module: gst, parallel: false, count: 1, duration: "
"10000, copy_matrix: false, target_stress: 9000, matrix_size_a: 8640, "
"matrix_size_b: 8640, matrix_size_c: 8640, ops_type: sgemm, lda: 8640, "
"ldb: 8640, ldc: 8640}]}"},
// derived from conf/MI300X/babel.conf
{RDC_DIAG_RVS_MEMBW_TEST,
"{actions: [{name: babel-float-256MiB,"
"device: all, module: babel, "
"parallel: false, count: 1, num_iter: 5000, array_size: 268435456, "
"test_type: 1, mibibytes: true, o/p_csv: false, subtest: 5}]}"},
// derived from conf/MI300X/pebb_single.conf
{RDC_DIAG_RVS_H2DD2H_TEST,
"{actions: [{name: h2d-d2h-sequential-64MB,"
"device: all, module: pebb, duration: 120000, device_to_host: true, "
"host_to_device: true, parallel: false, block_size: 67108864, "
"link_type: 2, warm_calls: 10, hot_calls: 100, b2b: true}]}"},
// derived from conf/MI300X/iet_single.conf
{RDC_DIAG_RVS_IET_TEST,
"{actions: [{name: iet-400W-1K-rand-dgemm,"
"device: all, module: iet, parallel: true, duration: 60000, "
"sample_interval: 3000, target_power: 400, matrix_size: 1024, "
"matrix_init: rand, ops_type: dgemm}]}"},
// this map only makes sense in context of test config locations as originally
// designed in RVS
static const std::map<uint64_t, std::string> gfx_to_rvs_conf = {
{0x90a, "MI210"}, // ?
{0x940, "MI300A"}, // ?
{0x941, "MI300A"}, // ?
{0x942, "MI300X"}, // ?
{0x94a, "MI308X"}, // ?
{0x1030, "nv21"}, //
{0x1031, "nv21"}, // ?
{0x1032, "nv21"}, // ?
{0x1033, "nv21"}, // ?
{0x1034, "nv21"}, // ?
{0x1035, "nv21"}, // ?
{0x1100, "nv31"}, // ?
{0x1101, "nv31"}, // ?
{0x1102, "nv31"}, // ?
{0x1103, "nv31"}, // ?
};
static const std::map<rdc_diag_test_cases_t, std::string> test_to_name = {
{RDC_DIAG_RVS_GST_TEST, "RVS_GST_TEST"},
{RDC_DIAG_RVS_MEMBW_TEST, "RVS_MEMBW_TEST"},
{RDC_DIAG_RVS_H2DD2H_TEST, "RVS_H2DD2H_TEST"},
{RDC_DIAG_RVS_IET_TEST, "RVS_IET_TEST"},
{RDC_DIAG_RVS_GST_TEST, "gst_single.conf"}, {RDC_DIAG_RVS_MEMBW_TEST, "babel.conf"},
{RDC_DIAG_RVS_H2DD2H_TEST, "pebb_single.conf"}, {RDC_DIAG_RVS_IET_TEST, "iet_stress.conf"},
{RDC_DIAG_RVS_CUSTOM, "CUSTOM_CONFIG"},
};
namespace amd {
namespace rdc {
inline amdsmi_status_t get_processor_handle_from_id(uint32_t gpu_id,
amdsmi_processor_handle* processor_handle) {
uint32_t socket_count;
uint32_t processor_count;
auto ret = amdsmi_get_socket_handles(&socket_count, nullptr);
if (ret != AMDSMI_STATUS_SUCCESS) {
return ret;
}
std::vector<amdsmi_socket_handle> sockets(socket_count);
std::vector<amdsmi_processor_handle> all_processors{};
ret = amdsmi_get_socket_handles(&socket_count, sockets.data());
for (auto& socket : sockets) {
ret = amdsmi_get_processor_handles(socket, &processor_count, nullptr);
if (ret != AMDSMI_STATUS_SUCCESS) {
return ret;
}
std::vector<amdsmi_processor_handle> processors(processor_count);
ret = amdsmi_get_processor_handles(socket, &processor_count, processors.data());
if (ret != AMDSMI_STATUS_SUCCESS) {
return ret;
}
for (auto& processor : processors) {
processor_type_t processor_type = {};
ret = amdsmi_get_processor_type(processor, &processor_type);
if (processor_type != AMDSMI_PROCESSOR_TYPE_AMD_GPU) {
RDC_LOG(RDC_ERROR, "Expect AMD_GPU device type!");
return AMDSMI_STATUS_NOT_SUPPORTED;
}
all_processors.push_back(processor);
}
}
if (gpu_id >= all_processors.size()) {
return AMDSMI_STATUS_INPUT_OUT_OF_BOUNDS;
}
// Get processor handle from GPU id
*processor_handle = all_processors[gpu_id];
return AMDSMI_STATUS_SUCCESS;
}
class RdcRVSBase {
public:
RdcRVSBase() { s_instance = this; };
~RdcRVSBase() {
if (s_instance == this) {
s_instance = nullptr;
}
};
RdcRVSBase();
~RdcRVSBase();
// only one instance allowed
RdcRVSBase(const RdcRVSBase&) = delete;
@@ -87,12 +122,16 @@ class RdcRVSBase {
RdcRVSBase& operator=(RdcRVSBase&&) = delete;
rvs_status_t run_rvs_app(const char* config, size_t config_size, rdc_diag_callback_t* callback);
std::vector<std::string> get_rvs_configs();
std::map<rdc_diag_test_cases_t, std::string> get_test_to_conf();
private:
static RdcRVSBase* s_instance;
volatile rvs_session_state_t _state = RVS_SESSION_STATE_IDLE;
rdc_diag_callback_t* _callback = nullptr;
rvs_session_callback _rvs_callback = nullptr;
std::vector<std::string> _rvs_config_list = {};
std::map<rdc_diag_test_cases_t, std::string> _test_to_conf = {};
// Static callback function that the C API will call
static void static_callback(rvs_session_id_t session_id, const rvs_results_t* results) {
@@ -101,7 +140,7 @@ class RdcRVSBase {
s_instance->session_callback(session_id, results);
}
}
void session_callback(rvs_session_id_t session_id, const rvs_results_t* results) {
void session_callback(rvs_session_id_t /*session_id*/, const rvs_results_t* results) {
_state = results->state;
// std::string output = "\n";
// output += "session id -> " + std::to_string(session_id) + "\n";