10#if !defined(__KERNEL_GPU__) && defined(__KERNEL_SSE2__)
18#if defined(__KERNEL_METAL__)
29 *((
ccl_private int *)&f) = ((val.s & 0x8000) << 16) | (((val.s & 0x7c00) + 0x1C000) << 13) |
30 ((val.s & 0x03FF) << 13);
38# if !defined(__KERNEL_CUDA__) && !defined(__KERNEL_HIP__) && !defined(__KERNEL_ONEAPI__)
44 half(
const unsigned short &
i) : v(
i) {}
45 operator unsigned short()
72#if defined(__KERNEL_METAL__) || defined(__KERNEL_ONEAPI__)
74#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
79 uint sign_bit = u & 0x80000000;
82 const uint exponent_bits = u & 0x7f800000;
84 uint value_bits = u & 0x7fffffff;
86 value_bits -= 0x1c000;
88 value_bits = (exponent_bits < 0x38800000) ? 0 : value_bits;
90 value_bits = (exponent_bits > 0x47000000) ? 0x7bff : value_bits;
92 value_bits = (exponent_bits == 0 ? 0 : value_bits);
94 return (value_bits | sign_bit);
100#if defined(__KERNEL_METAL__)
101 return half_to_float(h);
102#elif defined(__KERNEL_ONEAPI__)
104#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
107 const int x = ((h & 0x8000) << 16) | (((h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
118 __m128i
x = _mm_castpd_si128(_mm_load_sd((
const double *)&h));
119 return float4(_mm_cvtph_ps(
x));
137#if defined(__KERNEL_METAL__) || defined(__KERNEL_ONEAPI__)
139#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
142 const int x =
__float_as_int((f > 0.0f) ? ((f < 65504.0f) ? f : 65504.0f) : 0.0f);
146 const int rshift = (
result >> 13);
147 return (rshift & 0x7FFF);
156# ifdef __KERNEL_AVX2__
163 int4 rpack =
int4(_mm_packs_epi32(rshift, rshift));
166 _mm_storel_pi((__m64 *)&h, _mm_castsi128_ps(rpack));
ATTR_WARN_UNUSED_RESULT const BMVert * v
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
half & operator=(const unsigned short &i)
half(const unsigned short &i)
#define ccl_device_inline
ccl_device_forceinline float __half2float(const half h)
#define CCL_NAMESPACE_END
VecBase< float, 4 > float4
ccl_device_inline half float_to_half_display(const float f)
ccl_device_inline half float_to_half_image(const float f)
ccl_device_inline float4 half4_to_float4_image(const half4 h)
ccl_device_inline float half_to_float_image(half h)
ccl_device_inline half4 float4_to_half4_display(const float4 f)
float half_to_float(uint16_t v)