Skip to content

Fix stale device global initializers on RTC program reuse#21730

Open
kweronsx wants to merge 2 commits intosyclfrom
test/sycl-device-globals-fix-cuda-illegal-mem-addr
Open

Fix stale device global initializers on RTC program reuse#21730
kweronsx wants to merge 2 commits intosyclfrom
test/sycl-device-globals-fix-cuda-illegal-mem-addr

Conversation

@kweronsx
Copy link
Copy Markdown
Contributor

Prevent stale MDeviceGlobalInitializers entries from colliding with new entries when program handles are reused in RuntimeCompiled kernel loops. Implement explicit cleanup via removeDeviceGlobalInitializer() during program teardown.

Prevent stale MDeviceGlobalInitializers entries from colliding with new entries
when program handles are reused in RuntimeCompiled kernel loops. Implement
explicit cleanup via removeDeviceGlobalInitializer() during program teardown.
@kweronsx kweronsx requested a review from a team as a code owner April 10, 2026 12:05
@kweronsx kweronsx requested a review from sergey-semenov April 10, 2026 12:05
Copy link
Copy Markdown
Contributor

@sergey-semenov sergey-semenov left a comment

Choose a reason for hiding this comment

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

Please extend sycl/unittests/program_manager/Cleanup.cpp (or another unit test, if more appropriate) to cover this.

@kweronsx
Copy link
Copy Markdown
Contributor Author

This change is required to fix this test failure: https://github.com/intel/llvm/actions/runs/24240135791/job/70775597393?pr=21728

image

Please extend sycl/unittests/program_manager/Cleanup.cpp (or another unit test, if more appropriate) to cover this.

I have extended the sycl_device_globals test to catch this: (#21728)

Additional info:
When a program goes out of scope, its entry in the device global initializer map is now removed. Previously, if the adapter reused the same program handle for a newly created program, the stale entry (already marked as fully initialized) would be found by initializeDeviceGlobals and initialization would be silently skipped. This means device globals would retain stale state from the previous program lifetime. Now the entry is cleaned up on program teardown, so the next time the program is built and run — even inside a loop — its device globals are properly re-initialized.

@sergey-semenov
Copy link
Copy Markdown
Contributor

I have extended the sycl_device_globals test to catch this

That's an E2E test, but since we have a dedicated unit test for the cleanup mechanism when removing images, I think it should be updated to include this too.

@kweronsx kweronsx force-pushed the test/sycl-device-globals-fix-cuda-illegal-mem-addr branch 2 times, most recently from 593ea5c to da616c9 Compare April 13, 2026 10:05
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