Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Consolidate program-scope variable init into one kernel (#582) - #1355

#1355
Open
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)#1355
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

@pvelesko

Copy link
Copy Markdown
Collaborator

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_all kernel (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

@pvelesko

Copy link
Copy Markdown
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
pvelesko force-pushed the fix-582-progvar-init-perf branch from d01596a to f9cc8a2 Compare July 24, 2026 20:02
@pvelesko

Copy link
Copy Markdown
Collaborator Author

/run-aurora-ci

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.

Program scope variable initialization is slow

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.