-
Notifications
You must be signed in to change notification settings - Fork 752
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][DOC] Add spec and design for "if_device" #8917
base: sycl
Are you sure you want to change the base?
Conversation
Add a proposed extension specification and design for `if_device`, an alternative to `__SYCL_DEVICE_ONLY__`, which is implementable in a 1-pass compiler. This commit also renames the proposed extension "sycl_ext_oneapi_device_if" to "sycl_ext_oneapi_if_device_has" in order to avoid confusion with this new extension.
sycl/doc/extensions/proposed/sycl_ext_oneapi_if_device.asciidoc
Outdated
Show resolved
Hide resolved
Allow the `fn` parameter to be a function pointer for the cases that run on the host.
Specification PR is at intel#8917.
sycl/doc/extensions/proposed/sycl_ext_oneapi_if_device.asciidoc
Outdated
Show resolved
Hide resolved
Pass the callable object using perfect forwarding, rather than by value. This enables (weird) cases where the callable object is not copy constructible: ``` struct move_only { move_only(); move_only(move_only &&other); void operator()() {/* code that runs only on device */} }; void foo() { syclex::if_device(move_only{}); } ```
sycl/doc/design/IfDevice.md
Outdated
|
||
template<typename T> | ||
static auto if_device(T &&fn) { | ||
detail::call_if_on_device(fn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I do not need to use std::forward
here, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the std::forward
, if a r-value-ref gets passed to if_device
then call_if_on_device
gets passed a l-value-ref. If the callable only works with an r-value-ref this break. Always use forward
for any universal reference (if you don't use it anymore afterwards).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Added in f3e15a7.
Use `std::forward` when passing callable object in code snippet.
Update the overview section and add an example showing how to interpret data differently on host vs. device.
Ping to reviewers (@rolandschulz @steffenlarsen). If there are no more comments, I'd like to merge this PR. Merging is not a commitment to implement this feature. We can decide that separately. |
This feature looks really useful, in particular we need in it in ESIMD component/development. |
No, it's not blocked by anything in particular; our focus just turned to other things. I think we just need approvals from @intel/dpcpp-doc-reviewers and @intel/llvm-reviewers-runtime, and I need to fix the merge conflicts. |
This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days. |
Add a proposed extension specification and design for
if_device
, an alternative to__SYCL_DEVICE_ONLY__
, which is implementable in a 1-pass compiler.This commit also renames the proposed extension
"sycl_ext_oneapi_device_if" to "sycl_ext_oneapi_if_device_has" in order to avoid confusion with this new extension.