class Yadriggy::C::OclCodeGen

OpenCL-code generator

Constants

HelperSource

Public Instance Methods

build_cmd() click to toggle source
Calls superclass method Yadriggy::C::CodeGen#build_cmd
# File lib/yadriggy/c/opencl.rb, line 174
def build_cmd
  super + Config::OpenCLoptions
end
expand_functions(func_names, func_types) click to toggle source
# File lib/yadriggy/c/opencl.rb, line 209
def expand_functions(func_names, func_types)
  voidFunc = MethodType.new([], Void)
  return func_names + ['ocl_init', 'ocl_finish'],
         func_types + [MethodType.new([Integer], Void),
                       MethodType.new([], Void)]
end
headers() click to toggle source
Calls superclass method Yadriggy::C::CodeGen#headers
# File lib/yadriggy/c/opencl.rb, line 178
def headers()
  super
  Config::OpenCLHeaders.each {|h| @printer << h << :nl }
  @printer << :nl
end
preamble() click to toggle source
Calls superclass method Yadriggy::C::CodeGen#preamble
# File lib/yadriggy/c/opencl.rb, line 197
def preamble
  super
  @printer << 'int ocl_init(int);'  << :nl
  @printer << 'void ocl_finish();' << :nl << :nl

  print_kernel_source
  @printer << HelperSource
  print_ocl_init
  print_ocl_finish
  print_callers
end
variable_declarations() click to toggle source
# File lib/yadriggy/c/opencl.rb, line 184
def variable_declarations()
  super
  @gvariables.each do |obj, name|
    if obj.is_a?(CType::OclArray)
      @printer << 'static cl_mem ' << name << ';' << :nl
    end
  end
  @typechecker.blocks.each do |obj, name_and_vars|
    @printer << 'static cl_kernel ' << name_and_vars[0] << ';' << :nl
  end
  @printer << :nl
end

Private Instance Methods

c_type(type) click to toggle source
Calls superclass method Yadriggy::C::CodeGen#c_type
# File lib/yadriggy/c/opencl.rb, line 290
def c_type(type)
  if @printer.is_a?(KernelPrinter) &&
      (type == RubyClass::Integer || type == Integer)
    return 'int'
  else
    super
  end
end
print_callers() click to toggle source
print_create_buffer_code() click to toggle source

generate the code for creating buffers.

print_create_kernel_code() click to toggle source

generate the code for creating kernels.

print_kernel_source() click to toggle source

generate kenrel source.

print_ocl_finish() click to toggle source
print_ocl_init() click to toggle source
print_type_in_kernel(type) click to toggle source

@param [Type|Class] type