mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Add cl_ext_immutable_memory_objects tests writing to and from buffer (#2432)
This change extends the test coverage for https://github.com/KhronosGroup/OpenCL-Docs/pull/1280 The change tests: 1. Writing to immutable buffers. 2. Writing to buffer/image from immutable buffers. 3. Reading from immutable buffers. This change adds the following tests: 1. `test_negative_imagearraycopy` 2. `test_negative_imagearraycopy3d` 3. `test_immutable_bufferreadwriterect` 4. `test_immutable_arrayreadwrite` 5. `test_write_from_immutable_buffer_to_buffer` 6. `test_immutable_buffer_map_*` and extends the following tests: 1. `test_arrayimagecopy3d` 2. `test_arrayimagecopy` 3. `test_imagearraycopy3d` 4. `test_imagearraycopy` 5. `test_buffer_copy` 6. `test_buffer_partial_copy` Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "harness/compat.h"
|
||||
#include "errorHelpers.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -194,6 +195,43 @@ int copy_region(size_t src, size_t soffset[3], size_t sregion[3], size_t dst, si
|
||||
return 0;
|
||||
}
|
||||
|
||||
int immutable_copy_region(size_t src, size_t soffset[3], size_t sregion[3],
|
||||
size_t dst, size_t doffset[3], size_t dregion[3])
|
||||
{
|
||||
|
||||
// Copy between cl buffers.
|
||||
size_t src_slice_pitch =
|
||||
(width[src] * height[src] != 1) ? width[src] * height[src] : 0;
|
||||
size_t dst_slice_pitch =
|
||||
(width[dst] * height[dst] != 1) ? width[dst] * height[dst] : 0;
|
||||
size_t src_row_pitch = width[src];
|
||||
|
||||
cl_int err;
|
||||
if (check_overlap_rect(soffset, doffset, sregion, src_row_pitch,
|
||||
src_slice_pitch))
|
||||
{
|
||||
log_info("Copy overlap reported, skipping copy buffer rect\n");
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = clEnqueueCopyBufferRect(gQueue, buffer[src], buffer[dst], soffset,
|
||||
doffset, sregion, /*dregion,*/
|
||||
width[src], src_slice_pitch, width[dst],
|
||||
dst_slice_pitch, 0, nullptr, nullptr);
|
||||
if (err != CL_INVALID_OPERATION)
|
||||
{
|
||||
log_error(
|
||||
"clEnqueueCopyBufferRect should return "
|
||||
"CL_INVALID_OPERATION but returned %s between %zu and %zu",
|
||||
IGetErrorString(err), src, dst);
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
// This function compares the destination region in the buffer pointed
|
||||
// to by device, to the source region of the specified verify buffer.
|
||||
int verify_region(BufferType* device, size_t src, size_t soffset[3], size_t sregion[3], size_t dst, size_t doffset[3]) {
|
||||
@@ -337,6 +375,32 @@ int write_region(size_t src, size_t soffset[3], size_t sregion[3], size_t dst, s
|
||||
return 0;
|
||||
}
|
||||
|
||||
int immutable_write_region(size_t src, size_t soffset[3], size_t sregion[3],
|
||||
size_t dst, size_t doffset[3], size_t dregion[3])
|
||||
{
|
||||
initialize_image(tmp_buffer, tmp_buffer_size, 1, 1, mt);
|
||||
|
||||
size_t src_slice_pitch =
|
||||
(width[src] * height[src] != 1) ? width[src] * height[src] : 0;
|
||||
size_t dst_slice_pitch =
|
||||
(width[dst] * height[dst] != 1) ? width[dst] * height[dst] : 0;
|
||||
|
||||
cl_int error = clEnqueueWriteBufferRect(
|
||||
gQueue, buffer[dst], CL_TRUE, doffset, soffset, dregion, width[dst],
|
||||
dst_slice_pitch, width[src], src_slice_pitch, tmp_buffer, 0, nullptr,
|
||||
nullptr);
|
||||
|
||||
if (error != CL_INVALID_OPERATION)
|
||||
{
|
||||
log_error("clEnqueueWriteBufferRect should return CL_INVALID_OPERATION "
|
||||
"but retured %s between %zu and %zu",
|
||||
IGetErrorString(error), src, dst);
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
void CL_CALLBACK mem_obj_destructor_callback( cl_mem, void *data )
|
||||
{
|
||||
free( data );
|
||||
@@ -591,3 +655,16 @@ REGISTER_TEST(bufferreadwriterect)
|
||||
device, context, queue, num_elements,
|
||||
CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, test_functions);
|
||||
}
|
||||
|
||||
REGISTER_TEST(immutable_bufferreadwriterect)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_ext_immutable_memory_objects");
|
||||
|
||||
TestFunctions test_functions;
|
||||
test_functions.copy = immutable_copy_region;
|
||||
test_functions.read = read_verify_region;
|
||||
test_functions.write = immutable_write_region;
|
||||
return test_bufferreadwriterect_impl(
|
||||
device, context, queue, num_elements,
|
||||
CL_MEM_USE_HOST_PTR | CL_MEM_IMMUTABLE_EXT, test_functions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user