DPC++ Runtime
Runtime libraries for oneAPI DPC++
bf16_storage_builtins.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <sycl/builtins.hpp>
9 
11 namespace sycl {
12 namespace ext {
13 namespace oneapi {
14 
15 namespace detail {
16 
17 template <typename T> struct is_bf16_storage_type {
18  static constexpr int value = false;
19 };
20 
21 template <> struct is_bf16_storage_type<uint16_t> {
22  static constexpr int value = true;
23 };
24 
25 template <> struct is_bf16_storage_type<uint32_t> {
26  static constexpr int value = true;
27 };
28 
29 template <int N> struct is_bf16_storage_type<vec<uint16_t, N>> {
30  static constexpr int value = true;
31 };
32 
33 template <int N> struct is_bf16_storage_type<vec<uint32_t, N>> {
34  static constexpr int value = true;
35 };
36 
37 } // namespace detail
38 
39 template <typename T>
40 std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fabs(T x) {
41 #ifdef __SYCL_DEVICE_ONLY__
42  return __clc_fabs(x);
43 #else
44  (void)x;
45  throw runtime_error("bf16 is not supported on host device.",
46  PI_ERROR_INVALID_DEVICE);
47 #endif
48 }
49 template <typename T>
50 std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fmin(T x, T y) {
51 #ifdef __SYCL_DEVICE_ONLY__
52  return __clc_fmin(x, y);
53 #else
54  (void)x;
55  (void)y;
56  throw runtime_error("bf16 is not supported on host device.",
57  PI_ERROR_INVALID_DEVICE);
58 #endif
59 }
60 template <typename T>
61 std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fmax(T x, T y) {
62 #ifdef __SYCL_DEVICE_ONLY__
63  return __clc_fmax(x, y);
64 #else
65  (void)x;
66  (void)y;
67  throw runtime_error("bf16 is not supported on host device.",
68  PI_ERROR_INVALID_DEVICE);
69 #endif
70 }
71 template <typename T>
72 std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fma(T x, T y, T z) {
73 #ifdef __SYCL_DEVICE_ONLY__
74  return __clc_fma(x, y, z);
75 #else
76  (void)x;
77  (void)y;
78  (void)z;
79  throw runtime_error("bf16 is not supported on host device.",
80  PI_ERROR_INVALID_DEVICE);
81 #endif
82 }
83 
84 } // namespace oneapi
85 } // namespace ext
86 } // namespace sycl
87 } // __SYCL_INLINE_NAMESPACE(cl)
spirv_ops.hpp
builtins.hpp
T
type_traits.hpp
sycl
Definition: invoke_simd.hpp:68
generic_type_lists.hpp
cl::sycl::fma
detail::enable_if_t< detail::is_genfloat< T >::value, T > fma(T a, T b, T c) __NOEXC
Definition: builtins.hpp:196
generic_type_traits.hpp
cl::sycl::fmax
detail::enable_if_t< detail::is_genfloat< T >::value, T > fmax(T x, T y) __NOEXC
Definition: builtins.hpp:203
cl::sycl::ext::oneapi::detail::is_bf16_storage_type
Definition: bf16_storage_builtins.hpp:17
cl::sycl::fmin
detail::enable_if_t< detail::is_genfloat< T >::value, T > fmin(T x, T y) __NOEXC
Definition: builtins.hpp:216
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::ext::oneapi::fabs
std::enable_if_t< detail::is_bf16_storage_type< T >::value, T > fabs(T x)
Definition: bf16_storage_builtins.hpp:40
builtins.hpp
cl::sycl::vec
Provides a cross-patform vector class template that works efficiently on SYCL devices as well as in h...
Definition: aliases.hpp:19
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:11