diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.cpp b/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.cpp index eb579027db8..bac00369ae2 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.cpp @@ -188,7 +188,7 @@ namespace xdp { aie::profile::configGroupEvents(&aieDevInst, loc, mod, type, metricSet, startEvent, channel0); if (aie::profile::isStreamSwitchPortEvent(startEvent)) - configStreamSwitchPorts(tileMetric.first, loc, type, metricSet, channel0); + configStreamSwitchPorts(tileMetric.first, loc, type, metricSet, channel0, startEvent); // Convert enums to physical event IDs for reporting purposes uint8_t tmpStart; @@ -257,10 +257,11 @@ namespace xdp { // NOTE: Used to monitor streams: trace, interfaces, and MEM tiles void AieProfile_WinImpl::configStreamSwitchPorts(const tile_type& tile, const XAie_LocType& loc, - const module_type& type, const std::string& metricSet, const uint8_t channel) + const module_type& type, const std::string& metricSet, const uint8_t channel, const XAie_Events startEvent) { // Hardcoded uint8_t rscId = 0; + uint8_t portnum = aie::profile::getPortNumberFromEvent(startEvent); // AIE Tiles (e.g., trace streams) if (type == module_type::core) { auto slaveOrMaster = (metricSet.find("mm2s") != std::string::npos) ? @@ -278,7 +279,10 @@ namespace xdp { // Grab slave/master and stream ID // NOTE: stored in getTilesForProfiling() above auto slaveOrMaster = (tile.is_master == 0) ? XAIE_STRMSW_SLAVE : XAIE_STRMSW_MASTER; - auto streamPortId = tile.stream_id; + uint8_t streamPortId = (portnum >= tile.stream_ids.size()) ? + 0 : static_cast(tile.stream_ids.at(portnum)); + + // auto streamPortId = tile.stream_id; // Define stream switch port to monitor interface XAie_EventSelectStrmPort(&aieDevInst, loc, rscId, slaveOrMaster, SOUTH, streamPortId); std::stringstream msg; diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.h b/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.h index 587f012f2c4..7e884e78491 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.h +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/client/aie_profile.h @@ -44,7 +44,7 @@ namespace xdp { void configStreamSwitchPorts( const tile_type& tile, const XAie_LocType& loc, const module_type& type, const std::string& metricSet, - const uint8_t channel + const uint8_t channel, const XAie_Events startEvent ); private: const std::vector falModuleTypes = { diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.cpp b/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.cpp index fabd0395f02..e0bd7d5665d 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.cpp @@ -362,6 +362,65 @@ namespace xdp::aie::profile { return (tlastEvents.find(event) != tlastEvents.end()); } + + uint8_t getPortNumberFromEvent(const XAie_Events event) + { + switch (event) { + case XAIE_EVENT_PORT_RUNNING_7_CORE: + case XAIE_EVENT_PORT_STALLED_7_CORE: + case XAIE_EVENT_PORT_IDLE_7_CORE: + case XAIE_EVENT_PORT_RUNNING_7_PL: + case XAIE_EVENT_PORT_STALLED_7_PL: + case XAIE_EVENT_PORT_IDLE_7_PL: + return 7; + case XAIE_EVENT_PORT_RUNNING_6_CORE: + case XAIE_EVENT_PORT_STALLED_6_CORE: + case XAIE_EVENT_PORT_IDLE_6_CORE: + case XAIE_EVENT_PORT_RUNNING_6_PL: + case XAIE_EVENT_PORT_STALLED_6_PL: + case XAIE_EVENT_PORT_IDLE_6_PL: + return 6; + case XAIE_EVENT_PORT_RUNNING_5_CORE: + case XAIE_EVENT_PORT_STALLED_5_CORE: + case XAIE_EVENT_PORT_IDLE_5_CORE: + case XAIE_EVENT_PORT_RUNNING_5_PL: + case XAIE_EVENT_PORT_STALLED_5_PL: + case XAIE_EVENT_PORT_IDLE_5_PL: + return 5; + case XAIE_EVENT_PORT_RUNNING_4_CORE: + case XAIE_EVENT_PORT_STALLED_4_CORE: + case XAIE_EVENT_PORT_IDLE_4_CORE: + case XAIE_EVENT_PORT_RUNNING_4_PL: + case XAIE_EVENT_PORT_STALLED_4_PL: + case XAIE_EVENT_PORT_IDLE_4_PL: + return 4; + case XAIE_EVENT_PORT_RUNNING_3_CORE: + case XAIE_EVENT_PORT_STALLED_3_CORE: + case XAIE_EVENT_PORT_IDLE_3_CORE: + case XAIE_EVENT_PORT_RUNNING_3_PL: + case XAIE_EVENT_PORT_STALLED_3_PL: + case XAIE_EVENT_PORT_IDLE_3_PL: + return 3; + case XAIE_EVENT_PORT_RUNNING_2_CORE: + case XAIE_EVENT_PORT_STALLED_2_CORE: + case XAIE_EVENT_PORT_IDLE_2_CORE: + case XAIE_EVENT_PORT_RUNNING_2_PL: + case XAIE_EVENT_PORT_STALLED_2_PL: + case XAIE_EVENT_PORT_IDLE_2_PL: + return 2; + case XAIE_EVENT_PORT_RUNNING_1_CORE: + case XAIE_EVENT_PORT_STALLED_1_CORE: + case XAIE_EVENT_PORT_IDLE_1_CORE: + case XAIE_EVENT_PORT_RUNNING_1_PL: + case XAIE_EVENT_PORT_STALLED_1_PL: + case XAIE_EVENT_PORT_IDLE_1_PL: + return 1; + default: + return 0; + } + } + + /**************************************************************************** * Get XAie module enum at the module index ***************************************************************************/ diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.h b/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.h index 4e8b719a96e..6d64dcad37c 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.h +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/util/aie_profile_util.h @@ -134,6 +134,8 @@ namespace xdp::aie::profile { */ bool isPortTlastEvent(const XAie_Events event); + uint8_t getPortNumberFromEvent(const XAie_Events event); + /** * @brief Get XAie module enum at the module index * @param moduleIndex module index