DPC++ Runtime
Runtime libraries for oneAPI DPC++
reduction_forward.hpp
Go to the documentation of this file.
1 //==---- reduction_forward.hpp - SYCL reduction forward decl ---*- C++ -*---==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 // ===--------------------------------------------------------------------=== //
8 
9 #pragma once
10 
11 #include <sycl/detail/helpers.hpp> // for Builder
12 #include <sycl/detail/item_base.hpp> // for range
13 #include <sycl/id.hpp> // for id
14 #include <sycl/item.hpp> // for item
15 #include <sycl/nd_range.hpp> // for nd_range
16 #include <sycl/range.hpp> // for range
17 
18 #include <stddef.h> // for size_t
19 
20 // To be included in <sycl/handler.hpp>. Note that reductions implementation
21 // need complete sycl::handler type so we cannot include whole
22 // <sycl/reduction.hpp> there.
23 
24 namespace sycl {
25 inline namespace _V1 {
26 class handler;
27 namespace detail {
28 template <typename T, class BinaryOperation, int Dims, size_t Extent,
29  bool ExplicitIdentity, typename RedOutVar>
30 class reduction_impl_algo;
31 
32 namespace reduction {
33 enum class strategy : int {
35 
36  // These three are only auto-selected for sycl::range entry point.
40 
44  basic,
45 
46  multi,
47 };
48 
49 // Reductions implementation need access to private members of handler. Those
50 // are limited to those below.
51 inline void finalizeHandler(handler &CGH);
52 template <class FunctorTy> void withAuxHandler(handler &CGH, FunctorTy Func);
53 
54 template <int Dims>
56  return Builder::createItem<Dims, false>(Range, Id);
57 }
58 } // namespace reduction
59 
60 template <typename KernelName,
62  int Dims, typename PropertiesT, typename... RestT>
63 void reduction_parallel_for(handler &CGH, range<Dims> NDRange,
64  PropertiesT Properties, RestT... Rest);
65 
66 template <typename KernelName,
68  int Dims, typename PropertiesT, typename... RestT>
70  PropertiesT Properties, RestT... Rest);
71 
75 
77 template <typename T> struct IsReduction {
78  static constexpr bool value =
79  std::is_base_of_v<reduction_impl_base, std::remove_reference_t<T>>;
80 };
81 
84 template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
85  static constexpr bool value =
87 };
88 
91 template <typename T> struct AreAllButLastReductions<T> {
92  static constexpr bool value = !IsReduction<T>::value;
93 };
94 
95 } // namespace detail
96 } // namespace _V1
97 } // namespace sycl
Base non-template class which is a base class for all reduction implementation classes.
Command group handler class.
Definition: handler.hpp:467
Identifies an instance of the function object executing at each point in a range.
Definition: item.hpp:37
Defines the iteration domain of both the work-groups and the overall dispatch.
Definition: nd_range.hpp:22
item< Dims, false > getDelinearizedItem(range< Dims > Range, id< Dims > Id)
void withAuxHandler(handler &CGH, FunctorTy Func)
Definition: reduction.hpp:1171
void finalizeHandler(handler &CGH)
Definition: reduction.hpp:1170
void reduction_parallel_for(handler &CGH, range< Dims > NDRange, PropertiesT Properties, RestT... Rest)
Definition: reduction.hpp:2717
auto reduction(buffer< T, 1, AllocatorT > Var, handler &CGH, BinaryOperation Combiner, const property_list &PropList={})
Constructs a reduction object using the given buffer Var, handler CGH, reduction operation Combiner,...
Definition: reduction.hpp:2843
Definition: access.hpp:18
Predicate returning true if all template type parameters except the last one are reductions.
Predicate returning true if a type is a reduction.