From 20263f22f2aefd033454f30c5232c72f2c369fa1 Mon Sep 17 00:00:00 2001 From: Dongkyun Ahn Date: Fri, 12 Nov 2021 16:15:41 -0800 Subject: [PATCH 1/3] [SYCL] Data alignment is applied for vector type under Windows - For Windows alignment request for vector type larger than 64 is applied, but limited to 64 - Before this change, alignment request was ignored due to 64 byte from MSVC limit and default alignment was applied - This default alignment could cause segmentation fault for 16-byte aligned memory access such as memory access for XMM --- sycl/include/CL/sycl/types.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index 5ec1c9325c79a..ec3cd592e764e 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -544,10 +544,10 @@ using vec_data_t = typename detail::vec_helper::RetType; // (https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention). #pragma message ("Alignment of class vec is not in accordance with SYCL \ specification requirements, a limitation of the MSVC compiler(Error C2719).\ -Applied default alignment.") -#define __SYCL_ALIGNAS(x) +Requested alignment applied, limited at 64.") +#define __SYCL_ALIGNED_VAR(type, x, var) type __declspec(align((x<64)?x:64)) var #else -#define __SYCL_ALIGNAS(N) alignas(N) +#define __SYCL_ALIGNED_VAR(type, x, var) alignas(x) type var #endif /// Provides a cross-patform vector class template that works efficiently on @@ -1363,12 +1363,12 @@ template class vec { } // fields - // Used "__SYCL_ALIGNAS" instead "alignas" to handle MSVC compiler. + // Used "__SYCL_ALIGNED_VAR" instead "alignas" to handle MSVC compiler. // For MSVC compiler max alignment is 64, e.g. vec required // alignment of 128 and MSVC compiler cann't align a parameter with requested - // alignment of 128. - __SYCL_ALIGNAS((detail::vector_alignment::value)) - DataType m_Data; + // alignment of 128. For alignment request larger than 64, 64-alignment + // is applied + __SYCL_ALIGNED_VAR(DataType, (detail::vector_alignment::value), m_Data); // friends template class T4, @@ -2494,4 +2494,4 @@ struct CheckDeviceCopyable< } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) -#undef __SYCL_ALIGNAS +#undef __SYCL_ALIGNED_VAR From a3de672e1aaf4c9ddb6667ddce1d932b297b6086 Mon Sep 17 00:00:00 2001 From: Dongkyun Ahn Date: Fri, 12 Nov 2021 16:23:58 -0800 Subject: [PATCH 2/3] clang-format fix --- sycl/include/CL/sycl/types.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index ec3cd592e764e..c5b827c04ed4a 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -542,10 +542,11 @@ using vec_data_t = typename detail::vec_helper::RetType; // For information on calling conventions for x64 processors, see // Calling Convention // (https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention). -#pragma message ("Alignment of class vec is not in accordance with SYCL \ +#pragma message("Alignment of class vec is not in accordance with SYCL \ specification requirements, a limitation of the MSVC compiler(Error C2719).\ Requested alignment applied, limited at 64.") -#define __SYCL_ALIGNED_VAR(type, x, var) type __declspec(align((x<64)?x:64)) var +#define __SYCL_ALIGNED_VAR(type, x, var) \ + type __declspec(align((x < 64) ? x : 64)) var #else #define __SYCL_ALIGNED_VAR(type, x, var) alignas(x) type var #endif @@ -1368,7 +1369,9 @@ template class vec { // alignment of 128 and MSVC compiler cann't align a parameter with requested // alignment of 128. For alignment request larger than 64, 64-alignment // is applied - __SYCL_ALIGNED_VAR(DataType, (detail::vector_alignment::value), m_Data); + __SYCL_ALIGNED_VAR(DataType, + (detail::vector_alignment::value), + m_Data); // friends template class T4, From 889f0adda76c4a87def017f413e0e0bec85040a6 Mon Sep 17 00:00:00 2001 From: Dongkyun Ahn Date: Tue, 16 Nov 2021 17:27:25 -0800 Subject: [PATCH 3/3] Warning message fix for stdcpp_compat.cpp - Updating expected warning message from types.hpp --- sycl/test/basic_tests/stdcpp_compat.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/test/basic_tests/stdcpp_compat.cpp b/sycl/test/basic_tests/stdcpp_compat.cpp index a51501204fc8a..512a5cb9d9136 100644 --- a/sycl/test/basic_tests/stdcpp_compat.cpp +++ b/sycl/test/basic_tests/stdcpp_compat.cpp @@ -16,8 +16,7 @@ // warning_extension-warning@* 0-1 {{#warning is a language extension}} // // The next warning is emitted for windows only -// expected-warning@* 0-1 {{Alignment of class vec is not in accordance with SYCL specification requirements, a limitation of the MSVC compiler(Error C2719).Applied default alignment.}} - +// expected-warning@* 0-1 {{Alignment of class vec is not in accordance with SYCL specification requirements, a limitation of the MSVC compiler(Error C2719).Requested alignment applied, limited at 64.}} class KernelName1;