[SWDEV-493274/SWDEV-514998] Add AMD SMI partition tests + Add Guest amd-smi static --partition (#127)

* [SWDEV-493274/SWDEV-514998] Add AMD SMI partition tests + Add Guest amd-smi static --partition

Changes:
    - Added amd-smi static --partition for guest systems
    - Added C++ tests for memory and compute (accelerator) partitions
    - Added Python tests for amdsmi_get_gpu_vram_info(),
       amdsmi_get_gpu_accelerator_partition_profile_config()
    - Updated Python tests for
      amdsmi_get_gpu_accelerator_partition_profile()
      Now includes more profile and resource detail
    - Added amdsmi_get_gpu_xcd_counter();
      Tests provided for both C++/Python APIs
    - Added AmdSmiVramType & AmdSmiVramVendor: they were missing
      python testing required adding.

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

[ROCm/amdsmi commit: 48cb5529d2]
This commit is contained in:
Poag, Charis
2025-03-11 16:38:46 -05:00
zatwierdzone przez GitHub
rodzic cb56b5e193
commit 267fa91e8a
30 zmienionych plików z 3505 dodań i 399 usunięć
+20 -1
Wyświetl plik
@@ -407,7 +407,7 @@ typedef enum {
//!< work together with shared memory
AMDSMI_COMPUTE_PARTITION_QPX, //!< Quad GPU mode (QPX)- Quarter XCCs
//!< work together with shared memory
AMDSMI_COMPUTE_PARTITION_CPX, //!< Core mode (CPX)- Per-chip XCC with
AMDSMI_COMPUTE_PARTITION_CPX //!< Core mode (CPX)- Per-chip XCC with
//!< shared memory
} amdsmi_compute_partition_type_t;
@@ -5847,6 +5847,25 @@ amdsmi_get_power_cap_info(amdsmi_processor_handle processor_handle, uint32_t sen
*/
amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, amdsmi_pcie_info_t *info);
/**
* @brief Returns the 'xcd_counter' from the GPU metrics associated with the device
*
* @ingroup tagAsicBoardInfo
*
* @platform{gpu_bm_linux} @platform{guest_1vf} @platform{guest_mvf}
*
* @param[in] processor_handle Device which to query
*
* @param[inout] xcd_count a pointer to uint16_t to which the device gpu
* metric unit will be stored. Must be allocated by user.
*
* @retval ::AMDSMI_STATUS_SUCCESS is returned upon successful call.
* ::AMDSMI_STATUS_NOT_SUPPORTED is returned in case the metric unit
* does not exist for the given device.
*/
amdsmi_status_t amdsmi_get_gpu_xcd_counter(amdsmi_processor_handle processor_handle,
uint16_t *xcd_count);
/** @} End tagAsicBoardInfo */
/*****************************************************************************/
@@ -27,7 +27,6 @@
#include "amd_smi/impl/amd_smi_processor.h"
#include "amd_smi/impl/amd_smi_drm.h"
#include "shared_mutex.h" // NOLINT
#include "rocm_smi/rocm_smi_logger.h"
namespace amd {
namespace smi {
@@ -26,10 +26,10 @@
#include <limits>
#include <type_traits>
#include <string>
#include <utility>
#include "amd_smi/amdsmi.h"
#include "amd_smi/impl/amd_smi_gpu_device.h"
#include "rocm_smi/rocm_smi_utils.h"
#define SMIGPUDEVICE_MUTEX(MUTEX) \
@@ -55,6 +55,63 @@ amdsmi_status_t smi_amdgpu_is_gpu_power_management_enabled(amd::smi::AMDSmiGPUDe
std::string smi_split_string(std::string str, char delim);
std::string smi_amdgpu_get_status_string(amdsmi_status_t ret, bool fullStatus);
/**
* @brief Get the device index given the processor handle.
*
* @details Given a processor handle @p processor_handle
* and a pointer to a uint32_t @p device_index will be returned.
*
* @param[in] processor_handle Device which to query
*
* @param[inout] device_index a pointer to uint32_t to which the matching device
* index will be stored
*
* @retval ::AMDSMI_STATUS_SUCCESS is returned upon successful call.
* ::AMDSMI_STATUS_INVAL is returned if user provides a null pointer
* for device_index.
* ::AMDSMI_STATUS_API_FAILED is returned if the corresponding device
* index for the processor handle cannot be found.
*/
amdsmi_status_t smi_amdgpu_get_device_index(amdsmi_processor_handle processor_handle,
uint32_t* device_index);
/**
* @brief Get total number of devices
*
* @details Given a pointer to a uint32_t @p total_num_devices will be returned
*
* @param[inout] total_num_devices a pointer to uint32_t to which the total number
* of devices will be stored
*
* @retval ::AMDSMI_STATUS_SUCCESS is returned upon successful call.
* ::AMDSMI_STATUS_INVAL is returned if user provides a null pointer
* for total_num_devices.
*/
amdsmi_status_t smi_amdgpu_get_device_count(uint32_t *total_num_devices);
/**
* @brief Get the processor handle given the device index.
*
* @details Given a uint32_t @p device_index and a pointer to
* a processor handle @p processor_handle, the device index will be used to
* find the processor handle of the device and store it in the provided pointer
*
* @param[in] device_index a uint32_t to value to help find the corresponding
* processor handle
*
* @param[inout] processor_handle a pointer to amdsmi_processor_handle
* which the corresponding processor_handle will be stored
*
* @retval ::AMDSMI_STATUS_SUCCESS is returned upon successful call.
* ::AMDSMI_STATUS_INVAL is returned if user provides a null pointer
* for processor_handle.
* ::AMDSMI_STATUS_API_FAILED is returned if the device_index is cannot
* be found.
*/
amdsmi_status_t smi_amdgpu_get_processor_handle_by_index(
uint32_t device_index,
amdsmi_processor_handle *processor_handle);
template<typename>
constexpr bool is_dependent_false_v = false;
@@ -72,8 +129,7 @@ constexpr T get_std_num_limit()
{
if constexpr (is_supported_type_v<T>) {
return std::numeric_limits<T>::max();
}
else {
} else {
return std::numeric_limits<T>::min();
static_assert(is_dependent_false_v<T>, "Error: Type not supported...");
}
@@ -98,12 +154,11 @@ constexpr T translate_umax_or_assign_value(U source_value, V target_value)
}
return result;
}
else {
} else {
static_assert(is_dependent_false_v<T>, "Error: Type not supported...");
}
return result;
}
#endif //
#endif // AMD_SMI_INCLUDE_AMD_SMI_UTILS_H_