Skip to content

Switch aie-rt submodule from personal fork to upstream + vendored patches#3334

Draft
jgmelber wants to merge 1 commit into
mainfrom
eval/aie-rt-upstream-vendor
Draft

Switch aie-rt submodule from personal fork to upstream + vendored patches#3334
jgmelber wants to merge 1 commit into
mainfrom
eval/aie-rt-upstream-vendor

Conversation

@jgmelber

Copy link
Copy Markdown
Collaborator

Summary

  • third_party/aie-rt tracked stephenneuendorffer/aie-rt (a personal fork with no review process) on branch strix_2024.2, pinned at 6a15e48b. Point it at upstream Xilinx/aie-rt instead, pinned at e2aca220 — the exact merge-base with the fork — so this is a pure de-fork with zero behavior/version drift.
  • Vendor the functionality mlir-aie actually needs that isn't upstream yet as third_party/patches/aie-rt/0001-vck5000-cdo-sim-fixes.patch, applied automatically at CMake configure time:
    • The VCK5000/AMDAIR IO backend (xaie_amdair.c), actively used by runtime_lib/test_lib/test_library.cpp for VCK5000 hardware testing — not dead code, and not present anywhere upstream.
    • cdo_rts.h/main_rts.h workarounds avoiding Vitis-only header dependencies.
    • A resource-manager memory leak fix (RscArrPerTile).
  • Wired the patch application into every build path that consumes third_party/aie-rt: the standalone runtime_lib/xaiengine (used by the xaiengine_<target> ExternalProject) and the in-tree xaienginecdo_static target in runtime_lib/CMakeLists.txt, which previously globbed the submodule directly at parent-configure time.

Why not other approaches

  • Pointing at a different fork (even one we control) doesn't address the actual problem — it's still an unreviewed moving branch. Vendoring as an in-tree patch file makes the delta visible and reviewable in mlir-aie's own PR history.
  • Jumping straight to upstream HEAD instead of the merge-base would drop the need for one small patch (upstream later deleted the leaky resource-manager code entirely) but pulls in 136 unaudited commits of drift — a bigger, separate upgrade worth doing deliberately later.

Test plan

  • Confirmed the vendored patch applies cleanly to a fresh checkout of upstream e2aca220 and reproduces a tree byte-identical to the previous fork-pinned tree (aside from Makefile.Linux, which mlir-aie's CMake build doesn't use).
  • Built runtime_lib/xaiengine standalone (the xaienginecdo shared lib) from a clean, unpatched submodule checkout — patch auto-applies once at configure, is a no-op on reconfigure, and the resulting .so exports AmdAirBackend.
  • Built the full project (LLVM/MLIR-AIE, with real Vitis 2024.2 + xchesscc for AIE2/AIE2P) from a clean, unpatched submodule checkout, exercising all three consumers: the xaiengine_x86_64 ExternalProject, the in-tree xaienginecdo_static target, and test_lib (which references XAIE_IO_BACKEND_AMDAIR) — all build, link, and install successfully.
  • No VCK5000/NPU hardware available in this environment, so this is a compile/link-level verification, not a hardware functional test.

🤖 Generated with Claude Code

…ches

third_party/aie-rt tracked stephenneuendorffer/aie-rt (a personal fork with
no review process) instead of upstream Xilinx/aie-rt. Point the submodule at
upstream, pinned at the exact merge-base with the fork so this is a pure
de-fork with no behavior change, and vendor the functionality mlir-aie
actually needs that isn't upstream yet (VCK5000/AMDAIR IO backend used by
runtime_lib/test_lib/test_library.cpp, cdo_rts.h/main_rts.h Vitis-header
workarounds, and a resource-manager leak fix) as a patch file under
third_party/patches/aie-rt, applied automatically at CMake configure time.

Verified the patched tree is byte-identical to the previous fork-pinned
tree, and that all three build paths that consume third_party/aie-rt
(the xaiengine ExternalProject, the in-tree xaienginecdo_static target, and
test_lib) build correctly from a freshly-unpatched submodule checkout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 22:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR de-forks the third_party/aie-rt submodule by pointing it at upstream Xilinx/aie-rt, and preserves required downstream-only behavior by vendoring the fork delta as an in-tree patch series that is applied automatically during CMake configure.

Changes:

  • Switched the third_party/aie-rt submodule URL from a personal fork to upstream (.gitmodules).
  • Added a vendored patch (third_party/patches/aie-rt/0001-...) plus documentation for the downstream delta.
  • Integrated automatic patch application into both the in-tree runtime build and the standalone xaiengine build paths.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
third_party/patches/aie-rt/README.md Documents the purpose and contents of vendored aie-rt patches.
third_party/patches/aie-rt/0001-vck5000-cdo-sim-fixes.patch Introduces the downstream aie-rt delta as a git apply-able patch (AMDAIR backend, sim/CDO header workarounds, leak fix, etc.).
runtime_lib/xaiengine/lib/CMakeLists.txt Applies vendored aie-rt patches before building xaiengine from the submodule.
runtime_lib/xaiengine/aiert.cmake Adds the patch-application function invoked by multiple build entry points.
runtime_lib/CMakeLists.txt Ensures patches are applied early enough for in-tree targets that glob aie-rt sources at configure time.
.gitmodules Updates the aie-rt submodule to track upstream instead of a personal fork/branch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +18
+/* Suppress warning of unused parameter */
+#define UNUSED(_x) (_x = _x)
Comment on lines +77 to +83
@@ -103,6 +103,7 @@ typedef enum {
XAIE_IO_BACKEND_IPU, /* IPU Backend */
XAIE_IO_BACKEND_SOCKET, /* Socket backend */
XAIE_IO_BACKEND_CONTROLCODE,
+ XAIE_IO_BACKEND_AMDAIR, /* Use with amdair driver */
XAIE_IO_BACKEND_MAX
} XAie_BackendType;
*
*******************************************************************************/
-#define XAie_InstDeclare(Inst, ConfigPtr) XAie_DevInst Inst = { 0 }
+#define XAie_InstDeclare(Inst, ConfigPtr) XAie_DevInst Inst = {}
Comment on lines +880 to +883
+#include <unistd.h>
+
+typedef unsigned int uint;
+
Comment on lines +8 to +31
function(apply_aie_rt_vendor_patches AIE_RT_ROOT PATCH_DIR)
set(_sentinel ${AIE_RT_ROOT}/driver/src/io_backend/ext/xaie_amdair.c)
if(EXISTS ${_sentinel})
return()
endif()

file(GLOB _patches ${PATCH_DIR}/*.patch)
list(SORT _patches)
find_package(Git REQUIRED)
foreach(_patch ${_patches})
message(STATUS "Applying vendored aie-rt patch: ${_patch}")
execute_process(
COMMAND ${GIT_EXECUTABLE} apply ${_patch}
WORKING_DIRECTORY ${AIE_RT_ROOT}
RESULT_VARIABLE _patch_result
ERROR_VARIABLE _patch_error)
if(NOT _patch_result EQUAL 0)
message(FATAL_ERROR
"Failed to apply vendored aie-rt patch ${_patch}:\n${_patch_error}\n"
"If ${AIE_RT_ROOT} has local modifications, reset it with "
"'git -C ${AIE_RT_ROOT} checkout -- .' and re-run CMake.")
endif()
endforeach()
endfunction()
Comment on lines +304 to +306
+ read(value, buf, strlen(buf) + 1);
+ close(value);
+ *Data = strtoul(buf, 0, 0);
Comment on lines +497 to +506
+ UNUSED(IOInst);
+ UNUSED(RegOff);
+ UNUSED(Mask);
+ UNUSED(Value);
+ UNUSED(TimeOutUs);
+
+ XAIE_DBG("NPIMP: 0x%lx, 0x%x, 0x%x, 0x%d\n", AmdAirIOInst->NpiBaseAddr + RegOff,
+ Mask, Value, TimeOutUs);
+
+ return XAIE_OK;
Comment on lines +209 to +213
+ // recover sysfs path
+ if (!DevInst->IOInst) {
+ XAIE_ERROR("sysfs path not present!\n");
+ return XAIE_ERR;
+ }
@jgmelber jgmelber marked this pull request as draft July 13, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants