Skip to content

[SYCL] Fix returned alignment of allocation functions #6205

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
merged 2 commits into from
May 26, 2022

Conversation

aelovikov-intel
Copy link
Contributor

A test is being added in intel/llvm-test-suite#1042.

gmlueck
gmlueck previously approved these changes May 26, 2022
Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -158,7 +158,8 @@ T *malloc_device(
const property_list &PropList = {},
const detail::code_location CodeLoc = detail::code_location::current()) {
return static_cast<T *>(
malloc_device(Count * sizeof(T), Dev, Ctxt, PropList, CodeLoc));
aligned_alloc_device(std::max(alignof(T), alignof(std::max_align_t)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlueck , after reading your comment in the llvm-test-suite PR I think this is overly pessimistic and should be just alignof(T) without any std::max. Would you agree?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. In fact, the spec says this:

No alignment parameter; Templated on allocation type T
Pointer is suitably aligned for an object of type T.

Thanks for noticing.

@againull againull merged commit 3114f02 into intel:sycl May 26, 2022
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request May 31, 2022
againull pushed a commit that referenced this pull request May 31, 2022
@aelovikov-intel aelovikov-intel deleted the aliggn_alloc_functions branch July 28, 2022 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants