Skip to content

Conversation

@frasercrmck
Copy link
Contributor

@frasercrmck frasercrmck commented Mar 4, 2024

This is not explicitly forbidden by the current unified OpenCL specification for clEnqueueReadBuffer, clEnqueueWriteBuffer, or clEnqueueCopyBuffer; though it was forbidden up to and including OpenCL 2.0.

Therefore, make the checks for size 0 dependent on the OpenCL version being built.

A size of zero for clEnqueueFillBuffer has always been valid, so explicitly test that. The muxCommandFillBuffer function forbids a size of 0, so it was a bug to call that function when size was 0.

@frasercrmck frasercrmck force-pushed the enqueue-buffer-size-zero branch from d427afc to 679de07 Compare March 4, 2024 10:44
This is not explicitly forbidden by the current unified OpenCL
specification for clEnqueueReadBuffer, clEnqueueWriteBuffer, or
clEnqueueCopyBuffer; though it *was* forbidden up to and including
OpenCL 2.0.

Therefore, make the checks for size 0 dependent on the OpenCL version
being built.

A size of zero for clEnqueueFillBuffer has always been valid, so
explicitly test that. The muxCommandFillBuffer function forbids a size
of 0, so it was a bug to call that function when size was 0.

This requires updating the mux specification to allow sizes of 0 in all
of these functions. It also implicitly allows the same in the HAL,
though this is not as tightly specified.
@frasercrmck frasercrmck force-pushed the enqueue-buffer-size-zero branch from 679de07 to 677b9bb Compare March 4, 2024 14:33
inBuffer, 0, nullptr, nullptr));
TEST_F(clEnqueueReadBufferTest, SizeZero) {
// An error when size == 0 was removed starting with OpenCL 2.1.
if (UCL::isDeviceVersionAtLeast({2, 1})) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we test OpenCL <3.0 anywhere?

}
if (!mem_write(dst, temp.data(), size, locker)) {
return false;
if (size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm assuming this is because mem_read and mem_write still require size to be greater than zero? Are they used anywhere directly where a size of zero should be allowed?

@coldav
Copy link
Collaborator

coldav commented Jul 15, 2025

Hi @frasercrmck, do you think we should just close this one now?

@frasercrmck
Copy link
Contributor Author

Hi @frasercrmck, do you think we should just close this one now?

Blast from the past. I've personally no drive to get this over the line - I can't even remember why it was required/desired? I'm happy if you want to close it. Presumably it can't be that important if you hadn't needed it in over a year.

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