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

[SYCL][HIP] Implemented supported make_* interop functions. #10526

Merged
merged 16 commits into from
Aug 30, 2023

Conversation

JackAKirk
Copy link
Contributor

@JackAKirk JackAKirk commented Jul 21, 2023

This PR adds missing functions in the hip backend to allow for interoperability in programs that create sycl objects from native hip objects. The new function implementations are:

  • make_device
  • make_queue
  • make_event

Note that it would really make sense for #10491 to be merged first because this PR makes the same code change in pi2ur, for a fix that is attributed to #10491.

Jack Kirk added 7 commits July 17, 2023 10:53
Signed-off-by: Jack Kirk <[email protected]>
Signed-off-by: Jack Kirk <[email protected]>
Signed-off-by: Jack Kirk <[email protected]>
urDeviceCreateWithNativeHandle can never be reached in the hip backend
(see comment in code) so I removed the impl I added earlier.

Signed-off-by: Jack Kirk <[email protected]>
Signed-off-by: Jack Kirk <[email protected]>
Signed-off-by: Jack Kirk <[email protected]>
@JackAKirk JackAKirk temporarily deployed to aws July 21, 2023 16:28 — with GitHub Actions Inactive
@JackAKirk JackAKirk marked this pull request as ready for review July 21, 2023 16:41
@JackAKirk JackAKirk requested review from a team as code owners July 21, 2023 16:41
@JackAKirk JackAKirk temporarily deployed to aws July 21, 2023 17:07 — with GitHub Actions Inactive
@JackAKirk JackAKirk temporarily deployed to aws July 25, 2023 10:03 — with GitHub Actions Inactive
@JackAKirk JackAKirk temporarily deployed to aws July 25, 2023 10:41 — with GitHub Actions Inactive
@@ -310,7 +322,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetNativeHandle(
///
/// \return UR_RESULT_ERROR_UNSUPPORTED_FEATURE
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed that I should update this function descriptor. Will do this following review.

}
// HIP uses a 32-bit int instead of an opaque pointer like other backends,
// so we need a specialization with static_cast instead of reinterpret_cast.
return static_cast<backend_return_t<backend::ext_oneapi_hip, device>>(
Obj.getNative());
}

template <>
inline device make_device<backend::ext_oneapi_hip>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this code unique to HIP?

Copy link
Contributor Author

@JackAKirk JackAKirk Jul 25, 2023

Choose a reason for hiding this comment

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

There are a hierarchy of reasons. Firstly if we want to unique devices (#6055) like in the cuda backend, #7550 , then the code is unique to HIP (since the cuda implementation is in the experimental namespace). If we chose to not unique the device, then we would still need the code to be unique to hip, since, like the cuda backend, we would need to static_cast between pi_native_handle and backend_input_t<backend::ext_oneapi_cuda, device> since the default make_device uses reinterpret_cast which does not work.

Comment on lines 20 to 21
throw sycl::exception(make_error_code(errc::backend_mismatch),
"Backends mismatch");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we can do that outside ABI breaking window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I can revert this. Thanks.

@aelovikov-intel
Copy link
Contributor

SYCL RT part is LGTM (I'll approve after minor revert mentioned above is pushed here). Haven't looked into anything under plugins/ - I expect UR reviewers to do that.

Update comments.

Signed-off-by: Jack Kirk <[email protected]>
@JackAKirk JackAKirk temporarily deployed to aws July 25, 2023 18:58 — with GitHub Actions Inactive
@JackAKirk JackAKirk temporarily deployed to aws July 25, 2023 19:42 — with GitHub Actions Inactive
@JackAKirk JackAKirk requested a review from a team as a code owner August 11, 2023 11:31
Copy link
Contributor

@jandres742 jandres742 left a comment

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

@npmiller npmiller left a comment

Choose a reason for hiding this comment

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

LGTM

@JackAKirk
Copy link
Contributor Author

@sergey-semenov could you review this please? Thanks

Copy link
Contributor

@sergey-semenov sergey-semenov left a comment

Choose a reason for hiding this comment

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

Non-blocking nitpick, feel free to apply separately.

sycl/include/sycl/backend.hpp Outdated Show resolved Hide resolved
JackAKirk and others added 2 commits August 29, 2023 15:37
Signed-off-by: Jack Kirk <[email protected]>
@JackAKirk
Copy link
Contributor Author

@intel/llvm-gatekeepers This is now ready to be merged. Thanks

@steffenlarsen steffenlarsen merged commit 5e9d07b into intel:sycl Aug 30, 2023
9 checks passed
fabiomestre pushed a commit to fabiomestre/llvm that referenced this pull request Sep 26, 2023
)

This PR adds missing functions in the hip backend to allow for
interoperability in programs that create sycl objects from native hip
objects. The new function implementations are:

- `make_device`
- `make_queue`
- `make_event`

Note that it would really make sense for
intel#10491 to be merged first because this
PR makes the same code change in pi2ur, for a fix that is attributed to
intel#10491.

---------

Signed-off-by: Jack Kirk <[email protected]>
veselypeta pushed a commit to veselypeta/llvm that referenced this pull request Sep 28, 2023
)

This PR adds missing functions in the hip backend to allow for
interoperability in programs that create sycl objects from native hip
objects. The new function implementations are:

- `make_device`
- `make_queue`
- `make_event`

Note that it would really make sense for
intel#10491 to be merged first because this
PR makes the same code change in pi2ur, for a fix that is attributed to
intel#10491.

---------

Signed-off-by: Jack Kirk <[email protected]>
steffenlarsen pushed a commit that referenced this pull request Sep 29, 2023
All CI backends (cuda, hip, l0, opencl) currently support these three
types of interop, that are probably the most important cases, but a
complete e2e test did not previously exist. opencl is also the only
backend with an existing test-e2e that calls make_* for these three sycl
objects.

This adds a short test-e2e corresponding to e.g.
#10526.

---------

Signed-off-by: JackAKirk <[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.

6 participants