-
Notifications
You must be signed in to change notification settings - Fork 794
[SYCL] Switch to use plain array in sycl::vec in more cases
#17656
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
Merged
AlexeySachkov
merged 4 commits into
intel:sycl
from
AlexeySachkov:private/asachkov/switch-to-plain-array-in-vec-earlier
Mar 27, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // RUN: %clangxx -fsycl -Xclang -verify %s -fsyntax-only | ||
| // RUN: %clangxx -fsycl -Xclang -verify %s -fsyntax-only -fpreview-breaking-changes | ||
| // RUN: %clangxx -fsycl -Xclang -verify %s -fsyntax-only -D__SYCL_USE_NEW_VEC_IMPL=1 | ||
| // expected-no-diagnostics | ||
|
|
||
| #include <sycl/vector.hpp> | ||
|
|
||
| #include <type_traits> | ||
|
|
||
| namespace sycl { | ||
| namespace detail { | ||
| template <typename T, int N> class vec_base_test { | ||
| public: | ||
| static void do_check() { | ||
| constexpr bool uses_std_array = | ||
| std::is_same_v<typename sycl::vec<T, N>::DataType, std::array<T, N>>; | ||
| constexpr bool uses_plain_array = | ||
| std::is_same_v<typename sycl::vec<T, N>::DataType, T[N]>; | ||
|
|
||
| constexpr bool std_array_and_plain_array_have_the_same_layout = | ||
| sizeof(std::array<T, N>) == sizeof(T[N]) && | ||
| alignof(std::array<T, N>) == alignof(T[N]); | ||
|
|
||
| #if defined(__INTEL_PREVIEW_BREAKING_CHANGES) || __SYCL_USE_NEW_VEC_IMPL | ||
| static_assert(uses_plain_array, | ||
| "We must use plain array regardless of " | ||
| "layout, because user is opted-in for a potential ABI-break"); | ||
| #else | ||
| static_assert(std_array_and_plain_array_have_the_same_layout == | ||
| uses_plain_array, | ||
| "If layouts are the same, we must use safer plain array " | ||
| "instead of std::array, or vice versa"); | ||
| static_assert( | ||
| !std_array_and_plain_array_have_the_same_layout == uses_std_array, | ||
| "If layouts are not the same, we must use std::array to preserve ABI"); | ||
| #endif | ||
| } | ||
| }; | ||
| } // namespace detail | ||
| } // namespace sycl | ||
|
|
||
| int main() { sycl::detail::vec_base_test<int, 4>::do_check(); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
FYI, I think @aelovikov-intel is also using this flag for some other (draft?)
sycl::vecrefactoring work. So, if the user explicitly specifies__SYCL_USE_NEW_VEC_IMPLmacro, it might bring in Andrei's changes as well, along with the switch to using C-arrays.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 main point here is to have some sort of opt-in mechanism for customers who value building in debug mode on windows using
clang.exe(instead ofclang-cl.exe) over backwards compatibility or potential ABI issues. So, I'm fine with choosing any other name here, I've just re-used what we had alreadyThere 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.
True. Let's use some other macro name
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.
Done in 0c1c53d