From 5e77c58bd021491aa58f369d00f9f944fa9b3d3f Mon Sep 17 00:00:00 2001 From: "Belton-Schure, Aidan" Date: Fri, 27 Jun 2025 09:50:16 +0100 Subject: [PATCH] SWDEV-536813 - Make alignment 16 for special cases (#609) --- .../include/hip/amd_detail/amd_hip_vector_types.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hipamd/include/hip/amd_detail/amd_hip_vector_types.h b/hipamd/include/hip/amd_detail/amd_hip_vector_types.h index baf0bdfeec..1443d69f66 100644 --- a/hipamd/include/hip/amd_detail/amd_hip_vector_types.h +++ b/hipamd/include/hip/amd_detail/amd_hip_vector_types.h @@ -39,10 +39,11 @@ THE SOFTWARE. #if defined(__has_attribute) #if __has_attribute(ext_vector_type) #define __HIP_USE_NATIVE_VECTOR__ 1 - #define __NATIVE_VECTOR__(n, T) T __attribute__((ext_vector_type(n))) - #else - #define __NATIVE_VECTOR__(n, T) alignas(n * sizeof(T)) T[n] - #endif +#define __NATIVE_VECTOR__(n, T) \ + T __attribute__((ext_vector_type(n))) __attribute__((aligned(__hip_vec_align_v))) +#else +#define __NATIVE_VECTOR__(n, T) alignas(__hip_vec_align_v) T[n] +#endif #if defined(__cplusplus) #if !defined(__HIPCC_RTC__) @@ -51,6 +52,10 @@ THE SOFTWARE. #include #endif // defined(__HIPCC_RTC__) +template +inline constexpr __hip_internal::size_t __hip_vec_align_v = + ((N == 4 && alignof(T) == 8) ? 16 : N * alignof(T)); + template struct HIP_vector_base; template struct HIP_vector_type;