-
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
Merged
romanovvlad
merged 3 commits into
intel:sycl
from
dongkyunahn-intel:vector_alignment_fix_windows
Nov 23, 2021
Merged
Changes from all commits
Commits
Show all changes
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -542,12 +542,13 @@ using vec_data_t = typename detail::vec_helper<T>::RetType; | |
// For information on calling conventions for x64 processors, see | ||
// Calling Convention | ||
// (https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention). | ||
#pragma message ("Alignment of class vec is not in accordance with SYCL \ | ||
#pragma message("Alignment of class vec is not in accordance with SYCL \ | ||
specification requirements, a limitation of the MSVC compiler(Error C2719).\ | ||
Applied default alignment.") | ||
#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 commentThe reason will be displayed to describe this comment to others. Learn more. Can't we continue using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
#else | ||
#define __SYCL_ALIGNAS(N) alignas(N) | ||
#define __SYCL_ALIGNED_VAR(type, x, var) alignas(x) type var | ||
#endif | ||
|
||
/// Provides a cross-patform vector class template that works efficiently on | ||
|
@@ -1363,12 +1364,14 @@ template <typename Type, int NumElements> class vec { | |
} | ||
|
||
// fields | ||
// Used "__SYCL_ALIGNAS" instead "alignas" to handle MSVC compiler. | ||
// Used "__SYCL_ALIGNED_VAR" instead "alignas" to handle MSVC compiler. | ||
// For MSVC compiler max alignment is 64, e.g. vec<double, 16> required | ||
// alignment of 128 and MSVC compiler cann't align a parameter with requested | ||
// alignment of 128. | ||
__SYCL_ALIGNAS((detail::vector_alignment<DataT, NumElements>::value)) | ||
DataType m_Data; | ||
// alignment of 128. For alignment request larger than 64, 64-alignment | ||
// is applied | ||
__SYCL_ALIGNED_VAR(DataType, | ||
(detail::vector_alignment<DataT, NumElements>::value), | ||
m_Data); | ||
|
||
// friends | ||
template <typename T1, typename T2, typename T3, template <typename> class T4, | ||
|
@@ -2494,4 +2497,4 @@ struct CheckDeviceCopyable< | |
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) | ||
|
||
#undef __SYCL_ALIGNAS | ||
#undef __SYCL_ALIGNED_VAR |
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
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.
@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: