Module: OpenCL::Kernel::OpenCL21

Included in:
OpenCL::Kernel
Defined in:
lib/opencl_ruby_ffi/Kernel.rb

Instance Method Summary collapse

Instance Method Details

#cloneObject



392
393
394
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 392

def clone
  return OpenCL.clone_kernel( self )
end

#compile_num_sub_groups(device = program.devices.first) ⇒ Object



345
346
347
348
349
350
351
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 345

def compile_num_sub_groups(device = program.devices.first)
  error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
  ptr = MemoryPointer::new( :size_t )
  error = OpenCL.clGetKernelSubGroupInfo(self, device, COMPILE_NUM_SUB_GROUPS, 0, nil, ptr.size, ptr, nil)
  error_check(error)
  return ptr.read_size_t
end

#local_size_for_sub_group_count(sub_group_number, device = program.devices.first) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 379

def local_size_for_sub_group_count(sub_group_number, device = program.devices.first)
  error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
  sgp_p = MemoryPointer::new( :size_t )
  sgp_p.write_size_t(sub_group_number)
  size_ptr = MemoryPointer::new( :size_t )
  error = OpenCL.clGetKernelSubGroupInfo(self, device, LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sgp_p.size, sgp_p, 0, nil, size_ptr)
  error_check(error)
  lws_p = MemoryPointer::new( size_ptr.read_size_t )
  error = OpenCL.clGetKernelSubGroupInfo(self, device, LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sgp_p.size, sgp_p, lws_p.size, lws_p, nil)
  error_check(error)
  return lws_p.get_array_of_size_t(0, lws_p.size/size_ptr.size)
end

#max_num_sub_groups(device = program.devices.first) ⇒ Object



337
338
339
340
341
342
343
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 337

def max_num_sub_groups(device = program.devices.first)
  error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
  ptr = MemoryPointer::new( :size_t )
  error = OpenCL.clGetKernelSubGroupInfo(self, device, MAX_NUM_SUB_GROUPS, 0, nil, ptr.size, ptr, nil)
  error_check(error)
  return ptr.read_size_t
end

#max_sub_group_size_for_ndrange(local_work_size, device = program.devices.first) ⇒ Object



353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 353

def max_sub_group_size_for_ndrange(local_work_size, device = program.devices.first)
  error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
  local_work_size = [local_work_size].flatten
  lws_p = MemoryPointer::new( :size_t, local_work_size.length )
  local_work_size.each_with_index { |e,i|
    lws_p[i].write_size_t( e )
  }
  ptr = MemoryPointer::new( :size_t )
  error = OpenCL.clGetKernelSubGroupInfo(self, device, MAX_SUB_GROUP_SIZE_FOR_NDRANGE, lws_p.size, lws_p, ptr.size, ptr, nil)
  error_check(error)
  return ptr.read_size_t
end

#sub_groups_count_for_ndrange(local_work_size, device = program.devices.first) ⇒ Object



366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 366

def sub_groups_count_for_ndrange(local_work_size, device = program.devices.first)
  error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
  local_work_size = [local_work_size].flatten
  lws_p = MemoryPointer::new( :size_t, local_work_size.length )
  local_work_size.each_with_index { |e,i|
    lws_p[i].write_size_t( e )
  }
  ptr = MemoryPointer::new( :size_t )
  error = OpenCL.clGetKernelSubGroupInfo(self, device, SUB_GROUP_COUNT_FOR_NDRANGE, lws_p.size, lws_p, ptr.size, ptr, nil)
  error_check(error)
  return ptr.read_size_t
end