Consolidate program-scope variable init into one kernel (#582) - #1355
#1355Open
pvelesko wants to merge 1 commit into
mainCHIP-SPV/chipStar:mainfrom
fix-582-progvar-init-perfCHIP-SPV/chipStar:fix-582-progvar-init-perfCopy head branch name to clipboard
Open
Consolidate program-scope variable init into one kernel (#582)#1355pvelesko wants to merge 1 commit intomainCHIP-SPV/chipStar:mainfrom fix-582-progvar-init-perfCHIP-SPV/chipStar:fix-582-progvar-init-perfCopy head branch name to clipboard
pvelesko wants to merge 1 commit into
mainCHIP-SPV/chipStar:mainfrom
fix-582-progvar-init-perfCHIP-SPV/chipStar:fix-582-progvar-init-perfCopy head branch name to clipboard
Conversation
Collaborator
Author
|
/run-aurora-ci |
Program-scope (__device__/__constant__) variable initialization launched one single-work-item shadow kernel per variable (__chip_var_init_<name>), so a module with N host-accessible globals paid O(N) kernel-launch overhead at first use. Emit a single combined init shadow kernel (__chip_var_init_all) that initializes all such variables in one launch, and launch it once from prepareDeviceVariablesNoLock. The per-variable init body (memcpy for plain data, or the runtime-constant store fallback for initializers referencing other lowered globals) is factored into emitGlobalVarInitBody and reused unchanged, so correctness is preserved. The combined kernel is emitted only in the default program-scope-globals lowering. The globals-as-kernel-args (rusticl) path keeps per-variable init kernels because lowerGlobalsToKernelArgs() reworks each into an address-argument kernel; the runtime falls back to the per-variable path when the combined kernel is absent. Warm first-use init+launch for 256 initialized globals on Intel Arc B570 (Level Zero) drops from ~42ms to ~26ms. Full dgpu level0 and opencl suites pass with no new failures.
pvelesko
force-pushed
the
fix-582-progvar-init-perf
branch
from
July 24, 2026 20:02
d01596a to
f9cc8a2
Compare
Collaborator
Author
|
/run-aurora-ci |
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.
Program-scope (device/constant) variable init launched one single-work-item shadow kernel per variable, costing O(N) launches at first module use. Consolidate them into a single
__chip_var_init_allkernel (reusing the existing runtime-constant-initializer pattern). Backend-agnostic; the rusticl globals-as-kernel-args path keeps per-variable kernels and the runtime auto-detects which to use.Validated on Arc B570: values correct across symbol/constant-memory tests; check.py 100% pass on level0 (1043) and opencl (1009); ~37% faster first-use init for 256 globals.
Note: a separate compile-time axis of #582 (a single large program-scope variable overflowing the SPIR-V translator) is not addressed here.
Closes #582