From cd6c8fc2fb9a6883fe6e732d8115a60c88373495 Mon Sep 17 00:00:00 2001 From: Sarbojit Sarkar Date: Tue, 26 Jul 2022 09:41:49 +0000 Subject: [PATCH] SWDEV-293749 - Fix for operator mixup Change-Id: I61d1fea5a6ed2176dd92050c6d96cee1af3a39fb [ROCm/clr commit: d0920c59591d970197b3d52c48a4610118c61760] --- .../include/hip/amd_detail/amd_hip_complex.h | 17 ++++++---- .../hip/amd_detail/amd_hip_vector_types.h | 31 ++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/projects/clr/hipamd/include/hip/amd_detail/amd_hip_complex.h b/projects/clr/hipamd/include/hip/amd_detail/amd_hip_complex.h index eba6eb535d..9d9dfd5e9d 100644 --- a/projects/clr/hipamd/include/hip/amd_detail/amd_hip_complex.h +++ b/projects/clr/hipamd/include/hip/amd_detail/amd_hip_complex.h @@ -106,15 +106,20 @@ THE SOFTWARE. return lhs; \ } -#define COMPLEX_MUL_PREOP_OVERLOAD(type) \ - __HOST_DEVICE__ static inline type& operator*=(type& lhs, const type& rhs) { \ - lhs = lhs * rhs; \ - return lhs; \ +#define COMPLEX_MUL_PREOP_OVERLOAD(type) \ + __HOST_DEVICE__ static inline type& operator*=(type& lhs, const type& rhs) { \ + type temp{lhs}; \ + lhs.x = rhs.x * temp.x - rhs.y * temp.y; \ + lhs.y = rhs.y * temp.x + rhs.x * temp.y; \ + return lhs; \ } #define COMPLEX_DIV_PREOP_OVERLOAD(type) \ - __HOST_DEVICE__ static inline type& operator/=(type& lhs, const type& rhs) { \ - lhs = lhs / rhs; \ + __HOST_DEVICE__ static inline type& operator/=(type& lhs, const type& rhs) { \ + type temp; \ + temp.x = (lhs.x*rhs.x + lhs.y * rhs.y) / (rhs.x*rhs.x + rhs.y*rhs.y); \ + temp.y = (lhs.y * rhs.x - lhs.x * rhs.y) / (rhs.x*rhs.x + rhs.y*rhs.y); \ + lhs = temp; \ return lhs; \ } 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 dfd3b39ab6..8215fb02e2 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 @@ -544,6 +544,13 @@ template struct is_scalar : public integral_constant struct is_scalar : public integral_constant struct is_scalar : public integral_constant{x} -= y; } - template - __HOST_DEVICE__ - inline - constexpr - HIP_vector_type operator*( - const HIP_vector_type& x, const HIP_vector_type& y) noexcept - { - return HIP_vector_type{x} *= y; - } template __HOST_DEVICE__ inline @@ -737,15 +741,6 @@ template struct is_scalar : public integral_constant{x} *= y; } - template - __HOST_DEVICE__ - inline - constexpr - HIP_vector_type operator/( - const HIP_vector_type& x, const HIP_vector_type& y) noexcept - { - return HIP_vector_type{x} /= y; - } template __HOST_DEVICE__ inline