33 template<
class index_t,
class RefIn,
class RefOut,
class Functor>
50 auto acc_in = in.get_read_access(depends_list);
51 auto acc_in_out = in_out.get_write_access(depends_list);
57 [&](
auto &...__acc_in) {
59 [&](
auto &...__acc_in_out) {
61 e = q.
submit(depends_list, kernel_gen(n, __acc_in..., __acc_in_out...));
67 in.complete_event_state(e);
68 in_out.complete_event_state(e);
76 template<
class index_t,
class RefIn,
class RefOut>
79 using args_types =
decltype(std::tuple_cat(
80 std::tuple<index_t>{},
82 std::declval<decltype(std::declval<RefIn>().get_read_access(
83 std::declval<sham::EventList &>()))>(),
85 std::declval<decltype(std::declval<RefOut>().get_write_access(
86 std::declval<sham::EventList &>()))>()));
90 template<
typename Tuple>
93 template<
typename... Ts>
95 using type = void(Ts...);
99 template<
typename Signature>
102 template<
typename Ret,
typename... Ts>
106 template<
class index_t,
class RefIn,
class RefOut>
108 typename kernel_gen_args<index_t, RefIn, RefOut>::args_types>::type>;
111 template<
typename F,
typename Signature>
114 template<
typename F,
typename Ret,
typename... Ts>
116 : std::bool_constant<std::invocable<F, Ts...>> {};
121 template<
typename F,
typename Signature>
126 template<
typename Signature>
129 template<
typename Ret,
typename... Ts>
131 using type = Ret(Ts...);
135 template<
class ExpectedFnSignature>
143 template<
class index_t,
class RefIn,
class RefOut,
class Functor>
152 using expected_sig = kernel_expected_signature<index_t, RefIn, RefOut>;
154 if constexpr (is_kernel_invocable<Functor, expected_sig>::value) {
157 typed_index_kernel_call_lambda(
163 = std::forward<Functor>(func)](
u32 n,
auto... __acc_in,
auto... __acc_in_out) {
164 return [=](sycl::handler &cgh) {
165 cgh.parallel_for(sycl::range<1>{n}, [=](sycl::item<1> item) {
166 func(index_t(item.get_linear_id()), __acc_in..., __acc_in_out...);
174 "Kernel functor is not invocable with the expected signature; see "
175 "matches_expected_kernel_signature<void(...)> for the required argument list.");
343 template<
class RefIn,
class RefOut,
class Functor>
354 details::typed_index_kernel_call<u32, RefIn, RefOut>(
355 q, in, in_out, n, std::forward<Functor>(func));
359 template<
class RefIn,
class RefOut,
class Functor>
370 details::typed_index_kernel_call<u64, RefIn, RefOut>(
371 q, in, in_out, n, std::forward<Functor>(func));
375 template<
class RefIn,
class RefOut,
class Functor>
376 void kernel_call_hndl(
377 sham::DeviceQueue &q,
381 Functor &&kernel_gen,
382 SourceLocation &&callsite = SourceLocation{}) {
387 q, in, in_out, n, std::forward<Functor>(kernel_gen));
391 template<
class RefIn,
class RefOut,
class Functor>
397 Functor &&kernel_gen,
402 details::typed_index_kernel_call_lambda<u64, RefIn, RefOut>(
403 q, in, in_out, n, std::forward<Functor>(kernel_gen));
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
A SYCL queue associated with a device and a context.
sycl::event submit(Fct &&fct)
Submits a kernel to the SYCL queue.
Class to manage a list of SYCL events.
constexpr bool matches_expected_kernel_signature
Always-false flag parameterized by the expected function type (shown in static_assert).
void typed_index_kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, index_t n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
expected_kernel_signature< typename tuple_to_signature< typename kernel_gen_args< index_t, RefIn, RefOut >::args_types >::type > kernel_expected_signature
The expected signature of the kernel generator.
void typed_index_kernel_call_lambda(sham::DeviceQueue &q, RefIn in, RefOut in_out, index_t n, Functor &&kernel_gen, SourceLocation &&callsite=SourceLocation{})
internal implementation of typed_index_kernel_call
namespace for backends this one is named only sham since shambackends is too long to write
void kernel_call_u64(sham::DeviceQueue &q, RefIn in, RefOut in_out, u64 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
u64 indexed variant of kernel_call
void kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, u32 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
Submit a kernel to a SYCL queue.
void kernel_call_hndl_u64(sham::DeviceQueue &q, RefIn in, RefOut in_out, u64 n, Functor &&kernel_gen, SourceLocation &&callsite=SourceLocation{})
u64 indexed variant of kernel_call_hndl
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
#define __shamrock_stack_entry_with_callsite(callsite)
Macro to create a stack entry.
#define __shamrock_log_callsite(callsite)
Macro to create a stack entry from a given location. Can be used only on SourceLocation &&.
provide information about the source location
Trick to name the error message if we want to use it.
Helper to check if the functor is invocable with the expected signature.
helper type to get the arguments types of the kernel generator
Helper to extract the function signature from a tuple of types.