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

Refractor dust

parent 656d835e
......@@ -49,7 +49,7 @@ opencl_model.yaml: $(srcdir)/gen_opencl_model.rb $(srcdir)/opencl_model.rb $(ML_
opencl_babeltrace_model.yaml: $(srcdir)/gen_babeltrace_cl_model.rb opencl_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_babeltrace_cl_model.rb > $@
opencl_dummy_trace.yaml: opencl_babeltrace_model.yaml
tests/opencl_dummy_trace.yaml: opencl_babeltrace_model.yaml
$(RUBY) $(top_srcdir)/utils/gen_dummy_trace.rb opencl_babeltrace_model.yaml > $@
opencl_tracepoints.tp: $(srcdir)/gen_opencl_probes.rb $(srcdir)/opencl_model.rb tracer_opencl.h $(ML_FILES) cl.xml.patched $(srcdir)/opencl_tracepoints.rb $(srcdir)/opencl_wrapper_events.yaml
......@@ -231,7 +231,7 @@ TEST_EXTENSIONS = .dust
DUST_LOG_COMPILER = ./test_wrapper.sh
check_DATA = \
test_wrapper.sh \
opencl_dummy_trace.yaml
tests/opencl_dummy_trace.yaml
data_DATA = \
opencl_model.yaml \
......@@ -275,7 +275,7 @@ CLEANFILES = \
cl.xml.patched \
opencl_model.yaml \
opencl_babeltrace_model.yaml \
opencl_dummy_trace.yaml \
tests/opencl_dummy_trace.yaml \
babeltrace_cl_dispatchers.c \
babeltrace_cl_callbacks.h \
clprof.c \
......
#!/usr/bin/env sh
name="$(basename $1 .dust)"
echo BABELTRACE_PLUGIN_PATH=@builddir@/.libs/ DUST_TRACE_DIR=@srcdir@/tests @RUBY@ @top_srcdir@/utils/dust.rb -s @builddir@/opencl_babeltrace_model.yaml -f $1
BABELTRACE_PLUGIN_PATH=@builddir@/.libs/ DUST_TRACE_DIR=@srcdir@/tests @RUBY@ @top_srcdir@/utils/dust.rb -s @builddir@/opencl_babeltrace_model.yaml -f $1
set -o xtrace
DUST_MODELS_DIR=@abs_builddir@/ \
BABELTRACE_PLUGIN_PATH=@builddir@/.libs/ \
DUST_TRACE_DIR=@abs_srcdir@/tests:@abs_builddir@/tests \
@RUBY@ @top_srcdir@/utils/bt2.rb -f $1
---
:trace: API_call.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: souce.ruby.dust
:name: dust
:params:
test: API_call
schemas: [opencl_babeltrace_model.yaml]
trace: API_call.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: API_call
:connections:
- dust:testing_clprof
---
:trace: device_name.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: device_name
schemas: [opencl_babeltrace_model.yaml]
trace: device_name.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: device_name
:connections:
- dust:testing_clprof
---
:trace: kernel_name.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: kernel_name
schemas: [opencl_babeltrace_model.yaml]
trace: kernel_name.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: kernel_name
:connections:
- dust:testing_clprof
---
:trace: opencl_dummy_trace.yaml
:plugins:
- :name: sink:opencl:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
schemas: [opencl_babeltrace_model.yaml]
trace: opencl_dummy_trace.yaml
- :plugin: sink.text.details
:name: details
:connections:
- dust:details
---
:trace: profiling_block.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_block
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_block.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_block
:connections:
- dust:testing_clprof
---
:trace: profiling_fast.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_fast
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_fast.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_fast
:connections:
- dust:testing_clprof
---
:trace: profiling_interleave_process.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_interleave_process
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_interleave_process.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_interleave_process
:connections:
- dust:testing_clprof
---
:trace: profiling_interleave_thread.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_interleave_thread
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_interleave_thread.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_interleave_thread
:connections:
- dust:testing_clprof
---
:trace: profiling_inversed.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_inversed
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_inversed.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_inversed
:connections:
- dust:testing_clprof
---
:trace: profiling_normal.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_normal
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_normal.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_normal
:connections:
- dust:testing_clprof
---
:trace: profiling_normal_command_queue.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_normal_command_queue
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_normal_command_queue.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_normal_command_queue
:connections:
- dust:testing_clprof
---
:trace: profiling_normal_command_queue_created_in_other_thread.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_normal_command_queue_created_in_other_thread
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_normal_command_queue_created_in_other_thread.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_normal_command_queue_created_in_other_thread
:connections:
- dust:testing_clprof
---
:trace: profiling_normal_nd_range_kernel_name.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_normal_nd_range_kernel_name
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_normal_nd_range_kernel_name.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_normal_nd_range_kernel_name
:connections:
- dust:testing_clprof
---
:trace: profiling_with_error.yaml
:plugins:
- :name: sink:testing_clprof:dispatch
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
test: profiling_with_error
schemas: [opencl_babeltrace_model.yaml]
trace: profiling_with_error.yaml
- :plugin: sink.testing_clprof.dispatch
:name: testing_clprof
:params:
test: profiling_with_error
:connections:
- dust:testing_clprof
---
:trace: trace.yaml
:plugins:
- :name: sink:text:pretty
:graph_plugins:
:components:
- :plugin: source.ruby.dust
:name: dust
:params:
schemas: [opencl_babeltrace_model.yaml]
trace: trace.yaml
- :plugin: sink.text.pretty
:name: pretty
:connections:
- dust:pretty
......@@ -15,4 +15,6 @@ EXTRA_DIST = \
yaml_ast.rb \
xprof_utils.h.erb \
gen_dummy_trace.rb \
dust.rb
bt2.rb \
bt_plugins/dust.rb \
bt_plugins/comparator.rb
require 'babeltrace2'
require 'yaml'
require 'optparse'
OptionParser.new do |opts|
opts.banner = 'Usage: dust.rb [options] trace_file'
opts.on('-f', '--file FILENAME', 'Configuration file Name') do |path|
$dust_schema = YAML.load_file(path)
end
end.parse!
def get_comment_class(type, plugin, name)
if plugin != 'ruby'
bt_plugins = BT2::BTPlugin.find(plugin)
bt_plugins.send("get_#{type}_component_class_by_name", name)
else
require_relative 'bt_plugins/comparator'
require_relative 'bt_plugins/dust'
Object.const_get(name.capitalize).new.create_component_class
end
end
# TODO: Create only the components who are connected
def create_bt_components(graph, compopents)
compopents.map do |component|
type, plugin, name = component[:plugin].split('.')
bt_component_class = get_comment_class(type, plugin, name)
bt_component = graph.add(bt_component_class,
component[:name],
params: component.fetch(:params, {}))
[component[:name], bt_component]
end.to_h
end
def connect_ports(graph, bt_components, connections)
starting_port = Hash.new(0)
connections.each do |connection|
component_in, component_out = connection.split(':')
bt_component = bt_components[component_in]
sp = starting_port[component_out]
bt_component.output_ports
.each.with_index(sp) do |op, i|
ip = bt_components[component_out].input_port(i)
graph.connect_ports(op, ip)
end
starting_port[component_out] += bt_component.output_port_count
end
end
graph = BT2::BTGraph.new
bt_components = create_bt_components(graph, $dust_schema[:graph_plugins][:components])
connect_ports(graph, bt_components, $dust_schema[:graph_plugins][:connections])
graph.run
require 'babeltrace2'
require 'yaml'
require 'optparse'
class Comparator
def consume_method(_self_component)
# This function will comsume message for all the message iterator
# and compare events fields
# If the number of message consumed by message iterator are differnts
# an error is raised
stack_messages = [[], []]
@message_iterators.each_with_index { |message_iterator, i|
message_iterator.next_messages.each { |m|
stack_messages[i] << m.event if m.type == :BT_MESSAGE_TYPE_EVENT
}
}
stack_messages.transpose.each { |i, j|
%w[payload specific_context common_context].each { |tf|
i_value = i.send("get_#{tf}_field")
i_value = i_value.value if i_value
j_value = j.send("get_#{tf}_field")
j_value = j_value.value if j_value
unless i_value == j_value
pp({ in0: i_value, in1: j_value })
raise "Traces for #{tf} fields are different!"
end
}
}
end
def initialize_method(self_component, _configuration, _params, _data)
self_component.add_input_port('in0')
self_component.add_input_port('in1')
end
def graph_is_configured_method(self_component)
@message_iterators = self_component.get_input_port_count.times.map { |i|
p = self_component.get_input_port_by_index(i)
self_component.create_message_iterator(p)
}
end
def create_component_class
component_class = BT2::BTComponentClass::Sink.new(name: 'comparator',
consume_method: lambda(&method(:consume_method)))
component_class.initialize_method = lambda(&method(:initialize_method))
component_class.graph_is_configured_method = lambda(&method(:graph_is_configured_method))
component_class
end
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