Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate .def file with all UR entry points #2045

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

callumfare
Copy link
Contributor

@callumfare callumfare commented Sep 4, 2024

This was necessary for intel/llvm#15262 - it allows defining macros over every function in the API

@omarahmed1111 omarahmed1111 added the v0.10.x Include in the v0.10.x release label Sep 4, 2024
@callumfare callumfare marked this pull request as ready for review September 4, 2024 13:49
@callumfare callumfare requested a review from a team as a code owner September 4, 2024 13:49
@omarahmed1111 omarahmed1111 added the ready to merge Added to PR's which are ready to merge label Sep 4, 2024
@omarahmed1111 omarahmed1111 merged commit 229869c into oneapi-src:main Sep 4, 2024
72 checks passed
aarongreig pushed a commit to aarongreig/unified-runtime that referenced this pull request Sep 4, 2024
Generate .def file with all UR entry points
martygrant pushed a commit to intel/llvm that referenced this pull request Sep 6, 2024
The issues with DLLs and teardown of global objects on Windows is well
documented, and was the reason for the use of the `pi_win_proxy_loader`
library in SYCL-RT. When we ported from PI to UR, we ported this library
(it's now called `ur_win_proxy_loader`), but it was not actually fully
utilized. SYCL-RT still linked with `ur_loader.dll` and still
experienced issues with race conditions in the teardown of SYCL-RT and
Unified Runtime. See #14768.

This PR reintroduces the proxy loader as it was previously used with PI.
The UR loader (`ur_loader.dll`) is loaded via `LoadLibraryEx` at
initialization, and is therefore not cleaned up too early for normal
teardown to occur.

This necessitates changing the signature of `Plugin->call` to look like
it did with PI, taking an enum template argument to specify which UR
entry point to call.

On Windows, when each plugin (which is a wrapper over a UR adapter) is
loaded, it populates a table of function pointers to each API entry
point in the UR loader. When UR entry points are called, the function
pointer is retrieved from the table. This is more or less equivalent to
the previous PI implementation.

On Linux, the UR loader is dynamically linked as before. The
`Plugin->call` methods just use the regular UR functions rather than
programmatically looking up the symbols.

For the unittest executables, the UR loader is still dynamically linked
as before to avoid having to introduce noisy changes to the tests, and
since we aren't concerned about teardown issues there.

The implementation of these changes in the runtime should avoid as much
overhead as possible (and be no worse than PI), but suggestions on how
to improve and tidy things are more than welcome.

Associated UR change:
oneapi-src/unified-runtime#2045
AlexeySachkov pushed a commit to AlexeySachkov/llvm that referenced this pull request Nov 27, 2024
The issues with DLLs and teardown of global objects on Windows is well
documented, and was the reason for the use of the `pi_win_proxy_loader`
library in SYCL-RT. When we ported from PI to UR, we ported this library
(it's now called `ur_win_proxy_loader`), but it was not actually fully
utilized. SYCL-RT still linked with `ur_loader.dll` and still
experienced issues with race conditions in the teardown of SYCL-RT and
Unified Runtime. See intel#14768.

This PR reintroduces the proxy loader as it was previously used with PI.
The UR loader (`ur_loader.dll`) is loaded via `LoadLibraryEx` at
initialization, and is therefore not cleaned up too early for normal
teardown to occur.

This necessitates changing the signature of `Plugin->call` to look like
it did with PI, taking an enum template argument to specify which UR
entry point to call.

On Windows, when each plugin (which is a wrapper over a UR adapter) is
loaded, it populates a table of function pointers to each API entry
point in the UR loader. When UR entry points are called, the function
pointer is retrieved from the table. This is more or less equivalent to
the previous PI implementation.

On Linux, the UR loader is dynamically linked as before. The
`Plugin->call` methods just use the regular UR functions rather than
programmatically looking up the symbols.

For the unittest executables, the UR loader is still dynamically linked
as before to avoid having to introduce noisy changes to the tests, and
since we aren't concerned about teardown issues there.

The implementation of these changes in the runtime should avoid as much
overhead as possible (and be no worse than PI), but suggestions on how
to improve and tidy things are more than welcome.

Associated UR change:
oneapi-src/unified-runtime#2045
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Added to PR's which are ready to merge v0.10.x Include in the v0.10.x release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants