diff options
author | Junyan He <junyan.he@linux.intel.com> | 2013-10-09 15:55:43 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2013-10-10 13:33:39 +0800 |
commit | 240520c7aa3f3c7a80519cb7193344bbb7775b30 (patch) | |
tree | ad36207056ae0da6fc74e66200fe624e77607251 /utests/enqueue_copy_buf.cpp | |
parent | 4b03f5ba110666111f9bb3cdce69b155a13709ae (diff) | |
download | beignet-240520c7aa3f3c7a80519cb7193344bbb7775b30.tar.gz |
Add the test case for clEnqueueCopyBuffer
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'utests/enqueue_copy_buf.cpp')
-rw-r--r-- | utests/enqueue_copy_buf.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/utests/enqueue_copy_buf.cpp b/utests/enqueue_copy_buf.cpp new file mode 100644 index 00000000..969eaa88 --- /dev/null +++ b/utests/enqueue_copy_buf.cpp @@ -0,0 +1,66 @@ +#include "utest_helper.hpp" + +void test_copy_buf(size_t sz, size_t src_off, size_t dst_off, size_t cb) +{ + unsigned int i; + OCL_MAP_BUFFER(0); + + for (i=0; i < sz; i++) { + ((char*)buf_data[0])[i] = (rand() & 63); + } + + OCL_UNMAP_BUFFER(0); + + if (src_off + cb > sz || dst_off + cb > sz) { + /* Expect Error. */ + OCL_ASSERT(clEnqueueCopyBuffer(queue, buf[0], buf[1], + src_off, dst_off, cb*sizeof(char), 0, NULL, NULL)); + return; + } + + OCL_ASSERT(!clEnqueueCopyBuffer(queue, buf[0], buf[1], + src_off, dst_off, cb*sizeof(char), 0, NULL, NULL)); + + OCL_MAP_BUFFER(0); + OCL_MAP_BUFFER(1); + +#if 0 + printf("\n########### Src buffer: \n"); + for (i = 0; i < cb; ++i) + printf(" %2.2u", ((unsigned char*)buf_data[0])[i + src_off]); + + printf("\n########### dst buffer: \n"); + for (i = 0; i < cb; ++i) + printf(" %2.2u", ((unsigned char*)buf_data[1])[i + dst_off]); +#endif + + // Check results + for (i = 0; i < cb; ++i) { + if (((char*)buf_data[0])[i + src_off] != ((char*)buf_data[1])[i + dst_off]) { + printf ("different index is %d\n", i); + OCL_ASSERT(0); + } + } + + OCL_UNMAP_BUFFER(0); + OCL_UNMAP_BUFFER(1); + +} + +void enqueue_copy_buf(void) +{ + size_t i; + size_t j; + const size_t sz = 1024; + + OCL_CREATE_BUFFER(buf[0], 0, sz * sizeof(char), NULL); + OCL_CREATE_BUFFER(buf[1], 0, sz * sizeof(char), NULL); + + for (i=0; i<sz; i+=8) { + for (j=0; j<sz; j+=10) { + test_copy_buf(sz, i, j, sz/2); + } + } +} + +MAKE_UTEST_FROM_FUNCTION(enqueue_copy_buf); |