Skip to content

[SYCL] Use wide alignment for sycl::marray to improve performance#22275

Draft
uditagarwal97 wants to merge 3 commits into
syclfrom
private/udit/marray_align
Draft

[SYCL] Use wide alignment for sycl::marray to improve performance#22275
uditagarwal97 wants to merge 3 commits into
syclfrom
private/udit/marray_align

Conversation

@uditagarwal97

@uditagarwal97 uditagarwal97 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Currently, sycl::marray uses sizeof(DataType) alignment while sycl::vec uses sizeof(DataType)*NumElements alignment, that's why for 16- and 8-bit data types, IGC is able to vectorize sycl::vec code but not sycl::marray. This caused performance regression when migrating from sycl::vec to sycl::marray.

This PR fixes sycl::marray alignment.

@uditagarwal97 uditagarwal97 self-assigned this Jun 10, 2026
@uditagarwal97 uditagarwal97 changed the title [SYCL] Use wide alignment for sycl::marray to improve performance [SYCL] Use wide alignment for sycl::marray to improve performance Jun 10, 2026
@uditagarwal97 uditagarwal97 requested a review from Copilot June 10, 2026 00:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an opt-in (preview-breaking-changes) ABI-impacting alignment change for sycl::marray storage to improve vectorized access performance, and adds test coverage to validate the resulting IR/ABI differences plus an informational benchmark to compare sycl::vec vs sycl::marray.

Changes:

  • Add a constexpr alignment computation for sycl::marray and (under preview-breaking-changes) apply alignas(...) to its storage.
  • Add an LLVM IR check test covering marray ops with and without preview-breaking-changes to validate alignment/ABI effects.
  • Add a manual (UNSUPPORTED) e2e microbenchmark that prints timing comparisons between sycl::vec and sycl::marray.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
sycl/include/sycl/marray.hpp Introduces wide-alignment logic (preview-guarded) via a new alignment computation helper and alignas storage.
sycl/test/check_device_code/marray/marray_ops.cpp New IR-check test validating marray ABI/alignment differences between default and preview builds.
sycl/test-e2e/Performance/vec_vs_marray.cpp New manual performance comparison tool (UNSUPPORTED) printing vec vs marray timings across types/sizes.

Comment thread sycl/test-e2e/Performance/vec_vs_marray.cpp Outdated
Comment thread sycl/include/sycl/marray.hpp
Comment thread sycl/include/sycl/marray.hpp
Comment thread sycl/include/sycl/marray.hpp Outdated
Comment thread sycl/test-e2e/Performance/vec_vs_marray.cpp
@uditagarwal97 uditagarwal97 marked this pull request as ready for review June 10, 2026 05:22
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner June 10, 2026 05:22

template <typename T> struct is_device_copyable;

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this breaks my heart. Do we have customers actually using the preview breaking changes flag?

I guess there is nothing to be done about it, and come 2027.0 we'll once again sweep up all this ABI breaking stuff in, but I wish we had a better approach. We work hard to get these improvements into the product, but then hide them where no one will find them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, it's sad that we can't make this change default because it will break the ABI :(

// The alignment guarantee is limited to 64 bytes because some host compilers
// (e.g. on Microsoft Windows) limit the maximum alignment of function
// parameters to this value.
constexpr std::size_t marrayAlignment(std::size_t NumElements,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably not worth the effort but is there anyway vec and marray can use the SAME affordance for calculating alignment instead of duplicating the code in two different places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we should do that because (1) sycl::vec will be deprecated in future in favor of sycl::marray (2) Alignment calculation of sycl::vec and sycl::marray is different because, unlike sycl::vec, sycl::marray can accept any arbitrary size

@cperkinsintel cperkinsintel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

had some non-blocking commentary.

@sys-ce-bb

Copy link
Copy Markdown
Contributor

@intel/llvm-gatekeepers please consider merging

@uditagarwal97 uditagarwal97 marked this pull request as draft June 10, 2026 17:39
@uditagarwal97

Copy link
Copy Markdown
Contributor Author

Changing the PR to draft for the time being because of some ongoing internal discussions about sycl::marray alignment.

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.

4 participants