Refactor: drop vestigial orch_built_on_host flag#766
Merged
poursoul merged 1 commit intoMay 13, 2026
Conversation
`Runtime::orch_built_on_host_` distinguished the host-built-graph runtime from the (removed) aicpu_build_graph one. With only host_build_graph and tensormap_and_ringbuffer left, the flag is a per-runtime constant: - host_build_graph hard-coded `get_orch_built_on_host()` to `true` and, since hw-native-sys#760 removed the last platform-layer caller, nothing reads it — delete it. - tensormap_and_ringbuffer always sets it to `false` in bind_prepared_to_runtime_impl (the runtime ctor's `= true` was overwritten before any reader saw it), so every `get_orch_built_on_host()` site there takes the device-orchestration branch. Inline that: drop the field, getter, setter; the AICPU executor's "host orchestration, no-op" dead branch becomes a plain scope; the SM-header spin-wait and the rt-destroy guard lose their always-true `!get_orch_built_on_host()` prefix; the scheduler's `orchestrator_done_` init becomes a literal `false`. No behavior change — every removed branch was statically unreachable.
There was a problem hiding this comment.
Code Review
This pull request removes the orch_built_on_host flag and its associated logic from the a2a3 and a5 runtimes, simplifying the AicpuExecutor and scheduler by consolidating the orchestration path. Review feedback suggests implementing RAII guards or try-catch blocks for resources like dlopen handles within the refactored orchestration scopes to prevent potential resource leaks.
poursoul
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Runtime::orch_built_on_host_used to distinguish the host-built-graph runtimefrom the (since removed, #701)
aicpu_build_graphone. With onlyhost_build_graphandtensormap_and_ringbufferleft it is a per-runtimeconstant, and after #760 removed the last platform-layer caller it is also
unreferenced outside the runtime internals. This drops it:
host_build_graph(a2a3 + a5):get_orch_built_on_host()was hard-codedto
trueand has no callers — deleted.tensormap_and_ringbuffer(a2a3 + a5):bind_prepared_to_runtime_implunconditionally sets the flag to
falsebefore the runtime struct reachesany reader (the ctor's
= truewas always overwritten first), so everyget_orch_built_on_host()site already took the device-orchestration path.Inlined that:
orch_built_on_host_field + getter + setter (runtime.h,runtime/shared/runtime.cpp) and theset_orch_built_on_host(false)callin
host/runtime_maker.cpp;aicpu/aicpu_executor.cpp: theif (get_orch_built_on_host()) { /* host orchestration, no-op */ } else { ... }becomes a plain scope (kept as ablock so the per-callable dlopen / SO-table locals stay scoped); the
SM-header spin-wait and the
rt-destroy guard lose their always-true!get_orch_built_on_host()prefix;runtime/scheduler/scheduler_cold_path.cpp:orchestrator_done_initbecomes a literal
false.No behavior change — every removed branch was statically unreachable.
Testing
libhost_runtime.so(both runtimes) rebuild cleanly;pre-commit (clang-format, clang-tidy, cpplint) passes.
tensormap_and_ringbufferST (e.g. an AICPU-orchexample) still runs to completion — the touched code is the AICPU
executor's orchestrator/scheduler path.