DPC++ Runtime
Runtime libraries for oneAPI DPC++
functional.hpp
Go to the documentation of this file.
1 //==----------- functional.hpp --- SYCL functional -------------------------==//
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 
12 
13 #include <functional>
14 
16 namespace sycl {
17 
18 template <typename T = void> using plus = std::plus<T>;
19 template <typename T = void> using multiplies = std::multiplies<T>;
20 template <typename T = void> using bit_and = std::bit_and<T>;
21 template <typename T = void> using bit_or = std::bit_or<T>;
22 template <typename T = void> using bit_xor = std::bit_xor<T>;
23 template <typename T = void> using logical_and = std::logical_and<T>;
24 template <typename T = void> using logical_or = std::logical_or<T>;
25 
26 template <typename T = void> struct minimum {
27  T operator()(const T &lhs, const T &rhs) const {
28  return std::less<T>()(lhs, rhs) ? lhs : rhs;
29  }
30 };
31 
32 template <> struct minimum<void> {
33  struct is_transparent {};
34  template <typename T, typename U>
35  auto operator()(T &&lhs, U &&rhs) const ->
36  typename std::common_type<T &&, U &&>::type {
37  return std::less<>()(std::forward<const T>(lhs), std::forward<const U>(rhs))
38  ? std::forward<T>(lhs)
39  : std::forward<U>(rhs);
40  }
41 };
42 
43 template <typename T = void> struct maximum {
44  T operator()(const T &lhs, const T &rhs) const {
45  return std::greater<T>()(lhs, rhs) ? lhs : rhs;
46  }
47 };
48 
49 template <> struct maximum<void> {
50  struct is_transparent {};
51  template <typename T, typename U>
52  auto operator()(T &&lhs, U &&rhs) const ->
53  typename std::common_type<T &&, U &&>::type {
54  return std::greater<>()(std::forward<const T>(lhs),
55  std::forward<const U>(rhs))
56  ? std::forward<T>(lhs)
57  : std::forward<U>(rhs);
58  }
59 };
60 
61 } // namespace sycl
62 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::bit_xor
std::bit_xor< T > bit_xor
Definition: functional.hpp:22
cl::sycl::minimum< void >::operator()
auto operator()(T &&lhs, U &&rhs) const -> typename std::common_type< T &&, U && >::type
Definition: functional.hpp:35
defines_elementary.hpp
cl::sycl::multiplies
std::multiplies< T > multiplies
Definition: functional.hpp:19
cl::sycl::maximum::operator()
T operator()(const T &lhs, const T &rhs) const
Definition: functional.hpp:44
sycl
Definition: invoke_simd.hpp:68
cl::sycl::bit_or
std::bit_or< T > bit_or
Definition: functional.hpp:21
cl::sycl::maximum
Definition: functional.hpp:43
cl::sycl::minimum::operator()
T operator()(const T &lhs, const T &rhs) const
Definition: functional.hpp:27
cl::sycl::minimum
Definition: functional.hpp:26
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::bit_and
std::bit_and< T > bit_and
Definition: functional.hpp:20
cl::sycl::logical_and
std::logical_and< T > logical_and
Definition: functional.hpp:23
cl::sycl::maximum< void >::operator()
auto operator()(T &&lhs, U &&rhs) const -> typename std::common_type< T &&, U && >::type
Definition: functional.hpp:52
cl::sycl::plus
std::plus< T > plus
Definition: functional.hpp:18
cl::sycl::logical_or
std::logical_or< T > logical_or
Definition: functional.hpp:24
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12