DPC++ Runtime
Runtime libraries for oneAPI DPC++
bfloat16_math.hpp File Reference
#include <sycl/builtins.hpp>
#include <sycl/builtins_utils_vec.hpp>
#include <sycl/detail/memcpy.hpp>
#include <sycl/ext/oneapi/bfloat16.hpp>
#include <sycl/marray.hpp>
#include <cstring>
#include <stdint.h>
#include <type_traits>
Include dependency graph for bfloat16_math.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 sycl
 
 sycl::_V1
 
 sycl::_V1::ext
 
 sycl::_V1::ext::oneapi
 
 sycl::_V1::ext::oneapi::experimental
 
 sycl::_V1::ext::oneapi::experimental::detail
 

Macros

#define BFLOAT16_MATH_FP32_WRAPPERS(op)
 
#define BFLOAT16_MATH_FP32_WRAPPERS_MARRAY(op)
 
#define BFLOAT16_MATH_FP32_WRAPPERS_VEC(op)
 

Functions

template<size_t N>
uint32_t sycl::_V1::ext::oneapi::experimental::detail::to_uint32_t (sycl::marray< bfloat16, N > x, size_t start)
 
template<typename T >
std::enable_if_t< std::is_same_v< T, bfloat16 >, bool > sycl::_V1::ext::oneapi::experimental::isnan (T x)
 
template<size_t N>
sycl::marray< bool, N > sycl::_V1::ext::oneapi::experimental::isnan (sycl::marray< bfloat16, N > x)
 
template<typename T , int N = num_elements_v<T>>
std::enable_if_t< is_vec_or_swizzle_bf16_v< T >, sycl::vec< int16_t, N > > sycl::_V1::ext::oneapi::experimental::isnan (T x)
 
template<typename T >
std::enable_if_t< std::is_same_v< T, bfloat16 >, T > sycl::_V1::ext::oneapi::experimental::fabs (T x)
 
template<size_t N>
sycl::marray< bfloat16, N > sycl::_V1::ext::oneapi::experimental::fabs (sycl::marray< bfloat16, N > x)
 
template<typename T , int N = num_elements_v<T>>
std::enable_if_t< is_vec_or_swizzle_bf16_v< T >, sycl::vec< bfloat16, N > > sycl::_V1::ext::oneapi::experimental::fabs (T x)
 
template<typename T >
std::enable_if_t< std::is_same_v< T, bfloat16 >, T > sycl::_V1::ext::oneapi::experimental::fmin (T x, T y)
 
template<size_t N>
sycl::marray< bfloat16, N > sycl::_V1::ext::oneapi::experimental::fmin (sycl::marray< bfloat16, N > x, sycl::marray< bfloat16, N > y)
 
template<typename T1 , typename T2 , int N1 = num_elements_v<T1>, int N2 = num_elements_v<T2>>
std::enable_if_t< is_vec_or_swizzle_bf16_v< T1 > &&is_vec_or_swizzle_bf16_v< T2 > &&N1==N2, sycl::vec< bfloat16, N1 > > sycl::_V1::ext::oneapi::experimental::fmin (T1 x, T2 y)
 
template<typename T >
std::enable_if_t< std::is_same_v< T, bfloat16 >, T > sycl::_V1::ext::oneapi::experimental::fmax (T x, T y)
 
template<size_t N>
sycl::marray< bfloat16, N > sycl::_V1::ext::oneapi::experimental::fmax (sycl::marray< bfloat16, N > x, sycl::marray< bfloat16, N > y)
 
template<typename T1 , typename T2 , int N1 = num_elements_v<T1>, int N2 = num_elements_v<T2>>
std::enable_if_t< is_vec_or_swizzle_bf16_v< T1 > &&is_vec_or_swizzle_bf16_v< T2 > &&N1==N2, sycl::vec< bfloat16, N1 > > sycl::_V1::ext::oneapi::experimental::fmax (T1 x, T2 y)
 
template<typename T >
std::enable_if_t< std::is_same_v< T, bfloat16 >, T > sycl::_V1::ext::oneapi::experimental::fma (T x, T y, T z)
 
template<size_t N>
sycl::marray< bfloat16, N > sycl::_V1::ext::oneapi::experimental::fma (sycl::marray< bfloat16, N > x, sycl::marray< bfloat16, N > y, sycl::marray< bfloat16, N > z)
 
template<typename T1 , typename T2 , typename T3 , int N1 = num_elements_v<T1>, int N2 = num_elements_v<T2>, int N3 = num_elements_v<T3>>
std::enable_if_t< is_vec_or_swizzle_bf16_v< T1 > &&is_vec_or_swizzle_bf16_v< T2 > &&is_vec_or_swizzle_bf16_v< T3 > &&N1==N2 &&N2==N3, sycl::vec< bfloat16, N1 > > sycl::_V1::ext::oneapi::experimental::fma (T1 x, T2 y, T3 z)
 

Variables

template<typename T >
constexpr bool sycl::_V1::ext::oneapi::experimental::is_vec_or_swizzle_bf16_v
 
template<typename T >
constexpr int sycl::_V1::ext::oneapi::experimental::num_elements_v = sycl::detail::num_elements<T>::value
 

Macro Definition Documentation

◆ BFLOAT16_MATH_FP32_WRAPPERS

#define BFLOAT16_MATH_FP32_WRAPPERS (   op)
Value:
template <typename T> \
std::enable_if_t<std::is_same<T, bfloat16>::value, T> op(T x) { \
return sycl::ext::oneapi::bfloat16{sycl::op(float{x})}; \
}
autodecltype(x) x

Definition at line 393 of file bfloat16_math.hpp.

◆ BFLOAT16_MATH_FP32_WRAPPERS_MARRAY

#define BFLOAT16_MATH_FP32_WRAPPERS_MARRAY (   op)
Value:
template <size_t N> \
sycl::marray<bfloat16, N> op(sycl::marray<bfloat16, N> x) { \
sycl::marray<bfloat16, N> res; \
for (size_t i = 0; i < N; i++) { \
res[i] = op(x[i]); \
} \
return res; \
}
Provides a cross-platform math array class template that works on SYCL devices as well as in host C++...
Definition: marray.hpp:49

Definition at line 399 of file bfloat16_math.hpp.

◆ BFLOAT16_MATH_FP32_WRAPPERS_VEC

#define BFLOAT16_MATH_FP32_WRAPPERS_VEC (   op)
Value:
/* Overload for BF16 vec and swizzles. */ \
template <typename T, int N = num_elements_v<T>> \
std::enable_if_t<is_vec_or_swizzle_bf16_v<T>, sycl::vec<bfloat16, N>> op( \
T x) { \
sycl::vec<bfloat16, N> res; \
for (size_t i = 0; i < N; i++) { \
res[i] = op(x[i]); \
} \
return res; \
}

Definition at line 421 of file bfloat16_math.hpp.