1- // SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
1+ // SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
22//
33// SPDX-License-Identifier: BSD-3-Clause
44
@@ -68,7 +68,7 @@ struct device_numeric_limits<__half> {
6868};
6969
7070
71- #if defined( GKO_COMPILING_CUDA)
71+ #ifdef GKO_COMPILING_CUDA
7272
7373
7474template <>
@@ -101,9 +101,6 @@ struct device_numeric_limits<__nv_bfloat16> {
101101#ifdef GKO_COMPILING_HIP
102102
103103
104- #if HIP_VERSION >= 60200000
105-
106-
107104template <>
108105struct device_numeric_limits <__hip_bfloat16> {
109106 static GKO_ATTRIBUTES GKO_INLINE auto inf ()
@@ -129,35 +126,6 @@ struct device_numeric_limits<__hip_bfloat16> {
129126};
130127
131128
132- #else
133-
134-
135- template <>
136- struct device_numeric_limits <hip_bfloat16> {
137- static GKO_ATTRIBUTES GKO_INLINE auto inf ()
138- {
139- hip_bfloat16 vals;
140- vals.data = static_cast <uint16>(0b0'11111111'0000000u );
141- return vals;
142- }
143-
144- static GKO_ATTRIBUTES GKO_INLINE auto max ()
145- {
146- hip_bfloat16 vals;
147- vals.data = static_cast <uint16>(0b0'11111110'1111111u );
148- return vals;
149- }
150-
151- static GKO_ATTRIBUTES GKO_INLINE auto min ()
152- {
153- hip_bfloat16 vals;
154- vals.data = static_cast <uint16>(0b0'00000001'0000000u );
155- return vals;
156- }
157- };
158-
159-
160- #endif
161129#endif
162130
163131namespace detail {
@@ -375,8 +343,7 @@ __device__ __forceinline__ bool is_finite(const thrust::complex<__half>& value)
375343__device__ __forceinline__ bool is_nan (const vendor_bf16& val)
376344{
377345 // from the cuda_bf16.hpp, amd_hip_bf16.h
378- #if GINKGO_HIP_PLATFORM_HCC && HIP_VERSION >= 60200000 || \
379- (defined (__CUDA_ARCH__) && __CUDA_ARCH__ >= 800 )
346+ #if (defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800)
380347 return __hisnan (val);
381348#else
382349 return isnan (static_cast <float >(val));
@@ -391,8 +358,7 @@ __device__ __forceinline__ bool is_nan(const thrust::complex<vendor_bf16>& val)
391358
392359__device__ __forceinline__ vendor_bf16 abs (const vendor_bf16& val)
393360{
394- #if GINKGO_HIP_PLATFORM_HCC && HIP_VERSION >= 60200000 || \
395- (defined (__CUDA_ARCH__) && __CUDA_ARCH__ >= 800 )
361+ #if (defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800)
396362 return __habs (val);
397363#else
398364 return static_cast <vendor_bf16>(abs (static_cast <float >(val)));
@@ -402,8 +368,7 @@ __device__ __forceinline__ vendor_bf16 abs(const vendor_bf16& val)
402368
403369__device__ __forceinline__ vendor_bf16 sqrt (const vendor_bf16& val)
404370{
405- #if GINKGO_HIP_PLATFORM_HCC && HIP_VERSION >= 60200000 || \
406- (defined (__CUDA_ARCH__) && __CUDA_ARCH__ >= 800 )
371+ #if (defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800)
407372 return hsqrt (val);
408373#else
409374 return static_cast <vendor_bf16>(sqrt (static_cast <float >(val)));
@@ -424,28 +389,7 @@ __device__ __forceinline__ bool is_finite(
424389 return is_finite (value.real ()) && is_finite (value.imag ());
425390}
426391
427- #if defined(GKO_COMPILING_HIP) && HIP_VERSION < 60200000
428-
429-
430- // hip_bfloat16 does not have a constexpr constructor from int
431- template <>
432- GKO_INLINE vendor_bf16 one<vendor_bf16>()
433- {
434- vendor_bf16 val;
435- val.data = static_cast <uint16>(0b0'01111111'0000000u );
436- return val;
437- }
438-
439- // hip_bfloat16 does not have an implicit conversion from float
440- template <>
441- GKO_INLINE thrust::complex <vendor_bf16> one<thrust::complex <vendor_bf16>>()
442- {
443- thrust::complex <vendor_bf16> val (one<vendor_bf16>());
444- return val;
445- }
446-
447392
448- #endif
449393#endif // GINKGO_ENABLE_BFLOAT16
450394#endif // defined(__CUDACC__) || defined(GKO_COMPILING_HIP)
451395
0 commit comments