Class: Yadriggy::C::OclCodeGen
- Inherits:
-
CodeGen
- Object
- Yadriggy::Checker
- CodeGen
- Yadriggy::C::OclCodeGen
- Defined in:
- lib/yadriggy/c/opencl.rb
Overview
OpenCL-code generator
Defined Under Namespace
Classes: KernelPrinter
Constant Summary
Constants included from Yadriggy
Instance Method Summary collapse
- #build_cmd ⇒ Object
- #expand_functions(func_names, func_types) ⇒ Object
- #headers ⇒ Object
- #preamble ⇒ Object
- #variable_declarations ⇒ Object
Methods inherited from CodeGen
#build_lib, #c_function, #c_function_name, c_src_file, #call_with_block, #initialize, #name_global_variables, #printer, #prototype, #typechecker
Methods inherited from Yadriggy::Checker
#ast, #ast_env, #check, #check_all, #check_later, #error!, #error_found!, #error_messages, #errors?, #initialize, #last_error, #make_base_env, #proceed, rule
Methods included from Yadriggy
debug, debug=, define_syntax, reify, reset_pry
Constructor Details
This class inherits a constructor from Yadriggy::C::CodeGen
Instance Method Details
#build_cmd ⇒ Object
174 175 176 |
# File 'lib/yadriggy/c/opencl.rb', line 174 def build_cmd super + Config::OpenCLoptions end |
#expand_functions(func_names, func_types) ⇒ Object
209 210 211 212 213 214 |
# File 'lib/yadriggy/c/opencl.rb', line 209 def (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 ⇒ Object
178 179 180 181 182 |
# File 'lib/yadriggy/c/opencl.rb', line 178 def headers() super Config::OpenCLHeaders.each {|h| @printer << h << :nl } @printer << :nl end |
#preamble ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 |
# 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 ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 |
# 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 |