Commit fe234414 authored by Thomas Applencourt's avatar Thomas Applencourt
Browse files

Merge branch 'master' into 'modularize'

Merge with master

See merge request !13
parents 49b0585a e1a2cd9f
Pipeline #12817 canceled with stage
......@@ -10,6 +10,7 @@ enums = {}
objects = CL_OBJECTS + CL_EXT_OBJECTS
int_scalars = CL_INT_SCALARS
float_scalars = CL_FLOAT_SCALARS
lttng_enums = {}
events = {}
res = {
......@@ -19,6 +20,7 @@ res = {
"int_scalars" => int_scalars,
"float_scalars" => float_scalars,
"type_map" => CL_TYPE_MAP,
"lttng_enums" => lttng_enums,
"events" => events
}
......@@ -163,6 +165,13 @@ YAML::load_file(File.join(SRC_DIR,"opencl_wrapper_events.yaml")).each { |namespa
}
YAML::load_file(File.join(SRC_DIR,"opencl_events.yaml")).each { |namespace, h|
if h["enums"]
h["enums"].each { |e|
lttng_enums[e["name"]] = {
values: e["values"].collect { |v| { type: v[0], name: v[1], value: v[2] }}
}
}
end
h["events"].each { |e|
event = get_fields(e["args"], e["fields"])
events["#{namespace}:#{e["name"]}"] = event
......
......@@ -390,7 +390,7 @@ class Prototype < CLXML
end
class MetaParameter
def initialize(command, name)
def initialize(command, name, nocheck: false)
@command = command
@name = name
end
......@@ -448,23 +448,23 @@ class InMetaParameter < MetaParameter
end
class OutScalar < OutMetaParameter
def initialize(command, name)
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_out_type = ["ctf_enum", "lttng_ust_opencl", ENUM_PARAM_NAME_MAP[name], type, name+"_val", "#{name} == NULL ? 0 : *#{name}"]
@lttng_out_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_out_type = ["ctf_integer_hex", "uintptr_t", name+"_val", "(uintptr_t)(#{name} == NULL ? 0 : *#{name})"]
@lttng_out_type = ["ctf_integer_hex", "uintptr_t", name+"_val", nocheck ? "(uintptr_t)(*#{name})" : "(uintptr_t)(#{name} == NULL ? 0 : *#{name})"]
when *CL_INT_SCALARS
@lttng_out_type = ["ctf_integer", type, name+"_val", "#{name} == NULL ? 0 : *#{name}"]
@lttng_out_type = ["ctf_integer", type, name+"_val", nocheck ? "*#{name}" : "#{name} == NULL ? 0 : *#{name}"]
when *CL_FLOAT_SCALARS
@lttng_out_type = ["ctf_float", type, name+"_val", "#{name} == NULL ? 0 : *#{name}"]
@lttng_out_type = ["ctf_float", type, name+"_val", nocheck ? "*#{name}" : "#{name} == NULL ? 0 : *#{name}"]
when "void"
@lttng_out_type = ["ctf_integer_hex", "uintptr_t", name+"_val", "(uintptr_t)(#{name} == NULL ? 0 : *#{name})"]
@lttng_out_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
......@@ -573,13 +573,13 @@ class EventWaitList < AutoMetaParameter
end
class AutoOutScalar
def self.create(name)
def self.create(name, nocheck: false)
str = <<EOF
Class::new(AutoMetaParameter) do
def self.create_if_match(command)
par = command.parameters.find { |p| p.name == "#{name}" && p.pointer? }
if par
return OutScalar::new(command, "#{name}")
return OutScalar::new(command, "#{name}", nocheck: #{nocheck})
end
nil
end
......@@ -612,9 +612,9 @@ class TracepointParameter
end
end
ErrCodeRet = AutoOutScalar::create("errcode_ret")
ErrCodeRet = AutoOutScalar::create("errcode_ret", nocheck: true)
ParamValueSizeRet = AutoOutScalar::create("param_value_size_ret")
ParamValueSizeRet = AutoOutScalar::create("param_value_size_ret", nocheck: true)
Event = AutoOutScalar::create("event")
......@@ -753,6 +753,16 @@ OPENCL_POINTER_NAMES = ($opencl_commands.collect { |c|
[c, c.prototype.pointer_name]
}).to_h
($opencl_commands+$opencl_extension_commands).select { |c|
c.parameters.find { |p| p.name == "errcode_ret" && p.pointer? }
}.each { |c|
c.prologues.push <<EOF
cl_int _errcode_ret_force;
if (!errcode_ret)
errcode_ret = &_errcode_ret_force;
EOF
}
($opencl_commands+$opencl_extension_commands).select { |c|
c.parameters.find { |p| p.name == "param_value_size_ret" && p.pointer? }
}.each { |c|
......
......@@ -18,6 +18,10 @@ class LTTng
args[0].match("string")
end
def self.enum?(*args)
args[0].match("enum")
end
def self.expression(*args)
case args[0]
when "ctf_string"
......@@ -107,6 +111,9 @@ def get_field(args, field)
res["string"] = true
res.delete("pointer")
end
if LTTng.enum?(*field)
res["enum_type"] = field[2]
end
res["lttng"] = field[0]
[ name, res ]
end
......
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