use different pointer alignment for different implementation

Submitted by Guo Yejun on Aug. 1, 2016, 8:16 p.m.

Details

Message ID 1470082579-24081-1-git-send-email-yejun.guo@intel.com
State New
Headers show
Series "use different pointer alignment for different implementation" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Guo Yejun Aug. 1, 2016, 8:16 p.m.
beignet only requirs 64 bytes alignment while other implementations
might require 4096 alignment.

and also change function cl_check_beignet for better output message.

Signed-off-by: Guo Yejun <yejun.guo@intel.com>
---
 utests/compiler_time_stamp.cpp        |  4 +++-
 utests/runtime_use_host_ptr_image.cpp |  8 ++++++--
 utests/utest_helper.cpp               | 10 ++++++----
 3 files changed, 15 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/utests/compiler_time_stamp.cpp b/utests/compiler_time_stamp.cpp
index e376522..43165c1 100644
--- a/utests/compiler_time_stamp.cpp
+++ b/utests/compiler_time_stamp.cpp
@@ -16,8 +16,10 @@  static void cpu(int global_id, int *src, int *dst) {
 
 void compiler_time_stamp(void)
 {
-  if (!cl_check_beignet())
+  if (!cl_check_beignet()) {
+    printf("Not beignet device , Skip!");
     return;
+  }
 
   const size_t n = 16;
   int cpu_dst[16], cpu_src[16];
diff --git a/utests/runtime_use_host_ptr_image.cpp b/utests/runtime_use_host_ptr_image.cpp
index 2de9194..4a30e89 100644
--- a/utests/runtime_use_host_ptr_image.cpp
+++ b/utests/runtime_use_host_ptr_image.cpp
@@ -18,8 +18,12 @@  static void runtime_use_host_ptr_image(void)
   desc.image_width = w;
   desc.image_height = h;
 
+  size_t alignment = 4096;  //page size
+  if (cl_check_beignet())
+    alignment = 64;     //cacheline size, beignet has loose limitaiont to enable userptr
+
   //src image
-  int ret = posix_memalign(&buf_data[0], 64, sizeof(uint32_t) * w * h);
+  int ret = posix_memalign(&buf_data[0], alignment, sizeof(uint32_t) * w * h);
   OCL_ASSERT(ret == 0);
   for (size_t i = 0; i < w*h; ++i)
     ((uint32_t*)buf_data[0])[i] = i;
@@ -27,7 +31,7 @@  static void runtime_use_host_ptr_image(void)
   OCL_CREATE_IMAGE(buf[0], CL_MEM_USE_HOST_PTR, &format, &desc, buf_data[0]);
 
   //dst image
-  ret = posix_memalign(&buf_data[1], 64, sizeof(uint32_t) * w * h);
+  ret = posix_memalign(&buf_data[1], alignment, sizeof(uint32_t) * w * h);
   OCL_ASSERT(ret == 0);
   for (size_t i = 0; i < w*h; ++i)
     ((uint32_t*)buf_data[1])[i] = 0;
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index da4cfbf..3388d9f 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -860,7 +860,6 @@  int cl_check_beignet(void)
   size_t ret_sz;
   OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_VERSION, 0, 0, &param_value_size);
   if(param_value_size == 0) {
-    printf("Not beignet device , Skip!");
     return 0;
   }
   char* device_version_str = (char* )malloc(param_value_size * sizeof(char) );
@@ -869,7 +868,6 @@  int cl_check_beignet(void)
 
   if(!strstr(device_version_str, "beignet")) {
     free(device_version_str);
-    printf("Not beignet device , Skip!");
     return 0;
   }
   free(device_version_str);
@@ -906,8 +904,10 @@  int cl_check_ocl20(void)
     if(cl_check_beignet()) {
       printf("Beignet extension test!");
       return 1;
+    } else {
+      printf("Not beignet device , Skip!");
+      return 0;
     }
-    return 0;
   }
   char* device_version_str = (char* )malloc(param_value_size * sizeof(char) );
   OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, (void*)device_version_str, &ret_sz);
@@ -919,8 +919,10 @@  int cl_check_ocl20(void)
     if(cl_check_beignet()) {
       printf("Beignet extension test!");
       return 1;
+    } else {
+      printf("Not beignet device , Skip!");
+      return 0;
     }
-    return 0;
   }
   free(device_version_str);
   return 1;