Module: OpenCL::Kernel::OpenCL21

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

Instance Method Summary collapse

Instance Method Details

#cloneObject



428
429
430
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 428

def clone
  return OpenCL.clone_kernel( self )
end

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



381
382
383
384
385
386
387
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 381

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



415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 415

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



373
374
375
376
377
378
379
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 373

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



389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 389

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



402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 402

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