diff options
author | Denis Steckelmacher <steckdenis@yahoo.fr> | 2011-07-27 16:32:39 +0200 |
---|---|---|
committer | Denis Steckelmacher <steckdenis@yahoo.fr> | 2011-07-27 16:32:39 +0200 |
commit | 28144b892f01f16cf5ee0581e58860674b53112a (patch) | |
tree | 59cc5120d15f261a99c89244429fe9e56fc314f4 /tests | |
parent | 0567a9ba7a08c76d4b6c81803aa2485ac52666de (diff) |
Implement clEnqueueCopyBufferRect
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_commandqueue.cpp | 33 | ||||
-rw-r--r-- | tests/test_mem.cpp | 3 |
2 files changed, 34 insertions, 2 deletions
diff --git a/tests/test_commandqueue.cpp b/tests/test_commandqueue.cpp index cbf7c1f..ea27497 100644 --- a/tests/test_commandqueue.cpp +++ b/tests/test_commandqueue.cpp @@ -1,4 +1,5 @@ #include <cstring> +#include <cstdlib> #include <iostream> #include "test_commandqueue.h" @@ -352,7 +353,7 @@ START_TEST (test_read_write_rect) cl_context ctx; cl_command_queue queue; cl_int result; - cl_mem buf; + cl_mem buf, buf_part; // Grid xyz = (5 x 7 x 2) unsigned char grid[70] = { @@ -414,6 +415,13 @@ START_TEST (test_read_write_rect) "cannot create a valid CL_MEM_USE_HOST_PTR read-write buffer" ); + buf_part = clCreateBuffer(ctx, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, + sizeof(buffer_part), buffer_part, &result); + fail_if( + result != CL_SUCCESS, + "cannot create a buffer for the part that will be read" + ); + // Write grid into buffer result = clEnqueueWriteBufferRect(queue, buf, 1, buf_origin, host_origin, region, 0, 0, 0, 0, grid, 0, 0, 0); @@ -446,6 +454,29 @@ START_TEST (test_read_write_rect) "the part of the buffer was not correctly read" ); + // Clear the temporary region and re-read into it using buf_part + std::memset(buffer_part, 0, sizeof(buffer_part)); + cl_event event; + + result = clEnqueueCopyBufferRect(queue, buf, buf_part, buf_origin, + host_origin, region, 5, 5*7, 0, 0, 0, 0, &event); + fail_if( + result != CL_SUCCESS, + "unable to queue a copy buffer rect event" + ); + + result = clWaitForEvents(1, &event); + fail_if( + result != CL_SUCCESS, + "unable to wait for the event" + ); + + fail_if( + std::memcmp(buffer_part, part, sizeof(part)) != 0, + "the part of the buffer was not correctly read using a buffer" + ); + + clReleaseMemObject(buf_part); clReleaseMemObject(buf); clReleaseCommandQueue(queue); clReleaseContext(ctx); diff --git a/tests/test_mem.cpp b/tests/test_mem.cpp index b1fd477..cbb37e2 100644 --- a/tests/test_mem.cpp +++ b/tests/test_mem.cpp @@ -1,7 +1,8 @@ +#include <iostream> + #include "test_mem.h" #include "CL/cl.h" - START_TEST (test_create_buffer) { cl_context ctx; |