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

Make sure ext_oneapi_get_default_context doesn't broke runtime on windows #2742

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

anmyachev
Copy link
Contributor

@anmyachev anmyachev commented Nov 18, 2024

Part of #2478 (to reduce diff)

These are quite stable changes, we can merge it without CI on Windows. @gshimansky if you don't mind.

@anmyachev anmyachev marked this pull request as ready for review November 18, 2024 22:03
@@ -194,8 +194,18 @@ static PyObject *loadBinary(PyObject *self, PyObject *args) {
const size_t binary_size = PyBytes_Size(py_bytes);

uint8_t *binary_ptr = (uint8_t *)PyBytes_AsString(py_bytes);
const auto ctx =
sycl_device.get_platform().ext_oneapi_get_default_context();
auto platform = sycl_device.get_platform();
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have exceptions in this code block - but I suppose I might feel better if this was in a free function that had compile time definitions for windows (where we need the exception handling) and linux (where we don't).

Also, how can the code properly run with no valid context? What if a valid context is thrown on linux?

(I realize I probably approved the Windows PR that has this change but missed the details over there - maybe we should split some other changes out of the Windows PR for a more thorough individual review).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Also, how can the code properly run with no valid context?

This is a explanation for Windows case: https://github.com/intel/intel-xpu-backend-for-triton/pull/2478/files#r1844125901

@gshimansky
Copy link
Contributor

I found how pytorch implements the same functionality on Linux and Windows. You may want to take a look.
https://github.com/pytorch/pytorch/blob/main/c10/xpu/XPUFunctions.cpp#L59-L72

@anmyachev
Copy link
Contributor Author

I found how pytorch implements the same functionality on Linux and Windows. You may want to take a look. https://github.com/pytorch/pytorch/blob/main/c10/xpu/XPUFunctions.cpp#L59-L72

This is interesting, but it will also require us to implement enumDevices function https://github.com/pytorch/pytorch/blob/0c7c5d78faa61245700ba6f2d0c237019090f684/c10/xpu/XPUFunctions.cpp#L30. Let's leave the current version for now, since it works, and open an issue on how this can be improved.

@anmyachev
Copy link
Contributor Author

@alexbaden ready for review

Copy link
Contributor

@alexbaden alexbaden left a comment

Choose a reason for hiding this comment

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

looks fine for now

@anmyachev anmyachev merged commit 29d27d7 into main Nov 19, 2024
4 checks passed
@anmyachev anmyachev deleted the amyachev/def-ctx branch November 19, 2024 15:02
@anmyachev
Copy link
Contributor Author

#2757

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.

3 participants