[SYCL] Please stop using global destructors.
- Dominant language
- LLVM
- Stars
- 1.5k
- Forks
- 854
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 137
Description
**Is your feature request related to a problem? Please describe**
Currently the SYCL runtime uses global destructors (https://github.com/intel/llvm/blob/sycl/sycl/source/detail/global_handler.cpp).
global destructors a generally bad for composability since there is no reliable way to ensure the order in which destructors run across translation units.
if a user were to have some SYCL code running a in a global destructor or if a backend (wrongfully) uses global destructors. The SYCL application may or may not work depending on the destruction order.
**Describe the solution you would like**
I would like the SYCL runtime to keep creating the GlobalHandler on demand, but store in via shared_ptr it each SYCL object and destruct it when the last SYCL object is destructed.
the only negative consequences I can see is that if an SYCL application destroys every SYCL object and then start creating SYCL objects again. The SYCL runtime would have to initialize the global state again. but I expect that it is rare to have such applications.
Contributor guide
Assessment
This issue has not been assessed yet.