Commit 96c9739c authored by Thomas Applencourt's avatar Thomas Applencourt
Browse files

ze compiling

parent 4f79e170
......@@ -49,7 +49,6 @@ struct clinterval_dispatch {
struct clinterval_callbacks *callbacks;
/* Hash table by name */
struct clinterval_event_callbacks *event_callbacks;
/* Downstream message */
bt_stream *stream;
......@@ -72,8 +71,6 @@ struct clinterval_message_iterator {
void * callbacks_state;
};
// To talk to the callbacks
extern void init_clinterval_callbacks(struct clinterval_dispatch*);
extern void* init_clinterval_callbacks_state();
......
......@@ -58,21 +58,21 @@ static void create_and_enqueue_device_message(const char* hostname, const proces
%>
bool downstream_message_queue_empty(struct clinterval_message_iterator *clinterval_dispatch_iter)
bool downstream_message_queue_empty(struct clinterval_message_iterator *interval_dispatch_iter)
{
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_dispatch_iter->callbacks_state;
clinterval_callbacks_state* state = (clinterval_callbacks_state*) interval_dispatch_iter->callbacks_state;
return state->downstream_message_queue.empty();
}
size_t downstream_message_queue_size(struct clinterval_message_iterator *clinterval_dispatch_iter)
size_t downstream_message_queue_size(struct clinterval_message_iterator *interval_dispatch_iter)
{
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_dispatch_iter->callbacks_state;
clinterval_callbacks_state* state = (clinterval_callbacks_state*) interval_dispatch_iter->callbacks_state;
return state->downstream_message_queue.size();
}
const bt_message* downstream_message_queue_pop(struct clinterval_message_iterator *clinterval_dispatch_iter)
const bt_message* downstream_message_queue_pop(struct clinterval_message_iterator *interval_dispatch_iter)
{
clinterval_callbacks_state* state = (clinterval_callbacks_state*) clinterval_dispatch_iter->callbacks_state;
clinterval_callbacks_state* state = (clinterval_callbacks_state*) interval_dispatch_iter->callbacks_state;
const bt_message* m = state->downstream_message_queue.front();
state->downstream_message_queue.pop();
return m;
......@@ -84,8 +84,6 @@ const bt_message* downstream_message_queue_pop(struct clinterval_message_iterato
\_ (_| | | |_) (_| (_ |< _>
%>
// Some of the map used may grow arbitraly large
// we may do something about it at some point buy remove data we don't need anymore
<% $dbt_events.each do | dbt_event| %>
static void clinterval_<%= dbt_event.name %>_callback(
......@@ -297,3 +295,12 @@ void init_clinterval_callbacks(struct clinterval_dispatch *opencl_interval) {
clinterval_register_callback(opencl_interval, "<%= dbt_event.name_unsanitized %>", (void *) &clinterval_<%= dbt_event.name %>_callback);
<% end %>
}
<%#
_
|_ o ._ _. | o _ _
| | | | (_| | | /_ (/_
%>
//void finalize_zeinterval_callbacks() {}
......@@ -208,32 +208,28 @@ install-exec-hook::
ln -s $(libdir)/libTracerZE.so.0.0.0 $(pkglibdir)/ze/libze_loader.so.1
ln -s $(pkglibdir)/ze/libze_loader.so.1 $(pkglibdir)/ze/libze_loader.so
ZEPROF = \
$(srcdir)/zeprof_callbacks.cpp.erb \
$(srcdir)/zeprof_callbacks.h.erb \
$(srcdir)/zeprof.c.erb \
$(srcdir)/gen_zeprof.rb
zeprof.c: $(ZEPROF) babeltrace_ze_callbacks.h
zeinterval_dispatchers.c: $(srcdir)/gen_babeltrace_ze_dispatchers.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_babeltrace_ze_dispatchers.rb "zeinterval" > $(srcdir)/clinterval_dispatchers.c
zeinterval_callbacks.cpp: $(srcdir)/gen_zeprof.rb $(ZEPROF) babeltrace_ze_callbacks.h $(srcdir)/zeinterval_callbacks.cpp.erb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_zeprof.rb
zeprof_callbacks.cpp zeprof_callbacks.h: zeprof.c
@if test -f $@; then \
touch $@; \
else \
rm -f zeprof.c; \
$(MAKE) $(AM_MAKEFLAGS) zeprof.c; \
fi
zeinterval.h: $(srcdir)/interval.h.erb
$(ERB) namespace="zeinterval" $(srcdir)/interval.h.erb > $(srcdir)/zeinterval.h
zeinterval.c: $(srcdir)/interval.c.erb
$(ERB) namespace="zeinterval" $(srcdir)/interval.c.erb > $(srcdir)/zeinterval.c
CLEANFILES += \
zeprof.c \
zeprof_callbacks.cpp \
zeprof_callbacks.h
zeinterval_callbacks.cpp \
zeinterval_callbacks.h
nodist_libZEProf_la_SOURCES = \
zeprof.c \
zeprof_callbacks.cpp \
zeprof_callbacks.h \
zeinterval_callbacks.cpp \
zeinterval_callbacks.h \
babeltrace_ze_dispatchers.c
libZEProf_la_SOURCES = \
babeltrace_ze.h
......
......@@ -5,7 +5,7 @@
* standard output.
*/
//static
//void print_event(struct ze_dispatch *ze_dispatch, struct ze_callbacks *ze_callbacks, const bt_event *event)
//void print_event(struct babeltrace_ze_dispatch *babeltrace_ze_dispatch, struct babeltrace_ze_callbacks *babeltrace_ze_callbacks, const bt_event *event)
//{
// const bt_event_class *event_class = bt_event_borrow_class_const(event);
//
......@@ -22,31 +22,31 @@
// member_count, member_count == 1 ? "" : "s");
//}
struct ze_event_callbacks * ze_create_event_callbacks(const char *name) {
intptr_t mem = (intptr_t)calloc(1, sizeof(struct ze_event_callbacks) + strlen(name) + 1);
struct ze_event_callbacks * callbacks = (struct ze_event_callbacks *)mem;
callbacks->name = (const char *)(mem + sizeof(struct ze_event_callbacks));
struct babeltrace_ze_event_callbacks * ze_create_event_callbacks(const char *name) {
intptr_t mem = (intptr_t)calloc(1, sizeof(struct babeltrace_ze_event_callbacks) + strlen(name) + 1);
struct babeltrace_ze_event_callbacks * callbacks = (struct babeltrace_ze_event_callbacks *)mem;
callbacks->name = (const char *)(mem + sizeof(struct babeltrace_ze_event_callbacks));
strcpy((char *)(callbacks->name), name);
utarray_new(callbacks->callbacks, &ut_ptr_icd);
return callbacks;
}
void ze_register_dispatcher(struct ze_dispatch *ze_dispatch, const char *name, ze_dispatcher_t *dispatcher) {
struct ze_event_callbacks *callbacks = NULL;
HASH_FIND_STR(ze_dispatch->event_callbacks, name, callbacks);
void babeltrace_ze_register_dispatcher(struct babeltrace_ze_dispatch *babeltrace_ze_dispatch, const char *name, babeltrace_ze_dispatcher_t *dispatcher) {
struct babeltrace_ze_event_callbacks *callbacks = NULL;
HASH_FIND_STR(babeltrace_ze_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = ze_create_event_callbacks(name);
HASH_ADD_KEYPTR(hh, ze_dispatch->event_callbacks, callbacks->name, strlen(callbacks->name), callbacks);
HASH_ADD_KEYPTR(hh, babeltrace_ze_dispatch->event_callbacks, callbacks->name, strlen(callbacks->name), callbacks);
}
callbacks->dispatcher = dispatcher;
}
void ze_register_callback(struct ze_dispatch *ze_dispatch, const char *name, void *func) {
struct ze_event_callbacks *callbacks;
HASH_FIND_STR(ze_dispatch->event_callbacks, name, callbacks);
void ze_register_callback(struct babeltrace_ze_dispatch *babeltrace_ze_dispatch, const char *name, void *func) {
struct babeltrace_ze_event_callbacks *callbacks;
HASH_FIND_STR(babeltrace_ze_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = ze_create_event_callbacks(name);
HASH_ADD_STR(ze_dispatch->event_callbacks, name, callbacks);
HASH_ADD_STR(babeltrace_ze_dispatch->event_callbacks, name, callbacks);
}
if (func)
utarray_push_back(callbacks->callbacks, &func);
......@@ -56,18 +56,18 @@ void ze_register_callback(struct ze_dispatch *ze_dispatch, const char *name, voi
* Initializes the sink component.
*/
static
bt_component_class_initialize_method_status ze_dispatch_initialize(
bt_component_class_initialize_method_status babeltrace_ze_dispatch_initialize(
bt_self_component_sink *self_component_sink,
bt_self_component_sink_configuration *configuration,
const bt_value *params, void *initialize_method_data)
{
/* Allocate a private data structure */
struct ze_dispatch *ze_dispatch = calloc(1, sizeof(struct ze_dispatch));
struct babeltrace_ze_dispatch *babeltrace_ze_dispatch = calloc(1, sizeof(struct babeltrace_ze_dispatch));
/* Set the component's user data to our private data structure */
bt_self_component_set_data(
bt_self_component_sink_as_self_component(self_component_sink),
ze_dispatch);
babeltrace_ze_dispatch);
/*
* Add an input port named `in` to the sink component.
......@@ -80,7 +80,7 @@ bt_component_class_initialize_method_status ze_dispatch_initialize(
bt_self_component_sink_add_input_port(self_component_sink,
"in", NULL, NULL);
init_dispatchers(ze_dispatch);
init_babeltrace_ze_dispatch(babeltrace_ze_dispatch);
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
}
......@@ -88,25 +88,25 @@ bt_component_class_initialize_method_status ze_dispatch_initialize(
* Finalizes the sink component.
*/
static
void ze_dispatch_finalize(bt_self_component_sink *self_component_sink)
void babeltrace_ze_dispatch_finalize(bt_self_component_sink *self_component_sink)
{
/* Retrieve our private data from the component's user data */
struct ze_dispatch *ze_dispatch = bt_self_component_get_data(
struct babeltrace_ze_dispatch *babeltrace_ze_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
struct ze_callbacks *s, *tmp;
HASH_ITER(hh, ze_dispatch->callbacks, s, tmp) {
HASH_DEL(ze_dispatch->callbacks, s);
struct babeltrace_ze_callbacks *s, *tmp;
HASH_ITER(hh, babeltrace_ze_dispatch->callbacks, s, tmp) {
HASH_DEL(babeltrace_ze_dispatch->callbacks, s);
free(s);
}
struct ze_event_callbacks *s2, *tmp2;
HASH_ITER(hh, ze_dispatch->event_callbacks, s2, tmp2) {
HASH_DEL(ze_dispatch->event_callbacks, s2);
struct babeltrace_ze_event_callbacks *s2, *tmp2;
HASH_ITER(hh, babeltrace_ze_dispatch->event_callbacks, s2, tmp2) {
HASH_DEL(babeltrace_ze_dispatch->event_callbacks, s2);
utarray_free(s2->callbacks);
free(s2);
}
/* Free the allocated structure */
free(ze_dispatch);
free(babeltrace_ze_dispatch);
}
/*
......@@ -117,10 +117,10 @@ void ze_dispatch_finalize(bt_self_component_sink *self_component_sink)
*/
static
bt_component_class_sink_graph_is_configured_method_status
ze_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
babeltrace_ze_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
{
/* Retrieve our private data from the component's user data */
struct ze_dispatch *ze_dispatch = bt_self_component_get_data(
struct babeltrace_ze_dispatch *babeltrace_ze_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
/* Borrow our unique port */
......@@ -130,7 +130,7 @@ ze_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
/* Create the uptream message iterator */
bt_message_iterator_create_from_sink_component(self_component_sink,
in_port, &ze_dispatch->message_iterator);
in_port, &babeltrace_ze_dispatch->message_iterator);
return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
}
......@@ -140,27 +140,27 @@ ze_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
* the standard output.
*/
static
bt_component_class_sink_consume_method_status ze_dispatch_consume(
bt_component_class_sink_consume_method_status babeltrace_ze_dispatch_consume(
bt_self_component_sink *self_component_sink)
{
bt_component_class_sink_consume_method_status status =
BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
/* Retrieve our private data from the component's user data */
struct ze_dispatch *ze_dispatch = bt_self_component_get_data(
struct babeltrace_ze_dispatch *babeltrace_ze_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
/* Consume a batch of messages from the upstream message iterator */
bt_message_array_const messages;
uint64_t message_count;
bt_message_iterator_next_status next_status =
bt_message_iterator_next(ze_dispatch->message_iterator, &messages,
bt_message_iterator_next(babeltrace_ze_dispatch->message_iterator, &messages,
&message_count);
switch (next_status) {
case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
/* End of iteration: put the message iterator's reference */
bt_message_iterator_put_ref(ze_dispatch->message_iterator);
bt_message_iterator_put_ref(babeltrace_ze_dispatch->message_iterator);
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
......@@ -183,18 +183,18 @@ bt_component_class_sink_consume_method_status ze_dispatch_consume(
if (bt_message_get_type(message) == BT_MESSAGE_TYPE_EVENT) {
const bt_event *event = bt_message_event_borrow_event_const(message);
const bt_event_class *event_class = bt_event_borrow_class_const(event);
struct ze_callbacks *callbacks = NULL;
struct babeltrace_ze_callbacks *callbacks = NULL;
const char * class_name = bt_event_class_get_name(event_class);
HASH_FIND_STR(ze_dispatch->callbacks, class_name, callbacks);
HASH_FIND_STR(babeltrace_ze_dispatch->callbacks, class_name, callbacks);
if (!callbacks) {
const size_t class_name_sz = strlen(class_name);
callbacks = (struct ze_callbacks *)calloc(1, sizeof(struct ze_callbacks) + class_name_sz + 1);
callbacks = (struct babeltrace_ze_callbacks *)calloc(1, sizeof(struct babeltrace_ze_callbacks) + class_name_sz + 1);
callbacks->name = (const char *)callbacks + class_name_sz;
strncpy((char *)(callbacks->name), class_name, class_name_sz + 1);
HASH_ADD_KEYPTR(hh, ze_dispatch->callbacks, class_name, class_name_sz, callbacks);
struct ze_event_callbacks *event_callbacks = NULL;
HASH_FIND_STR(ze_dispatch->event_callbacks, class_name, event_callbacks);
HASH_ADD_KEYPTR(hh, babeltrace_ze_dispatch->callbacks, class_name, class_name_sz, callbacks);
struct babeltrace_ze_event_callbacks *event_callbacks = NULL;
HASH_FIND_STR(babeltrace_ze_dispatch->event_callbacks, class_name, event_callbacks);
if (event_callbacks) {
callbacks->dispatcher = event_callbacks->dispatcher;
callbacks->callbacks = event_callbacks->callbacks;
......@@ -202,7 +202,7 @@ bt_component_class_sink_consume_method_status ze_dispatch_consume(
}
/* Print line for current message if it's an event message */
if (callbacks->dispatcher)
callbacks->dispatcher(ze_dispatch, callbacks, event, bt_message_event_borrow_default_clock_snapshot_const(message));
callbacks->dispatcher(babeltrace_ze_dispatch, callbacks, event, bt_message_event_borrow_default_clock_snapshot_const(message));
/* Put this message's reference */
}
......@@ -221,10 +221,10 @@ BT_PLUGIN_MODULE();
BT_PLUGIN(ze);
/* Define the `text` sink component class */
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch, ze_dispatch_consume);
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch, babeltrace_ze_dispatch_consume);
/* Set some of the `text` sink component class's optional methods */
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(dispatch, ze_dispatch_initialize);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dispatch, ze_dispatch_finalize);
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(dispatch, ze_dispatch_graph_is_configured);
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(dispatch, babeltrace_ze_dispatch_initialize);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dispatch, babeltrace_ze_dispatch_finalize);
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(dispatch, babeltrace_ze_dispatch_graph_is_configured);
......@@ -15,50 +15,50 @@
extern "C" {
#endif
struct ze_dispatch;
struct ze_callbacks;
struct babeltrace_ze_dispatch;
struct babeltrace_ze_callbacks;
extern void init_dispatchers(struct ze_dispatch *ze_dispatch);
extern void init_babeltrace_ze_dispatch(struct babeltrace_ze_dispatch *ze_dispatch);
typedef void (ze_dispatcher_t)
(struct ze_dispatch *ze_dispatch,
struct ze_callbacks *callbacks,
typedef void (babeltrace_ze_dispatcher_t)
(struct babeltrace_ze_dispatch *ze_dispatch,
struct babeltrace_ze_callbacks *callbacks,
const bt_event *message,
const bt_clock_snapshot *clock);
struct ze_callbacks {
struct babeltrace_ze_callbacks {
const char* name;
ze_dispatcher_t *dispatcher;
babeltrace_ze_dispatcher_t *dispatcher;
UT_array *callbacks;
UT_hash_handle hh;
};
struct ze_event_callbacks {
struct babeltrace_ze_event_callbacks {
const char *name;
ze_dispatcher_t *dispatcher;
babeltrace_ze_dispatcher_t *dispatcher;
UT_array *callbacks;
UT_hash_handle hh;
};
/* Sink component's private data */
struct ze_dispatch {
struct babeltrace_ze_dispatch {
/* Upstream message iterator (owned by this) */
bt_message_iterator *message_iterator;
/* Hash table */
struct ze_callbacks *callbacks;
struct babeltrace_ze_callbacks *callbacks;
/* Hash table by name */
struct ze_event_callbacks *event_callbacks;
struct babeltrace_ze_event_callbacks *event_callbacks;
};
extern void
ze_register_dispatcher(struct ze_dispatch *ze_dispatch,
babeltrace_ze_register_dispatcher(struct babeltrace_ze_dispatch *ze_dispatch,
const char *name,
ze_dispatcher_t *dispatcher);
babeltrace_ze_dispatcher_t *dispatcher);
extern void
ze_register_callback(struct ze_dispatch *ze_dispatch,
babeltrace_ze_register_callback(struct babeltrace_ze_dispatch *ze_dispatch,
const char *name,
void *func);
#ifdef __cplusplus
......
require_relative 'gen_ze_library_base.rb'
if ARGV.empty?
namespace = "babeltrace_ze"
else
namespace = ARGV[0]
end
puts <<EOF
#include <ze_api.h>
#include <ze_ddi.h>
......@@ -40,7 +47,7 @@ meta_parameter_lambda = lambda { |m, dir|
gen_event_callback = lambda { |provider, c, dir|
puts <<EOF
typedef void (#{provider}_#{c.name}_#{SUFFIXES[dir]}_cb)(
typedef void (#{namespace}_#{provider}_#{c.name}_#{SUFFIXES[dir]}_cb)(
EOF
fields = ["const bt_event *bt_evt",
"const bt_clock_snapshot *bt_clock"]
......@@ -71,7 +78,7 @@ EOF
gen_extra_event_callback =lambda { |provider, event|
puts <<EOF
typedef void (#{provider}_#{event["name"]}_cb)(
typedef void (#{namespace}_#{provider}_#{event["name"]}_cb)(
EOF
fields = ["const bt_event *bt_evt",
"const bt_clock_snapshot *bt_clock"]
......
if ARGV.empty?
namespace = "babeltrace_ze"
else
namespace = ARGV[0]
end
require_relative 'gen_ze_library_base.rb'
puts <<EOF
#include <ze_api.h>
......@@ -9,8 +17,8 @@ puts <<EOF
#include <layers/zel_tracing_api.h>
#include <layers/zel_tracing_ddi.h>
#include <babeltrace2/babeltrace.h>
#include "babeltrace_ze.h"
#include "babeltrace_ze_callbacks.h"
#include "#{namespace}.h"
#include "#{namespace}_callbacks.h"
EOF
......@@ -248,9 +256,9 @@ end
gen_event_dispatcher = lambda { |provider, c, dir|
puts <<EOF
static void
#{provider}_#{c.name}_#{SUFFIXES[dir]}_dispatcher(
struct ze_dispatch *ze_dispatch,
struct ze_callbacks *callbacks,
#{namespace}_#{provider}_#{c.name}_#{SUFFIXES[dir]}_dispatcher(
struct #{namespace}_dispatch *dispatch,
struct #{namespace}_callbacks *callbacks,
const bt_event *bt_evt,
const bt_clock_snapshot *bt_clock) {
EOF
......@@ -264,7 +272,7 @@ EOF
puts <<EOF
void **_p = NULL;
while( (_p = utarray_next(callbacks->callbacks, _p)) ) {
((#{provider}_#{c.name}_#{SUFFIXES[dir]}_cb *)*_p)(
((#{namespace}_#{provider}_#{c.name}_#{SUFFIXES[dir]}_cb *)*_p)(
#{(["bt_evt", "bt_clock"] + get_fields_names(c, dir)).join(",\n ")});
}
EOF
......@@ -299,9 +307,9 @@ gen_extra_event_dispatcher = lambda { |provider, event|
}
puts <<EOF
static void
#{provider}_#{event["name"]}_dispatcher(
struct ze_dispatch *ze_dispatch,
struct ze_callbacks *callbacks,
#{namespace}_#{provider}_#{event["name"]}_dispatcher(
struct #{namespace}_dispatch *dispatch,
struct #{namespace}_callbacks *callbacks,
const bt_event *bt_evt,
const bt_clock_snapshot *bt_clock) {
const bt_field *payload_field = bt_event_borrow_payload_field_const(bt_evt);
......@@ -313,7 +321,7 @@ EOF
puts <<EOF
void **_p = NULL;
while( (_p = utarray_next(callbacks->callbacks, _p)) ) {
((#{provider}_#{event["name"]}_cb *)*_p)(
((#{namespace}_#{provider}_#{event["name"]}_cb *)*_p)(
#{(["bt_evt", "bt_clock"] + param_fields.collect { |param_field| param_field[2] }).join(",\n ")});
}
EOF
......@@ -357,18 +365,18 @@ ze_events.each { |provider, es|
gen_event_dispatch_init = lambda { |provider, c, dir|
puts <<EOF
ze_register_dispatcher(ze_dispatch, "#{provider}:#{c.name}_#{SUFFIXES[dir]}", &#{provider}_#{c.name}_#{SUFFIXES[dir]}_dispatcher);
#{namespace}_register_dispatcher(dispatch, "#{namespace}_#{provider}:#{c.name}_#{SUFFIXES[dir]}", &#{namespace}_#{provider}_#{c.name}_#{SUFFIXES[dir]}_dispatcher);
EOF
}
gen_extra_event_dispatch_init = lambda { |provider, e|
puts <<EOF
ze_register_dispatcher(ze_dispatch, "#{provider}:#{e["name"]}", &#{provider}_#{e["name"]}_dispatcher);
#{namespace}_register_dispatcher(dispatch, "#{namespace}_#{provider}:#{e["name"]}", &#{namespace}_#{provider}_#{e["name"]}_dispatcher);
EOF
}
puts <<EOF
void init_dispatchers(struct ze_dispatch *ze_dispatch) {
void init_#{namespace}_dispatchers(struct #{namespace}_dispatch *dispatch) {
EOF
provider = :lttng_ust_ze
......
......@@ -142,7 +142,7 @@ $dbt_events += ze_events.map{ |provider,es|
}
}.flatten
write_file_via_template("zeprof_callbacks.cpp")
write_file_via_template("zeprof_callbacks.h")
write_file_via_template("zeprof.c")
write_file_via_template("zeinterval_callbacks.cpp")
#write_file_via_template("zeprof_callbacks.h")
#write_file_via_template("zeprof.c")
../xprof/interval.c.erb
\ No newline at end of file
../xprof/interval.h.erb
\ No newline at end of file
../utils/xprof_utils.cpp
\ No newline at end of file
#include <iomanip>
#include <iostream>
#include "zeinterval.h"
#include "zeinterval_callbacks.hpp"
#include "xprof_utils.hpp"
#include <babeltrace2/babeltrace.h>
#include <ze_api.h>
#include <ze_ddi.h>
#include <zet_api.h>
#include <zet_ddi.h>
#include <zes_api.h>
#include <zes_ddi.h>
#include "babeltrace2/babeltrace.h"
#include "babeltrace_ze.h"
#include "xprof_utils.h"
#include <iomanip>
#include <zel_tracepoints.h>
#
#include <vector>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <tuple>
#include <climits>
#include "zeprof_callbacks.h"
#include <set>
/* Callback */
typedef std::tuple<hostname_t, process_id_t, ze_event_handle_t> hp_event_t;
typedef std::tuple<hostname_t, process_id_t, ze_kernel_handle_t> hp_kernel_t;
typedef std::tuple<hostname_t, process_id_t, ze_command_list_handle_t> hp_command_list_t;
typedef std::tuple<hostname_t, process_id_t, ze_command_queue_handle_t> hp_command_queue_t;
typedef std::tuple<uint64_t, uint64_t> timerResolution_kernelTimestampValidBits_t;
// Need to be moved in `zeinterval_callbacks.hpp`
std::unordered_map<hpt_t, thapi_function_name> last_command;
std::unordered_map<hpt_t, thapi_function_name> last_kernel;
......@@ -47,9 +41,6 @@ std::unordered_map<hp_command_list_t, dsd_t> command_list_to_device;
std::unordered_map<hp_device_t, timerResolution_kernelTimestampValidBits_t> device_to_timerResolution_kernelTimestampValidBits;
//std::unordered_map<hpt_device_function_name_t, StatTime> device_id_result;
//std::unordered_map<hpt_function_name_t, StatTime> api_call;
//std::unordered_map<hpt_function_name_t, StatByte> memory_trafic;
std::unordered_map<hp_device_t, std::string> device_to_name;
std::unordered_map<hp_device_t, thapi_device_id> device_to_rootdevice;
......@@ -58,40 +49,6 @@ std::unordered_map<hpt_t, thapi_function_name> profiled_function_name;
std::unordered_map<hpt_function_name_t, dsd_t> function_name_to_dsd;
<%# _
|\/| _ _ _ _. _ _ / ._ _ _. _|_ o _ ._
| | (/_ _> _> (_| (_| (/_ \_ | (/_ (_| |_ | (_) | |
_|
%>
/*
Utils function
*/
static
const hostname_t borrow_hostname(const bt_event *event){
const bt_stream *stream = bt_event_borrow_stream_const(event);
const bt_trace *trace = bt_stream_borrow_trace_const(stream);
const bt_value *host_name_str = bt_trace_borrow_environment_entry_value_by_name_const(trace, "hostname");
return bt_value_string_get(host_name_str);
}
static
process_id_t borrow_process_id(const bt_event *event){
const bt_field *common_context_field = bt_event_borrow_common_context_field_const(event);
const bt_field *field = bt_field_structure_borrow_member_field_by_index_const(common_context_field, 0);
return bt_field_integer_signed_get_value(field);
}
static
thread_id_t borrow_thread_id(const bt_event *event){
const bt_field *common_context_field = bt_event_borrow_common_context_field_const(event);
const bt_field *field = bt_field_structure_borrow_member_field_by_index_const(common_context_field, 1);