Commit 02f2135a authored by Thomas Applencourt's avatar Thomas Applencourt
Browse files

OpenCL is now using new plugins

parent 3c690f6b
Pipeline #13180 failed with stage
......@@ -28,9 +28,9 @@ static void create_and_enqueue_host_message(const char* hostname, const process_
/* Message creation */
bt_message *message = create_host_message(hostname, process_id, thread_id, name, ts, duration, err,
clinterval_iter_g->dispatch->host_event_class,
self_message_iterator_g,
clinterval_iter_g->dispatch->stream);
clinterval_iter_g->dispatch->host_event_class,
self_message_iterator_g,
clinterval_iter_g->dispatch->stream);
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_iter_g->callbacks_state;
state->downstream_message_queue.push(message);
......@@ -42,16 +42,31 @@ static void create_and_enqueue_device_message(const char* hostname, const proces
/* Message creation */
bt_message *message = create_device_message(hostname, process_id, thread_id, device_id, subdevice_id, name, ts, duration, err,
clinterval_iter_g->dispatch->device_event_class,
self_message_iterator_g,
clinterval_iter_g->dispatch->stream);
clinterval_iter_g->dispatch->device_event_class,
self_message_iterator_g,
clinterval_iter_g->dispatch->stream);
/* Set message */
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_iter_g->callbacks_state;
state->downstream_message_queue.push(message);
}
static void create_and_enqueue_device_name_message(const char* hostname, const process_id_t process_id,
const thapi_device_id device_id,
const char* name) {
/* Message creation */
bt_message *message = create_device_name_message(hostname, process_id, device_id, name,
clinterval_iter_g->dispatch->device_name_event_class,
self_message_iterator_g,
clinterval_iter_g->dispatch->stream);
/* Set message */
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_iter_g->callbacks_state;
state->downstream_message_queue.push(message);
}
static void create_and_enqueue_traffic_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id, const char* name,
const uint64_t size) {
......@@ -65,6 +80,8 @@ static void create_and_enqueue_traffic_message(const char* hostname, const proce
state->downstream_message_queue.push(message);
}
<%#
_ _ _ ___
| \ _ ._ _ _|_ ._ _ _. ._ _ / \ _ _ /\ |_) |
......@@ -203,10 +220,9 @@ static void clinterval_<%= dbt_event.name %>_callback(
state->command_queue_to_device[hp_command_queue_t(hostname,process_id,command_queue)] = dsd_t(device, 0) ;
}
<% elsif dbt_event.name_unsanitized == "lttng_ust_opencl_devices:device_name" %>
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_iter_g->callbacks_state;
const hostname_t hostname{ borrow_hostname(bt_evt)};
const process_id_t process_id = borrow_process_id(bt_evt);
state->device_to_name[hp_device_t(hostname,process_id,(thapi_device_id) device)] = hostname_t{name};
const process_id_t process_id {borrow_process_id(bt_evt) };
create_and_enqueue_device_name_message(hostname.c_str(),process_id,(thapi_device_id) device, name);
<% end %>
<%#
......
......@@ -21,7 +21,6 @@ struct clinterval_callbacks_state {
std::unordered_map<hp_kernel_t, thapi_function_name> kernel_to_name;
std::unordered_map<hpt_function_name_t, uint64_t> host_start;
std::unordered_map<hp_device_t, std::string> device_to_name;
std::unordered_map<hp_device_t, thapi_device_id> device_to_rootdevice;
std::unordered_map<hpt_t, thapi_device_id> start_device;
std::unordered_map<hpt_t, thapi_function_name> profiled_function_name;
......
......@@ -156,7 +156,10 @@ summary() {
fi
<% if languages.include?("opencl") %>
ocl_output=$(babeltrace2 --plugin-path=$libdir --component=sink.clprof.dispatch --params="display=$display" ${lttng_last_session})
ocl_output=$(babeltrace2 --plugin-path=$libdir \
${lttng_last_session} \
--component=filter.clinterval.interval \
--component=sink.xprof.tally --params="display=$display")
if [ -n "$ocl_output" ]; then
echo "== OpenCL == "
echo "$ocl_output"
......
......@@ -120,6 +120,43 @@ bt_message* create_device_message(const char* hostname, const process_id_t proce
return message;
}
bt_message* create_device_name_message(const char* hostname, const process_id_t process_id,
const thapi_device_id device_id, const char* name,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream) {
/* Message creation */
bt_message *message = bt_message_event_create(
message_iterator, event_class, stream);
/* event */
bt_event *downstream_event = bt_message_event_borrow_event(message);
/* Common context */
bt_field *context_field = bt_event_borrow_common_context_field(downstream_event);
// Hostname
bt_field *hostname_msg_field = bt_field_structure_borrow_member_field_by_index(context_field,0);
bt_field_string_set_value(hostname_msg_field, hostname);
// pid
bt_field *vpid_field = bt_field_structure_borrow_member_field_by_index(context_field,1);
bt_field_integer_signed_set_value(vpid_field, process_id);
// vid
/* Payload */
bt_field *payload_field = bt_event_borrow_payload_field(downstream_event);
// name
bt_field *name_field = bt_field_structure_borrow_member_field_by_index(payload_field, 0);
bt_field_string_set_value(name_field, name);
// did
bt_field *device_id_field = bt_field_structure_borrow_member_field_by_index(payload_field,1);
bt_field_integer_unsigned_set_value(device_id_field, device_id);
return message;
}
bt_message* create_traffic_message(const char *hostname, const process_id_t process_id , const thread_id_t thread_id,
const char *name, const uint64_t size,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream) {
......
......@@ -89,6 +89,10 @@ bt_message* create_device_message(const char *hostname, const process_id_t, cons
const char *name, const uint64_t ts, const uint64_t duration, const bool err,
bt_event_class*, bt_self_message_iterator*, bt_stream*);
bt_message* create_device_name_message(const char* hostname, const process_id_t process_id,
const thapi_device_id device_id, const char* name,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream);
bt_message* create_traffic_message(const char *hostname, const process_id_t, const thread_id_t,
const char *name, const uint64_t size,
bt_event_class*, bt_self_message_iterator*, bt_stream*);
......
......@@ -178,6 +178,37 @@ bt_event_class* create_traffic_event_class_message(bt_trace_class *trace_class,
return event_class;
}
bt_event_class* create_device_name_event_class_message(bt_trace_class *trace_class, bt_stream_class *stream_class)
{
bt_event_class *event_class = bt_event_class_create(stream_class);
bt_event_class_set_name(event_class, "lttng:device_name");
// No need to set the common field,
// Already set by `create_host_event_class_message`
/* Payload */
bt_field_class *payload_field_class = bt_field_class_structure_create(trace_class);
// Name
bt_field_class *name_field_class = bt_field_class_string_create(trace_class);
bt_field_class_structure_append_member(payload_field_class, "name", name_field_class);
// Did
bt_field_class *device_id_field_class= bt_field_class_integer_unsigned_create(trace_class);
bt_field_class_structure_append_member(payload_field_class, "did", device_id_field_class);
// Put the ref and clean
bt_event_class_set_payload_field_class(event_class, payload_field_class);
bt_field_class_put_ref(payload_field_class);
bt_field_class_put_ref(name_field_class);
bt_field_class_put_ref(device_id_field_class);
return event_class;
}
/*
* Initializes the filter component.
*/
......@@ -225,6 +256,8 @@ bt_component_class_initialize_method_status <%= namespace %>_dispatch_initialize
dispatch->host_event_class = create_host_event_class_message(trace_class,stream_class);
dispatch->device_event_class = create_device_event_class_message(trace_class, stream_class);
dispatch->traffic_event_class = create_traffic_event_class_message(trace_class, stream_class);
dispatch->device_name_event_class = create_device_name_event_class_message(trace_class, stream_class);
/* Create a default trace from (instance of `trace_class`) */
bt_trace *trace = bt_trace_create(trace_class);
......
......@@ -55,7 +55,8 @@ struct <%= namespace %>_dispatch {
bt_event_class *host_event_class;
bt_event_class *device_event_class;
bt_event_class *traffic_event_class;
bt_event_class *device_name_event_class;
/* Component's input port (weak) */
bt_self_component_port_input *in_port;
};
......
......@@ -24,6 +24,12 @@
:preferred_display_base: 16
- :name: err
:class: bool
- :name: lttng:device_name
:payload:
- :name: name
:class: string
- :name: did
:class: unsigned
- :name: lttng:traffic
:payload:
- :name: name
......
......@@ -63,7 +63,7 @@ bt_component_class_sink_consume_method_status tally_dispatch_consume(
const bt_field *payload_field = bt_event_borrow_payload_field_const(event);
const bt_field *name_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 0);
const std::string name = std::string{bt_field_string_get_value(name_field)};
const std::string name(bt_field_string_get_value(name_field));
// I should compare type. Not somme string.
if (strcmp(class_name,"lttng:host") == 0 ) {
......@@ -87,11 +87,18 @@ bt_component_class_sink_consume_method_status tally_dispatch_consume(
dispatch->device[hpt_device_function_name_t(hostname,process_id, thread_id, did, sdid, (thapi_function_name) name)].delta(dur, false);
} else if ( strcmp(class_name,"lttng:traffic") == 0 ) {
const bt_field *size_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 1);
const long size = bt_field_integer_unsigned_get_value(size_field);
const bt_field *size_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 1);
const long size = bt_field_integer_unsigned_get_value(size_field);
dispatch->traffic[hpt_function_name_t(hostname,process_id, thread_id, name)].delta(size, false);
dispatch->traffic[hpt_function_name_t(hostname,process_id, thread_id, name)].delta(size, false);
} else if ( strcmp(class_name,"lttng:device_name") == 0 ) {
const bt_field *did_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 1);
const thapi_device_id did = bt_field_integer_unsigned_get_value(did_field);
dispatch->device_name[hp_device_t(hostname,process_id, (thapi_device_id) did)] = name;
}
}
bt_message_put_ref(message);
}
......@@ -107,8 +114,13 @@ bt_component_class_initialize_method_status tally_dispatch_initialize(
bt_self_component_sink_configuration *configuration,
const bt_value *params, void *initialize_method_data)
{
/*Read env variable */
const std::string display_mode(bt_value_string_get(bt_value_map_borrow_entry_value_const(params, "display")));
/* Allocate a private data structure */
struct tally_dispatch *dispatch = new tally_dispatch; //(tally_dispatch*) calloc(1, sizeof(struct tally_dispatch));
struct tally_dispatch *dispatch = new tally_dispatch;
dispatch->display_compact = (display_mode == "compact");
/* Set the component's user data to our private data structure */
bt_self_component_set_data(
......@@ -137,9 +149,15 @@ void tally_dispatch_finalize(bt_self_component_sink *self_component_sink)
struct tally_dispatch *dispatch = (tally_dispatch*) bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
print_compact_host(dispatch->host);
print_compact_device(dispatch->device);
print_compact_traffic(dispatch->traffic);
if (dispatch->display_compact) {
print_compact_host(dispatch->host);
print_compact_device(dispatch->device);
print_compact_traffic(dispatch->traffic);
} else {
print_extented_host(dispatch->host);
print_extented_device(dispatch->device, dispatch->device_name);
print_extented_traffic(dispatch->traffic);
}
}
/*
......
......@@ -6,8 +6,10 @@
/* Sink component's private data */
struct tally_dispatch {
bt_message_iterator *message_iterator;
bool display_compact;
std::unordered_map<hpt_function_name_t, StatTime> host;
std::unordered_map<hpt_device_function_name_t, StatTime> device;
std::unordered_map<hpt_function_name_t, StatByte> traffic;
std::unordered_map<hp_device_t, std::string> device_name;
};
......@@ -132,7 +132,9 @@ class <%= n %>: public StatIprof {
["StatByte", "format_byte", [ 'Name', 'Byte', 'Byte(%)', 'Calls', 'Average', 'Min', 'Max', 'Failed'] ] ] %>
<% d_headers.each do | main_type, main_function, l_headers | %>
void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggregated, std::string header, unsigned int _print_error= 0) {
void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggregated,
std::string header,
unsigned int _print_error= 0) {
<%# print_error = 0 -> Never print error
= 1 -> Print only when error
>= 2 -> Always print error
......@@ -251,11 +253,11 @@ void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggr
] %>
<% output.each do |main_type, tuple_typle, result,header, error, type, var| %>
void print_compact_<%= result %>( <%=tuple_typle %> <%=result%> ){
void print_compact_<%= result %>( <%=tuple_typle %> <%=result%> ){
<% var.each do |t,n,_ | %>
std::set<<%= t %>> s_<%= n.gsub(' ','_') %>;
<% end %>
<%# Agreagate API Call Result and compute total time spend %>
<% end %>
<%# Agreagate API Call Result and compute total time spend %>
std::unordered_map<thapi_function_name, <%= main_type %> > aggregated;
for (auto element: <%= result %>)
{
......@@ -274,21 +276,20 @@ void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggr
<% end %>
<% end %>
aggregated[function_name].merge(time);
}
<% if type == "hpt_dsd_t" %>
{
std::set<hp_dsd_t> s_ToDelete;
for (auto element: s_SubDevice_pointers) {
}
<% if type == "hpt_dsd_t" %>
{
std::set<hp_dsd_t> s_ToDelete;
for (auto element: s_SubDevice_pointers) {
auto [ _a, _b, d1, d2 ] = element;
(void)_a; (void)_b; <%# Use un-used variable %>
if ( d1 == d2 ) {
s_ToDelete.insert(element);
}
}
for (auto element: s_ToDelete) {
s_SubDevice_pointers.erase(element);
}
}
for (auto element: s_ToDelete)
s_SubDevice_pointers.erase(element);
}
<% end %>
std::ostringstream oss;
......@@ -302,10 +303,10 @@ void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggr
std::cout << std::endl;
};
<% if result == 'device_id_result' %>
void print_extented_<%= result %>( <%=tuple_typle %> <%=result%>, std::unordered_map<hp_device_t, std::string> device_to_name ){
<% if result == 'device' %>
void print_extented_<%= result %>( <%=tuple_typle %> <%=result%>, std::unordered_map<hp_device_t, std::string> device_to_name ){
<% else %>
void print_extented_<%= result %>( <%=tuple_typle %> <%=result%> ){
void print_extented_<%= result %>( <%=tuple_typle %> <%=result%> ){
<% end %>
<% args = var.map{ |t,_,n| n}.join(',') %>
......@@ -323,7 +324,7 @@ void print_extented_<%= result %>( <%=tuple_typle %> <%=result%> ){
std::ostringstream oss;
<% if type == "hpt_dsd_t" %>
if (Device != SubDevice) {
if (Device != SubDevice) {
<% end %>
oss << "<%= header %>"
<% var.each do | _,_, n | %>
......@@ -332,13 +333,13 @@ void print_extented_<%= result %>( <%=tuple_typle %> <%=result%> ){
<< std::hex << std::showbase << std::internal << std::setfill('0')
<% end %>
<< <%= n %>
<% if n =='Device' and result == 'device_id_result' %>
<% if n =='Device' and result == 'device' %>
<< " (" << device_to_name[hp_device_t(Hostname,Process,Device)] << ")"
<% end %>
<% end %>
<< std::endl;
<% if type == "hpt_dsd_t" %>
} else {
} else {
oss << "<%= header %>"
<% var.map{| _,_, n | n}.filter{ |n| n != 'SubDevice'}.each do |n| %>
<< " | <%= n %>: "
......@@ -346,16 +347,16 @@ void print_extented_<%= result %>( <%=tuple_typle %> <%=result%> ){
<< std::hex << std::showbase << std::internal << std::setfill('0')
<% end %>
<< <%= n %>
<% if n =='Device' and result == 'device_id_result' %>
<% if n =='Device' and result == 'device' %>
<< " (" << device_to_name[hp_device_t(Hostname,Process,Device)] << ")"
<% end %>
<% end %>
<< std::endl;
}
<% end %>
print_array(aggregated, oss.str(), <%= error %>);
std::cout << std::endl;
}
print_array(aggregated, oss.str(), <%= error %>);
std::cout << std::endl;
}
};
<% end %>
......@@ -7,6 +7,7 @@
- :plugin: sink.xprof.tally
:name: tally
:params:
display: compact
:connections:
- dust_out:tally
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