Skip to content

Commit

Permalink
using right column for broadcasting start core (#8092)
Browse files Browse the repository at this point in the history
Co-authored-by: ch vamshi krishna <[email protected]>
  • Loading branch information
chvamshi-xilinx and ch vamshi krishna authored Apr 21, 2024
1 parent 4b05aa2 commit 5e38d68
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
36 changes: 33 additions & 3 deletions src/runtime_src/core/edge/common/aie_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<uint8_t>();
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<uint32_t>("startColumn");
uint32_t num_columns = part.second.template get<uint32_t>("numColumns");
return (start_column <= column) && (column < (start_column + num_columns));
});

if(itr != partitions.get().end())
return itr->second.get<uint32_t>("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<std::string>("name") != graph_name)
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct graph_config
std::vector<short> iterMemRows;
std::vector<size_t> iterMemAddrs;
std::vector<bool> triggered;
uint32_t broadcast_column;
};

struct rtp_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5e38d68

Please sign in to comment.