Skip to content

feat(codegen): codegen support for system.bar_{all,v,m} - #2240

Open
Shenggan wants to merge 2 commits into
hw-native-sys:mainfrom
Shenggan:feat/pto-barrier-codegen
Open

feat(codegen): codegen support for system.bar_{all,v,m}#2240
Shenggan wants to merge 2 commits into
hw-native-sys:mainfrom
Shenggan:feat/pto-barrier-codegen

Conversation

@Shenggan

Copy link
Copy Markdown

Summary

This PR adds PTO codegen support for the sync ops below:

  • system.bar_all -> pto.barrier <PIPE_ALL>
  • system.bar_v -> pto.barrier <PIPE_V>
  • system.bar_m -> pto.barrier <PIPE_M>

It also adds unit tests to verify the emitted MLIR and updates the IR operator docs to describe the exact PTO lowering.

Motivation

system.bar_all, system.bar_v, and system.bar_m are already exposed at the IR / Python API level, but PTO backend codegen did not yet register these ops.

This change closes that gap so these sync ops lower cleanly during PTO codegen and have explicit test coverage.

Changes

  • register system.bar_all, system.bar_v, and system.bar_m in PTO backend codegen
  • lower them to:
    • pto.barrier <PIPE_ALL>
    • pto.barrier <PIPE_V>
    • pto.barrier <PIPE_M>
  • add codegen unit tests for all three barrier ops
  • update English and Chinese IR operator docs with the exact lowering forms

Testing

Added unit tests covering:

  • pl.system.bar_all() emits pto.barrier <PIPE_ALL>
  • pl.system.bar_v() emits pto.barrier <PIPE_V>
  • pl.system.bar_m() emits pto.barrier <PIPE_M>

Copilot AI review requested due to automatic review settings July 31, 2026 11:17

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 31036213-0198-4f30-9320-2d4ed661f83a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change adds PTO code generation for system.bar_all, system.bar_v, and system.bar_m. Tests verify their pipeline scopes. English and Chinese IR documentation now describe the lowering targets.

Changes

PTO barrier lowering

Layer / File(s) Summary
Register and validate barrier lowering
src/backend/common/pto_ops_memory.cpp, tests/ut/codegen/test_pto_codegen_ops.py, docs/en/dev/ir/05-operators.md, docs/zh/dev/ir/05-operators.md
The backend registers no-argument barriers for PIPE_ALL, PIPE_V, and PIPE_M. Code-generation tests verify the emitted MLIR. Both documentation files describe the corresponding PTO barriers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit hops through barriers three,
PIPE_ALL, PIPE_V, PIPE_M with glee.
The MLIR marks each proper lane,
Tests check the paths again and again.
Docs now tell the tale clearly.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: PTO codegen support for the three system barrier operations.
Description check ✅ Passed The description directly explains the codegen changes, lowering targets, tests, and documentation updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8def295d9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +888 to +889
register_pipe_barrier("system.bar_v", "PIPE_V");
register_pipe_barrier("system.bar_m", "PIPE_M");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Set core affinity for pipe-specific barriers

When these newly lowered ops appear in mixed InCore kernels, the split pass still sees system.bar_v/system.bar_m as no-arg ops with no explicit IR core affinity, so ClassifyCallAffinity falls through to SHARED and BuildCoreBody keeps the statement on both AIC and AIV lanes. That means pl.system.bar_m() can emit pto.barrier <PIPE_M> in the AIV function, and pl.system.bar_v() can be duplicated into the AIC function; set the IR op entries to CoreAffinity::VECTOR/CoreAffinity::CUBE (or classify them specially) before exposing the PTO lowering.

Useful? React with 👍 / 👎.

Copilot AI review requested due to automatic review settings August 3, 2026 07:29

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants