Skip to content

[SYCL] default context as default on windows #12599

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

Merged

Conversation

cperkinsintel
Copy link
Contributor

Now that there have been improvements to Windows shutdown made by the proxy loader, host task handling, and the unified runtime, we are finally able to have Windows support a "default" context. This makes any routine that loops over queue creation, etc perform much faster.

Note that on Windows the UR L0 Leak check does not work correctly with the default contexts on Windows. This is because on Windows the release of the plugin DLLs races against the release of static global variables (like the default context). This has been reported.

The tests that use this feature have been modified to use a new %{l0_leak_check} substitution that will NOT use default context on Windows.

Copy link
Contributor

github-actions bot commented Feb 3, 2024

✅ With the latest revision this PR passed the Python code formatter.

Copy link
Contributor

github-actions bot commented Feb 3, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@cperkinsintel cperkinsintel changed the title [WIP][SYCL] default context as default on windows [SYCL] default context as default on windows Feb 6, 2024
@cperkinsintel cperkinsintel marked this pull request as ready for review February 6, 2024 22:00
@cperkinsintel cperkinsintel requested review from a team as code owners February 6, 2024 22:00
…ced it when resolving merge conflicts. Removing it from this PR
Comment on lines -233 to -244
#else
// Windows does not maintain dependencies between dynamically loaded libraries
// and can unload SYCL runtime dependencies before sycl.dll's DllMain has
// finished. To avoid calls to nowhere, intentionally leak platform to device
// cache. This will prevent destructors from being called, thus no PI cleanup
// routines will be called in the end.
// Update: the pi_win_proxy_loader addresses this for SYCL's own dependencies,
// but the GPU device dlls seem to manually load yet another DLL which may
// have been released when this function is called. So we still release() and
// leak until that is addressed. context destructs fine on CPU device.
MPlatformToDefaultContextCache.Inst.release();
#endif
Copy link
Contributor

@againull againull Feb 8, 2024

Choose a reason for hiding this comment

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

Do I get it right that you have to modify all the tests because this workaround is removed? Do we have to remove it to make default context as default?

Copy link
Contributor Author

@cperkinsintel cperkinsintel Feb 12, 2024

Choose a reason for hiding this comment

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

This workaround (or not) has no bearing on the leak check itself. If Windows uses a default context, the leak check races and may report leaks. If Windows does not use a default context, it doesn't.
But the call here to .release() vs. .reset() DOES determine whether the default context (if one exists) ACTUALLY leaks or not. We want .reset() so that it is actually destroyed, otherwise it leaks.
And we want the behavior Lin vs Win to the same ( as much as we can manage ) so it is easier to think about.

Copy link
Contributor

@kbenzie kbenzie left a comment

Choose a reason for hiding this comment

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

UR LGTM

Copy link
Contributor

@mfrancepillois mfrancepillois left a comment

Choose a reason for hiding this comment

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

Sycl-Graph LGTM

Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

sycl/test-e2e/Graph/RecordReplay/usm_memset_shortcut.cpp which just merged in #12508 will need UR_L0_LEAKS_DEBUG=1 updated too

@cperkinsintel
Copy link
Contributor Author

@intel/sycl-graphs-reviewers - ping for review. This touches the //RUN directive of many of your tests, but just changing the LEAK check to a placeholder.

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.

5 participants