Skip to content

Commit 677b9bb

Browse files
committed
[cl] Permit sizes of 0 in clEnqueueXXXBuffer; mux; HAL
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.
1 parent 7cd729b commit 677b9bb

File tree

17 files changed

+72
-39
lines changed

17 files changed

+72
-39
lines changed

doc/modules/mux/changes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ version increases mean backward compatible bug fixes have been applied.
1111
Versions prior to 1.0.0 may contain breaking changes in minor
1212
versions as the API is still under development.
1313

14+
0.81.0
15+
------
16+
17+
* ``muxCommandReadBuffer``, ``muxCommandWriteBuffer``,
18+
``muxCommandCopyBuffer``, and ``muxCommandFillBuffer`` now accept a ``size``
19+
of zero.
20+
1421
0.80.0
1522
------
1623

doc/specifications/mux-compiler-spec.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ComputeMux Compiler Specification
22
=================================
33

4-
This is version 0.80.0 of the specification.
4+
This is version 0.81.0 of the specification.
55

66
ComputeMux is Codeplay’s proprietary API for executing compute workloads across
77
heterogeneous devices. ComputeMux is an extremely lightweight,

doc/specifications/mux-runtime-spec.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ComputeMux Runtime Specification
22
================================
33

4-
This is version 0.80.0 of the specification.
4+
This is version 0.81.0 of the specification.
55

66
ComputeMux is Codeplay’s proprietary API for executing compute workloads across
77
heterogeneous devices. ComputeMux is an extremely lightweight,

examples/refsi/hal_refsi/source/refsi_hal_g1.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,14 @@ bool refsi_g1_hal_device::mem_copy(hal::hal_addr_t dst, hal::hal_addr_t src,
273273
dst, src, size);
274274
}
275275

276-
std::vector<uint8_t> temp(size);
277-
if (!mem_read(temp.data(), src, size, locker)) {
278-
return false;
279-
}
280-
if (!mem_write(dst, temp.data(), size, locker)) {
281-
return false;
276+
if (size) {
277+
std::vector<uint8_t> temp(size);
278+
if (!mem_read(temp.data(), src, size, locker)) {
279+
return false;
280+
}
281+
if (!mem_write(dst, temp.data(), size, locker)) {
282+
return false;
283+
}
282284
}
283285

284286
return true;

examples/refsi/hal_refsi/source/refsi_hal_m1.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ bool refsi_m1_hal_device::mem_copy(hal::hal_addr_t dst, hal::hal_addr_t src,
455455
dst, src, size);
456456
}
457457

458+
if (!size) {
459+
return true;
460+
}
461+
458462
refsi_command_buffer cb;
459463

460464
// Start a 1D DMA transfer to copy data from one buffer to another.

modules/mux/include/mux/mux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern "C" {
3737
/// @brief Mux major version number.
3838
#define MUX_MAJOR_VERSION 0
3939
/// @brief Mux minor version number.
40-
#define MUX_MINOR_VERSION 80
40+
#define MUX_MINOR_VERSION 81
4141
/// @brief Mux patch version number.
4242
#define MUX_PATCH_VERSION 0
4343
/// @brief Mux combined version number.

modules/mux/source/command_buffer.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ mux_result_t muxCommandCopyBuffer(mux_command_buffer_t command_buffer,
160160
return mux_error_invalid_value;
161161
}
162162

163-
if (0 == size) {
164-
return mux_error_invalid_value;
165-
}
166-
167163
if ((size + src_offset) > src_buffer->memory_requirements.size) {
168164
return mux_error_invalid_value;
169165
}
@@ -350,10 +346,6 @@ mux_result_t muxCommandFillBuffer(mux_command_buffer_t command_buffer,
350346
return mux_error_invalid_value;
351347
}
352348

353-
if (0 == size) {
354-
return mux_error_invalid_value;
355-
}
356-
357349
if ((size + offset) > buffer->memory_requirements.size) {
358350
return mux_error_invalid_value;
359351
}
@@ -397,10 +389,6 @@ mux_result_t muxCommandReadBuffer(mux_command_buffer_t command_buffer,
397389
return mux_error_invalid_value;
398390
}
399391

400-
if (0 == size) {
401-
return mux_error_invalid_value;
402-
}
403-
404392
if ((size + offset) > buffer->memory_requirements.size) {
405393
return mux_error_invalid_value;
406394
}
@@ -552,10 +540,6 @@ mux_result_t muxCommandWriteBuffer(mux_command_buffer_t command_buffer,
552540
return mux_error_invalid_value;
553541
}
554542

555-
if (0 == size) {
556-
return mux_error_invalid_value;
557-
}
558-
559543
if ((size + offset) > buffer->memory_requirements.size) {
560544
return mux_error_invalid_value;
561545
}

modules/mux/targets/host/include/host/host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
/// @brief Host major version number.
3030
#define HOST_MAJOR_VERSION 0
3131
/// @brief Host minor version number.
32-
#define HOST_MINOR_VERSION 80
32+
#define HOST_MINOR_VERSION 81
3333
/// @brief Host patch version number.
3434
#define HOST_PATCH_VERSION 0
3535
/// @brief Host combined version number.

modules/mux/targets/host/source/queue.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ void commandWriteBuffer(host::command_info_s *info) {
9494
void commandFillBuffer(host::command_info_s *info) {
9595
host::command_info_fill_buffer_s *const fill = &(info->fill_command);
9696

97+
if (!fill->size) {
98+
return;
99+
}
100+
97101
auto buffer = static_cast<host::buffer_s *>(fill->buffer);
98102

99103
size_t size = fill->pattern_size;

modules/mux/targets/riscv/include/riscv/riscv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
/// @brief Riscv major version number.
3030
#define RISCV_MAJOR_VERSION 0
3131
/// @brief Riscv minor version number.
32-
#define RISCV_MINOR_VERSION 80
32+
#define RISCV_MINOR_VERSION 81
3333
/// @brief Riscv patch version number.
3434
#define RISCV_PATCH_VERSION 0
3535
/// @brief Riscv combined version number.

0 commit comments

Comments
 (0)