Skip to content

Add: [Context Prepare] prepare and freeze kernel resources - #2173

Closed
TaoZQY wants to merge 1 commit into
hw-native-sys:mainfrom
TaoZQY:codex/hbg-pr-context-resources
Closed

TaoZQY wants to merge 1 commit into
hw-native-sys:mainfrom
TaoZQY:codex/hbg-pr-context-resources

Conversation

@TaoZQY

@TaoZQY TaoZQY commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Move kernel device capacity ownership into context resource preparation. Allocate one aligned heap and one packed runtime arena, with Definition and scheduler slices, then freeze their addresses and capacities. Launch binding only checks context identity and required sizes before borrowing existing addresses.

Preserve platform allocator accounting and retain ownership after rollback or close failures so cleanup can be retried. Context stream creation distinguishes dedicated non-hidden AICPU from hidden AICore; caller remains a separate borrowed stream.

Validation

  • Both HBG C++ suites passed (32 cases per architecture), together with context and contract tests at this milestone.
  • Full rebased stack at H3 Add: [H3] seal and validate HBG execution slots #2175: 147 C++ test executables and 159 Python tests passed (4 hardware-marked skips), covering ABI, task interfaces and simulator DMA workspace.
  • Full-stack simulation with the pinned PTO ISA required: A2/A3 74 passed, 8 skipped; A5 71 passed.
  • Runtime libraries rebuilt; repository pre-commit checks passed. Each earlier milestone was independently compiled and tested.
  • mkdocs build --strict passed separately at all five PR heads. The HBG contract page is included in navigation from H1; the execution-slot page is included from H3.

Public K1 owner integration remains pending. Context close requires external quiescence and captured-graph lifetime ordering; these resource helpers do not introduce hidden synchronization.

Dependency and review scope

Draft 3/5: Context prepare/freeze. Depends on #2172.

This draft is rebased onto main at a1aa7fddf42b2d28849bc3fb6fe1eb50ab891324 and squashed to one commit. The rebase retains the upstream documentation-theme update. Source and test files match the previous PR head exactly; the squash preserves the complete rebased tree. Applicable pre-commit checks passed again.

All five HBG drafts target main. Each PR has exactly one commit, containing K1 plus all HBG milestones through the stage in its title. Squashing changes commit history, not the cumulative code scope. The original isolated diff above remains available to review this stage alone. Rebase in dependency order after prerequisites land.

The K1 snapshot originally carried from 21fb15c0 is included in this squashed commit, with its human author retained as co-author. Upstream #2064 remains open and has advanced; alignment with its final version remains public execution integration work.

No idle onboard devices were available. Simulation golden checks cover existing program-mode regression; mixed ACLGraph capture/replay, DSV4 CSA device accuracy and comparative performance remain unvalidated.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

Make the kernel context own an aligned heap and packed runtime arena,
including Definition and scheduler regions. Prepare capacity once and
freeze it explicitly; launch binding only validates identity and sizes
before borrowing existing addresses.

Preserve ownership on failed allocation rollback or close for retry, and
retain platform allocator accounting. Distinguish dedicated AICPU and
hidden AICore stream creation and their completion events.

Test capacity boundaries, lifecycle, allocator failures, close retry and
concurrent preparation on both HBG architectures.

Include the kernel-mode C ABI, state and invocation headers required
by this implementation. Retain the preceding HBG resource and packet
changes present in this draft where applicable. Public kernel launch
integration remains pending.

Co-authored-by: sunkaixuan2018 <baiyi@mail.ustc.edu.cn>
@TaoZQY TaoZQY changed the title Add: prepare and freeze kernel context device resources Add: [Context Prepare] prepare and freeze kernel resources Sep 10, 2026
@ChaoWao

ChaoWao commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

关闭:交付路线已替代(superseded)

根据维护者确认,关闭这份旧 kernel-mode PR。

**原因:**这份累计的 HBG prepare/freeze 旧栈已被 #2216 的集成线吸收;后续资源与初始化合同又在那里继续演进。当前 main 的执行与发布边界已经不同,不继续将此累计快照作为独立合入单元。

**仍需保留/迁移:**保留资源规划、对齐/容量预检、冻结地址及失败后保有资源的机制和测试;后续接当前共同执行层的 owner、容量与退休合同。

当前确定路线是 Pipeline A → kernel eager → capture/replay:两种资源模式接共同执行与退休层,每次 eager 重新准备并提交一次。集成分支中的采用不等于已合入 main,也不代表本 PR 的全部目标已交付。

本次只关闭旧 PR,保留分支、提交、作者贡献、测试及实验记录,供后续按能力迁移。

本次核查 head:15741ac05b24908c71703c72f2549f5fe0e9fa53;main 基线:2d3661517

@ChaoWao ChaoWao closed this Sep 19, 2026
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