From b005d758b937b7b921becf9cddb0ed1dc86c6856 Mon Sep 17 00:00:00 2001 From: taosang2 Date: Thu, 22 Jun 2023 23:12:46 -0400 Subject: [PATCH] SWDEV-407139 - Update __hipMapVector Update __hipMapVector for C++11 Change-Id: I6179d9f3b2ddf4e42b9a6f7f3912322cfca02cfe [ROCm/clr commit: d9955b6707dd3fe0b3f284c6e5a580e285560d9b] --- .../hip/amd_detail/amd_hip_vector_types.h | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/projects/clr/hipamd/include/hip/amd_detail/amd_hip_vector_types.h b/projects/clr/hipamd/include/hip/amd_detail/amd_hip_vector_types.h index d145c7fad5..58bc9daf6e 100644 --- a/projects/clr/hipamd/include/hip/amd_detail/amd_hip_vector_types.h +++ b/projects/clr/hipamd/include/hip/amd_detail/amd_hip_vector_types.h @@ -1060,23 +1060,34 @@ template struct is_scalar : public integral_constant to HIP_vector_type */ - template< - typename T, - unsigned int rankT, - typename U, - unsigned int rankU> - __forceinline__ - __HOST_DEVICE__ - typename std::enable_if< - (rankT >= 1 && rankT <= 4 && rankU >= 1 && rankU <= 4), - const HIP_vector_type>::type - __hipMapVector(const HIP_vector_type &u) { - HIP_vector_type t; // Initialized to 0 - if constexpr (rankT >= 1 && rankU >= 1) t.x = static_cast(u.x); - if constexpr (rankT >= 2 && rankU >= 2) t.y = static_cast(u.y); - if constexpr (rankT >= 3 && rankU >= 3) t.z = static_cast(u.z); - if constexpr (rankT >= 4 && rankU >= 4) t.w = static_cast(u.w); - return t; + template + __forceinline__ __HOST_DEVICE__ typename std::enable_if<(rankT == 1 && rankU >= rankT), + const HIP_vector_type>::type + __hipMapVector(const HIP_vector_type& u) { + return HIP_vector_type(static_cast(u.x)); + }; + + template + __forceinline__ __HOST_DEVICE__ typename std::enable_if<(rankT == 2 && rankU >= rankT), + const HIP_vector_type>::type + __hipMapVector(const HIP_vector_type& u) { + return HIP_vector_type(static_cast(u.x), static_cast(u.y)); + }; + + template + __forceinline__ __HOST_DEVICE__ typename std::enable_if<(rankT == 3 && rankU >= rankT), + const HIP_vector_type>::type + __hipMapVector(const HIP_vector_type& u) { + return HIP_vector_type(static_cast(u.x), static_cast(u.y), + static_cast(u.z)); + }; + + template + __forceinline__ __HOST_DEVICE__ typename std::enable_if<(rankT == 4 && rankU >= rankT), + const HIP_vector_type>::type + __hipMapVector(const HIP_vector_type& u) { + return HIP_vector_type(static_cast(u.x), static_cast(u.y), + static_cast(u.z), static_cast(u.w)); }; #define __MAKE_VECTOR_TYPE__(CUDA_name, T) \