DPC++ Runtime
Runtime libraries for oneAPI DPC++
|
|
Go to the documentation of this file.
14 #if !defined(__SYCL_DEVICE_ONLY__)
25 namespace ext::oneapi {
51 #if defined(__SYCL_DEVICE_ONLY__)
52 #if defined(__NVPTX__)
53 #if (__SYCL_CUDA_ARCH__ >= 800)
54 return __nvvm_f2bf16_rn(a);
65 uint32_t roundingBias = ((intStorage >> 16) & 0x1) + 0x00007FFF;
66 return static_cast<uint16_t
>((intStorage + roundingBias) >> 16);
81 uint32_t roundingBias = ((intStorage >> 16) & 0x1) + 0x00007FFF;
82 return static_cast<uint16_t
>((intStorage + roundingBias) >> 16);
87 #if defined(__SYCL_DEVICE_ONLY__) && defined(__SPIR__)
101 bfloat16(
const float &a) { value = from_float(a); }
104 value = from_float(rhs);
112 value = from_float(rhs);
117 operator float()
const {
return to_float(value); }
123 explicit operator bool() {
return to_float(value) != 0.0f; }
127 #if defined(__SYCL_DEVICE_ONLY__)
128 #if defined(__NVPTX__)
129 #if (__SYCL_CUDA_ARCH__ >= 800)
132 return -to_float(lhs.value);
138 return -to_float(lhs.value);
144 friend bfloat16 &operator op(bfloat16 &lhs) { \
145 float f = to_float(lhs.value); \
146 lhs.value = from_float(op f); \
149 friend bfloat16 operator op(bfloat16 &lhs, int) { \
150 bfloat16 old = lhs; \
160 friend bfloat16 &operator op(bfloat16 &lhs, const bfloat16 &rhs) { \
161 float f = static_cast<float>(lhs); \
162 f op static_cast<float>(rhs); \
165 template <typename T> \
166 friend bfloat16 &operator op(bfloat16 &lhs, const T &rhs) { \
167 float f = static_cast<float>(lhs); \
168 f op static_cast<float>(rhs); \
171 template <typename T> friend T &operator op(T &lhs, const bfloat16 &rhs) { \
172 float f = static_cast<float>(lhs); \
173 f op static_cast<float>(rhs); \
183 #define OP(type, op) \
184 friend type operator op(const bfloat16 &lhs, const bfloat16 &rhs) { \
185 return type{static_cast<float>(lhs) op static_cast<float>(rhs)}; \
187 template <typename T> \
188 friend type operator op(const bfloat16 &lhs, const T &rhs) { \
189 return type{static_cast<float>(lhs) op static_cast<float>(rhs)}; \
191 template <typename T> \
192 friend type operator op(const T &lhs, const bfloat16 &rhs) { \
193 return type{static_cast<float>(lhs) op static_cast<float>(rhs)}; \
bfloat16 & operator=(const float &rhs)
#define __SYCL_INLINE_VER_NAMESPACE(X)
---— Error handling, matching OpenCL plugin semantics.
__DPCPP_SYCL_EXTERNAL float __devicelib_ConvertBF16ToFINTEL(const uint16_t &) noexcept
uint16_t Bfloat16StorageT
std::enable_if_t< std::is_same< T, bfloat16 >::value, bool > isnan(T x)
bfloat16 bitsToBfloat16(const Bfloat16StorageT Value)
bfloat16(const sycl::half &a)
sycl::detail::half_impl::half half
__DPCPP_SYCL_EXTERNAL uint16_t __devicelib_ConvertFToBF16INTEL(const float &) noexcept
bfloat16 & operator=(const sycl::half &rhs)
friend bfloat16 operator-(bfloat16 &lhs)
Bfloat16StorageT bfloat16ToBits(const bfloat16 &Value)
#define __DPCPP_SYCL_EXTERNAL