31namespace shamalgs::reduction {
34 T sum(sycl::queue &q, sycl::buffer<T> &buf1,
u32 start_id,
u32 end_id) {
35#ifdef SYCL2020_FEATURE_GROUP_REDUCTION
36 return details::GroupReduction<T, 32>::sum(q, buf1, start_id, end_id);
38 return details::FallbackReduction<T>::sum(q, buf1, start_id, end_id);
43 T max(sycl::queue &q, sycl::buffer<T> &buf1,
u32 start_id,
u32 end_id) {
44#ifdef SYCL2020_FEATURE_GROUP_REDUCTION
45 return details::GroupReduction<T, 32>::max(q, buf1, start_id, end_id);
47 return details::FallbackReduction<T>::max(q, buf1, start_id, end_id);
52 T min(sycl::queue &q, sycl::buffer<T> &buf1,
u32 start_id,
u32 end_id) {
53#ifdef SYCL2020_FEATURE_GROUP_REDUCTION
54 return details::GroupReduction<T, 32>::min(q, buf1, start_id, end_id);
56 return details::FallbackReduction<T>::min(q, buf1, start_id, end_id);
61 bool has_nan(sham::DeviceBuffer<T> &buf,
u64 cnt) {
62 if constexpr (shambase::VectorProperties<T>::is_float_based) {
66 sham::DeviceBuffer<u8> res(cnt, dev_sched);
73 [](
u32 i,
const T *in,
u8 *out) {
74 out[i] = !sham::has_nan(in[i]);
84 bool has_inf(sham::DeviceBuffer<T> &buf,
u64 cnt) {
85 if constexpr (shambase::VectorProperties<T>::is_float_based) {
89 sham::DeviceBuffer<u8> res(cnt, dev_sched);
96 [](
u32 i,
const T *in,
u8 *out) {
97 out[i] = !sham::has_inf(in[i]);
107 bool has_nan_or_inf(sham::DeviceBuffer<T> &buf,
u64 cnt) {
108 if constexpr (shambase::VectorProperties<T>::is_float_based) {
112 sham::DeviceBuffer<u8> res(cnt, dev_sched);
119 [](
u32 i,
const T *in,
u8 *out) {
120 out[i] = !sham::has_nan_or_inf(in[i]);
153 template _arg_ sum(sycl::queue &q, sycl::buffer<_arg_> &buf1, u32 start_id, u32 end_id); \
154 template _arg_ max(sycl::queue &q, sycl::buffer<_arg_> &buf1, u32 start_id, u32 end_id); \
155 template _arg_ min(sycl::queue &q, sycl::buffer<_arg_> &buf1, u32 start_id, u32 end_id); \
156 template bool has_nan(sham::DeviceBuffer<_arg_> &buf1, u64 cnt); \
157 template bool has_inf(sham::DeviceBuffer<_arg_> &buf1, u64 cnt); \
158 template bool has_nan_or_inf(sham::DeviceBuffer<_arg_> &buf1, u64 cnt);
std::uint8_t u8
8 bit unsigned integer
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::shared_ptr< DeviceScheduler > & get_dev_scheduler_ptr()
Gets the Device scheduler pointer corresponding to the held allocation.
Boolean reduction algorithm for checking if all elements are non-zero.
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.
bool is_all_true(sycl::buffer< T > &buf, u32 cnt)
Check if all elements in a sycl::buffer are non-zero.
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
main include file for memory algorithms