-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][COMPAT] Add launch lambda overload #18021
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
Changes from 5 commits
49a2930
e33b16b
d9667ef
8e4f15c
197ab96
7d66d7e
b98ec72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,22 @@ launch(const dim3 &grid, const dim3 &threads, Args... args) { | |
return launch<F>(grid, threads, get_default_queue(), args...); | ||
} | ||
|
||
// Overload taking zero-argument function object | ||
template <class F, int Dim> | ||
std::enable_if_t<std::is_invocable_v<const F &>, sycl::event> | ||
launch(const F &f, const sycl::nd_range<Dim> &range, | ||
sycl::queue q = get_default_queue()) { | ||
return q.parallel_for(detail::transform_nd_range<Dim>(range), | ||
[=](sycl::nd_item<Dim>) { f(); }); | ||
} | ||
// Alternative launch through dim3 objects | ||
template <class F> | ||
std::enable_if_t<std::is_invocable_v<const F &>, sycl::event> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that this is unchanged, but I think you will want an overload of these launch functions that do not return an event, and that use the new enqueue_functions API (nd_launch): see https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_enqueue_functions.asciidoc I do not know whether having the function calling nd_launch in the implementation might change other design decisions here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree we want a version which doesn't return an event and calls nd_launch. I don't think internally calling nd_launch will change the design decision here. An overload isn't a good way to add a version which doesn't return an event. Given that one can't overload by return type, it would need to be a property or something like it to opt-out of the event. But getting an event back should be opt-in nor opt-out. It would be best if we could just remove the return value. But I assume we don't want to break API. If so I think we need to add a new function like |
||
launch(const F &f, const dim3 &grid, const dim3 &threads, | ||
sycl::queue q = get_default_queue()) { | ||
return launch(f, sycl::nd_range<3>{grid * threads, threads}, q); | ||
} | ||
|
||
} // namespace syclcompat | ||
|
||
namespace syclcompat::experimental { | ||
|
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.
Unsure what order of argument is best: