@@ -1438,7 +1438,29 @@ template <typename Type, int NumElements> class vec {
1438
1438
1439
1439
// Alignment is the same as size, to a maximum size of 64 (with some
1440
1440
// exceptions, see detail::vector_alignment).
1441
- alignas (detail::vector_alignment<DataT, NumElements>::value) DataType m_Data;
1441
+ #if defined(_WIN32) && (_MSC_VER)
1442
+ #define __SYCL_ALIGNED_VAR (type, x, var ) \
1443
+ type __declspec (align ((x < MaxVecAlignment) ? x : MaxVecAlignment)) var
1444
+ #else
1445
+ #define __SYCL_ALIGNED_VAR (type, x, var ) alignas (x) type var
1446
+ #endif
1447
+ // Used "__SYCL_ALIGNED_VAR" instead of "alignas" to handle MSVC compiler.
1448
+ //
1449
+ // SYCL 2020 spec allows us to have at most 64-byte alignment for vec, but
1450
+ // alignas requires that passed alignment is greater or equal to a minumum
1451
+ // required alignment for a type. That is 128 bytes for types like
1452
+ // vec<double, 16> and MSVC is not able to support that, which makes it
1453
+ // impossible to use alignas directly.
1454
+ //
1455
+ // We have prepared a vec refactoring which changes underlying storage data
1456
+ // type so we are able to use alignas directly, but it is hidden under preview
1457
+ // breaking changes macro for now.
1458
+ // FIXME: we should be able to drop the macro and directly use alignas once
1459
+ // functionality under preview breaking changes macro is promoted.
1460
+ __SYCL_ALIGNED_VAR (DataType,
1461
+ (detail::vector_alignment<DataT, NumElements>::value),
1462
+ m_Data);
1463
+ #undef __SYCL_ALIGNED_VAR
1442
1464
1443
1465
// friends
1444
1466
template <typename T1, typename T2, typename T3, template <typename > class T4 ,
0 commit comments