Skip to content

[cert] Add page/section-based CERT lowering#3253

Open
fifield wants to merge 6 commits into
mainfrom
update-cert
Open

[cert] Add page/section-based CERT lowering#3253
fifield wants to merge 6 commits into
mainfrom
update-cert

Conversation

@fifield

@fifield fifield commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Adopt a page-based CERT representation in the AIEX dialect and lower aie.runtime_sequence into it for emission to uC control code.

  • CERTOps.td: add CertPageOp, CertSectionOp, CertPreemptOp, CertLoadPdiOp; widen CertJobOp parents to pages/sections.
  • AIENpuToCert (aie-npu-to-cert): page-based lowering with Run-op inlining, Configure->Section, page wrapping/splitting (fixes the page-split infinite loop), and PDI-id assignment.
  • AIETargetUcCert (aie-cert-to-asm): emit page/section/preempt/load_pdi and a .partition header; outputPath plumbing.
  • Tests (npu2): page_legalize, split_blockwrite, cert_to_asm.

The lowering and emission are device-neutral and exercised on npu2 via aie-opt/aie-translate. CERT full-ELF generation in aiecc and the AIE2PS/AIE4 device glue depend on a CERT-capable device target that is not yet upstream; they are deferred to land alongside device enablement.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Created: 2026-07-13 23:20

Click here for information about interpreting this report.

FilenameFunction CoverageLine CoverageRegion CoverageBranch Coverage
home/runner/work/mlir-aie/mlir-aie/lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp 72.22% 61.83% 55.53% 46.56%
Totals 72.22% 61.83% 55.53% 46.56%
Generated by llvm-cov -- llvm version 18.1.3

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 updates the AIEX CERT pipeline to use a page/section-based CERT IR, lowers aie.runtime_sequence into that representation (including configurecert.section + cert.load_pdi), and extends the uC CERT emitter to output pages/sections and the new CERT opcodes.

Changes:

  • Add page/section/PDI/preempt CERT ops and update CERT job parenting to support page/section structure.
  • Rework -aie-npu-to-cert to produce page-wrapped jobs, absorb referenced devices into cert.section, and add PDI-id assignment + Run-op inlining.
  • Update aie-cert-to-asm emission for pages/sections and add new tests for page legalization, blockwrite splitting, and CERT-to-asm output.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/Targets/NPU/cert_to_asm.mlir New translation test covering aie-cert-to-asm output formatting and emitted chain/data.
test/Targets/AIETargetUcCert/split_blockwrite.mlir New test for blockwrite splitting behavior as part of -aie-npu-to-cert.
test/Targets/AIETargetUcCert/page_legalize.mlir New test input for page-legalization / splitting behavior.
test/Conversion/NpuToCert/split_blockwrite.mlir Adjust FileCheck ordering for split globals vs BD emission.
lib/Targets/AIETargetUcCert.cpp Add emission for pages/sections/load_pdi/preempt; add outputPath plumbing and .partition header.
lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp Major rewrite of lowering to page-based CERT, including device absorption and legalization patterns.
include/aie/Targets/AIETargets.h Extend AIETranslateToUcDma API with optional outputPath.
include/aie/Dialect/AIEX/Transforms/AIEXPasses.td Change aie-npu-to-cert to a ModuleOp pass and add --device-name option.
include/aie/Dialect/AIEX/Transforms/AIEXPasses.h Update pass factory signature for the ModuleOp pass.
include/aie/Dialect/AIEX/IR/CERTOps.td Add cert.page, cert.section, cert.load_pdi, cert.preempt and widen cert.job parents.
Comments suppressed due to low confidence (1)

lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp:928

  • SplitNpuBlockWriteOpPattern is applied to getOperation() (the whole module) even though processDevice() is intended to operate on one device at a time. This can rewrite other devices earlier than intended, and the failure path doesn't return after signalPassFailure(), so the pass may continue in a failed state. Apply the pattern to currentDevice and return on failure.
    // Split oversized NpuBlockWriteOps before lowering them to cert ops
    {
      RewritePatternSet p(&getContext());
      p.insert<SplitNpuBlockWriteOpPattern>(&getContext());
      if (failed(applyPatternsGreedily(getOperation(), std::move(p))))
        signalPassFailure();

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

Comment thread lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp
Comment thread lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp
Comment thread lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp
Comment thread lib/Dialect/AIEX/Transforms/AIENpuToCert.cpp
Comment thread lib/Targets/AIETargetUcCert.cpp
Comment thread lib/Targets/AIETargetUcCert.cpp
@fifield fifield force-pushed the update-cert branch 4 times, most recently from c04b4a8 to 7a5f26c Compare July 13, 2026 15:24
@fifield fifield marked this pull request as ready for review July 13, 2026 16:00
fifield and others added 6 commits July 13, 2026 16:56
…emission

Adopt the page-based CERT representation in the AIEX dialect and lower
aie.runtime_sequence into it for emission to uC control code.

- CERTOps.td: add CertPageOp, CertSectionOp, CertPreemptOp, CertLoadPdiOp;
  widen CertJobOp parents to pages/sections.
- AIENpuToCert (aie-npu-to-cert): page-based lowering with Run-op inlining,
  Configure->Section, page wrapping/splitting (fixes the page-split infinite
  loop), and PDI-id assignment.
- AIETargetUcCert (aie-cert-to-asm): emit page/section/preempt/load_pdi and a
  .partition header; outputPath plumbing.
- Tests (npu2): page_legalize, split_blockwrite, cert_to_asm.

The lowering and emission are device-neutral and exercised on npu2 via
aie-opt/aie-translate. CERT full-ELF generation in aiecc and the AIE2PS/AIE4
device glue depend on a CERT-capable device target that is not yet upstream;
they are deferred to land alongside device enablement.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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