Added support for: clEnqueueReadBuffer clgetkernelWorkGroupInfo: For this currently...
authorhlthantr <devnull@localhost>
Wed, 31 Aug 2011 20:07:24 +0000 (20:07 +0000)
committerKeith Packard <keithp@keithp.com>
Fri, 10 Aug 2012 23:14:50 +0000 (16:14 -0700)
Fixed issue:
A return value issue in drm_intel_bo_subdata, where different versions of the library differ in how they treat error. In one case, an rval of zero indicates success,
and in the other, it indicates failure. Fix is to remove the checking of rval entirely.

src/cl_api.c
src/cl_device_id.c
src/cl_device_id.h
src/cl_mem.c

index 23bb33c..beab87f 100644 (file)
@@ -574,8 +574,11 @@ clGetKernelWorkGroupInfo(cl_kernel                   kernel,
                          void *                      param_value,
                          size_t *                    param_value_size_ret)
 {
-  NOT_IMPLEMENTED;
-  return 0;
+  return cl_get_kernel_workgroup_info(device, 
+                                       param_name, 
+                                       param_value_size, 
+                                       param_value, 
+                                       param_value_size_ret);
 }
 
 cl_int
@@ -680,8 +683,10 @@ clEnqueueReadBuffer(cl_command_queue command_queue,
                     const cl_event * event_wait_list,
                     cl_event *       event)
 {
-  NOT_IMPLEMENTED;
-  return 0;
+       cl_int err = CL_SUCCESS;
+       assert(ptr != NULL);
+       ptr = clIntelMapBuffer(buffer, &err);
+       return err;
 }
 
 cl_int
index ff2a7be..0251ff6 100644 (file)
@@ -34,7 +34,10 @@ static struct _cl_device_id intel_snb_gt2_device = {
   .max_work_item_sizes = {512, 512, 512},
   .max_work_group_size = 512,
   .max_clock_frequency = 1350,
-
+  /* Does not really belong here, but for now this seems the most
+   * natural place to put it */
+   .wg_sz = 512,
+   .compile_wg_sz = {0},       
   #include "cl_gen6_device.h"
 };
 
@@ -43,6 +46,8 @@ static struct _cl_device_id intel_snb_gt1_device = {
   .max_work_item_sizes = {256, 256, 256},
   .max_work_group_size = 256,
   .max_clock_frequency = 1000,
+  .wg_sz = 256,
+  .compile_wg_sz = {0},        
 
   #include "cl_gen6_device.h"
 };
@@ -53,6 +58,8 @@ static struct _cl_device_id intel_ivb_gt2_device = {
   .max_work_group_size = 512,
   .max_clock_frequency = 1000,
 
+   .wg_sz = 1024,
+   .compile_wg_sz = {0},       
   #include "cl_gen7_device.h"
 };
 
@@ -61,6 +68,8 @@ static struct _cl_device_id intel_ivb_gt1_device = {
   .max_work_item_sizes = {512, 512, 512},
   .max_work_group_size = 512,
   .max_clock_frequency = 1000,
+  .wg_sz = 512,
+  .compile_wg_sz = {0},        
 
   #include "cl_gen7_device.h"
 };
@@ -249,4 +258,38 @@ cl_device_get_version(cl_device_id device, cl_int *ver)
     *ver = 7;
   return CL_SUCCESS;
 }
+#undef DECL_FIELD
+#define DECL_FIELD(CASE,FIELD)                                      \
+  case JOIN(CL_KERNEL_,CASE):                                       \
+      if (param_value_size < sizeof(((cl_device_id)NULL)->FIELD))   \
+        return CL_INVALID_VALUE;                                    \
+      if (param_value_size_ret != NULL)                             \
+        *param_value_size_ret = sizeof(((cl_device_id)NULL)->FIELD);\
+      memcpy(param_value,                                           \
+             &device->FIELD,                                        \
+             sizeof(((cl_device_id)NULL)->FIELD));                  \
+        return CL_SUCCESS;
 
+LOCAL cl_int cl_get_kernel_workgroup_info(
+                               cl_device_id device,
+                               cl_kernel_work_group_info param_name,
+                               size_t param_value_size,
+                               void* param_value,
+                               size_t* param_value_size_ret)
+{
+       if (UNLIKELY(device != &intel_snb_gt1_device &&
+                       device != &intel_snb_gt2_device &&
+                       device != &intel_ivb_gt1_device &&
+                       device != &intel_ivb_gt2_device))
+               return CL_INVALID_DEVICE;
+       if (UNLIKELY(param_value == NULL))
+               return CL_INVALID_VALUE;
+       
+       switch (param_name) {
+               DECL_FIELD(WORK_GROUP_SIZE, wg_sz)
+               DECL_FIELD(COMPILE_WORK_GROUP_SIZE, compile_wg_sz)
+               default: return CL_INVALID_VALUE;
+       };
+
+
+}
index 3b2f1be..9213608 100644 (file)
@@ -87,6 +87,9 @@ struct _cl_device_id {
   size_t profile_sz;
   size_t opencl_c_version_sz;
   size_t extensions_sz;
+ /* Kernel specific info that we're assigning statically */
+  size_t wg_sz;
+  size_t compile_wg_sz[3];
   uint32_t gfx_id; /* Used by shaders */
 };
 
@@ -107,6 +110,11 @@ extern cl_int cl_get_device_info(cl_device_id     device,
                                  void *           param_value,
                                  size_t *         param_value_size_ret);
 
+extern cl_int cl_get_kernel_workgroup_info(cl_device_id     device,
+                                 cl_kernel_work_group_info   param_name,
+                                 size_t           param_value_size,
+                                 void *           param_value,
+                                 size_t *         param_value_size_ret);
 /* Returns the Gen device ID */
 extern cl_int cl_device_get_version(cl_device_id device, cl_int *ver);
 
index 503c7d4..f37c846 100644 (file)
@@ -73,13 +73,16 @@ cl_mem_new(cl_context ctx,
     err = CL_MEM_ALLOCATION_FAILURE;
     goto error;
   }
-
   /* Copy the data if required */
   if (flags & CL_MEM_COPY_HOST_PTR) /* TODO check other flags too */
+       drm_intel_bo_subdata(mem->bo, 0, sz, data);
+   #if 0       
     if (UNLIKELY(drm_intel_bo_subdata(mem->bo, 0, sz, data) != 0)) {
       err = CL_MEM_ALLOCATION_FAILURE;
       goto error;
     }
+   #endif
+       
 
   /* Append the buffer in the context buffer list */
   pthread_mutex_lock(&ctx->buffer_lock);