[Beignet] [PATCH V2 4/4] Add the test case for clEnqueueCopyBuffer
Zou, Nanhai
nanhai.zou at intel.com
Wed Oct 9 23:43:44 PDT 2013
If I change the size to 4096.
It takes about 10s to finish the copy.
Is there anything wrong?
Thanks
Zou Nanhai
-----Original Message-----
From: beignet-bounces+nanhai.zou=intel.com at lists.freedesktop.org [mailto:beignet-bounces+nanhai.zou=intel.com at lists.freedesktop.org] On Behalf Of junyan.he at inbox.com
Sent: Wednesday, October 09, 2013 3:56 PM
To: beignet at lists.freedesktop.org
Cc: Junyan He
Subject: [Beignet] [PATCH V2 4/4] Add the test case for clEnqueueCopyBuffer
From: Junyan He <junyan.he at linux.intel.com>
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
utests/CMakeLists.txt | 1 +
utests/enqueue_copy_buf.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
create mode 100644 utests/enqueue_copy_buf.cpp
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index f18bd46..0cff1d4 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -143,6 +143,7 @@ set (utests_sources
compiler_long_cmp.cpp
compiler_bool_cross_basic_block.cpp
load_program_from_bin.cpp
+ enqueue_copy_buf.cpp
utest_assert.cpp
utest.cpp
utest_file_map.cpp
diff --git a/utests/enqueue_copy_buf.cpp b/utests/enqueue_copy_buf.cpp new file mode 100644 index 0000000..969eaa8
--- /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);
--
1.7.9.5
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list