Skip to content

Commit 12de028

Browse files
author
JackAKirk
committed
Add alignment attr for Windows.
Signed-off-by: JackAKirk <[email protected]>
1 parent 67864ef commit 12de028

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

sycl/include/sycl/marray.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,22 @@ constexpr std::size_t vecAlignment() {
4040
return res;
4141
}
4242

43+
#if defined(_WIN32) || defined(_WIN64)
44+
#define MARRAY_WINDOWS_ALIGN_ATTR \
45+
__declspec(align(vecAlignment<NumElements, sizeof(Type)>()))
46+
#define MARRAY_LINUX_ALIGN_ATTR
47+
#else
48+
#define MARRAY_WINDOWS_ALIGN_ATTR
49+
#define MARRAY_LINUX_ALIGN_ATTR \
50+
__attribute__((aligned(vecAlignment<NumElements, sizeof(Type)>())))
51+
#endif
52+
4353
/// Provides a cross-patform math array class template that works on
4454
/// SYCL devices as well as in host C++ code.
4555
///
4656
/// \ingroup sycl_api
47-
template <typename Type, std::size_t NumElements> class marray {
57+
template <typename Type, std::size_t NumElements>
58+
class MARRAY_WINDOWS_ALIGN_ATTR marray {
4859
using DataT = Type;
4960

5061
public:
@@ -321,7 +332,7 @@ template <typename Type, std::size_t NumElements> class marray {
321332
}
322333
return Ret;
323334
}
324-
} __attribute__((aligned(vecAlignment<NumElements, sizeof(Type)>())));
335+
} MARRAY_LINUX_ALIGN_ATTR;
325336

326337
#define __SYCL_MAKE_MARRAY_ALIAS(ALIAS, TYPE, N) \
327338
using ALIAS##N = sycl::marray<TYPE, N>;
@@ -359,5 +370,8 @@ __SYCL_MAKE_MARRAY_ALIASES_FOR_MARRAY_LENGTH(16)
359370
#undef __SYCL_MAKE_MARRAY_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES
360371
#undef __SYCL_MAKE_MARRAY_ALIASES_FOR_MARRAY_LENGTH
361372

373+
#undef MARRAY_LINUX_ALIGN_ATTR
374+
#undef MARRAY_WINDOWS_ALIGN_ATTR
375+
362376
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
363377
} // namespace sycl

0 commit comments

Comments
 (0)