-
Notifications
You must be signed in to change notification settings - Fork 798
Handler-less kernel submit API #19294
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
base: sycl
Are you sure you want to change the base?
Changes from all commits
3223842
fde19ca
13424de
fbc789d
591b3ec
d235b7c
6641601
0f41d5a
a6e711e
9c8040e
31cbdb9
c5cd091
998d592
4000c07
f8e9cd6
01af8bb
4469e59
ac1a5cf
5865f3a
072803c
27b3110
9041e94
ac2c5bb
8e155fb
502f637
d708c93
e9f6e4e
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 |
---|---|---|
|
@@ -111,6 +111,23 @@ event submit_with_event_impl(const queue &Q, PropertiesT Props, | |
return Q.submit_with_event<__SYCL_USE_FALLBACK_ASSERT>( | ||
Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc); | ||
} | ||
|
||
template <typename KernelName, typename PropertiesT, typename KernelType, | ||
int Dims> | ||
void submit_direct_impl(const queue &Q, PropertiesT Props, nd_range<Dims> Range, | ||
const KernelType &KernelFunc, | ||
const sycl::detail::code_location &CodeLoc) { | ||
Q.submit_direct_without_event<KernelName, PropertiesT, KernelType, Dims>( | ||
Props, Range, KernelFunc, CodeLoc); | ||
} | ||
template <typename KernelName, typename PropertiesT, typename KernelType, | ||
int Dims> | ||
event submit_direct_with_event_impl( | ||
const queue &Q, PropertiesT Props, nd_range<Dims> Range, | ||
const KernelType &KernelFunc, const sycl::detail::code_location &CodeLoc) { | ||
return Q.submit_direct_with_event<KernelName, PropertiesT, KernelType, Dims>( | ||
Props, Range, KernelFunc, CodeLoc); | ||
} | ||
} // namespace detail | ||
|
||
template <typename CommandGroupFunc, typename PropertiesT> | ||
|
@@ -128,6 +145,17 @@ void submit(const queue &Q, CommandGroupFunc &&CGF, | |
submit(Q, empty_properties_t{}, std::forward<CommandGroupFunc>(CGF), CodeLoc); | ||
} | ||
|
||
template <typename KernelName = sycl::detail::auto_name, typename PropertiesT, | ||
typename KernelType, int Dims> | ||
void submit(const queue &Q, PropertiesT Props, nd_range<Dims> Range, | ||
const KernelType &KernelFunc, | ||
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. Why not rvalue? 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. Seems like the convention in this file is to pass the KernelFunc as lvalue reference. Maybe it would make sense to change it everywhere in a separate PR, for consistency. |
||
const sycl::detail::code_location &CodeLoc = | ||
sycl::detail::code_location::current()) { | ||
sycl::ext::oneapi::experimental::detail::submit_direct_impl< | ||
KernelName, PropertiesT, KernelType, Dims>(Q, Props, Range, KernelFunc, | ||
CodeLoc); | ||
} | ||
|
||
template <typename CommandGroupFunc, typename PropertiesT> | ||
event submit_with_event(const queue &Q, PropertiesT Props, | ||
CommandGroupFunc &&CGF, | ||
|
@@ -145,6 +173,17 @@ event submit_with_event(const queue &Q, CommandGroupFunc &&CGF, | |
std::forward<CommandGroupFunc>(CGF), CodeLoc); | ||
} | ||
|
||
template <typename KernelName = sycl::detail::auto_name, typename PropertiesT, | ||
typename KernelType, int Dims> | ||
event submit_with_event(const queue &Q, PropertiesT Props, nd_range<Dims> Range, | ||
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 can't find where this function is used. Could you please clarify? 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. This is part of the API to be called by the app, when an event is needed. 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. So that's for unimplemented yet part of code. Thanks! |
||
const KernelType &KernelFunc, | ||
const sycl::detail::code_location &CodeLoc = | ||
sycl::detail::code_location::current()) { | ||
return sycl::ext::oneapi::experimental::detail::submit_direct_with_event_impl< | ||
KernelName, PropertiesT, KernelType, Dims>(Q, Props, Range, KernelFunc, | ||
CodeLoc); | ||
} | ||
|
||
template <typename KernelName = sycl::detail::auto_name, typename KernelType> | ||
void single_task(handler &CGH, const KernelType &KernelObj) { | ||
CGH.single_task<KernelName>(KernelObj); | ||
|
@@ -261,10 +300,21 @@ template <typename KernelName = sycl::detail::auto_name, int Dimensions, | |
typename KernelType, typename... ReductionsT> | ||
void nd_launch(queue Q, nd_range<Dimensions> Range, const KernelType &KernelObj, | ||
ReductionsT &&...Reductions) { | ||
#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT | ||
if constexpr (sizeof...(ReductionsT) == 0) { | ||
submit<KernelName>(std::move(Q), empty_properties_t{}, Range, KernelObj); | ||
} else { | ||
submit(std::move(Q), [&](handler &CGH) { | ||
nd_launch<KernelName>(CGH, Range, KernelObj, | ||
std::forward<ReductionsT>(Reductions)...); | ||
}); | ||
} | ||
#else | ||
submit(std::move(Q), [&](handler &CGH) { | ||
nd_launch<KernelName>(CGH, Range, KernelObj, | ||
std::forward<ReductionsT>(Reductions)...); | ||
}); | ||
#endif | ||
} | ||
|
||
template <typename KernelName = sycl::detail::auto_name, int Dimensions, | ||
|
@@ -285,10 +335,25 @@ template <typename KernelName = sycl::detail::auto_name, int Dimensions, | |
typename Properties, typename KernelType, typename... ReductionsT> | ||
void nd_launch(queue Q, launch_config<nd_range<Dimensions>, Properties> Config, | ||
const KernelType &KernelObj, ReductionsT &&...Reductions) { | ||
#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT | ||
if constexpr (sizeof...(ReductionsT) == 0) { | ||
ext::oneapi::experimental::detail::LaunchConfigAccess<nd_range<Dimensions>, | ||
Properties> | ||
ConfigAccess(Config); | ||
submit<KernelName>(std::move(Q), ConfigAccess.getProperties(), | ||
ConfigAccess.getRange(), KernelObj); | ||
} else { | ||
submit(std::move(Q), [&](handler &CGH) { | ||
nd_launch<KernelName>(CGH, Config, KernelObj, | ||
std::forward<ReductionsT>(Reductions)...); | ||
}); | ||
} | ||
#else | ||
submit(std::move(Q), [&](handler &CGH) { | ||
nd_launch<KernelName>(CGH, Config, KernelObj, | ||
std::forward<ReductionsT>(Reductions)...); | ||
}); | ||
#endif | ||
} | ||
|
||
template <int Dimensions, typename... ArgsT> | ||
|
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.
Having lots of layers of tiny template helpers is bad for compile time, why can't it be inlined?
Ideally, most of interfaces accepting the kernel type as a template param must process compile-time properties immediately and only call interfaces that accept type-erased kernel.
Additionally, less tiny layers makes the code much easier to read.
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.
This code follows the convention which is there for handler based submissions. We should probably refactor the entire file in a separate PR (after this PR is merged).