Skip to content

Commit

Permalink
Update to generate btx interval and model from THAPI model old format
Browse files Browse the repository at this point in the history
  • Loading branch information
DonAurelio committed Nov 1, 2023
1 parent 5305ea5 commit e7fbad9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
9 changes: 6 additions & 3 deletions hip/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ BTX_HIP_GENERATED = \

EXTRA_DIST = \
$(top_srcdir)/utils/babeltrace_to_metababel_model.rb \
$(top_srcdir)/utils/btx_interval_model.yaml \
$(top_srcdir)/xprof/interval_model.yaml \
btx_hipmatching_model.yaml

CLEANFILES = \
Expand All @@ -170,8 +170,11 @@ CLEANFILES = \
btx_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb hip_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $^ > $@

$(BTX_HIP_GENERATED) &: $(top_srcdir)/utils/btx_interval_model.yaml btx_hipmatching_model.yaml btx_model.yaml
$(METABABEL) -u btx_model.yaml -d $(top_srcdir)/utils/btx_interval_model.yaml -t FILTER -o btx_filter_hip -p hipinterval -c interval --matching $(srcdir)/btx_hipmatching_model.yaml -i hip.h.include
btx_interval_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb $(top_srcdir)/xprof/interval_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $^ > $@

$(BTX_HIP_GENERATED) &: btx_interval_model.yaml btx_hipmatching_model.yaml btx_model.yaml
$(METABABEL) -u btx_model.yaml -d btx_interval_model.yaml -t FILTER -o btx_filter_hip -p hipinterval -c interval --matching $(srcdir)/btx_hipmatching_model.yaml -i hip.h.include

$(MODIFIED_HIP_HDR) &: $(HIP_HDR) $(srcdir)/headers.patch
$(RM) -r modified_include/
Expand Down
8 changes: 8 additions & 0 deletions hip/gen_babeltrace_hip_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ def get_fields_types_name(c, dir)
}
}.flatten

environment = [
{
name: 'hostname',
class: 'string',
}
]

packet_context = [
{
name: 'cpu_id',
Expand Down Expand Up @@ -131,6 +138,7 @@ def get_fields_types_name(c, dir)

puts YAML.dump({
name: "thapi_hip",
environment: environment,
clock_snapshot_value: true,
packet_context: packet_context,
common_context: common_context,
Expand Down
25 changes: 18 additions & 7 deletions utils/babeltrace_to_metababel_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,26 @@ def get_stream_class(sc)
stream_class
end

def get_environment_entry(entry)
{ :name => entry[:name], :type => entry[:class] }
end

raise "Not input model provided" unless ARGV.length > 0
input_model_path = ARGV[0]
model = YAML.load_file(input_model_path)

trace = {
:environment => {
:entries => [{ :name => 'hostname', :type => 'string' }]
},
:stream_classes => [get_stream_class(model)],
}.to_yaml
# THAPI interval and HIP model differ.
if model.key?(:stream_classes)
stream_class = model.delete(:stream_classes).pop
event_classes = model.delete(:event_classes)
stream_class[:event_classes] = event_classes
else
stream_class = model
end

trace = {}
environment = model.delete(:environment)
trace[:environment] = { :entries => environment.map(&method(:get_environment_entry)) } if environment
trace[:stream_classes] = [get_stream_class(stream_class)]

puts trace
puts trace.to_yaml

0 comments on commit e7fbad9

Please sign in to comment.