Commit 8a8dd3e4 authored by Thomas Applencourt's avatar Thomas Applencourt
Browse files

Added memory traffic

parent 16b6c36b
Pipeline #12629 canceled with stage
......@@ -24,7 +24,7 @@ void *init_clinterval_callbacks_state() {
}
static void create_and_enqueue_host_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id, const char* name,
const uint64_t ts, const uint64_t duration, const bool err) {
const uint64_t ts, const uint64_t duration, const bool err) {
/* Message creation */
bt_message *message = create_host_message(hostname, process_id, thread_id, name, ts, duration, err,
......@@ -36,8 +36,9 @@ static void create_and_enqueue_host_message(const char* hostname, const process_
state->downstream_message_queue.push(message);
}
static void create_and_enqueue_device_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id, const thapi_device_id device_id, const thapi_device_id subdevice_id,
const char* name, const uint64_t ts, const uint64_t duration) {
static void create_and_enqueue_device_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id,
const thapi_device_id device_id, const thapi_device_id subdevice_id,
const char* name, const uint64_t ts, const uint64_t duration) {
/* Message creation */
bt_message *message = create_device_message(hostname, process_id, thread_id, device_id, subdevice_id, name, ts, duration,
......@@ -51,6 +52,19 @@ static void create_and_enqueue_device_message(const char* hostname, const proces
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) {
/* Message creation */
bt_message *message = create_traffic_message(hostname, process_id, thread_id, name, size,
clinterval_iter_g->dispatch->traffic_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);
}
<%#
_ _ _ ___
| \ _ ._ _ _|_ ._ _ _. ._ _ / \ _ _ /\ |_) |
......@@ -130,7 +144,7 @@ static void clinterval_<%= dbt_event.name %>_callback(
<%# To do handle Alloc and cl_mem_host_ptr %>
<%if dbt_event.name.include?("clEnqueue") and dbt_event.fields.key?("size") %>
// state->memory_trafic[hpt_function_name_t(hostname,process_id, thread_id, "<%= dbt_event.name_striped %>")].delta(size);
create_and_enqueue_traffic_message(hostname.c_str(), process_id, thread_id, "<%= dbt_event.name_striped %>",size);
<% end %>
<%# ___ __ _
......@@ -139,7 +153,7 @@ static void clinterval_<%= dbt_event.name %>_callback(
|
%>
<%if dbt_event.name_unsanitized == "lttng_ust_opencl_devices:device_timer" %>
const hostname_t hostname{borrow_hostname(bt_evt)};
const hostname_t hostname{borrow_hostname(bt_evt)};
const process_id_t process_id = borrow_process_id(bt_evt);
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_iter_g->callbacks_state;
......
......@@ -65,9 +65,10 @@ bt_message* create_host_message(const char* hostname, const process_id_t process
}
bt_message* create_device_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id, const thapi_device_id device_id, const thapi_device_id subdevice_id,
const char* name, const uint64_t ts,
const uint64_t duration, bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream) {
bt_message* create_device_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id,
const thapi_device_id device_id, const thapi_device_id subdevice_id,
const char* name, const uint64_t ts, const uint64_t duration,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream) {
/* Message creation */
bt_message *message = bt_message_event_create(
......@@ -115,4 +116,40 @@ bt_message* create_device_message(const char* hostname, const process_id_t proce
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) {
/* 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
bt_field *vtid_field = bt_field_structure_borrow_member_field_by_index(context_field,2);
bt_field_integer_signed_set_value(vtid_field, thread_id);
/* 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);
// size
bt_field *dur_field = bt_field_structure_borrow_member_field_by_index(payload_field, 1);
bt_field_integer_unsigned_set_value(dur_field, size);
return message;
}
......@@ -88,3 +88,8 @@ bt_message* create_host_message(const char *hostname, const process_id_t, const
bt_message* create_device_message(const char *hostname, const process_id_t, const thread_id_t, const thapi_device_id, const thapi_device_id,
const char *name, const uint64_t ts, const uint64_t duration,
bt_event_class*, bt_self_message_iterator*, bt_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*);
......@@ -146,6 +146,35 @@ bt_event_class* create_device_event_class_message(bt_trace_class *trace_class, b
return event_class;
}
bt_event_class* create_traffic_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:traffic");
// 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);
// Duration
bt_field_class *size_field_class = bt_field_class_integer_unsigned_create(trace_class);
bt_field_class_structure_append_member(payload_field_class, "size", size_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(size_field_class);
return event_class;
}
/*
* Initializes the filter component.
*/
......@@ -192,7 +221,7 @@ bt_component_class_initialize_method_status <%= namespace %>_dispatch_initialize
// We don't create a clock, because we ensure monotonic order for the downstream messages.
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);
/* Create a default trace from (instance of `trace_class`) */
bt_trace *trace = bt_trace_create(trace_class);
......
......@@ -54,7 +54,8 @@ struct <%= namespace %>_dispatch {
bt_stream *stream;
bt_event_class *host_event_class;
bt_event_class *device_event_class;
bt_event_class *traffic_event_class;
/* Component's input port (weak) */
bt_self_component_port_input *in_port;
};
......
......@@ -65,17 +65,19 @@ bt_component_class_sink_consume_method_status tally_dispatch_consume(
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 bt_field *dur_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 1);
const long dur = bt_field_integer_unsigned_get_value(dur_field);
// I should compare type. Not somme string.
if (strcmp(class_name,"lttng:host") == 0 ) {
const bt_field *err_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 2);
const bool err = bt_field_bool_get_value(err_field);
const bt_field *dur_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 1);
const long dur = bt_field_integer_unsigned_get_value(dur_field);
const bt_field *err_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 2);
const bool err = bt_field_bool_get_value(err_field);
//printf("%s %s, host\n",class_name, hostname.c_str() );
dispatch->host[hpt_function_name_t(hostname,process_id, thread_id, name)].delta(dur, err);
dispatch->host[hpt_function_name_t(hostname,process_id, thread_id, name)].delta(dur, err);
} else if ( strcmp(class_name,"lttng:device") == 0 ) {
const bt_field *dur_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 1);
const long dur = bt_field_integer_unsigned_get_value(dur_field);
const bt_field *did_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, 2);
const thapi_device_id did = bt_field_integer_unsigned_get_value(did_field);
......@@ -83,9 +85,14 @@ bt_component_class_sink_consume_method_status tally_dispatch_consume(
const thapi_device_id sdid = bt_field_integer_unsigned_get_value(sdid_field);
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);
dispatch->traffic[hpt_function_name_t(hostname,process_id, thread_id, name)].delta(size, false);
}
}
bt_message_put_ref(message);
}
end:
......@@ -130,8 +137,9 @@ 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_api_call(dispatch->host);
print_compact_device_id_result(dispatch->device);
print_compact_host(dispatch->host);
print_compact_device(dispatch->device);
print_compact_traffic(dispatch->traffic);
}
/*
......
......@@ -8,5 +8,6 @@ struct tally_dispatch {
bt_message_iterator *message_iterator;
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;
};
......@@ -234,17 +234,17 @@ void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggr
/
%>
<% output = [ ['StatTime', 'std::unordered_map<hpt_function_name_t, StatTime>', 'api_call', 'API calls', '1', 'hpt_t',
<% output = [ ['StatTime', 'std::unordered_map<hpt_function_name_t, StatTime>', 'host', 'API calls', '1', 'hpt_t',
[ ['hostname_t','Hostnames','Hostname'],
['process_id_t','Processes','Process'],
['thread_id_t','Threads','Thread'] ] ],
['StatTime', 'std::unordered_map<hpt_device_function_name_t, StatTime>', 'device_id_result','Device profiling', '0', 'hpt_dsd_t',
['StatTime', 'std::unordered_map<hpt_device_function_name_t, StatTime>', 'device','Device profiling', '0', 'hpt_dsd_t',
[ ['hostname_t','Hostnames','Hostname'],
['hp_t','Processes','Process'],
['hpt_t','Threads','Thread'] ,
['hp_device_t','Device pointers','Device'],
['hp_dsd_t','SubDevice pointers','SubDevice'] ] ],
['StatByte', 'std::unordered_map<hpt_function_name_t, StatByte>', 'memory_trafic', 'Explicit memory trafic', '0', 'hpt_t',
['StatByte', 'std::unordered_map<hpt_function_name_t, StatByte>', 'traffic', 'Explicit memory traffic', '0', 'hpt_t',
[ ['hostname_t','Hostnames','Hostname'],
['process_id_t','Processes','Process'],
['thread_id_t','Threads','Thread'] ] ],
......
......@@ -51,7 +51,8 @@ static void create_and_enqueue_host_message(const char* hostname, const process_
state->downstream_message_queue.push(message);
}
static __attribute__ ((unused)) void create_and_enqueue_device_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id, const thapi_device_id device_id, const thapi_device_id subdevice_id,
void create_and_enqueue_device_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id,
const thapi_device_id device_id, const thapi_device_id subdevice_id,
const char* name, const uint64_t ts, const uint64_t duration) {
/* Message creation */
......@@ -66,6 +67,19 @@ static __attribute__ ((unused)) void create_and_enqueue_device_message(const cha
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) {
/* Message creation */
bt_message *message = create_traffic_message(hostname, process_id, thread_id, name, size,
zeinterval_iter_g->dispatch->traffic_event_class,
self_message_iterator_g,
zeinterval_iter_g->dispatch->stream);
zeinterval_callbacks_state* state = (zeinterval_callbacks_state*) zeinterval_iter_g->callbacks_state;
state->downstream_message_queue.push(message);
}
<%#
_ _ _ ___
| \ _ ._ _ _|_ ._ _ _. ._ _ / \ _ _ /\ |_) |
......@@ -142,7 +156,7 @@ static void zeinterval_<%= dbt_event.uuid %>_callback(
/
%>
<% if (dbt_event.name.include?("Alloc") or dbt_event.name.include?("Memory")) and dbt_event.include? ("size_t size") %>
// memory_trafic[hpt_function_name_t(hostname,process_id, thread_id, "<%= dbt_event.name %>")].delta(size);
create_and_enqueue_traffic_message(hostname.c_str(), process_id, thread_id, "<%= dbt_event.name %>",size);
<% 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