Skip to content

[SYCL] Keep kernel compiler resources alive during static destruction - #23617

Draft
againull wants to merge 1 commit into
intel:syclfrom
againull:kernel_compiler_lifetime
Draft

againull wants to merge 1 commit into
intel:syclfrom
againull:kernel_compiler_lifetime

Conversation

@againull

Copy link
Copy Markdown
Contributor

Kernel bundles built from SYCL source can be stored in global or static caches and released after main() returns.

Before:

  • Destroying a cached source-built bundle at process exit could abort in ProgramManager::removeImages() because its image tables had already been freed by the runtime jit_compiler destructor.
  • The runtime jit_compiler and the JIT library's JITContext were function-local static objects. When initialized after the user's cache, they could be destroyed first, leaving bundle cleanup with dangling image descriptors and an already-destroyed binary registry.

After:

  • GlobalHandler owns the runtime jit_compiler and releases it after ProgramManager during late runtime shutdown, keeping image tables valid throughout user static destruction.
  • On non-Windows platforms, allocate JITContext lazily on the heap and delete it from a late JIT-library unload handler instead of ordinary static destruction. Cached bundles can unregister their images and destroy their code blobs while both owners are still alive.

Add a regression test for both ordinary bundle destruction and cleanup from a static cache. Executing cached kernels in the cache destructor provides an additional check that the resources remain usable.

Assisted-by: OpenCode (OpenAI GPT-6.1)

Kernel bundles built from SYCL source can be stored in global or static
caches and released after main() returns.

Before:
- Destroying a cached source-built bundle at process exit could abort in
  ProgramManager::removeImages() because its image tables had already
  been freed by the runtime jit_compiler destructor.
- The runtime jit_compiler and the JIT library's JITContext were
  function-local static objects. When initialized after the user's cache,
  they could be destroyed first, leaving bundle cleanup with dangling
  image descriptors and an already-destroyed binary registry.

After:
- GlobalHandler owns the runtime jit_compiler and releases it after
  ProgramManager during late runtime shutdown, keeping image tables valid
  throughout user static destruction.
- On non-Windows platforms, allocate JITContext lazily on the heap and
  delete it from a late JIT-library unload handler instead of ordinary
  static destruction. Cached bundles can unregister their images and
  destroy their code blobs while both owners are still alive.

Add a regression test for both ordinary bundle destruction and cleanup
from a static cache. Executing cached kernels in the cache destructor
provides an additional check that the resources remain usable.

Assisted-by: OpenCode (OpenAI GPT-6.1)

This branch has not been deployed

No deployments
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.

1 participant