Skip to content

[SYCL][E2E] Fix zero-sized buffers in Basic/buffer/reinterpret.cpp test on backends with 1-byte mem_base_addr_align - #23605

Draft
tfortunx wants to merge 2 commits into
intel:syclfrom
tfortunx:fix_mem_base_alignment_in_reinterpret_test
Draft

tfortunx wants to merge 2 commits into
intel:syclfrom
tfortunx:fix_mem_base_alignment_in_reinterpret_test

Conversation

@tfortunx

@tfortunx tfortunx commented Oct 23, 2026 •

Copy link
Copy Markdown

Fixes issue: #14430, and one of the defects from #20142

Description:
The test assumed that info::device::mem_base_addr_align is at least sizeof(int) and divisible by it. This is true on OpenCL, CUDA and HIP backends, but not on Level Zero, which currently report an alignment of 8 bits.

The old computation performed in the reintepret.cpp tests could produce zero-sized buffers and invalid char <-> int reinterpretation ranges when the reported alignment was smaller than sizeof(int).

@kweronsx
kweronsx requested a balanced review from Copilot October 23, 2026 13:24

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue
What changed in this PR

Updates the SYCL E2E buffer reinterpret tests to avoid creating zero-sized buffers on backends reporting very small mem_base_addr_align (e.g., Level Zero reporting 8 bits), enabling the test to run without XFAILs.

Changes:

  • Removed XFAIL directives for Level Zero GPU and native CPU for this test.
  • Updated sub-buffer offset/shape computations to use an alignment derived via std::lcm(mem_base_align_in_bytes, sizeof(int)).
  • Fixed an incorrect assertion message for the 2D char -> int case.
File Description
sycl/​test-e2e/​Basic/​buffer/​reinterpret.cpp Reworks alignment/offset math to prevent zero-sized buffers; removes XFAILs; corrects an assertion message.

Review effort: Lite

Comment on lines 1 to 4
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
//
// XFAIL: level_zero&&gpu
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/14430
// XFAIL: target-native_cpu
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/20142

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, the bug was also occuring on native cpu backend, but its one of the defects from that issue.

Comment on lines +119 to +121
const size_t sub_buf_align_in_bytes =
std::lcm(mem_base_align_in_bytes, sizeof(int));
const size_t sub_buf_align_in_ints = sub_buf_align_in_bytes / sizeof(int);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The device alignment is reported in bytes, but this test uses it to calculate offsets and dimensions in int elements. With a 1-byte alignment (coming from e.g. Level Zero backend), dividing the raw value by sizeof(int) truncates to zero, which produces zero-sized dimensions. Taking the LCM gives a byte alignment that is both a valid multiple of the device requirement and divisible by sizeof(int), so those calculations remain nonzero and correctly aligned.

This branch has not been deployed

No deployments
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.

2 participants