-
Notifications
You must be signed in to change notification settings - Fork 787
[DO NOT MERGE] [SYCL][ABI break] Make sycl::vec trivially_copyable and align layout #6816
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
Conversation
Before the patch the data sycl::vec used underneath was either cl_* types or clang vector types(aka ext_vector_type) depending on the host compiler. This was causing binary compatibility issues because such types are passed differently according to the SysV calling convention. The way such types are passed also depends on the instruction set a compiler allowed to use(aka -avx). The vector types were used underneath in order speed up sycl::vec operations on the host when available(when compiling with clang). So, to avoid performance degradation we need to continue doing the operations using vector types. The patch solves this problem by changing the underlying type to std::array in all the cases for the host compilation. And adds conversions to vector types when the host compiler is clang to avoid loosing performance. The GCC vector_size could be used to cover both compiler, but it has some problems to solve, e.g. it does not support vector of lenght 3. This also allows us to untie sycl::vec from OpenCL types. The are things to improve: 1. Use vectors data type in more sycl::vec methods 2. Use vectors for half type 3. Refactor several ifdef SYCL_DEVICE_ONLY to if constexpr constructs.
The pre-commit failed with very strange error. Cannot reproduce neither with clang nor with GCC 9.3. Anyway, adding an init to zero. |
@@ -63,6 +63,8 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) | |||
else() | |||
target_compile_options(${LIB_OBJ_NAME} PUBLIC | |||
-fvisibility=hidden -fvisibility-inlines-hidden) | |||
|
|||
target_compile_options(${LIB_OBJ_NAME} PUBLIC -Wno-psabi) |
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.
Add a comment:
Silencing GCC note about changed ABI in quite old version of GCC which is not supported by the product:
"the ABI for passing parameters with 32-byte alignment has changed in GCC 4.6"
BTW. For some reason I was not able to silence the note just using pragma
in the files, so silencing it globally.
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.
Changes LGTM. Is there any way we could add a test for the mentioned incompatibility so we don't have regressions in the future?
Speaking honestly, I don't have a good idea how to write such a test. We need to pass a sycl::vec object between two TUs compiled using clang and gcc to reproduce that. |
adapted from #6816 sycl::vec now uses std::array on host in all cases, but device access is via `ext_vector_type` so as to not lose performance. Alignment is set the same as the size to a maximum of 64 bytes, which aligns with an upcoming spec change proposal. In the cases where the size is greater than 64 we use std::array on the device. We no longer need to emit a pragma on Windows and we can use `alignas()` on all platforms.
adapted from intel#6816 sycl::vec now uses std::array on host in all cases, but device access is via `ext_vector_type` so as to not lose performance. Alignment is set the same as the size to a maximum of 64 bytes, which aligns with an upcoming spec change proposal. In the cases where the size is greater than 64 we use std::array on the device. We no longer need to emit a pragma on Windows and we can use `alignas()` on all platforms.
Before the patch the data sycl::vec used underneath was either cl_* types or clang vector types(aka ext_vector_type) depending on the host compiler.
This was causing binary compatibility issues because such types are passed differently according to the SysV calling convention. The way such types are passed also depends on the instruction set a compiler allowed to use(aka -avx).
The vector types were used underneath in order speed up sycl::vec operations on the host when available(when compiling with clang). So, to avoid performance degradation we need to continue doing the operations using vector types.
The patch solves this problem by changing the underlying type to std::array in all the cases for the host compilation. And adds conversions to vector types when the host compiler is clang to avoid loosing performance. The GCC vector_size could be used to cover both compiler, but it has some problems to solve, e.g. it does not support vector of lenght 3.
This also allows us to untie sycl::vec from OpenCL types.
The are things to improve: