Commit 964bf007 authored by Brice Videau's avatar Brice Videau
Browse files

Use blob for structures.

parent ebc2f788
Pipeline #12890 failed with stage
......@@ -32,6 +32,10 @@ def integer_size(type, pointer = false)
end
end
def cl_to_class(type)
"CL::" + type.sub(/\Acl_/,"").split("_").collect(&:capitalize).join
end
def parse_field(field)
d = {}
d[:name] = field['name'] if field['name']
......@@ -44,6 +48,7 @@ def parse_field(field)
d[:class_properties] = props
when 'ctf_string', 'ctf_sequence_text'
d[:class] = 'string'
d[:be_class] = cl_to_class(field['type']) if field['structure']
when 'ctf_array'
d[:class] = 'array_static'
d[:field] = parse_field({ 'lttng' => 'ctf_integer', 'type' => field['type'], 'pointer'=> field['pointer'] })
......@@ -72,8 +77,9 @@ schema_event = OPENCL_MODEL['events'].map { |name, fields|
cast_type << ' *' if field['pointer']
cast_type << ' *' if field['array']
cast_type << ' *' if field['string']
cast_type << ' *' if field['structure']
parsed_field[:cast_type] = cast_type
if field['array'] && field['lttng'].match('ctf_sequence')
if (field['array'] || field['structure']) && field['lttng'].match('ctf_sequence')
additional_parsed_field = parse_field({ 'name' => "_#{sub_name}_length",
'lttng' => 'ctf_integer', 'type' => 'size_t' })
additional_parsed_field[:cast_type] = 'size_t'
......
......@@ -20,6 +20,7 @@ res = {
"int_scalars" => int_scalars,
"float_scalars" => float_scalars,
"type_map" => CL_TYPE_MAP,
"structures" => CL_STRUCTS,
"lttng_enums" => lttng_enums,
"events" => events
}
......@@ -56,18 +57,6 @@ event_lambda = lambda { |c, dir|
param["type"] = ( (p.callback? || p.type == '') ? "void" : p.type == '*' ? "void*" : p.type)
param["pointer"] = true if p.pointer?
}
meta_structs = []
if $meta_parameters["meta_structs"][c.prototype.name]
meta_structs = $meta_parameters["meta_structs"][c.prototype.name]
end
meta_structs = meta_structs.to_h
meta_structs = meta_structs.collect { |pname, type|
[pname, CL_STRUCT_MAP[type].collect { |m|
Member::new(c, m, pname)
}.collect { |m|
[m.name, m]
}.to_h]
}.to_h
if dir == "start"
c.parameters.select { |p| p.lttng_in_type }.each { |p|
field = {}
......@@ -87,16 +76,7 @@ event_lambda = lambda { |c, dir|
pname = fname.gsub(/_val\z/, "")
meta_field["type"] = params[pname]["type"]
else
begin
meta_field["type"] = params[LTTng.expression(*lttng)]["type"]
rescue #must be a struct member
pname = LTTng.expression(*lttng).match(/(\w+) != NULL/)[1]
m = meta_structs[pname][fname.gsub(/\A#{pname}#{MEMBER_SEPARATOR}/,"")]
meta_field["name"] = m.name
meta_field["type"] = m.type
meta_field["pointer"] = m.pointer? if m.pointer?
meta_field["struct"] = pname
end
meta_field["type"] = params[LTTng.expression(*lttng)]["type"]
end
if meta_field["type"].match(/\*\z/)
meta_field["type"] = meta_field["type"].sub(/\*\z/, "")
......@@ -106,6 +86,12 @@ event_lambda = lambda { |c, dir|
meta_field["string"] = true if LTTng.string?(*lttng)
meta_field["lttng"] = lttng[0]
meta_field["length"] = lttng[4] if meta_field["lttng"].match("ctf_array")
if meta_field["array"] &&
!meta_field["pointer"] &&
CL_STRUCTS.include?(meta_field["type"])
meta_field.delete("array")
meta_field["structure"] = true
end
fields[fname] = meta_field
}
else
......@@ -144,6 +130,12 @@ event_lambda = lambda { |c, dir|
meta_field["string"] = true if LTTng.string?(*lttng)
meta_field["lttng"] = lttng[0]
meta_field["length"] = lttng[4] if meta_field["lttng"].match("ctf_array")
if meta_field["array"] &&
!meta_field["pointer"] &&
CL_STRUCTS.include?(meta_field["type"])
meta_field.delete("array")
meta_field["structure"] = true
end
fields[fname] = meta_field
}
end
......
......@@ -105,6 +105,13 @@ meta_parameters:
- [ InArray, input_programs, num_input_programs ]
clEnqueueFillBuffer:
- [ InArray, pattern, pattern_size ]
clCreateImage2D:
- [ InScalar, image_format ]
clCreateImage3D:
- [ InScalar, image_format ]
clCreateImage:
- [ InScalar, image_format ]
- [ InScalar, image_desc ]
clEnqueueFillImage:
- [ InFixedArray, origin, 3 ]
- [ InFixedArray, region, 3 ]
......@@ -152,11 +159,17 @@ meta_parameters:
- [ InNullArray, properties ]
clCreateImageWithProperties:
- [ InNullArray, properties ]
- [ InScalar, image_format ]
- [ InScalar, image_desc ]
clCreateBufferWithPropertiesINTEL:
- [ InNullArray, properties ]
clCreateImageWithPropertiesINTEL:
- [ InNullArray, properties ]
- [ InScalar, image_format ]
- [ InScalar, image_desc ]
clGetImageParamsINTEL:
- [ InScalar, image_format ]
- [ InScalar, image_desc ]
- [ OutScalar, image_row_pitch ]
- [ OutScalar, image_slice_pitch ]
clAddCommentINTEL:
......@@ -187,20 +200,3 @@ meta_parameters:
- [ InArray, global_work_offset, work_dim ]
- [ InArray, work_group_count, work_dim ]
- [ InArray, local_work_size, work_dim ]
meta_structs:
clCreateImage2D:
- [ image_format, cl_image_format ]
clCreateImage3D:
- [ image_format, cl_image_format ]
clCreateImage:
- [ image_format, cl_image_format ]
- [ image_desc, cl_image_desc ]
clCreateImageWithProperties:
- [ image_format, cl_image_format ]
- [ image_desc, cl_image_desc ]
clCreateImageWithPropertiesINTEL:
- [ image_format, cl_image_format ]
- [ image_desc, cl_image_desc ]
clGetImageParamsINTEL:
- [ image_format, cl_image_format ]
- [ image_desc, cl_image_desc ]
......@@ -447,6 +447,33 @@ class InMetaParameter < MetaParameter
end
end
class InScalar < InMetaParameter
def initialize(command, name, nocheck: false)
super
raise "Couldn't find variable #{name} for #{command.prototype.name}!" unless command[name]
type = command[name].type.gsub("*", "")
type = CL_TYPE_MAP[type] if CL_TYPE_MAP[type]
if ENUM_PARAM_NAME_MAP[name]
@lttng_in_type = ["ctf_enum", "lttng_ust_opencl", ENUM_PARAM_NAME_MAP[name], type, name+"_val", nocheck ? "*#{name}" : "#{name} == NULL ? 0 : *#{name}"]
else
case type
when *CL_OBJECTS, *CL_EXT_OBJECTS
@lttng_in_type = ["ctf_integer_hex", "uintptr_t", name+"_val", nocheck ? "(uintptr_t)(*#{name})" : "(uintptr_t)(#{name} == NULL ? 0 : *#{name})"]
when *CL_INT_SCALARS
@lttng_in_type = ["ctf_integer", type, name+"_val", nocheck ? "*#{name}" : "#{name} == NULL ? 0 : *#{name}"]
when *CL_FLOAT_SCALARS
@lttng_in_type = ["ctf_float", type, name+"_val", nocheck ? "*#{name}" : "#{name} == NULL ? 0 : *#{name}"]
when *CL_STRUCTS
@lttng_in_type = ["ctf_sequence_text", "uint8_t", name+"_val", "(uint8_t *)#{name}", "size_t", "#{name} == NULL ? 0 : sizeof(#{type})"]
when "void"
@lttng_in_type = ["ctf_integer_hex", "uintptr_t", name+"_val", nocheck ? "(uintptr_t)(*#{name})" : "(uintptr_t)(#{name} == NULL ? 0 : *#{name})"]
else
raise "Unknown Type: #{type.inspect}!"
end
end
end
end
class OutScalar < OutMetaParameter
def initialize(command, name, nocheck: false)
super
......@@ -623,15 +650,6 @@ def register_meta_parameter(method, type, *args)
META_PARAMETERS[method].push [type, args]
end
def register_meta_struct(method, name, type)
raise "Unknown method: #{method}!" unless OPENCL_COMMAND_NAMES.include?(method) || OPENCL_EXTENSION_COMMAND_NAMES.include?(method)
raise "Unknown struct: #{type}!" unless CL_STRUCTS.include?(type)
CL_STRUCT_MAP[type].each { |m|
META_PARAMETERS[method].push [Member, [m, name]]
}
end
def register_prologue(method, code)
raise "Unknown method: #{method}!" unless OPENCL_COMMAND_NAMES.include?(method) || OPENCL_EXTENSION_COMMAND_NAMES.include?(method)
PROLOGUES[method].push(code)
......@@ -721,12 +739,6 @@ $meta_parameters["meta_parameters"].each { |func, list|
}
}
$meta_parameters["meta_structs"].each { |func, list|
list.each { |args|
register_meta_struct func, *args
}
}
$opencl_commands = funcs_e.collect { |func|
Command::new(func)
}
......
......@@ -152,10 +152,16 @@ def populate_field(field, field_value)
thapi_root = ENV['THAPI_ROOT']
require "/#{thapi_root}/share/ze_bindings"
struct = ZE.const_get(n.to_sym).new
elsif n.star_with?('CL')
struct = OpenCL.const_get(n.to_sym).new
elsif n.start_with?('CL::')
require 'opencl_ruby_ffi/opencl_types'
require 'opencl_ruby_ffi/opencl_arithmetic_gen'
require 'opencl_ruby_ffi/opencl_ruby_ffi_base_gen'
require 'opencl_ruby_ffi/opencl_ruby_ffi_base'
struct = OpenCL.const_get(n[4..-1].to_sym).new
elsif n.start_with?('CU')
struct = CU.const_get(n.to_sym).new
else
raise "unsupported be_class structure #{n}"
end
be_populate_struc_field(struct, field_value) if field_value
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment