Module: OpenCL::Kernel::KernelProfilingINTEL

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

Instance Method Summary collapse

Instance Method Details

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/opencl_ruby_ffi/intel/kernel_profiling.rb', line 13

def binary_program_intel(device = program.devices.first)
  ptr_bin = nil
  begin
  ptr = MemoryPointer::new( :size_t )
  error = OpenCL.clGetKernelWorkGroupInfo(self, device, BINARY_PROGRAM_INTEL, 0, nil, ptr)
  error_check(error)
  bin_size = ptr.read_size_t
  ptr_bin = MemoryPointer::new(bin_size)
  error = OpenCL.clGetKernelWorkGroupInfo(self, device, BINARY_PROGRAM_INTEL, bin_size, ptr_bin, nil)
  error_check(error)
  rescue OpenCL::Error::INVALID_VALUE
    ptr = MemoryPointer::new( :size_t )
    error = OpenCL.clGetKernelInfo(self, BINARY_PROGRAM_INTEL, 0, nil, ptr)
    error_check(error)
    bin_size = ptr.read_size_t
    ptr_bin = MemoryPointer::new(bin_size)
    error = OpenCL.clGetKernelInfo(self, BINARY_PROGRAM_INTEL, bin_size, ptr_bin, nil)
    error_check(error)
  end
  return ptr_bin.read_bytes(bin_size)
end