Browse Source

Fix querying kernel work group sizes with Intel OpenCL CPU driver

This fixes the kernel test with Intel OpenCL CPU driver version 6.4.0.25.
Peter Colberg 2 years ago
parent
commit
d3b82a3335
1 changed files with 4 additions and 9 deletions
  1. 4
    9
      opencl/init.lua

+ 4
- 9
opencl/init.lua View File

@@ -77,6 +77,7 @@ local const_char_ptr                    = ffi.typeof("const char *")
77 77
 local const_char_ptr_1                  = ffi.typeof("const char *[1]")
78 78
 local size_t                            = ffi.typeof("size_t")
79 79
 local size_t_1                          = ffi.typeof("size_t[1]")
80
+local size_t_3                          = ffi.typeof("size_t[3]")
80 81
 local size_t_n                          = ffi.typeof("size_t[?]")
81 82
 local unsigned_char_n                   = ffi.typeof("unsigned char[?]")
82 83
 local unsigned_char_ptr                 = ffi.typeof("unsigned char *")
@@ -1172,17 +1173,11 @@ do
1172 1173
 
1173 1174
   local function get_kernel_work_group_info_sizes(name)
1174 1175
     return function(kernel, device)
1175
-      local size = size_t_1()
1176
-      local status = C.clGetKernelWorkGroupInfo(kernel, device, name, 0, nil, size)
1177
-      if status == C.CL_INVALID_VALUE or status == C.CL_INVALID_OPERATION then return end
1178
-      if status ~= C.CL_SUCCESS then return error(errors[status]) end
1179
-      local num_sizes = tonumber(size[0]) / ffi.sizeof(size_t)
1180
-      local value = size_t_n(num_sizes)
1176
+      local value = size_t_3()
1181 1177
       local status = C.clGetKernelWorkGroupInfo(kernel, device, name, ffi.sizeof(value), value, nil)
1178
+      if status == C.CL_INVALID_VALUE or status == C.CL_INVALID_OPERATION then return end
1182 1179
       if status ~= C.CL_SUCCESS then return error(errors[status]) end
1183
-      local sizes = {}
1184
-      for i = 0, num_sizes - 1 do sizes[i + 1] = tonumber(value[i]) end
1185
-      return sizes
1180
+      return {tonumber(value[0]), tonumber(value[1]), tonumber(value[2])}
1186 1181
     end
1187 1182
   end
1188 1183
 

Loading…
Cancel
Save