diff --git a/src/runtime_src/core/edge/common/aie_parser.cpp b/src/runtime_src/core/edge/common/aie_parser.cpp index 3695935b0d5..5c3f435d5c5 100755 --- a/src/runtime_src/core/edge/common/aie_parser.cpp +++ b/src/runtime_src/core/edge/common/aie_parser.cpp @@ -35,6 +35,7 @@ using counter_type = xrt_core::edge::aie::counter_type; using module_type = xrt_core::edge::aie::module_type; static constexpr uint32_t default_id = 1; +static constexpr uint32_t default_start_column = 0; inline void throw_if_error(bool err, const char* msg) @@ -111,18 +112,44 @@ get_aiecompiler_options(const pt::ptree& aie_meta) static uint8_t get_start_col(const pt::ptree& aie_meta) { - auto start_col = 0; + auto start_col = 0; auto overlay_start_cols = aie_meta.get_child_optional("aie_metadata.driver_config.partition_overlay_start_cols"); - if (overlay_start_cols && !overlay_start_cols->empty()) + if (overlay_start_cols && !overlay_start_cols->empty()) start_col = overlay_start_cols->begin()->second.get_value(); return start_col; } +// get the start column of partition which gets used for broadcasting core start +// event +static uint32_t +get_partition_start_column(const pt::ptree& aie_meta, int column) +{ + try { + auto partitions = aie_meta.get_child_optional("aie_metadata.driver_config.aie_partition_json.AIE.ai_engine_0.partitions"); + + if (!partitions) + return default_start_column; // if no patitions are available, 0 would be start column for partition + + auto itr = std::find_if(partitions.get().begin(), partitions.get().end(),[column] (const auto& part) { + uint32_t start_column = part.second.template get("startColumn"); + uint32_t num_columns = part.second.template get("numColumns"); + return (start_column <= column) && (column < (start_column + num_columns)); + }); + + if(itr != partitions.get().end()) + return itr->second.get("startColumn"); + } + catch(...) { + // old xclbins may not have these sections. Use default_start_column + } + return default_start_column; +} + adf::graph_config get_graph(const pt::ptree& aie_meta, const std::string& graph_name) { adf::graph_config graph_config; - auto start_col = get_start_col(aie_meta); + auto start_col = get_start_col(aie_meta); for (auto& graph : aie_meta.get_child("aie_metadata.graphs")) { if (graph.second.get("name") != graph_name) @@ -137,6 +164,9 @@ get_graph(const pt::ptree& aie_meta, const std::string& graph_name) count++; } + if (graph_config.coreColumns.size()) // broadcasting column is same for one partition + graph_config.broadcast_column = get_partition_start_column(aie_meta, graph_config.coreColumns[0]); + int num_tiles = count; count = 0; diff --git a/src/runtime_src/core/edge/user/aie/common_layer/adf_api_config.h b/src/runtime_src/core/edge/user/aie/common_layer/adf_api_config.h index cc7e08d66b5..e4a9d2e77d0 100755 --- a/src/runtime_src/core/edge/user/aie/common_layer/adf_api_config.h +++ b/src/runtime_src/core/edge/user/aie/common_layer/adf_api_config.h @@ -56,6 +56,7 @@ struct graph_config std::vector iterMemRows; std::vector iterMemAddrs; std::vector triggered; + uint32_t broadcast_column; }; struct rtp_config diff --git a/src/runtime_src/core/edge/user/aie/common_layer/adf_runtime_api.cpp b/src/runtime_src/core/edge/user/aie/common_layer/adf_runtime_api.cpp index 2a7e505d898..2c2fbb2f9af 100755 --- a/src/runtime_src/core/edge/user/aie/common_layer/adf_runtime_api.cpp +++ b/src/runtime_src/core/edge/user/aie/common_layer/adf_runtime_api.cpp @@ -124,13 +124,13 @@ err_code graph_api::run() //Trigger event XAIE_EVENT_BROADCAST_A_8_PL in shim_tile at column 0 by writing to Event_Generate. The resources have been acquired by aiecompiler. // In case of multi-partition flow still XAie_TileLoc(0, 0) will be used to generate event trigger, but here (0,0) indicates the relative // tile location i.e. absolute bottom left tile post translation by partition start column is always 0,0. - XAie_EventGenerate(config_manager::s_pDevInst, XAie_TileLoc(0, 0), XAIE_PL_MOD, XAIE_EVENT_BROADCAST_A_8_PL); + XAie_EventGenerate(config_manager::s_pDevInst, XAie_TileLoc(pGraphConfig->broadcast_column, 0), XAIE_PL_MOD, XAIE_EVENT_BROADCAST_A_8_PL); // Waiting for 150 cycles to reset the core enable event unsigned long long StartTime, CurrentTime = 0; - driverStatus |= XAie_ReadTimer(config_manager::s_pDevInst, XAie_TileLoc(0, 0), XAIE_PL_MOD, (u64*)(&StartTime)); + driverStatus |= XAie_ReadTimer(config_manager::s_pDevInst, XAie_TileLoc(pGraphConfig->broadcast_column, 0), XAIE_PL_MOD, (u64*)(&StartTime)); do { - driverStatus |= XAie_ReadTimer(config_manager::s_pDevInst, XAie_TileLoc(0, 0), XAIE_PL_MOD, (u64*)(&CurrentTime)); + driverStatus |= XAie_ReadTimer(config_manager::s_pDevInst, XAie_TileLoc(pGraphConfig->broadcast_column, 0), XAIE_PL_MOD, (u64*)(&CurrentTime)); } while ((CurrentTime - StartTime) <= 150); XAie_StartTransaction(config_manager::s_pDevInst, XAIE_TRANSACTION_ENABLE_AUTO_FLUSH);