From f8c78ec23df38b21d159a26fcbd8a10cf7f9d60f Mon Sep 17 00:00:00 2001 From: parthash0804 Date: Fri, 20 Dec 2024 18:15:03 +0530 Subject: [PATCH 1/5] Broadcast Network and timer sync changes Signed-off-by: parthash0804 --- .../database/static_info/aie_constructs.h | 1 + .../profile/database/static_info/aie_util.cpp | 9 +- .../filetypes/aie_control_config_filetype.cpp | 2 + .../profile/plugin/aie_trace/CMakeLists.txt | 9 +- .../util/aie_trace_common_config.cpp | 197 ++++++++++++++++++ .../aie_trace/util/aie_trace_common_config.h | 20 ++ .../plugin/aie_trace/ve2/aie_trace.cpp | 40 ++++ .../profile/plugin/aie_trace/ve2/aie_trace.h | 1 + 8 files changed, 274 insertions(+), 5 deletions(-) create mode 100755 src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp create mode 100755 src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_constructs.h b/src/runtime_src/xdp/profile/database/static_info/aie_constructs.h index 941d0349e80..9228d32e8a9 100644 --- a/src/runtime_src/xdp/profile/database/static_info/aie_constructs.h +++ b/src/runtime_src/xdp/profile/database/static_info/aie_constructs.h @@ -31,6 +31,7 @@ namespace xdp::aie { bool broadcast_enable_core; bool graph_iterator_event; std::string event_trace; + bool enable_multi_layer; }; struct driver_config diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp index 2cc0808b13a..0be0dcfc0e0 100755 --- a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp +++ b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp @@ -407,9 +407,12 @@ namespace xdp::aie { { boost::property_tree::ptree infoPt; try { - xrt::hw_context context = xrt_core::hw_context_int::create_hw_context_from_implementation(hwCtxImpl); - auto device = xrt_core::hw_context_int::get_core_device(context); - + #ifdef XDP_CLIENT_BUILD + xrt::hw_context context = xrt_core::hw_context_int::create_hw_context_from_implementation(hwCtxImpl); + auto device = xrt_core::hw_context_int::get_core_device(context); + #else + auto device = xrt_core::get_userpf_device(hwCtxImpl); + #endif auto info = xrt_core::device_query_default(device.get(), {}); for(const auto& e : info) { boost::property_tree::ptree pt; diff --git a/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp b/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp index 2cde02b0a10..52b5b5513d1 100644 --- a/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp +++ b/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp @@ -66,6 +66,8 @@ AIEControlConfigFiletype::getAIECompilerOptions() const aie_meta.get("aie_metadata.aiecompiler_options.graph_iterator_event", false); aiecompiler_options.event_trace = aie_meta.get("aie_metadata.aiecompiler_options.event_trace", "runtime"); + aiecompiler_options.enable_multi_layer = + aie_meta.get("aie_metadata.aiecompiler_options.enable_multi_layer", false); return aiecompiler_options; } diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt b/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt index af0f9c5aeed..e53fdfd8c73 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt @@ -42,13 +42,18 @@ file(GLOB AIE_TRACE_UTIL_FILES "${PROFILE_DIR}/plugin/aie_trace/util/*.cpp" ) +file(GLOB AIE_TRACE_COMMON_UTIL_FILES + "${PROFILE_DIR}/plugin/aie_trace/util/aie_trace_common_config.h" + "${PROFILE_DIR}/plugin/aie_trace/util/aie_trace_common_config.cpp" +) + file(GLOB AIE_DRIVER_COMMON_UTIL_FILES "${PROFILE_DIR}/device/common/*.h" "${PROFILE_DIR}/device/common/*.cpp" ) if(XDP_VE2_BUILD_CMAKE STREQUAL "yes") - add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_TRACE_UTIL_FILES}) + add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_TRACE_UTIL_FILES} ${AIE_TRACE_COMMON_UTIL_FILES}) add_dependencies(xdp_aie_trace_plugin xdp_core xrt_coreutil) target_link_libraries(xdp_aie_trace_plugin PRIVATE xdp_core xrt_coreutil xaiengine) @@ -62,7 +67,7 @@ if(XDP_VE2_BUILD_CMAKE STREQUAL "yes") elseif (XDP_CLIENT_BUILD_CMAKE STREQUAL "yes") - add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_DRIVER_COMMON_UTIL_FILES}) + add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_DRIVER_COMMON_UTIL_FILES} ${AIE_TRACE_COMMON_UTIL_FILES}) add_dependencies(xdp_aie_trace_plugin xdp_core xrt_coreutil) target_link_libraries(xdp_aie_trace_plugin PRIVATE xdp_core xrt_coreutil xaiengine) target_compile_definitions(xdp_aie_trace_plugin PRIVATE XDP_CLIENT_BUILD=1 -DXAIE_FEATURE_MSVC) diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp new file mode 100755 index 00000000000..11a3eeb1252 --- /dev/null +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp @@ -0,0 +1,197 @@ +#include + +#include "xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h" +#include "xdp/profile/database/static_info/aie_constructs.h" + +namespace xdp::aie::trace { + + module_type getTileType(std::shared_ptr metadata, uint8_t absRow) + { + if (absRow == 0) + return module_type::shim; + if (absRow < metadata->getRowOffset()) + return module_type::mem_tile; + return module_type::core; + } + + void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols) { + // void *hwCtxImpl = metadata->getHandle(); + // boost::property_tree::ptree aiePartitionPt = xdp::aie::getAIEPartitionInfoClient(hwCtxImpl); + // Currently, assuming only one Hw Context is alive at a time + // uint8_t startCol = static_cast(aiePartitionPt.front().second.get("start_col")); + // uint8_t numCols = static_cast(aiePartitionPt.front().second.get("num_cols")); + + std::vector maxRowAtCol(startCol + numCols, 0); + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col; + auto row = tile.row; + maxRowAtCol[startCol + col] = std::max(maxRowAtCol[col], (uint8_t)row); + } + + XAie_Events bcastEvent2_PL = (XAie_Events) (XAIE_EVENT_BROADCAST_A_0_PL + broadcastId2); + XAie_EventBroadcast(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, broadcastId2, event); + + for(uint8_t col = startCol; col < startCol + numCols; col++) { + for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { + module_type tileType = getTileType(metadata, row); + auto loc = XAie_TileLoc(col, row); + + if(tileType == module_type::shim) { + // first channel is only used to send north + if(col == startCol) { + XAie_EventBroadcast(aieDevInst, loc, XAIE_PL_MOD, broadcastId1, event); + } + else { + XAie_EventBroadcast(aieDevInst, loc, XAIE_PL_MOD, broadcastId1, bcastEvent2_PL); + } + if(maxRowAtCol[col] != row) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); + } + + // second channel is only used to send east + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); + + if(col != startCol + numCols - 1) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH | XAIE_EVENT_BROADCAST_EAST); + } + } + else if(tileType == module_type::mem_tile) { + if(maxRowAtCol[col] != row) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); + } + } + else { //core tile + if(maxRowAtCol[col] != row) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); + } + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); + } + } + } + } + + void reset2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, uint8_t startCol, uint8_t numCols) { + std::vector maxRowAtCol(startCol + numCols, 0); + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col; + auto row = tile.row; + maxRowAtCol[startCol + col] = std::max(maxRowAtCol[col], (uint8_t)row); + } + + XAie_EventBroadcastReset(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, broadcastId2); + + for(uint8_t col = startCol; col < startCol + numCols; col++) { + for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { + module_type tileType = getTileType(metadata, row); + auto loc = XAie_TileLoc(col, row); + + if(tileType == module_type::shim) { + XAie_EventBroadcastReset(aieDevInst, loc, XAIE_PL_MOD, broadcastId1); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId2, XAIE_EVENT_BROADCAST_ALL); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_ALL); + } + else if(tileType == module_type::mem_tile) { + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + } + else { //core tile + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + } + } + } + } + + void timerSyncronization(XAie_DevInst* aieDevInst, xaiefal::XAieDev* aieDevice, std::shared_ptr metadata, uint8_t startCol, uint8_t numCols) + { + std::shared_ptr traceStartBroadcastCh1 = nullptr, traceStartBroadcastCh2 = nullptr; + std::vector vL; + traceStartBroadcastCh1 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); + traceStartBroadcastCh1->reserve(); + traceStartBroadcastCh2 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); + traceStartBroadcastCh2->reserve(); + + uint8_t broadcastId1 = traceStartBroadcastCh1->getBc(); + uint8_t broadcastId2 = traceStartBroadcastCh2->getBc(); + + //build broadcast network + aie::trace::build2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, traceStartBroadcastCh2->getBc(), XAIE_EVENT_USER_EVENT_0_PL, startCol, numCols); + + //set timer control register + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col + startCol; + auto row = tile.row; + auto type = aie::getModuleType(row, metadata->getRowOffset()); + auto loc = XAie_TileLoc(col, row); + + if(type == module_type::shim) { + XAie_Events resetEvent = (XAie_Events)(XAIE_EVENT_BROADCAST_A_0_PL + broadcastId2); + if(col == 0) + { + resetEvent = XAIE_EVENT_USER_EVENT_0_PL; + } + + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_PL_MOD, resetEvent, XAIE_RESETDISABLE); + } + else if(type == module_type::mem_tile) { + XAie_Events resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM_TILE + broadcastId1); + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + else { + XAie_Events resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_CORE + broadcastId1); + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_CORE_MOD, resetEvent, XAIE_RESETDISABLE); + resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM + broadcastId1); + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + } + + //Generate the event to trigger broadcast network to reset timer + XAie_EventGenerate(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, XAIE_EVENT_USER_EVENT_0_PL); + + //reset timer control register so that timer are not reset after this point + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col + startCol; + auto row = tile.row; + auto type = aie::getModuleType(row, metadata->getRowOffset()); + auto loc = XAie_TileLoc(col, row); + + if(type == module_type::shim) { + XAie_Events resetEvent = XAIE_EVENT_NONE_PL ; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_PL_MOD, resetEvent, XAIE_RESETDISABLE); + } + else if(type == module_type::mem_tile) { + XAie_Events resetEvent = XAIE_EVENT_NONE_MEM_TILE; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + else { + XAie_Events resetEvent = XAIE_EVENT_NONE_CORE; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_CORE_MOD, resetEvent, XAIE_RESETDISABLE); + resetEvent = XAIE_EVENT_NONE_MEM; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + } + + //reset broadcast network + reset2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, broadcastId2, startCol, numCols); + + //release the channels used for timer sync + traceStartBroadcastCh1->release(); + traceStartBroadcastCh2->release(); + } +} \ No newline at end of file diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h new file mode 100755 index 00000000000..e6c99877009 --- /dev/null +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h @@ -0,0 +1,20 @@ +#ifndef AIE_TRACE_COMMON_CONFIG_DOT_H +#define AIE_TRACE_COMMON_CONFIG_DOT_H + +#include +#include "xaiefal/xaiefal.hpp" +#include "xdp/profile/plugin/aie_trace/aie_trace_metadata.h" + +extern "C" { + #include + #include +} + +namespace xdp::aie::trace { + module_type getTileType(std::shared_ptr metadata, uint8_t absRow); + void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols); + void reset2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, uint8_t startCol, uint8_t numCols); + void timerSyncronization(XAie_DevInst* aieDevInst, xaiefal::XAieDev* aieDevice, std::shared_ptr metadata, uint8_t startCol, uint8_t numCols); +} + +#endif \ No newline at end of file diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp index a4f1ec0578e..69ef689d0da 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp @@ -291,6 +291,12 @@ namespace xdp { return false; } + // Get partition columns + boost::property_tree::ptree aiePartitionPt = xdp::aie::getAIEPartitionInfoClient(handle); + // Currently, assuming only one Hw Context is alive at a time + uint8_t startCol = static_cast(aiePartitionPt.front().second.get("start_col")); + uint8_t numCols = static_cast(aiePartitionPt.front().second.get("num_cols")); + // Get channel configurations (memory and interface tiles) auto configChannel0 = metadata->getConfigChannel0(); auto configChannel1 = metadata->getConfigChannel1(); @@ -306,6 +312,35 @@ namespace xdp { mNumTileTraceEvents[m][n] = 0; } + auto metadataReader = (VPDatabase::Instance()->getStaticInfo()).getAIEmetadataReader(); + if (!metadataReader) { + if (aie::isDebugVerbosity()) { + std::stringstream msg; + msg << "AIE metadata reader is null"; + xrt_core::message::send(severity_level::debug, "XRT", msg.str()); + } + } + + auto compilerOptions = metadataReader->getAIECompilerOptions(); + std::shared_ptr traceStartBroadcastCh1 = nullptr, traceStartBroadcastCh2 = nullptr; + if(compilerOptions.enable_multi_layer) { + + aie::trace::timerSyncronization(aieDevInst,aieDevice, metadata, startCol, numCols); + if(xrt_core::config::get_aie_trace_settings_trace_start_broadcast()) + { + std::vector vL; + traceStartBroadcastCh1 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); + traceStartBroadcastCh1->reserve(); + traceStartBroadcastCh2 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); + traceStartBroadcastCh2->reserve(); + aie::trace::build2ChannelBroadcastNetwork(aieDevInst, metadata, traceStartBroadcastCh1->getBc(), traceStartBroadcastCh2->getBc(), XAIE_EVENT_USER_EVENT_0_PL, startCol, numCols); + + coreTraceStartEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_CORE + traceStartBroadcastCh1->getBc()); + memoryTileTraceStartEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM_TILE + traceStartBroadcastCh1->getBc()); + interfaceTileTraceStartEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_A_0_PL + traceStartBroadcastCh2->getBc()); + } + } + // Using user event for trace end to enable flushing // NOTE: Flush trace module always at the end because for some applications // core might be running infinitely. @@ -661,6 +696,11 @@ namespace xdp { traceEndEvent = comboEvents.at(1); } + if(type == module_type::core && xrt_core::config::get_aie_trace_settings_trace_start_broadcast()) + { + traceStartEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM + traceStartBroadcastCh1->getBc()); + } + // Configure event ports on stream switch // NOTE: These are events from the core module stream switch // outputted on the memory module trace stream. diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h index 6a320ba6bec..af437c5ae94 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h @@ -22,6 +22,7 @@ #include "xaiefal/xaiefal.hpp" #include "xdp/profile/plugin/aie_trace/aie_trace_impl.h" #include "xdp/profile/plugin/aie_trace/util/aie_trace_config.h" +#include "xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h" namespace xdp { From 80b9ea5aa127f5824c76ed0f9670a02c72babe68 Mon Sep 17 00:00:00 2001 From: parthash0804 Date: Fri, 20 Dec 2024 18:26:32 +0530 Subject: [PATCH 2/5] Buf fix Signed-off-by: parthash0804 --- src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp index 69ef689d0da..258425eb016 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp @@ -696,7 +696,7 @@ namespace xdp { traceEndEvent = comboEvents.at(1); } - if(type == module_type::core && xrt_core::config::get_aie_trace_settings_trace_start_broadcast()) + if(compilerOptions.enable_multi_layer && type == module_type::core && xrt_core::config::get_aie_trace_settings_trace_start_broadcast()) { traceStartEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM + traceStartBroadcastCh1->getBc()); } From 99f7cf8cea25546aa5b0a375c3ec6dc5de9172e6 Mon Sep 17 00:00:00 2001 From: parthash0804 Date: Wed, 1 Jan 2025 23:13:04 +0530 Subject: [PATCH 3/5] clean up Signed-off-by: parthash0804 --- .../profile/plugin/aie_trace/CMakeLists.txt | 8 ++----- .../util/aie_trace_common_config.cpp | 22 ++++--------------- .../plugin/aie_trace/ve2/aie_trace.cpp | 2 +- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt b/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt index e53fdfd8c73..6b44b250c1d 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/CMakeLists.txt @@ -42,10 +42,6 @@ file(GLOB AIE_TRACE_UTIL_FILES "${PROFILE_DIR}/plugin/aie_trace/util/*.cpp" ) -file(GLOB AIE_TRACE_COMMON_UTIL_FILES - "${PROFILE_DIR}/plugin/aie_trace/util/aie_trace_common_config.h" - "${PROFILE_DIR}/plugin/aie_trace/util/aie_trace_common_config.cpp" -) file(GLOB AIE_DRIVER_COMMON_UTIL_FILES "${PROFILE_DIR}/device/common/*.h" @@ -53,7 +49,7 @@ file(GLOB AIE_DRIVER_COMMON_UTIL_FILES ) if(XDP_VE2_BUILD_CMAKE STREQUAL "yes") - add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_TRACE_UTIL_FILES} ${AIE_TRACE_COMMON_UTIL_FILES}) + add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_TRACE_UTIL_FILES}) add_dependencies(xdp_aie_trace_plugin xdp_core xrt_coreutil) target_link_libraries(xdp_aie_trace_plugin PRIVATE xdp_core xrt_coreutil xaiengine) @@ -67,7 +63,7 @@ if(XDP_VE2_BUILD_CMAKE STREQUAL "yes") elseif (XDP_CLIENT_BUILD_CMAKE STREQUAL "yes") - add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_DRIVER_COMMON_UTIL_FILES} ${AIE_TRACE_COMMON_UTIL_FILES}) + add_library(xdp_aie_trace_plugin MODULE ${AIE_TRACE_PLUGIN_FILES} ${AIE_DRIVER_COMMON_UTIL_FILES}) add_dependencies(xdp_aie_trace_plugin xdp_core xrt_coreutil) target_link_libraries(xdp_aie_trace_plugin PRIVATE xdp_core xrt_coreutil xaiengine) target_compile_definitions(xdp_aie_trace_plugin PRIVATE XDP_CLIENT_BUILD=1 -DXAIE_FEATURE_MSVC) diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp index 11a3eeb1252..384ad62a296 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp @@ -5,22 +5,8 @@ namespace xdp::aie::trace { - module_type getTileType(std::shared_ptr metadata, uint8_t absRow) + void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols) { - if (absRow == 0) - return module_type::shim; - if (absRow < metadata->getRowOffset()) - return module_type::mem_tile; - return module_type::core; - } - - void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols) { - // void *hwCtxImpl = metadata->getHandle(); - // boost::property_tree::ptree aiePartitionPt = xdp::aie::getAIEPartitionInfoClient(hwCtxImpl); - // Currently, assuming only one Hw Context is alive at a time - // uint8_t startCol = static_cast(aiePartitionPt.front().second.get("start_col")); - // uint8_t numCols = static_cast(aiePartitionPt.front().second.get("num_cols")); - std::vector maxRowAtCol(startCol + numCols, 0); for (auto& tileMetric : metadata->getConfigMetrics()) { auto tile = tileMetric.first; @@ -34,7 +20,7 @@ namespace xdp::aie::trace { for(uint8_t col = startCol; col < startCol + numCols; col++) { for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { - module_type tileType = getTileType(metadata, row); + module_type tileType = aie::getModuleType(row, metadata->getRowOffset()); auto loc = XAie_TileLoc(col, row); if(tileType == module_type::shim) { @@ -96,7 +82,7 @@ namespace xdp::aie::trace { for(uint8_t col = startCol; col < startCol + numCols; col++) { for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { - module_type tileType = getTileType(metadata, row); + module_type tileType = aie::getModuleType(row, metadata->getRowOffset()); auto loc = XAie_TileLoc(col, row); if(tileType == module_type::shim) { @@ -129,7 +115,7 @@ namespace xdp::aie::trace { uint8_t broadcastId2 = traceStartBroadcastCh2->getBc(); //build broadcast network - aie::trace::build2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, traceStartBroadcastCh2->getBc(), XAIE_EVENT_USER_EVENT_0_PL, startCol, numCols); + aie::trace::build2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, broadcastId2, XAIE_EVENT_USER_EVENT_0_PL, startCol, numCols); //set timer control register for (auto& tileMetric : metadata->getConfigMetrics()) { diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp index 258425eb016..04781177055 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp @@ -296,7 +296,7 @@ namespace xdp { // Currently, assuming only one Hw Context is alive at a time uint8_t startCol = static_cast(aiePartitionPt.front().second.get("start_col")); uint8_t numCols = static_cast(aiePartitionPt.front().second.get("num_cols")); - + numCols = 36; // Get channel configurations (memory and interface tiles) auto configChannel0 = metadata->getConfigChannel0(); auto configChannel1 = metadata->getConfigChannel1(); From 6cfa945f6269b3a232ec1012b702323e0ff868b7 Mon Sep 17 00:00:00 2001 From: parthash0804 Date: Mon, 6 Jan 2025 15:54:34 +0530 Subject: [PATCH 4/5] start column Interface tile start event changes Signed-off-by: parthash0804 --- .../profile/database/static_info/aie_util.cpp | 31 +++++++++++++++---- .../profile/database/static_info/aie_util.h | 4 +++ .../plugin/aie_trace/ve2/aie_trace.cpp | 17 +++++++--- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp index 0be0dcfc0e0..d397d2a754a 100755 --- a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp +++ b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp @@ -407,12 +407,31 @@ namespace xdp::aie { { boost::property_tree::ptree infoPt; try { - #ifdef XDP_CLIENT_BUILD - xrt::hw_context context = xrt_core::hw_context_int::create_hw_context_from_implementation(hwCtxImpl); - auto device = xrt_core::hw_context_int::get_core_device(context); - #else - auto device = xrt_core::get_userpf_device(hwCtxImpl); - #endif + xrt::hw_context context = xrt_core::hw_context_int::create_hw_context_from_implementation(hwCtxImpl); + auto device = xrt_core::hw_context_int::get_core_device(context); + + auto info = xrt_core::device_query_default(device.get(), {}); + for(const auto& e : info) { + boost::property_tree::ptree pt; + pt.put("start_col", e.start_col); + pt.put("num_cols", e.num_cols); + infoPt.push_back(std::make_pair("", pt)); + } + } + catch(...) { + xrt_core::message::send(severity_level::info, "XRT", "Could not retrieve AIE Partition Info."); + return infoPt; + } + return infoPt; + } + + boost::property_tree::ptree + getAIEPartitionInfo(void* handle) + { + boost::property_tree::ptree infoPt; + try { + auto device = xrt_core::get_userpf_device(handle); + auto info = xrt_core::device_query_default(device.get(), {}); for(const auto& e : info) { boost::property_tree::ptree pt; diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_util.h b/src/runtime_src/xdp/profile/database/static_info/aie_util.h index cbf7416a25c..0056a646ed6 100755 --- a/src/runtime_src/xdp/profile/database/static_info/aie_util.h +++ b/src/runtime_src/xdp/profile/database/static_info/aie_util.h @@ -111,6 +111,10 @@ namespace xdp::aie { boost::property_tree::ptree getAIEPartitionInfoClient(void* hwCtxImpl); + XDP_CORE_EXPORT + boost::property_tree::ptree + getAIEPartitionInfo(void* handle); + XDP_CORE_EXPORT void displayColShiftInfo(uint8_t colShift); diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp index 04781177055..9353f31163b 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp @@ -292,11 +292,11 @@ namespace xdp { } // Get partition columns - boost::property_tree::ptree aiePartitionPt = xdp::aie::getAIEPartitionInfoClient(handle); + boost::property_tree::ptree aiePartitionPt = xdp::aie::getAIEPartitionInfo(handle); // Currently, assuming only one Hw Context is alive at a time uint8_t startCol = static_cast(aiePartitionPt.front().second.get("start_col")); uint8_t numCols = static_cast(aiePartitionPt.front().second.get("num_cols")); - numCols = 36; + // Get channel configurations (memory and interface tiles) auto configChannel0 = metadata->getConfigChannel0(); auto configChannel1 = metadata->getConfigChannel1(); @@ -862,8 +862,17 @@ namespace xdp { } auto shimTrace = shim.traceControl(); - if (shimTrace->setCntrEvent(interfaceTileTraceStartEvent, interfaceTileTraceEndEvent) != XAIE_OK) - break; + + if(col == startCol && compilerOptions.enable_multi_layer && xrt_core::config::get_aie_trace_settings_trace_start_broadcast()) + { + if (shimTrace->setCntrEvent(XAIE_EVENT_USER_EVENT_0_PL, interfaceTileTraceEndEvent) != XAIE_OK) + break; + } + else + { + if (shimTrace->setCntrEvent(interfaceTileTraceStartEvent, interfaceTileTraceEndEvent) != XAIE_OK) + break; + } auto ret = shimTrace->reserve(); if (ret != XAIE_OK) { From 2c56486233990748ad4f1ac155e9cca5016e03ff Mon Sep 17 00:00:00 2001 From: parthash0804 Date: Thu, 9 Jan 2025 16:16:46 +0530 Subject: [PATCH 5/5] Changes as per comments in the PR Signed-off-by: parthash0804 --- .../util/aie_trace_common_config.cpp | 183 ------------------ .../aie_trace/util/aie_trace_common_config.h | 20 -- .../aie_trace/util/aie_trace_config.cpp | 82 ++++++++ .../plugin/aie_trace/util/aie_trace_config.h | 13 ++ .../plugin/aie_trace/util/aie_trace_util.cpp | 103 ++++++++++ .../plugin/aie_trace/util/aie_trace_util.h | 23 +++ .../plugin/aie_trace/ve2/aie_trace.cpp | 6 +- .../profile/plugin/aie_trace/ve2/aie_trace.h | 1 - 8 files changed, 226 insertions(+), 205 deletions(-) delete mode 100755 src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp delete mode 100755 src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp deleted file mode 100755 index 384ad62a296..00000000000 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include - -#include "xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h" -#include "xdp/profile/database/static_info/aie_constructs.h" - -namespace xdp::aie::trace { - - void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols) - { - std::vector maxRowAtCol(startCol + numCols, 0); - for (auto& tileMetric : metadata->getConfigMetrics()) { - auto tile = tileMetric.first; - auto col = tile.col; - auto row = tile.row; - maxRowAtCol[startCol + col] = std::max(maxRowAtCol[col], (uint8_t)row); - } - - XAie_Events bcastEvent2_PL = (XAie_Events) (XAIE_EVENT_BROADCAST_A_0_PL + broadcastId2); - XAie_EventBroadcast(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, broadcastId2, event); - - for(uint8_t col = startCol; col < startCol + numCols; col++) { - for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { - module_type tileType = aie::getModuleType(row, metadata->getRowOffset()); - auto loc = XAie_TileLoc(col, row); - - if(tileType == module_type::shim) { - // first channel is only used to send north - if(col == startCol) { - XAie_EventBroadcast(aieDevInst, loc, XAIE_PL_MOD, broadcastId1, event); - } - else { - XAie_EventBroadcast(aieDevInst, loc, XAIE_PL_MOD, broadcastId1, bcastEvent2_PL); - } - if(maxRowAtCol[col] != row) { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST); - } - else { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); - } - - // second channel is only used to send east - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); - - if(col != startCol + numCols - 1) { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); - } - else { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH | XAIE_EVENT_BROADCAST_EAST); - } - } - else if(tileType == module_type::mem_tile) { - if(maxRowAtCol[col] != row) { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST); - } - else { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); - } - } - else { //core tile - if(maxRowAtCol[col] != row) { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST); - } - else { - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); - } - XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); - } - } - } - } - - void reset2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, uint8_t startCol, uint8_t numCols) { - std::vector maxRowAtCol(startCol + numCols, 0); - for (auto& tileMetric : metadata->getConfigMetrics()) { - auto tile = tileMetric.first; - auto col = tile.col; - auto row = tile.row; - maxRowAtCol[startCol + col] = std::max(maxRowAtCol[col], (uint8_t)row); - } - - XAie_EventBroadcastReset(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, broadcastId2); - - for(uint8_t col = startCol; col < startCol + numCols; col++) { - for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { - module_type tileType = aie::getModuleType(row, metadata->getRowOffset()); - auto loc = XAie_TileLoc(col, row); - - if(tileType == module_type::shim) { - XAie_EventBroadcastReset(aieDevInst, loc, XAIE_PL_MOD, broadcastId1); - XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); - XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId2, XAIE_EVENT_BROADCAST_ALL); - XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_ALL); - } - else if(tileType == module_type::mem_tile) { - XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); - } - else { //core tile - XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); - XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); - } - } - } - } - - void timerSyncronization(XAie_DevInst* aieDevInst, xaiefal::XAieDev* aieDevice, std::shared_ptr metadata, uint8_t startCol, uint8_t numCols) - { - std::shared_ptr traceStartBroadcastCh1 = nullptr, traceStartBroadcastCh2 = nullptr; - std::vector vL; - traceStartBroadcastCh1 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); - traceStartBroadcastCh1->reserve(); - traceStartBroadcastCh2 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); - traceStartBroadcastCh2->reserve(); - - uint8_t broadcastId1 = traceStartBroadcastCh1->getBc(); - uint8_t broadcastId2 = traceStartBroadcastCh2->getBc(); - - //build broadcast network - aie::trace::build2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, broadcastId2, XAIE_EVENT_USER_EVENT_0_PL, startCol, numCols); - - //set timer control register - for (auto& tileMetric : metadata->getConfigMetrics()) { - auto tile = tileMetric.first; - auto col = tile.col + startCol; - auto row = tile.row; - auto type = aie::getModuleType(row, metadata->getRowOffset()); - auto loc = XAie_TileLoc(col, row); - - if(type == module_type::shim) { - XAie_Events resetEvent = (XAie_Events)(XAIE_EVENT_BROADCAST_A_0_PL + broadcastId2); - if(col == 0) - { - resetEvent = XAIE_EVENT_USER_EVENT_0_PL; - } - - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_PL_MOD, resetEvent, XAIE_RESETDISABLE); - } - else if(type == module_type::mem_tile) { - XAie_Events resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM_TILE + broadcastId1); - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); - } - else { - XAie_Events resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_CORE + broadcastId1); - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_CORE_MOD, resetEvent, XAIE_RESETDISABLE); - resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM + broadcastId1); - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); - } - } - - //Generate the event to trigger broadcast network to reset timer - XAie_EventGenerate(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, XAIE_EVENT_USER_EVENT_0_PL); - - //reset timer control register so that timer are not reset after this point - for (auto& tileMetric : metadata->getConfigMetrics()) { - auto tile = tileMetric.first; - auto col = tile.col + startCol; - auto row = tile.row; - auto type = aie::getModuleType(row, metadata->getRowOffset()); - auto loc = XAie_TileLoc(col, row); - - if(type == module_type::shim) { - XAie_Events resetEvent = XAIE_EVENT_NONE_PL ; - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_PL_MOD, resetEvent, XAIE_RESETDISABLE); - } - else if(type == module_type::mem_tile) { - XAie_Events resetEvent = XAIE_EVENT_NONE_MEM_TILE; - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); - } - else { - XAie_Events resetEvent = XAIE_EVENT_NONE_CORE; - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_CORE_MOD, resetEvent, XAIE_RESETDISABLE); - resetEvent = XAIE_EVENT_NONE_MEM; - XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); - } - } - - //reset broadcast network - reset2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, broadcastId2, startCol, numCols); - - //release the channels used for timer sync - traceStartBroadcastCh1->release(); - traceStartBroadcastCh2->release(); - } -} \ No newline at end of file diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h deleted file mode 100755 index e6c99877009..00000000000 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef AIE_TRACE_COMMON_CONFIG_DOT_H -#define AIE_TRACE_COMMON_CONFIG_DOT_H - -#include -#include "xaiefal/xaiefal.hpp" -#include "xdp/profile/plugin/aie_trace/aie_trace_metadata.h" - -extern "C" { - #include - #include -} - -namespace xdp::aie::trace { - module_type getTileType(std::shared_ptr metadata, uint8_t absRow); - void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols); - void reset2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, uint8_t startCol, uint8_t numCols); - void timerSyncronization(XAie_DevInst* aieDevInst, xaiefal::XAieDev* aieDevice, std::shared_ptr metadata, uint8_t startCol, uint8_t numCols); -} - -#endif \ No newline at end of file diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.cpp index 5dcd852d489..9cfbf2a4857 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.cpp @@ -462,4 +462,86 @@ namespace xdp::aie::trace { return true; } + /**************************************************************************** + * Reset timer for the specified tile range + ***************************************************************************/ + void timerSyncronization(XAie_DevInst* aieDevInst, xaiefal::XAieDev* aieDevice, std::shared_ptr metadata, uint8_t startCol, uint8_t numCols) + { + std::shared_ptr traceStartBroadcastCh1 = nullptr, traceStartBroadcastCh2 = nullptr; + std::vector vL; + traceStartBroadcastCh1 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); + traceStartBroadcastCh1->reserve(); + traceStartBroadcastCh2 = aieDevice->broadcast(vL, XAIE_PL_MOD, XAIE_CORE_MOD); + traceStartBroadcastCh2->reserve(); + + uint8_t broadcastId1 = traceStartBroadcastCh1->getBc(); + uint8_t broadcastId2 = traceStartBroadcastCh2->getBc(); + + //build broadcast network + aie::trace::build2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, broadcastId2, XAIE_EVENT_USER_EVENT_0_PL, startCol, numCols); + + //set timer control register + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col + startCol; + auto row = tile.row; + auto type = aie::getModuleType(row, metadata->getRowOffset()); + auto loc = XAie_TileLoc(col, row); + + if(type == module_type::shim) { + XAie_Events resetEvent = (XAie_Events)(XAIE_EVENT_BROADCAST_A_0_PL + broadcastId2); + if(col == startCol) + { + resetEvent = XAIE_EVENT_USER_EVENT_0_PL; + } + + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_PL_MOD, resetEvent, XAIE_RESETDISABLE); + } + else if(type == module_type::mem_tile) { + XAie_Events resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM_TILE + broadcastId1); + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + else { + XAie_Events resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_CORE + broadcastId1); + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_CORE_MOD, resetEvent, XAIE_RESETDISABLE); + resetEvent = (XAie_Events) (XAIE_EVENT_BROADCAST_0_MEM + broadcastId1); + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + } + + //Generate the event to trigger broadcast network to reset timer + XAie_EventGenerate(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, XAIE_EVENT_USER_EVENT_0_PL); + + //reset timer control register so that timer are not reset after this point + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col + startCol; + auto row = tile.row; + auto type = aie::getModuleType(row, metadata->getRowOffset()); + auto loc = XAie_TileLoc(col, row); + + if(type == module_type::shim) { + XAie_Events resetEvent = XAIE_EVENT_NONE_PL ; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_PL_MOD, resetEvent, XAIE_RESETDISABLE); + } + else if(type == module_type::mem_tile) { + XAie_Events resetEvent = XAIE_EVENT_NONE_MEM_TILE; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + else { + XAie_Events resetEvent = XAIE_EVENT_NONE_CORE; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_CORE_MOD, resetEvent, XAIE_RESETDISABLE); + resetEvent = XAIE_EVENT_NONE_MEM; + XAie_SetTimerResetEvent(aieDevInst, loc, XAIE_MEM_MOD, resetEvent, XAIE_RESETDISABLE); + } + } + + //reset broadcast network + reset2ChannelBroadcastNetwork(aieDevInst, metadata, broadcastId1, broadcastId2, startCol, numCols); + + //release the channels used for timer sync + traceStartBroadcastCh1->release(); + traceStartBroadcastCh2->release(); + } + } // namespace xdp diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.h b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.h index 773845637ea..3df6472d4e5 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.h +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.h @@ -20,6 +20,7 @@ #include #include "xaiefal/xaiefal.hpp" #include "xdp/profile/database/static_info/aie_constructs.h" +#include "xdp/profile/plugin/aie_trace/aie_trace_metadata.h" namespace xdp::aie::trace { /** @@ -119,6 +120,18 @@ namespace xdp::aie::trace { */ bool configStartIteration(xaiefal::XAieMod& core, uint32_t iteration, XAie_Events& startEvent); + + /** + * @brief Reset timers for specified tile range + * @param aieDevInst AIE device Instance + * @param aieDevice AIE device + * @param metadata Trace Metadata + * @param startCol Start column of the partition + * @param numCols Num of columns in the partition + */ + void timerSyncronization(XAie_DevInst* aieDevInst, xaiefal::XAieDev* aieDevice, + std::shared_ptr metadata, uint8_t startCol, + uint8_t numCols); } // namespace xdp::aie::trace #endif diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.cpp index 6c6c994ad61..07e2828e1a0 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.cpp @@ -632,4 +632,107 @@ namespace xdp::aie::trace { XAIE_EVENT_DMA_S2MM_0_MEMORY_BACKPRESSURE_PL, XAIE_EVENT_DMA_S2MM_1_MEMORY_BACKPRESSURE_PL); } } + + /**************************************************************************** + * Set up broadcast network + ***************************************************************************/ + void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols) + { + std::vector maxRowAtCol(startCol + numCols, 0); + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col; + auto row = tile.row; + maxRowAtCol[startCol + col] = std::max(maxRowAtCol[col], (uint8_t)row); + } + + XAie_Events bcastEvent2_PL = (XAie_Events) (XAIE_EVENT_BROADCAST_A_0_PL + broadcastId2); + XAie_EventBroadcast(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, broadcastId2, event); + + for(uint8_t col = startCol; col < startCol + numCols; col++) { + for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { + module_type tileType = aie::getModuleType(row, metadata->getRowOffset()); + auto loc = XAie_TileLoc(col, row); + + if(tileType == module_type::shim) { + // first channel is only used to send north + if(col == startCol) { + XAie_EventBroadcast(aieDevInst, loc, XAIE_PL_MOD, broadcastId1, event); + } + else { + XAie_EventBroadcast(aieDevInst, loc, XAIE_PL_MOD, broadcastId1, bcastEvent2_PL); + } + if(maxRowAtCol[col] != row) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); + } + + // second channel is only used to send east + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); + + if(col != startCol + numCols - 1) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH | XAIE_EVENT_BROADCAST_EAST); + } + } + else if(tileType == module_type::mem_tile) { + if(maxRowAtCol[col] != row) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); + } + } + else { //core tile + if(maxRowAtCol[col] != row) { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST); + } + else { + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_NORTH); + } + XAie_EventBroadcastBlockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_SOUTH | XAIE_EVENT_BROADCAST_WEST | XAIE_EVENT_BROADCAST_EAST | XAIE_EVENT_BROADCAST_NORTH); + } + } + } + } + + /**************************************************************************** + * Reset broadcast network + ***************************************************************************/ + void reset2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, uint8_t startCol, uint8_t numCols) { + std::vector maxRowAtCol(startCol + numCols, 0); + for (auto& tileMetric : metadata->getConfigMetrics()) { + auto tile = tileMetric.first; + auto col = tile.col; + auto row = tile.row; + maxRowAtCol[startCol + col] = std::max(maxRowAtCol[col], (uint8_t)row); + } + + XAie_EventBroadcastReset(aieDevInst, XAie_TileLoc(startCol, 0), XAIE_PL_MOD, broadcastId2); + + for(uint8_t col = startCol; col < startCol + numCols; col++) { + for(uint8_t row = 0; row <= maxRowAtCol[col]; row++) { + module_type tileType = aie::getModuleType(row, metadata->getRowOffset()); + auto loc = XAie_TileLoc(col, row); + + if(tileType == module_type::shim) { + XAie_EventBroadcastReset(aieDevInst, loc, XAIE_PL_MOD, broadcastId1); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_A, broadcastId2, XAIE_EVENT_BROADCAST_ALL); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_PL_MOD, XAIE_EVENT_SWITCH_B, broadcastId2, XAIE_EVENT_BROADCAST_ALL); + } + else if(tileType == module_type::mem_tile) { + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + } + else { //core tile + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + XAie_EventBroadcastUnblockDir(aieDevInst, loc, XAIE_MEM_MOD, XAIE_EVENT_SWITCH_A, broadcastId1, XAIE_EVENT_BROADCAST_ALL); + } + } + } + } } // namespace xdp::aie diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.h b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.h index ae456fbfcd7..80fdcc06c6b 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.h +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_util.h @@ -20,6 +20,7 @@ #include #include "xaiefal/xaiefal.hpp" #include "xdp/profile/database/static_info/aie_constructs.h" +#include "xdp/profile/plugin/aie_trace/aie_trace_metadata.h" namespace xdp::aie::trace { /** @@ -178,6 +179,28 @@ namespace xdp::aie::trace { void modifyEvents(module_type type, io_type subtype, const std::string metricSet, uint8_t channel, std::vector& events); + /** + * @brief Build 2-channel broadcast network for specified tile range + * @param aieDevInst AIE device + * @param metadata Trace Metadata + * @param broadcastId1 Broadcast channel 1 + * @param broadcastId2 Broadcast channel 2 + * @param event Event to trigger broadcast network + * @param startCol Start column of the partition + * @param numCols Num of columns in the partition + */ + void build2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, XAie_Events event, uint8_t startCol, uint8_t numCols); + + /** + * @brief Reset 2-channel broadcast network for specified tile range + * @param aieDevInst AIE device + * @param metadata Trace Metadata + * @param broadcastId1 Broadcast channel 1 + * @param broadcastId2 Broadcast channel 2 + * @param startCol Start column of the partition + * @param numCols Num of columns in the partition + */ + void reset2ChannelBroadcastNetwork(XAie_DevInst* aieDevInst, std::shared_ptr metadata, uint8_t broadcastId1, uint8_t broadcastId2, uint8_t startCol, uint8_t numCols); } // namespace xdp::aie::trace #endif diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp index 9353f31163b..b050c9ba8dd 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.cpp @@ -296,7 +296,11 @@ namespace xdp { // Currently, assuming only one Hw Context is alive at a time uint8_t startCol = static_cast(aiePartitionPt.front().second.get("start_col")); uint8_t numCols = static_cast(aiePartitionPt.front().second.get("num_cols")); - + + //TODO: Remove below 2 lines once aie_partition_info from XRT returns correct values + const char* envNumCols = std::getenv("NUM_COLS"); + numCols = envNumCols ? static_cast(std::stoi(envNumCols)) : 4 ; + // Get channel configurations (memory and interface tiles) auto configChannel0 = metadata->getConfigChannel0(); auto configChannel1 = metadata->getConfigChannel1(); diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h index af437c5ae94..6a320ba6bec 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/ve2/aie_trace.h @@ -22,7 +22,6 @@ #include "xaiefal/xaiefal.hpp" #include "xdp/profile/plugin/aie_trace/aie_trace_impl.h" #include "xdp/profile/plugin/aie_trace/util/aie_trace_config.h" -#include "xdp/profile/plugin/aie_trace/util/aie_trace_common_config.h" namespace xdp {