Skip to content

[SYCL] Proxy DLL Loader for Windows #7756

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

Closed

Conversation

cperkinsintel
Copy link
Contributor

DLLs manually loaded by SYCL are not tracked as direct dependencies in the same way that linked DLLs are. This means these DLL may be unloaded before SYCLs shutdown() routine is called, which will lead to problems when that routine tries to call those DLL to release resources. This PR adds a new proxy DLL that is a linked dependency of SYCL itself. This proxy DLL loads all the SYCL manually loaded DLLs early, before SYCL itself is loaded, and conversely, they are not unloaded until the proxy itself unloads, which is after SYCL unloads. So now the manually loaded plugin DLLs will be resident when shutdown() is called and piTearDown can complete safely and successfully.

Signed-off-by: Chris Perkins [email protected]

… the same way that llinked DLLs are. This means these DLL may be unloaded before SYCLs shutdown() routine is called, which will lead to problems when that routine tries to call those DLL to release resources. This PR adds a new proxy DLL that is a linked dependency of SYCL itself. This proxy DLL loads all the SYCL manually loaded DLLs early, before SYCL itself is loaded, and conversely, they are not unloaded until the proxy itself unloads, which is after SYCL unloads. So now the manually loaded plugin DLLs will be resident when shutdown() is called and piTearDown can complete safely and successfully.

Signed-off-by: Chris Perkins <[email protected]>
@cperkinsintel cperkinsintel marked this pull request as ready for review December 21, 2022 01:11
@cperkinsintel cperkinsintel requested review from a team as code owners December 21, 2022 01:11
@cperkinsintel cperkinsintel temporarily deployed to aws December 21, 2022 17:22 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws December 21, 2022 17:59 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel marked this pull request as draft December 22, 2022 03:01
@cperkinsintel
Copy link
Contributor Author

This was all working fine, but there have been other recent PRs that have touched the CMakeLists.txt files, and now this I'm seeing strange errors "Entry Point Not Found" in L0 once this is merged. Reverting to draft while I investigate.

@cperkinsintel cperkinsintel temporarily deployed to aws December 23, 2022 21:53 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws December 23, 2022 22:23 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel marked this pull request as ready for review January 2, 2023 17:53
@cperkinsintel
Copy link
Contributor Author

The fixes that have been merged for the unified runtime now fix the testing problems I was encountering. test suite is passing on Windows. Ready for review.

@cperkinsintel cperkinsintel temporarily deployed to aws January 2, 2023 18:21 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 2, 2023 18:51 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 14, 2023 00:44 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 14, 2023 01:17 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 15, 2023 18:14 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 16, 2023 00:19 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 17, 2023 22:38 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 18, 2023 04:44 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 18, 2023 17:54 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws January 18, 2023 18:26 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws February 1, 2023 06:20 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws February 1, 2023 06:53 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel marked this pull request as ready for review February 1, 2023 07:52
@cperkinsintel cperkinsintel temporarily deployed to aws February 1, 2023 08:16 — with GitHub Actions Inactive
@cperkinsintel cperkinsintel temporarily deployed to aws February 1, 2023 08:47 — with GitHub Actions Inactive
@cperkinsintel
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1465

@cperkinsintel cperkinsintel marked this pull request as draft February 2, 2023 18:24
@cperkinsintel
Copy link
Contributor Author

The basics of this PR were straightforward, but it was encountering a lot of test failures and it turns out the root cause of that is a difference seen on Windows in how threads may be terminated. This is a separate issue that is now better understood and I'm addressing. But this PR got twisted up chasing that problem. Because this PR never really made it out of draft, I'm closing it. The final work is a new PR which is here: #8242

againull pushed a commit that referenced this pull request Mar 1, 2023
DLLs manually loaded by SYCL are not tracked as direct dependencies in
the same way that linked DLLs are. This means these DLL may be unloaded
before SYCLs shutdown() routine is called, which will lead to problems
when that routine tries to call those DLL to release resources. This PR
adds a new proxy DLL that is a linked dependency of SYCL itself. This
proxy DLL loads all the SYCL manually loaded DLLs early, before SYCL
itself is loaded, and conversely, they are not unloaded until the proxy
itself unloads, which is after SYCL unloads. So now the manually loaded
plugin DLLs will be resident when shutdown() is called and piTearDown
can complete safely and successfully.

I had a previous PR for this work (
#7756 ), but it encountered
interference with a difference in how Windows handles threads and their
termination. I'm addressing that problem separately. In this version, I
am reducing the shutdown() procedure on Windows to only release the
plugins and nothing else. This avoids the issue for now.

Tests are at intel/llvm-test-suite#1465

---------

Signed-off-by: Chris Perkins <[email protected]>
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