From f23d53edd42fea0f0acd08c194b4750ed77127e2 Mon Sep 17 00:00:00 2001 From: Saumya Garg <109280626+saumyag-xilinx@users.noreply.github.com> Date: Sat, 23 Mar 2024 16:53:57 +0530 Subject: [PATCH] VITIS-9887: xrt support for multiple graph linking and compilation (#8030) * xrt support for multiple graph linking and compilation Signed-off-by: saumya garg xrt support for multiple graph linking and compilation Signed-off-by: saumya garg xrt support for multiple graph linking and compilation Signed-off-by: saumya garg xrt support for multiple graph linking and compilation Signed-off-by: saumya garg xrt support for multiple graph linking and compilation Signed-off-by: saumya garg * fix review comments Signed-off-by: saumya garg fix review comments Signed-off-by: saumya garg --------- Signed-off-by: saumya garg Co-authored-by: saumya garg --- .../core/edge/common/aie_parser.cpp | 27 +++++++++++-------- .../core/edge/drm/zocl/edge/zocl_aie.c | 17 ++++++++---- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/runtime_src/core/edge/common/aie_parser.cpp b/src/runtime_src/core/edge/common/aie_parser.cpp index 1fdc83f3bbe..c7db779dc73 100755 --- a/src/runtime_src/core/edge/common/aie_parser.cpp +++ b/src/runtime_src/core/edge/common/aie_parser.cpp @@ -34,6 +34,8 @@ using gmio_type = xrt_core::edge::aie::gmio_type; 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; + inline void throw_if_error(bool err, const char* msg) { @@ -62,12 +64,12 @@ get_driver_config(const pt::ptree& aie_meta) driver_config.shim_row = aie_meta.get("aie_metadata.driver_config.shim_row"); if (!aie_meta.get_optional("aie_metadata.driver_config.mem_tile_row_start") || !aie_meta.get_optional("aie_metadata.driver_config.mem_tile_num_rows")) { - driver_config.mem_row_start = aie_meta.get("aie_metadata.driver_config.reserved_row_start"); - driver_config.mem_num_rows = aie_meta.get("aie_metadata.driver_config.reserved_num_rows"); + driver_config.mem_row_start = aie_meta.get("aie_metadata.driver_config.reserved_row_start"); + driver_config.mem_num_rows = aie_meta.get("aie_metadata.driver_config.reserved_num_rows"); } else { - driver_config.mem_row_start = aie_meta.get("aie_metadata.driver_config.mem_tile_row_start"); - driver_config.mem_num_rows = aie_meta.get("aie_metadata.driver_config.mem_tile_num_rows"); + driver_config.mem_row_start = aie_meta.get("aie_metadata.driver_config.mem_tile_row_start"); + driver_config.mem_num_rows = aie_meta.get("aie_metadata.driver_config.mem_tile_num_rows"); } driver_config.aie_tile_row_start = aie_meta.get("aie_metadata.driver_config.aie_tile_row_start"); driver_config.aie_tile_num_rows = aie_meta.get("aie_metadata.driver_config.aie_tile_num_rows"); @@ -83,24 +85,27 @@ get_hw_gen(const pt::ptree& aie_meta) static uint32_t get_partition_id(const pt::ptree& aie_meta) { - auto num_col = aie_meta.get("aie_metadata.driver_config.partition_num_cols"); + auto num_col = aie_meta.get_child_optional("aie_metadata.driver_config.partition_num_cols"); + if (!num_col) + return default_id; + auto num_col_value = num_col->get_value(); 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()) - start_col = overlay_start_cols->begin()->second.get_value(); + start_col = overlay_start_cols->begin()->second.get_value(); // AIE Driver expects the partition id format as below - uint32_t part = (num_col << 8U) | (start_col & 0xffU); + uint32_t part = (num_col_value << 8U) | (start_col & 0xffU); return part; } adf::aiecompiler_options get_aiecompiler_options(const pt::ptree& aie_meta) { - adf::aiecompiler_options aiecompiler_options; - aiecompiler_options.broadcast_enable_core = aie_meta.get("aie_metadata.aiecompiler_options.broadcast_enable_core"); - aiecompiler_options.event_trace = aie_meta.get("aie_metadata.aiecompiler_options.event_trace", "runtime"); - return aiecompiler_options; + adf::aiecompiler_options aiecompiler_options; + aiecompiler_options.broadcast_enable_core = aie_meta.get("aie_metadata.aiecompiler_options.broadcast_enable_core"); + aiecompiler_options.event_trace = aie_meta.get("aie_metadata.aiecompiler_options.event_trace", "runtime"); + return aiecompiler_options; } adf::graph_config diff --git a/src/runtime_src/core/edge/drm/zocl/edge/zocl_aie.c b/src/runtime_src/core/edge/drm/zocl/edge/zocl_aie.c index 35d32c4c159..fe6b20c55e1 100644 --- a/src/runtime_src/core/edge/drm/zocl/edge/zocl_aie.c +++ b/src/runtime_src/core/edge/drm/zocl/edge/zocl_aie.c @@ -251,6 +251,7 @@ zocl_read_aieresbin(struct drm_zocl_dev *zdev, struct axlf* axlf, char __user *x header = xrt_xclbin_get_section_hdr_next(axlf, AIE_RESOURCES_BIN, header); while (header) { int err = 0; + long start_col = 0, num_col = 0; struct aie_resources_bin *aie_p = (struct aie_resources_bin *)(xclbin + header->m_sectionOffset); void *data_portion = vmalloc(aie_p->m_image_size); @@ -262,12 +263,18 @@ zocl_read_aieresbin(struct drm_zocl_dev *zdev, struct axlf* axlf, char __user *x return err; } + if (kstrtol((char*)aie_p +aie_p->m_start_column, 10, &start_col) || + kstrtol((char*)aie_p +aie_p->m_num_columns, 10, &num_col)) { + vfree(data_portion); + return -EINVAL; + } + //Call the AIE Driver API - //int ret = aie_part_rscmgr_set_static_range(zdev->aie->aie_dev, aie_p->m_start_column, aie_p->m_num_columns, data_portion); - //if (ret != 0) { - // vfree(data_portion); - // return ret; - //} + int ret = aie_part_rscmgr_set_static_range(zdev->aie->aie_dev, start_col, num_col, data_portion); + if (ret != 0) { + vfree(data_portion); + return ret; + } vfree(data_portion); header = xrt_xclbin_get_section_hdr_next(axlf, AIE_RESOURCES_BIN, header); }