diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 4934ecfb79..6a7861ed7c 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -12,7 +12,8 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr ### Changed -- N/A +- **Removed `amdsmi_io_link_type_t` and replaced with amdsmi_link_type_t**. + - The IO Link type is no longer needed as the link type is sufficient. ### Removed diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index ca5596a22c..1a3538ef1a 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -3516,11 +3516,11 @@ class AMDSMICommands(): if src_gpu != dest_gpu: link_type = amdsmi_interface.amdsmi_topo_get_link_type(src_gpu, dest_gpu)['type'] if isinstance(link_type, int): - if link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_UNDEFINED: + if link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_INTERNAL: link_type = "UNKNOWN" - elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_PCIEXPRESS: + elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_PCIE: link_type = "PCIE" - elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_XGMI: + elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_XGMI: link_type = "XGMI" else: link_type = "N/A" @@ -3758,11 +3758,11 @@ class AMDSMICommands(): try: link_type = amdsmi_interface.amdsmi_topo_get_link_type(src_gpu, dest_gpu)['type'] if isinstance(link_type, int): - if link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_UNDEFINED: + if link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_INTERNAL: src_gpu_link_type[dest_gpu_key] = "UNKNOWN" - elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_PCIEXPRESS: + elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_PCIE: src_gpu_link_type[dest_gpu_key] = "PCIE" - elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_XGMI: + elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_XGMI: src_gpu_link_type[dest_gpu_key] = "XGMI" except amdsmi_exception.AmdSmiLibraryException as e: src_gpu_link_type[dest_gpu_key] = "N/A" @@ -5903,11 +5903,11 @@ class AMDSMICommands(): try: link_type = amdsmi_interface.amdsmi_topo_get_link_type(src_gpu, dest_gpu)['type'] if xgmi_dict['link_metrics']['link_type'] != "XGMI" and isinstance(link_type, int): - if link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_UNDEFINED: + if link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_INTERNAL: xgmi_dict['link_metrics']['link_type'] = "UNKNOWN" - elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_PCIEXPRESS: + elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_PCIE: xgmi_dict['link_metrics']['link_type'] = "PCIE" - elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_XGMI: + elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_LINK_TYPE_XGMI: xgmi_dict['link_metrics']['link_type'] = "XGMI" except amdsmi_exception.AmdSmiLibraryException as e: logging.debug("Failed to get link type for %s to %s | %s", diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 9123f74afd..829fd1cc5f 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -1523,19 +1523,6 @@ typedef enum { AMDSMI_MEM_PAGE_STATUS_UNRESERVABLE //!< Unable to reserve this page } amdsmi_memory_page_status_t; -/** - * @brief Types for IO Link - * - * @cond @tag{gpu_bm_linux} @endcond - */ -typedef enum { - AMDSMI_IOLINK_TYPE_UNDEFINED = 0, //!< unknown type. - AMDSMI_IOLINK_TYPE_PCIEXPRESS = 1, //!< PCI Express - AMDSMI_IOLINK_TYPE_XGMI = 2, //!< XGMI - AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES, //!< Number of IO Link types - AMDSMI_IOLINK_TYPE_SIZE = 0xFFFFFFFF //!< Max of IO Link types -} amdsmi_io_link_type_t; - /** * @brief The utilization counter type * @@ -5495,7 +5482,7 @@ amdsmi_get_minmax_bandwidth_between_processors(amdsmi_processor_handle processor * * @details Given a source processor handle @p processor_handle_src and * a destination processor handle @p processor_handle_dst, and a pointer to an - * uint64_t @p hops and a pointer to an AMDSMI_IO_LINK_TYPE @p type, + * uint64_t @p hops and a pointer to an AMDSMI_INK_TYPE @p type, * this function will write the number of hops and the connection type * between the device @p processor_handle_src and @p processor_handle_dst to the memory * pointed to by @p hops and @p type. @@ -5507,7 +5494,7 @@ amdsmi_get_minmax_bandwidth_between_processors(amdsmi_processor_handle processor * @param[in,out] hops A pointer to an uint64_t to which the * hops for the connection should be written. * - * @param[in,out] type A pointer to an ::AMDSMI_IO_LINK_TYPE to which the + * @param[in,out] type A pointer to an ::AMDSMI_LINK_TYPE to which the * type for the connection should be written. * * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail @@ -5515,7 +5502,7 @@ amdsmi_get_minmax_bandwidth_between_processors(amdsmi_processor_handle processor amdsmi_status_t amdsmi_topo_get_link_type(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, - uint64_t *hops, amdsmi_io_link_type_t *type); + uint64_t *hops, amdsmi_link_type_t *type); /** * @brief Retrieve the set of GPUs that are nearest to a given device @@ -5581,7 +5568,7 @@ amdsmi_is_P2P_accessible(amdsmi_processor_handle processor_handle_src, * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf} * * @details Given a source processor handle @p processor_handle_src and - * a destination processor handle @p processor_handle_dst, a pointer to an amdsmi_io_link_type_t @p type, + * a destination processor handle @p processor_handle_dst, a pointer to an amdsmi_link_type_t @p type, * and a pointer to amdsmi_p2p_capability_t @p cap. This function will write the connection type, * and io link capabilities between the device * @p processor_handle_src and @p processor_handle_dst to the memory @@ -5591,7 +5578,7 @@ amdsmi_is_P2P_accessible(amdsmi_processor_handle processor_handle_src, * * @param[in] processor_handle_dst the destination processor handle * - * @param[in,out] type A pointer to an ::amdsmi_io_link_type_t to which the + * @param[in,out] type A pointer to an ::amdsmi_link_type_t to which the * type for the connection should be written. * * @param[in,out] cap A pointer to an ::amdsmi_p2p_capability_t to which the @@ -5602,7 +5589,7 @@ amdsmi_is_P2P_accessible(amdsmi_processor_handle processor_handle_src, amdsmi_status_t amdsmi_topo_get_p2p_status(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, - amdsmi_io_link_type_t *type, amdsmi_p2p_capability_t *cap); + amdsmi_link_type_t *type, amdsmi_p2p_capability_t *cap); /** @} End tagHWTopology */ @@ -7132,3 +7119,4 @@ amdsmi_status_t amdsmi_get_cpu_socket_count(uint32_t *sock_count); #endif // __cplusplus #endif // __AMDSMI_H__ + diff --git a/projects/amdsmi/py-interface/__init__.py b/projects/amdsmi/py-interface/__init__.py index 85e5afd6b8..95a898213b 100644 --- a/projects/amdsmi/py-interface/__init__.py +++ b/projects/amdsmi/py-interface/__init__.py @@ -276,7 +276,6 @@ from .amdsmi_interface import AmdSmiMemoryType from .amdsmi_interface import AmdSmiFreqInd from .amdsmi_interface import AmdSmiXgmiStatus from .amdsmi_interface import AmdSmiMemoryPageStatus -from .amdsmi_interface import AmdSmiIoLinkType from .amdsmi_interface import AmdSmiLinkType from .amdsmi_interface import AmdSmiUtilizationCounterType from .amdsmi_interface import AmdSmiProcessorType diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 12c39e7da0..db7375ad5b 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -438,14 +438,6 @@ class AmdSmiMemoryPageStatus(IntEnum): UNRESERVABLE = amdsmi_wrapper.AMDSMI_MEM_PAGE_STATUS_UNRESERVABLE -class AmdSmiIoLinkType(IntEnum): - UNDEFINED = amdsmi_wrapper.AMDSMI_IOLINK_TYPE_UNDEFINED - PCIEXPRESS = amdsmi_wrapper.AMDSMI_IOLINK_TYPE_PCIEXPRESS - XGMI = amdsmi_wrapper.AMDSMI_IOLINK_TYPE_XGMI - NUMIOLINKTYPES = amdsmi_wrapper.AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES - SIZE = amdsmi_wrapper.AMDSMI_IOLINK_TYPE_SIZE - - class AmdSmiLinkType(IntEnum): AMDSMI_LINK_TYPE_INTERNAL = amdsmi_wrapper.AMDSMI_LINK_TYPE_INTERNAL AMDSMI_LINK_TYPE_XGMI = amdsmi_wrapper.AMDSMI_LINK_TYPE_XGMI diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 5e449bd0de..a71a0ae290 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -845,6 +845,21 @@ amdsmi_card_form_factor_t = ctypes.c_uint32 # enum class struct_amdsmi_pcie_info_t(Structure): pass +class struct_pcie_static_(Structure): + pass + +struct_pcie_static_._pack_ = 1 # source:False +struct_pcie_static_._fields_ = [ + ('max_pcie_width', ctypes.c_uint16), + ('PADDING_0', ctypes.c_ubyte * 2), + ('max_pcie_speed', ctypes.c_uint32), + ('pcie_interface_version', ctypes.c_uint32), + ('slot_type', amdsmi_card_form_factor_t), + ('max_pcie_interface_version', ctypes.c_uint32), + ('PADDING_1', ctypes.c_ubyte * 4), + ('reserved', ctypes.c_uint64 * 9), +] + class struct_pcie_metric_(Structure): pass @@ -865,21 +880,6 @@ struct_pcie_metric_._fields_ = [ ('reserved', ctypes.c_uint64 * 12), ] -class struct_pcie_static_(Structure): - pass - -struct_pcie_static_._pack_ = 1 # source:False -struct_pcie_static_._fields_ = [ - ('max_pcie_width', ctypes.c_uint16), - ('PADDING_0', ctypes.c_ubyte * 2), - ('max_pcie_speed', ctypes.c_uint32), - ('pcie_interface_version', ctypes.c_uint32), - ('slot_type', amdsmi_card_form_factor_t), - ('max_pcie_interface_version', ctypes.c_uint32), - ('PADDING_1', ctypes.c_ubyte * 4), - ('reserved', ctypes.c_uint64 * 9), -] - struct_amdsmi_pcie_info_t._pack_ = 1 # source:False struct_amdsmi_pcie_info_t._fields_ = [ ('pcie_static', struct_pcie_static_), @@ -1725,21 +1725,6 @@ AMDSMI_MEM_PAGE_STATUS_PENDING = 1 AMDSMI_MEM_PAGE_STATUS_UNRESERVABLE = 2 amdsmi_memory_page_status_t = ctypes.c_uint32 # enum -# values for enumeration 'amdsmi_io_link_type_t' -amdsmi_io_link_type_t__enumvalues = { - 0: 'AMDSMI_IOLINK_TYPE_UNDEFINED', - 1: 'AMDSMI_IOLINK_TYPE_PCIEXPRESS', - 2: 'AMDSMI_IOLINK_TYPE_XGMI', - 3: 'AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES', - 4294967295: 'AMDSMI_IOLINK_TYPE_SIZE', -} -AMDSMI_IOLINK_TYPE_UNDEFINED = 0 -AMDSMI_IOLINK_TYPE_PCIEXPRESS = 1 -AMDSMI_IOLINK_TYPE_XGMI = 2 -AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES = 3 -AMDSMI_IOLINK_TYPE_SIZE = 4294967295 -amdsmi_io_link_type_t = ctypes.c_uint32 # enum - # values for enumeration 'amdsmi_utilization_counter_type_t' amdsmi_utilization_counter_type_t__enumvalues = { 0: 'AMDSMI_UTILIZATION_COUNTER_FIRST', @@ -2732,7 +2717,7 @@ amdsmi_get_minmax_bandwidth_between_processors.restype = amdsmi_status_t amdsmi_get_minmax_bandwidth_between_processors.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)] amdsmi_topo_get_link_type = _libraries['libamd_smi.so'].amdsmi_topo_get_link_type amdsmi_topo_get_link_type.restype = amdsmi_status_t -amdsmi_topo_get_link_type.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(amdsmi_io_link_type_t)] +amdsmi_topo_get_link_type.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(amdsmi_link_type_t)] amdsmi_get_link_topology_nearest = _libraries['libamd_smi.so'].amdsmi_get_link_topology_nearest amdsmi_get_link_topology_nearest.restype = amdsmi_status_t amdsmi_get_link_topology_nearest.argtypes = [amdsmi_processor_handle, amdsmi_link_type_t, ctypes.POINTER(struct_amdsmi_topology_nearest_t)] @@ -2741,7 +2726,7 @@ amdsmi_is_P2P_accessible.restype = amdsmi_status_t amdsmi_is_P2P_accessible.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_bool)] amdsmi_topo_get_p2p_status = _libraries['libamd_smi.so'].amdsmi_topo_get_p2p_status amdsmi_topo_get_p2p_status.restype = amdsmi_status_t -amdsmi_topo_get_p2p_status.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(amdsmi_io_link_type_t), ctypes.POINTER(struct_amdsmi_p2p_capability_t)] +amdsmi_topo_get_p2p_status.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(amdsmi_link_type_t), ctypes.POINTER(struct_amdsmi_p2p_capability_t)] amdsmi_get_gpu_compute_partition = _libraries['libamd_smi.so'].amdsmi_get_gpu_compute_partition amdsmi_get_gpu_compute_partition.restype = amdsmi_status_t amdsmi_get_gpu_compute_partition.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_char), uint32_t] @@ -3081,14 +3066,12 @@ __all__ = \ 'AMDSMI_GPU_BLOCK_XGMI_WAFL', 'AMDSMI_INIT_ALL_PROCESSORS', 'AMDSMI_INIT_AMD_APUS', 'AMDSMI_INIT_AMD_CPUS', 'AMDSMI_INIT_AMD_GPUS', 'AMDSMI_INIT_NON_AMD_CPUS', - 'AMDSMI_INIT_NON_AMD_GPUS', 'AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES', - 'AMDSMI_IOLINK_TYPE_PCIEXPRESS', 'AMDSMI_IOLINK_TYPE_SIZE', - 'AMDSMI_IOLINK_TYPE_UNDEFINED', 'AMDSMI_IOLINK_TYPE_XGMI', - 'AMDSMI_LINK_TYPE_INTERNAL', 'AMDSMI_LINK_TYPE_NOT_APPLICABLE', - 'AMDSMI_LINK_TYPE_PCIE', 'AMDSMI_LINK_TYPE_UNKNOWN', - 'AMDSMI_LINK_TYPE_XGMI', 'AMDSMI_MEMORY_PARTITION_NPS1', - 'AMDSMI_MEMORY_PARTITION_NPS2', 'AMDSMI_MEMORY_PARTITION_NPS4', - 'AMDSMI_MEMORY_PARTITION_NPS8', 'AMDSMI_MEMORY_PARTITION_UNKNOWN', + 'AMDSMI_INIT_NON_AMD_GPUS', 'AMDSMI_LINK_TYPE_INTERNAL', + 'AMDSMI_LINK_TYPE_NOT_APPLICABLE', 'AMDSMI_LINK_TYPE_PCIE', + 'AMDSMI_LINK_TYPE_UNKNOWN', 'AMDSMI_LINK_TYPE_XGMI', + 'AMDSMI_MEMORY_PARTITION_NPS1', 'AMDSMI_MEMORY_PARTITION_NPS2', + 'AMDSMI_MEMORY_PARTITION_NPS4', 'AMDSMI_MEMORY_PARTITION_NPS8', + 'AMDSMI_MEMORY_PARTITION_UNKNOWN', 'AMDSMI_MEM_PAGE_STATUS_PENDING', 'AMDSMI_MEM_PAGE_STATUS_RESERVED', 'AMDSMI_MEM_PAGE_STATUS_UNRESERVABLE', 'AMDSMI_MEM_TYPE_FIRST', @@ -3303,8 +3286,7 @@ __all__ = \ 'amdsmi_hsmp_driver_version_t', 'amdsmi_hsmp_freqlimit_src_names', 'amdsmi_hsmp_metrics_table_t', 'amdsmi_init', 'amdsmi_init_flags_t', 'amdsmi_init_gpu_event_notification', - 'amdsmi_io_bw_encoding_t', 'amdsmi_io_link_type_t', - 'amdsmi_is_P2P_accessible', + 'amdsmi_io_bw_encoding_t', 'amdsmi_is_P2P_accessible', 'amdsmi_is_gpu_power_management_enabled', 'amdsmi_kfd_info_t', 'amdsmi_link_id_bw_type_t', 'amdsmi_link_metrics_t', 'amdsmi_link_type_t', 'amdsmi_memory_page_status_t', diff --git a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h index 672577ea94..e73a2d3ec0 100644 --- a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h @@ -4608,7 +4608,7 @@ rsmi_is_P2P_accessible(uint32_t dv_ind_src, uint32_t dv_ind_dst, * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf} * * @details Given a source processor handle @p processor_handle_src and - * a destination processor handle @p processor_handle_dst, a pointer to an amdsmi_io_link_type_t @p type, + * a destination processor handle @p processor_handle_dst, a pointer to an amdsmi_link_type_t @p type, * and a pointer to rsmi_p2p_capability_t @p cap. This function will write the connection type, * and io link capabilities between the device * @p processor_handle_src and @p processor_handle_dst to the memory diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index c25ac0c428..1b618a8217 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -2034,9 +2034,18 @@ amdsmi_status_t amdsmi_get_link_metrics(amdsmi_processor_handle processor_handle return AMDSMI_STATUS_SUCCESS; } +static void translated_link_type(amdsmi_link_type_t *type) { + // Convert type to match rocm-smi or amd-smi + if (*type == AMDSMI_LINK_TYPE_PCIE) + *type = AMDSMI_LINK_TYPE_XGMI; + else if (*type == AMDSMI_LINK_TYPE_XGMI) + *type = AMDSMI_LINK_TYPE_PCIE; + return; +} + amdsmi_status_t amdsmi_topo_get_link_type(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, - uint64_t *hops, amdsmi_io_link_type_t *type) { + uint64_t *hops, amdsmi_link_type_t *type) { AMDSMI_CHECK_INIT(); amd::smi::AMDSmiGPUDevice* src_device = nullptr; @@ -2047,8 +2056,12 @@ amdsmi_topo_get_link_type(amdsmi_processor_handle processor_handle_src, amdsmi_p r = get_gpu_device_from_handle(processor_handle_dst, &dst_device); if (r != AMDSMI_STATUS_SUCCESS) return r; + // Convert type to match rocm-smi + translated_link_type(type); auto rstatus = rsmi_topo_get_link_type(src_device->get_gpu_id(), dst_device->get_gpu_id(), hops, reinterpret_cast(type)); + // Convert type to match amd-smi + translated_link_type(type); return amd::smi::rsmi_to_amdsmi_status(rstatus); } @@ -2074,7 +2087,7 @@ amdsmi_is_P2P_accessible(amdsmi_processor_handle processor_handle_src, amdsmi_status_t amdsmi_topo_get_p2p_status(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, - amdsmi_io_link_type_t *type, amdsmi_p2p_capability_t *cap) { + amdsmi_link_type_t *type, amdsmi_p2p_capability_t *cap) { AMDSMI_CHECK_INIT(); amd::smi::AMDSmiGPUDevice* src_device = nullptr; @@ -2085,9 +2098,13 @@ amdsmi_topo_get_p2p_status(amdsmi_processor_handle processor_handle_src, r = get_gpu_device_from_handle(processor_handle_dst, &dst_device); if (r != AMDSMI_STATUS_SUCCESS) return r; + // Convert type to match rocm-smi + translated_link_type(type); auto rstatus = rsmi_topo_get_p2p_status(src_device->get_gpu_id(), dst_device->get_gpu_id(), reinterpret_cast(type), reinterpret_cast(cap)); + // Convert type to match amd-smi + translated_link_type(type); return amd::smi::rsmi_to_amdsmi_status(rstatus); } @@ -4436,38 +4453,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle, auto status(amdsmi_status_t::AMDSMI_STATUS_SUCCESS); - /* - * Note: This will need to be eventually consolidated within a unique link type. - */ - static const std::map kLinkToIoLinkTypeTranslationTable = - { - {amdsmi_link_type_t::AMDSMI_LINK_TYPE_INTERNAL, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED}, - {amdsmi_link_type_t::AMDSMI_LINK_TYPE_XGMI, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_XGMI}, - {amdsmi_link_type_t::AMDSMI_LINK_TYPE_PCIE, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_PCIEXPRESS}, - {amdsmi_link_type_t::AMDSMI_LINK_TYPE_NOT_APPLICABLE, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED}, - {amdsmi_link_type_t::AMDSMI_LINK_TYPE_UNKNOWN, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED} - }; - - auto translated_link_type = [&](amdsmi_link_type_t link_type) { - auto io_link_type(amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED); - if (kLinkToIoLinkTypeTranslationTable.find(link_type) != kLinkToIoLinkTypeTranslationTable.end()) { - io_link_type = kLinkToIoLinkTypeTranslationTable.at(link_type); - } - return io_link_type; - }; - - auto translated_io_link_type = [&](amdsmi_io_link_type_t io_link_type) { - auto link_type(amdsmi_link_type_t::AMDSMI_LINK_TYPE_UNKNOWN); - for (const auto& [key, value] : kLinkToIoLinkTypeTranslationTable) { - if (value == io_link_type) { - link_type = key; - break; - } - } - return link_type; - }; - // - struct LinkTopolyInfo_t { amdsmi_processor_handle target_processor_handle; @@ -4531,10 +4516,10 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle, } // Link type matches what we are searching for? - auto io_link_type = translated_link_type(link_type); + auto link_type_new = link_type; auto num_hops = uint64_t(0); - if (auto api_status = amdsmi_topo_get_link_type(processor_handle, device_list[device_idx], &num_hops, &io_link_type); - (api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) || (translated_io_link_type(io_link_type) != link_type)) { + if (auto api_status = amdsmi_topo_get_link_type(processor_handle, device_list[device_idx], &num_hops, &link_type_new); + (api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) || (link_type_new != link_type)) { continue; } @@ -4548,7 +4533,7 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle, // Topology nearest info LinkTopolyInfo_t link_info = { .target_processor_handle = device_list[device_idx], - .link_type = translated_io_link_type(io_link_type), + .link_type = link_type, .is_accessible = is_accessible, .num_hops = num_hops, .link_weight = link_weight diff --git a/projects/amdsmi/tests/amd_smi_test/functional/hw_topology_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/hw_topology_read.cc index 390dbec0ce..56888798a5 100644 --- a/projects/amdsmi/tests/amd_smi_test/functional/hw_topology_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/hw_topology_read.cc @@ -118,7 +118,7 @@ void TestHWTopologyRead::Run(void) { gpu_links[dv_ind_src][dv_ind_dst].cap = {UINT8_MAX, UINT8_MAX, UINT8_MAX, UINT8_MAX, UINT8_MAX}; } else { - amdsmi_io_link_type_t type; + amdsmi_link_type_t type; err = amdsmi_topo_get_link_type(processor_handles_[dv_ind_src], processor_handles_[dv_ind_dst], &gpu_links[dv_ind_src][dv_ind_dst].hops, &type); @@ -135,19 +135,18 @@ void TestHWTopologyRead::Run(void) { } } else { switch (type) { - case AMDSMI_IOLINK_TYPE_PCIEXPRESS: + case AMDSMI_LINK_TYPE_PCIE: gpu_links[dv_ind_src][dv_ind_dst].type = "PCIE"; break; - case AMDSMI_IOLINK_TYPE_XGMI: + case AMDSMI_LINK_TYPE_XGMI: gpu_links[dv_ind_src][dv_ind_dst].type = "XGMI"; break; default: gpu_links[dv_ind_src][dv_ind_dst].type = "XXXX"; IF_VERB(STANDARD) { - std::cout << "\t**Invalid IO LINK type. type=" << type << - std::endl; + std::cout << "\t**Invalid LINK type. type=" << type << std::endl; } } } @@ -167,15 +166,14 @@ void TestHWTopologyRead::Run(void) { } } else { switch (type) { - case AMDSMI_IOLINK_TYPE_PCIEXPRESS: - case AMDSMI_IOLINK_TYPE_XGMI: + case AMDSMI_LINK_TYPE_PCIE: + case AMDSMI_LINK_TYPE_XGMI: // Do nothing, the type is printed by the previous test for amdsmi_topo_get_link_type break; default: gpu_links[dv_ind_src][dv_ind_dst].type = "XXXX"; IF_VERB(STANDARD) { - std::cout << "\t**Invalid IO LINK type. type=" << type << - std::endl; + std::cout << "\t**Invalid LINK type. type=" << type << std::endl; } } }