Skip to content

Fix incorrectly passing buffer read/write copy rect tests#2701

Open
ahesham-arm wants to merge 2 commits into
KhronosGroup:mainfrom
ahesham-arm:buffer_rect
Open

Fix incorrectly passing buffer read/write copy rect tests#2701
ahesham-arm wants to merge 2 commits into
KhronosGroup:mainfrom
ahesham-arm:buffer_rect

Conversation

@ahesham-arm
Copy link
Copy Markdown
Collaborator

@ahesham-arm ahesham-arm commented May 24, 2026

Running test_basic bufferreadwriterect was reporting an error in the log, but the test was still reporting as passing.

Furthermore, the test itself is incorrect, it violates the specification for clEnqueueCopyBufferRect which states:

src_row_pitch is the length of each row in bytes to be used for the memory region associated with src_buffer. If src_row_pitch is 0, src_row_pitch is computed as region[0]
src_slice_pitch is the length of each 2D slice in bytes to be used for the memory region associated with src_buffer. If src_slice_pitch is 0, src_slice_pitch is computed as region[1] × src_row_pitch.

Effectively, this means that if src_row_pitch is zero, src_slice_pitch should be computed as region[1] × region[0], which was not being done, the two values were calculated independently.

This change has two commits, the first fixes the error reporting macro to actually fail the test, and the second fixes the test random generation logic.

The macro should fail the test, instead of just logging.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
The OpenCL specification states that for `clEnqueueCopyBufferRect`,
if `row_pitch` is 0, it is computed as `region[0]`. If `slice_pitch`
is not 0, it must be a multiple of the effective row_pitch.

The test was generating `row_pitch` and `slice_pitch` independentely,
so it could (and did) pass `row_pitch` 0 with `slice_pitch` based on
the full buffer width. For sub-rectangles, this can (and did) make
`slice_pitch` not a multiple of the computed `row_pitch`, causing the
implementation to correctly return `CL_INVALID_VALUE`.

Generate `row_pitch` first, then derive any explicit `slice_pitch`
from the effective `row_pitch`.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
Copy link
Copy Markdown
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Merging as discussed in the May 26th teleconference.

Waiting one more week for additional review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants