Class: MetaCL::Templates::KernelInit
- Inherits:
-
Mustache
- Object
- Mustache
- MetaCL::Templates::KernelInit
- Defined in:
- lib/metacl/templates/kernel_init.rb
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
-
#kernel_code ⇒ Object
readonly
Returns the value of attribute kernel_code.
-
#m_from ⇒ Object
readonly
Returns the value of attribute m_from.
-
#m_to ⇒ Object
readonly
Returns the value of attribute m_to.
-
#n_from ⇒ Object
readonly
Returns the value of attribute n_from.
-
#n_to ⇒ Object
readonly
Returns the value of attribute n_to.
-
#template_params ⇒ Object
readonly
Returns the value of attribute template_params.
Instance Method Summary collapse
- #gen_kernel_code ⇒ Object
- #gen_template_params ⇒ Object
- #render(from_border, to_border, code, result_object, objects, counter, platform) ⇒ Object
Instance Attribute Details
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def counter @counter end |
#kernel_code ⇒ Object (readonly)
Returns the value of attribute kernel_code.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def kernel_code @kernel_code end |
#m_from ⇒ Object (readonly)
Returns the value of attribute m_from.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def m_from @m_from end |
#m_to ⇒ Object (readonly)
Returns the value of attribute m_to.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def m_to @m_to end |
#n_from ⇒ Object (readonly)
Returns the value of attribute n_from.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def n_from @n_from end |
#n_to ⇒ Object (readonly)
Returns the value of attribute n_to.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def n_to @n_to end |
#template_params ⇒ Object (readonly)
Returns the value of attribute template_params.
4 5 6 |
# File 'lib/metacl/templates/kernel_init.rb', line 4 def template_params @template_params end |
Instance Method Details
#gen_kernel_code ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metacl/templates/kernel_init.rb', line 20 def gen_kernel_code params = [] @objects.each do |x| case x.klass when :matrix, :array params << "global const #{x.type}* #{x.name}" when :numeric # TODO end end params << "global #{@result_object.type}* #{@result_object.name}" @kernel_code = Templates::Kernel.render(params.join(', '), @code, @n_from, @m_from, @counter) @kernel_code = Utils.stringify_text(@kernel_code) end |
#gen_template_params ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/metacl/templates/kernel_init.rb', line 36 def gen_template_params params = [] @objects.each do |x| case x.klass when :matrix, :array params << "cl::Buffer&" when :numeric # TODO end end params << "cl::Buffer&" # for result @template_params = params.join(', ') end |
#render(from_border, to_border, code, result_object, objects, counter, platform) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/metacl/templates/kernel_init.rb', line 6 def render(from_border, to_border, code, result_object, objects, counter, platform) if platform == :cl @counter = counter @code = Utils.tab_text(code, 1) @result_object = result_object @objects = objects @n_from, @m_from = from_border @n_to, @m_to = to_border gen_kernel_code gen_template_params super IO.read("#{__dir__}/kernel_init.cl.template") end end |