-
Notifications
You must be signed in to change notification settings - Fork 792
[SYCL] Fix vec class alignment on windows platform #4953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SYCL] Fix vec class alignment on windows platform #4953
Conversation
- 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
#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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we continue using alignas
specifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alignas
failed as follows during kernel compilation for 'test_handler' from CTS.
In file included from C:\work\dongkyun\github\opensource\llvm_build\include\sycl\CL/sycl.hpp:11:
In file included from C:\work\dongkyun\github\opensource\llvm_build\include\sycl\CL/sycl/accessor.hpp:13:
In file included from C:\work\dongkyun\github\opensource\llvm_build\include\sycl\CL/sycl/buffer.hpp:11:
In file included from C:\work\dongkyun\github\opensource\llvm_build\include\sycl\CL/sycl/detail/buffer_impl.hpp:20:
C:\work\dongkyun\github\opensource\llvm_build\include\sycl\CL/sycl/types.hpp(1370,3): error: requested alignment is less than minimum alignment of 128 for type 'sycl::vec<double, 16>::DataType' (aka 'double __attribute__((ext_vector_type(16)))')
__SYCL_ALIGNAS((detail::vector_alignment<DataT, NumElements>::value))
^
C:\work\dongkyun\github\opensource\llvm_build\include\sycl\CL/sycl/types.hpp(548,27): note: expanded from macro '__SYCL_ALIGNAS'
#define __SYCL_ALIGNAS(x) alignas((x<64)?x:64)
^
specification requirements, a limitation of the MSVC compiler(Error C2719).\ | ||
Applied default alignment.") | ||
#define __SYCL_ALIGNAS(x) | ||
Requested alignment applied, limited at 64.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexbatashev
If I remember correctly you found that such a change is an ABI breaking one, could you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remind why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type alignment is part of ABI: assembled code has no notion of structure layout, it operates raw bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular change I do not see how setting alignment can break anything:
- The vector type is not passed directly to functions, but as part of the struct, so it's either passed by pointer or thru a register.
- The structure has only one field which is already considered to be aligned by the clang as it's a vector type(generates vector instructions)
- We set the alignment of vector type being equal to the size of the field itself, so we should not change the size. of the structure to trigger it to be passed differently.
/summary:run |
- Updating expected warning message from types.hpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch doesn't fix the problem completely, compiling with -march=skylake
triggers the issue even with the patch, but workaround the problem when compiling by "default".
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