@@ -98,9 +98,12 @@ template <typename TRes, typename TArg, int SZ>
98
98
ESIMD_NODEBUG ESIMD_INLINE simd<TRes, SZ>
99
99
__esimd_abs_common_internal (simd<TArg, SZ> src0) {
100
100
simd<TArg, SZ> Result;
101
- if constexpr (detail::is_generic_floating_point_v<TArg>)
102
- Result = simd<TArg, SZ>(__spirv_ocl_fabs<TArg, SZ>(src0.data ()));
103
- else
101
+ if constexpr (detail::is_generic_floating_point_v<TArg>) {
102
+ using CppT = __ESIMD_DNS::element_type_traits<TArg>::EnclosingCppT;
103
+ Result =
104
+ __ESIMD_DNS::convert_vector<TArg, CppT, SZ>(__spirv_ocl_fabs<CppT, SZ>(
105
+ __ESIMD_DNS::convert_vector<CppT, TArg, SZ>(src0.data ())));
106
+ } else
104
107
Result = simd<TArg, SZ>(__spirv_ocl_s_abs<TArg, SZ>(src0.data ()));
105
108
return convert<TRes>(Result);
106
109
}
@@ -184,8 +187,12 @@ template <typename T, int SZ, class Sat = saturation_off_tag>
184
187
__ESIMD_API simd<T, SZ>(max)(simd<T, SZ> src0, simd<T, SZ> src1, Sat sat = {}) {
185
188
constexpr bool is_sat = std::is_same_v<Sat, saturation_on_tag>;
186
189
187
- if constexpr (std::is_floating_point<T>::value) {
188
- auto Result = __spirv_ocl_fmax<T, SZ>(src0.data (), src1.data ());
190
+ if constexpr (detail::is_generic_floating_point_v<T>) {
191
+ using CppT = __ESIMD_DNS::element_type_traits<T>::EnclosingCppT;
192
+ auto Result =
193
+ __ESIMD_DNS::convert_vector<T, CppT, SZ>(__spirv_ocl_fmax<CppT, SZ>(
194
+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src0.data ()),
195
+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src1.data ())));
189
196
if constexpr (is_sat)
190
197
Result = __esimd_sat<T, T, SZ>(Result);
191
198
return simd<T, SZ>(Result);
@@ -269,8 +276,12 @@ template <typename T, int SZ, class Sat = saturation_off_tag>
269
276
__ESIMD_API simd<T, SZ>(min)(simd<T, SZ> src0, simd<T, SZ> src1, Sat sat = {}) {
270
277
constexpr bool is_sat = std::is_same_v<Sat, saturation_on_tag>;
271
278
272
- if constexpr (std::is_floating_point<T>::value) {
273
- auto Result = __spirv_ocl_fmin<T, SZ>(src0.data (), src1.data ());
279
+ if constexpr (detail::is_generic_floating_point_v<T>) {
280
+ using CppT = __ESIMD_DNS::element_type_traits<T>::EnclosingCppT;
281
+ auto Result =
282
+ __ESIMD_DNS::convert_vector<T, CppT, SZ>(__spirv_ocl_fmin<CppT, SZ>(
283
+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src0.data ()),
284
+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src1.data ())));
274
285
if constexpr (is_sat)
275
286
Result = __esimd_sat<T, T, SZ>(Result);
276
287
return simd<T, SZ>(Result);
@@ -1465,8 +1476,12 @@ template <typename T0, typename T1, int SZ> struct esimd_apply_prod {
1465
1476
template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_max {
1466
1477
template <typename ... T>
1467
1478
simd<T0, SZ> operator ()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
1468
- if constexpr (std::is_floating_point<T1>::value) {
1469
- return __spirv_ocl_fmax<T1, SZ>(v1.data (), v2.data ());
1479
+ if constexpr (detail::is_generic_floating_point_v<T1>) {
1480
+ using CppT = __ESIMD_DNS::element_type_traits<T1>::EnclosingCppT;
1481
+ return __ESIMD_DNS::convert_vector<T1, CppT, SZ>(
1482
+ __spirv_ocl_fmax<CppT, SZ>(
1483
+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v1.data ()),
1484
+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v2.data ())));
1470
1485
} else if constexpr (std::is_unsigned<T1>::value) {
1471
1486
return __esimd_umax<T1, SZ>(v1.data (), v2.data ());
1472
1487
} else {
@@ -1478,8 +1493,13 @@ template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_max {
1478
1493
template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_min {
1479
1494
template <typename ... T>
1480
1495
simd<T0, SZ> operator ()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
1481
- if constexpr (std::is_floating_point<T1>::value) {
1482
- return __spirv_ocl_fmin<T1, SZ>(v1.data (), v2.data ());
1496
+
1497
+ if constexpr (detail::is_generic_floating_point_v<T1>) {
1498
+ using CppT = __ESIMD_DNS::element_type_traits<T1>::EnclosingCppT;
1499
+ return __ESIMD_DNS::convert_vector<T1, CppT, SZ>(
1500
+ __spirv_ocl_fmin<CppT, SZ>(
1501
+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v1.data ()),
1502
+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v2.data ())));
1483
1503
} else if constexpr (std::is_unsigned<T1>::value) {
1484
1504
return __esimd_umin<T1, SZ>(v1.data (), v2.data ());
1485
1505
} else {
0 commit comments