name: kernelcodegen description: AIE kernel code generation, compilation, and (optional) testing for the aiehlc flow. Use when you need to (1) Generate kernel C++ (kernel.cc, compute_kernel.cc) from the MLIR unitest pipeline, (2) Compile the kernel to an AIE kernel ELF with xchesscc/xchessmk, (3) Bypass or run kernel tests on HW. Complements hostcodegen (host side); kernel runs on AIE tiles.
Kernelcodegen
This skill drives the generate → compile → (optional) test loop for aiehlc AIE kernel code.
Workflow
Generate: Build the unitest, run
./test(e.g. dfschedule). Outputs:worklocal/kernel.cc. Same generation step as host; both host.cc and kernel.cc are produced. Kernel dfschedule is generated by passblueprinttoschedulekernel (passblueprinttoschedulekernel.cpp); passdfscheduletokernelapi (passdfscheduletokernelapi.cpp) is in charge of kernel.cc generation (schedule → EmitC → C++).worklocal/compute_kernel.ccis a pre-existing file (hand-written) for now. Files involved and full pass flow: references/codegen-flow.md. Paths: references/project-layout.md.Compile: Kernel-only build via
KERNEL_ONLY=1 source script/hostcompile.sh(thecompile_one_kernelfunction; run withWORKLOCAL_DIRpointing at worklocal). Uses xchesscc (kernel.cc → LLVM IR; kernel.cc may include pre-existingcompute_kernel.cc), opt (xlopt), xchessmk (link with aie2ps.prx). ELF output:worklocal/build/kernel. For env and options see references/compile-env.md.Test (bypass for now): Kernel-on-HW testing can be bypassed. When needed later, see references/testing.md.
Bug fix
- Codegen error → Fix MLIR passes: BlueprintToScheduleKernelPass, DfscheduleToKernelApiPass; unitest driver in
src/mlir/mlirfront/tilinglinalg/pass/unitest/test.cpp(kernel module emit to kernel.cc). See references/codegen-flow.md for the full pass sequence. - Compile error → Fix
compile_one_kernel/kc.shincludes, xchesscc flags, or aie2ps.prx; ensure kernel.cc and compute_kernel.cc (if used) are consistent with AIE API.
Resources
| When | File |
|---|---|
| Paths for unitest, worklocal, kernel.cc, scripts | references/project-layout.md |
| Pass pipeline that generates kernel.cc (blueprint → kernel API → EmitC) | references/codegen-flow.md |
| setup.sh, XILINX_VITIS, xchesscc/xchessmk, compile errors | references/compile-env.md |
| Kernel testing (bypass / future) | references/testing.md |