38 template <
typename R,
typename... Args>
41 static constexpr std::size_t arity =
sizeof...(Args);
45 template <
typename R,
typename... Args>
53 template <auto Func, std::
size_t Index>
57 template <
typename T,
typename =
void>
65 T, std::void_t<typename T::element_type, typename T::kernel_buffer_direction>>
68 using direction_tag =
typename T::kernel_buffer_direction;
69 static constexpr
bool reads = direction_tag::reads_existing_data;
70 static constexpr
bool writes = direction_tag::writes_result;
73 static_assert(reads || writes,
"A directional kernel buffer needs read or write access");
82 template <
typename T,
typename =
void>
89 T, std::void_t<typename T::element_type, typename T::kernel_buffer_direction>>
101 static constexpr
bool valid =
false;
106 template <
typename T>
109 static constexpr
bool valid =
true;
114 template <
typename T>
122 template <
typename Param,
typename Actual,
bool = IsDirectionalKernelParamV<Param>>
127 template <
typename Param,
typename Actual>
131 using parameter_type = std::remove_cv_t<std::remove_reference_t<Param>>;
132 using parameter_element =
typename parameter_type::element_type;
133 using direction_tag =
typename parameter_type::kernel_buffer_direction;
136 static constexpr
bool writes = direction_tag::writes_result;
137 using wire_element = std::conditional_t<writes, parameter_element,
138 std::add_const_t<parameter_element>>;
141 static constexpr
bool value =
142 !std::is_reference_v<Param> &&
143 actual_buffer::valid &&
144 !std::is_void_v<std::remove_cv_t<parameter_element>> &&
145 !std::is_function_v<parameter_element> &&
146 (!writes || !std::is_const_v<parameter_element>) &&
147 std::is_same_v<std::remove_cv_t<actual_element>,
148 std::remove_cv_t<parameter_element>> &&
149 std::is_convertible_v<typename actual_buffer::pointer, wire_element*>;
152 template <
typename Param,
typename Actual>
156 template <
auto Func,
typename ActualTuple, std::size_t... Indices>
161 std::tuple_element_t<Indices, ActualTuple>> &&
165 template <
auto Func,
typename... Actual>
168 if constexpr (
sizeof...(Actual) != KernelArityV<Func>)
175 std::make_index_sequence<KernelArityV<Func>>{});
179 template <
auto Func,
typename... Actual>
183 template <
auto Func,
typename... Actual>
187 template <
auto Func, std::size_t... Indices>
195 directions.
args = {KernelParamDirectionV<KernelParamT<Func, Indices>>...};
202 return MakeKernelDirections<Func>(std::make_index_sequence<KernelArityV<Func>>{});
210 inline ArgDir directionAt(
const std::vector<ArgDir>& directions, std::size_t index) noexcept
212 return index < directions.size() ? directions[index] :
ArgDir::InOut;
NDArray is a class that can be used in both host and device code. NDArray is automatically divided in...
ArgDirections MakeKernelDirections(std::index_sequence< Indices... >)
constexpr bool KernelArgumentCompatibleV
constexpr ArgDir KernelParamDirectionV
constexpr std::size_t KernelArityV
constexpr bool IsDirectionalKernelParamV
constexpr bool KernelArgumentsCompatibleV
std::enable_if_t< KernelArgumentsCompatibleV< Func, Actual... >, int > EnableCompatibleKernelArguments
constexpr bool KernelArgumentsCompatible(std::index_sequence< Indices... >)
std::tuple_element_t< Index, typename KernelFunctionTraits< decltype(Func)>::parameters > KernelParamT
std::vector< ArgDir > args
static constexpr bool valid
std::tuple< Args... > parameters
static constexpr ArgDir value