@@ -317,13 +317,32 @@ template <typename T, int N> struct VectorAlignment {
317317
318318} // namespace detail
319319
320+ #if defined(_WIN32) && (_MSC_VER)
321+ // MSVC Compiler doesn't allow using of function arguments with alignment
322+ // requirements. MSVC Compiler Error C2719: 'parameter': formal parameter with
323+ // __declspec(align('#')) won't be aligned. The align __declspec modifier
324+ // is not permitted on function parameters. Function parameter alignment
325+ // is controlled by the calling convention used.
326+ // For more information, see Calling Conventions
327+ // (https://docs.microsoft.com/en-us/cpp/cpp/calling-conventions).
328+ // For information on calling conventions for x64 processors, see
329+ // Calling Convention
330+ // (https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention).
331+ #pragma message ("Alignment of class vec is not in accordance with SYCL \
332+ specification requirements, a limitation of the MSVC compiler (Error C2719).\
333+ Applied default alignment.")
334+ #define SYCL_ALIGNAS (x )
335+ #else
336+ #define SYCL_ALIGNAS (N ) alignas (N)
337+ #endif
338+
320339template <typename Type, int NumElements> class vec {
321340 using DataT = Type;
322341
323342 // This represent type of underlying value. There should be only one field
324343 // in the class, so vec<float, 16> should be equal to float16 in memory.
325- using DataType = typename detail::BaseCLTypeConverter<
326- DataT, detail::VectorLength< NumElements>::value >::DataType;
344+ using DataType =
345+ typename detail::BaseCLTypeConverter<DataT, NumElements>::DataType;
327346
328347 template <bool B, class T , class F >
329348 using conditional_t = typename std::conditional<B, T, F>::type;
@@ -1023,7 +1042,12 @@ template <typename Type, int NumElements> class vec {
10231042 }
10241043
10251044 // fields
1026- DataType m_Data;
1045+ // Used "SYCL_ALIGNAS" instead "alignas" to handle MSVC compiler.
1046+ // For MSVC compiler max alignment is 64, e.g. vec<double, 16> required
1047+ // alignment of 128 and MSVC compiler cann't align a parameter with requested
1048+ // alignment of 128.
1049+ SYCL_ALIGNAS ((detail::VectorAlignment<DataT, NumElements>::value))
1050+ DataType m_Data;
10271051
10281052 // friends
10291053 template <typename T1, typename T2, typename T3, template <typename > class T4 ,
@@ -1801,15 +1825,14 @@ using cl_schar16 = cl_char16;
18011825// As a result half values will be converted to the integer and passed as a
18021826// kernel argument which is expected to be floating point number.
18031827#ifndef __SYCL_DEVICE_ONLY__
1804- template <int NumElements>
1805- struct alignas (
1806- cl::sycl::detail::VectorAlignment<half, NumElements>::value) half_vec {
1807- std::array<half, cl::sycl::detail::VectorLength<NumElements>::value> s;
1828+ template <int NumElements> struct half_vec {
1829+ alignas (cl::sycl::detail::VectorAlignment<half, NumElements>::value)
1830+ std::array<half, NumElements> s;
18081831};
18091832
18101833using __half_t = half;
18111834using __half2_vec_t = half_vec<2 >;
1812- using __half3_vec_t = half_vec<4 >;
1835+ using __half3_vec_t = half_vec<3 >;
18131836using __half4_vec_t = half_vec<4 >;
18141837using __half8_vec_t = half_vec<8 >;
18151838using __half16_vec_t = half_vec<16 >;
@@ -2062,3 +2085,5 @@ DECLARE_SYCL_FLOAT_VEC(double)
20622085
20632086} // namespace sycl
20642087} // namespace cl
2088+
2089+ #undef SYCL_ALIGNAS
0 commit comments