Commit 0368a07f authored by Thomas Applencourt's avatar Thomas Applencourt
Browse files

Remove old file

parent 02f2135a
Pipeline #13185 failed with stage
......@@ -86,8 +86,6 @@ clprof.sh: $(top_builddir)/utils/xprof.sh.erb
BUILT_SOURCES = \
$(OPENCL_PROBES_INCL) \
babeltrace_cl_callbacks.h \
clprof_callbacks.h \
clprof.c \
babeltrace_clinterval.h \
babeltrace_clinterval_callbacks.h \
babeltrace_clinterval.c
......@@ -106,7 +104,7 @@ nodist_libtracepoints_la_SOURCES = \
libtracepoints_la_CFLAGS = $(LTTNG_FLAGS) $(LTTNG_UST_CFLAGS)
libtracepoints_la_LDFLAGS = $(LTTNG_UST_LIBS)
lib_LTLIBRARIES = libTracerOpenCL.la libCLProf.la libCLInterval.la
lib_LTLIBRARIES = libTracerOpenCL.la libCLInterval.la
nodist_libTracerOpenCL_la_SOURCES = \
$(OPENCL_PROBES_INCL) \
......@@ -132,38 +130,13 @@ uninstall-hook:
$(RM) -f $(DESTDIR)$(pkglibdir)/opencl/libOpenCL.so.1 $(DESTDIR)$(pkglibdir)/opencl/libOpenCL.so
-rmdir $(DESTDIR)$(pkglibdir)/opencl
clprof.c: $(srcdir)/clprof_callbacks.cpp.erb $(srcdir)/clprof_callbacks.h.erb $(srcdir)/clprof.c.erb $(srcdir)/gen_clprof.rb opencl_model.yaml babeltrace_cl_callbacks.h tracer_opencl.h
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_clprof.rb production
clprof_callbacks.cpp clprof_callbacks.h: clprof.c
@if test -f $@; then \
touch $@; \
else \
rm -f clprof.c; \
$(MAKE) $(AM_MAKEFLAGS) clprof.c; \
fi
nodist_libCLProf_la_SOURCES = \
clprof.c \
clprof_callbacks.cpp \
clprof_callbacks.h \
tracer_opencl.h \
babeltrace_cl_dispatchers.c
libCLProf_la_SOURCES = \
babeltrace_cl.h
libCLProf_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(srcdir)/include -I./
libCLProf_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libCLProf_la_CXXFLAGS = -std=c++17 -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libCLProf_la_LDFLAGS = $(BABELTRACE2_LIBS) -avoid-version -module
# Cannot use check_LTLIBRARIES because we need the shared version of those
# Thanks Vincent Danjean
# noinst_LTLIBRARIES would be the correct thing but then libtool
# only built non shared version :-( So, declaring the libs as
# pkglib_LTLIBRARIES and using an install hook to remove them.
tmplibdir = $(libdir)/tmp
tmplib_LTLIBRARIES = libBabeltraceCL.la libTestingCLProf.la
tmplib_LTLIBRARIES = libBabeltraceCL.la
install-data-hook:
$(RM) -r $(DESTDIR)$(tmplibdir)
......@@ -187,31 +160,6 @@ libBabeltraceCL_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/includ
libBabeltraceCL_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libBabeltraceCL_la_LDFLAGS = $(BABELTRACE2_LIBS) -avoid-version -module
testing_clprof.c: $(srcdir)/clprof_callbacks.cpp.erb $(srcdir)/clprof_callbacks.h.erb $(srcdir)/clprof.c.erb $(srcdir)/gen_clprof.rb opencl_model.yaml babeltrace_cl_callbacks.h tracer_opencl.h
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_clprof.rb testing
testing_clprof_callbacks.cpp testing_clprof_callbacks.h: testing_clprof.c
@if test -f $@; then \
touch $@; \
else \
rm -f testing_clprof.c; \
$(MAKE) $(AM_MAKEFLAGS) testing_clprof.c; \
fi
nodist_libTestingCLProf_la_SOURCES = \
testing_clprof.c \
testing_clprof_callbacks.cpp \
testing_clprof_callbacks.h \
tracer_opencl.h \
babeltrace_cl_dispatchers.c
libTestingCLProf_la_SOURCES = \
babeltrace_cl.h
libTestingCLProf_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(srcdir)/include -I./
libTestingCLProf_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libTestingCLProf_la_CXXFLAGS = -std=c++17 -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libTestingCLProf_la_LDFLAGS = $(BABELTRACE2_LIBS) -avoid-version -module
babeltrace_clinterval_callbacks.cpp: $(srcdir)/clinterval_callbacks.cpp.erb $(srcdir)/gen_clinterval_callbacks.rb opencl_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_clinterval_callbacks.rb > babeltrace_clinterval_callbacks.cpp
......@@ -276,24 +224,6 @@ $(INTERVAL_DUST_FILES): tests/interval_%.dust: tests/interval.dust.erb
nodist_libCLInterval_la_SOURCES+= \
$(INTERVAL_DUST_FILES)
CLPROF_DUST_FILES = \
tests/profiling_normal.dust \
tests/profiling_inversed.dust \
tests/profiling_block.dust \
tests/profiling_fast.dust \
tests/profiling_interleave_thread.dust \
tests/profiling_interleave_process.dust \
tests/profiling_normal_command_queue.dust \
tests/profiling_with_error.dust \
tests/profiling_normal_command_queue_created_in_other_thread.dust \
tests/device_name.dust \
tests/kernel_name.dust \
tests/profiling_normal_nd_range_kernel_name.dust \
tests/API_call.dust
$(CLPROF_DUST_FILES): tests/%.dust: tests/clprof.dust.erb
$(ERB) namespace="$@" $(srcdir)/tests/clprof.dust.erb > $@
TRACE_FILES = \
tests/profiling_normal.yaml \
tests/profiling_inversed.yaml \
......@@ -323,7 +253,6 @@ TRACE_FILES = \
TESTS = \
tests/opencl_dummy_trace.dust \
tests/trace.dust \
$(CLPROF_DUST_FILES) \
$(INTERVAL_DUST_FILES)
TEST_EXTENSIONS = .dust
......@@ -354,12 +283,8 @@ EXTRA_DIST += \
gen_opencl_model.rb \
gen_babeltrace_cl_model.rb \
gen_opencl_custom_probes.rb \
gen_clprof.rb \
clprof_callbacks.cpp.erb \
clprof_callbacks.h.erb \
babeltrace_opencl.in \
extract_enqueues \
clprof.c.erb \
gen_clinterval_callbacks.rb \
clinterval_callbacks.cpp.erb \
clinterval_callbacks.hpp\
......@@ -368,8 +293,7 @@ EXTRA_DIST += \
$(TRACE_FILES) \
tests/trace.dust \
tests/opencl_dummy_trace.dust \
tests/interval.dust.erb \
tests/clprof.dust.erb
tests/interval.dust.erb
CLEANFILES = \
$(OPENCL_PROBES_INCL) \
......@@ -383,12 +307,6 @@ CLEANFILES = \
tests/opencl_dummy_trace.yaml \
babeltrace_cl_dispatchers.c \
babeltrace_cl_callbacks.h \
clprof.c \
clprof_callbacks.cpp \
clprof_callbacks.h \
testing_clprof.c \
testing_clprof_callbacks.cpp \
testing_clprof_callbacks.h \
clprof.sh \
xprof_utils.cpp \
xprof_utils.hpp \
......
#include "babeltrace_cl.h"
<% if $sink_type == 'production' %>
#include "clprof_callbacks.h"
const bt_value *display_mode;
<% elsif $sink_type == 'testing' %>
#include "testing_clprof_callbacks.h"
const bt_value *test_type_value;
<% end %>
struct cl_event_callbacks * opencl_create_event_callbacks(const char *name) {
intptr_t mem = (intptr_t)calloc(1, sizeof(struct cl_event_callbacks) + strlen(name) + 1);
struct cl_event_callbacks * callbacks = (struct cl_event_callbacks *)mem;
callbacks->name = (const char *)(mem + sizeof(struct cl_event_callbacks));
strcpy((char *)(callbacks->name), name);
utarray_new(callbacks->callbacks, &ut_ptr_icd);
return callbacks;
}
void cl_register_dispatcher(struct cl_dispatch *opencl_dispatch, const char *name, cl_dispatcher_t *dispatcher) {
struct cl_event_callbacks *callbacks = NULL;
HASH_FIND_STR(opencl_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = opencl_create_event_callbacks(name);
HASH_ADD_KEYPTR(hh, opencl_dispatch->event_callbacks, callbacks->name, strlen(callbacks->name), callbacks);
}
callbacks->dispatcher = dispatcher;
}
void cl_register_callback(struct cl_dispatch *opencl_dispatch, const char *name, void *func) {
struct cl_event_callbacks *callbacks;
HASH_FIND_STR(opencl_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = opencl_create_event_callbacks(name);
HASH_ADD_STR(opencl_dispatch->event_callbacks, name, callbacks);
}
if (func)
utarray_push_back(callbacks->callbacks, &func);
}
/*
* Initializes the sink component.
*/
static
bt_component_class_initialize_method_status opencl_dispatch_initialize(
bt_self_component_sink *self_component_sink,
bt_self_component_sink_configuration *configuration,
const bt_value *params, void *initialize_method_data)
{
<% if $sink_type == 'testing' %>
test_type_value = bt_value_map_borrow_entry_value_const(params, "test");
bt_value_get_ref(test_type_value);
<% elsif $sink_type == 'production' %>
display_mode = bt_value_map_borrow_entry_value_const(params, "display");
bt_value_get_ref(display_mode);
<% end %>
/* Allocate a private data structure */
struct cl_dispatch *opencl_dispatch = calloc(1, sizeof(struct cl_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),
opencl_dispatch);
/*
* Add an input port named `in` to the sink component.
*
* This is needed so that this sink component can be connected to a
* filter or a source component. With a connected upstream
* component, this sink component can create a message iterator
* to consume messages.
*/
bt_self_component_sink_add_input_port(self_component_sink,
"in", NULL, NULL);
init_cl_dispatchers(opencl_dispatch);
init_cl_callbacks(opencl_dispatch);
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
}
/*
* Finalizes the sink component.
*/
static
void opencl_dispatch_finalize(bt_self_component_sink *self_component_sink)
{
finalize_cl_callbacks();
/* Retrieve our private data from the component's user data */
struct cl_dispatch *opencl_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
struct cl_callbacks *s, *tmp;
HASH_ITER(hh, opencl_dispatch->callbacks, s, tmp) {
HASH_DEL(opencl_dispatch->callbacks, s);
free(s);
}
struct cl_event_callbacks *s2, *tmp2;
HASH_ITER(hh, opencl_dispatch->event_callbacks, s2, tmp2) {
HASH_DEL(opencl_dispatch->event_callbacks, s2);
utarray_free(s2->callbacks);
free(s2);
}
<% if $sink_type == 'testing' %>
bt_value_put_ref(test_type_value);
<% elsif $sink_type == 'production' %>
bt_value_put_ref(display_mode);
<% end %>
/* Free the allocated structure */
free(opencl_dispatch);
}
/*
* Called when the trace processing graph containing the sink component
* is configured.
*
* This is where we can create our upstream message iterator.
*/
static
bt_component_class_sink_graph_is_configured_method_status
opencl_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
{
/* Retrieve our private data from the component's user data */
struct cl_dispatch *opencl_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
/* Borrow our unique port */
bt_self_component_port_input *in_port =
bt_self_component_sink_borrow_input_port_by_index(
self_component_sink, 0);
/* Create the uptream message iterator */
bt_message_iterator_create_from_sink_component(self_component_sink,
in_port, &opencl_dispatch->message_iterator);
return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
}
/*
* Consumes a batch of messages and writes the corresponding lines to
* the standard output.
*/
static
bt_component_class_sink_consume_method_status opencl_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 cl_dispatch *opencl_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(opencl_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(opencl_dispatch->message_iterator);
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
goto end;
default:
break;
}
/* For each consumed message */
for (uint64_t i = 0; i < message_count; i++) {
/* Current message */
const bt_message *message = messages[i];
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 cl_callbacks *callbacks = NULL;
const char * class_name = bt_event_class_get_name(event_class);
HASH_FIND_STR(opencl_dispatch->callbacks, class_name, callbacks);
if (!callbacks) {
const size_t class_name_sz = strlen(class_name);
callbacks = (struct cl_callbacks *)calloc(1, sizeof(struct cl_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, opencl_dispatch->callbacks, class_name, class_name_sz, callbacks);
struct cl_event_callbacks *event_callbacks = NULL;
HASH_FIND_STR(opencl_dispatch->event_callbacks, class_name, event_callbacks);
if (event_callbacks) {
callbacks->dispatcher = event_callbacks->dispatcher;
callbacks->callbacks = event_callbacks->callbacks;
}
}
/* Print line for current message if it's an event message */
if (callbacks->dispatcher)
callbacks->dispatcher(opencl_dispatch, callbacks, event, bt_message_event_borrow_default_clock_snapshot_const(message));
/* Put this message's reference */
}
bt_message_put_ref(message);
}
end:
return status;
}
/* Mandatory */
BT_PLUGIN_MODULE();
/* Define the `clprof` plugin */
<% if $sink_type == 'production' %>
BT_PLUGIN(clprof);
<% elsif $sink_type == 'testing' %>
BT_PLUGIN(testing_clprof);
<% end %>
/* Define the `text` sink component class */
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch, opencl_dispatch_consume);
/* Set some of the `text` sink component class's optional methods */
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(dispatch, opencl_dispatch_initialize);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dispatch, opencl_dispatch_finalize);
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(dispatch, opencl_dispatch_graph_is_configured);
#include "babeltrace2/babeltrace.h"
#include "babeltrace_cl.h"
#include "xprof_utils.h"
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <tuple>
#include <climits>
<% if $sink_type == 'production' %>
#include "clprof_callbacks.h"
#include <set>
<% elsif $sink_type == 'testing' %>
#include "testing_clprof_callbacks.h"
#include <cassert>
<% end %>
typedef std::tuple<hostname_t, process_id_t, cl_command_queue> hp_command_queue_t;
typedef std::tuple<hostname_t, process_id_t, cl_event> hp_event_t;
typedef std::tuple<hostname_t, process_id_t, cl_kernel> hp_kernel_t;
std::unordered_map<hp_command_queue_t, dsd_t> command_queue_to_device;
std::unordered_map<hpt_function_name_t, cl_device_id> function_name_to_device;
std::unordered_map<hp_event_t,t_function_name_t> event_to_function_name;
std::unordered_map<hp_event_t, uint64_t> event_result_to_delta;
std::unordered_map<hp_kernel_t, std::string> kernel_to_name;
<% $dbt_events.each do | dbt_event| %>
static void clprof_<%= dbt_event.name %>_callback(
<%= dbt_event.callback_signature %>
){
<%# ___ _
| _ _ _. | o _|_ | ._ _|_ _
|_ (_) (_ (_| | | |_ \/ _|_ | | | (_)
/
%>
<%if dbt_event.name_unsanitized.start_with?('lttng_ust_opencl:') %>
const hostname_t hostname = borrow_hostname(bt_evt);
const process_id_t process_id = borrow_process_id(bt_evt);
const thread_id_t thread_id = borrow_thread_id(bt_evt);
<%end %>
<%# _ ___
/\ |_) | _ _. | | _
/--\ | _|_ (_ (_| | | _>
%>
<%if dbt_event.name_unsanitized.start_with?('lttng_ust_opencl:') %>
int64_t ns_from_origin;
bt_clock_snapshot_get_ns_from_origin(bt_clock, &ns_from_origin);
<%if dbt_event.name.end_with?(START) %>
api_call[hpt_function_name_t(hostname,process_id, thread_id, "<%= dbt_event.name_striped %>")].start(ns_from_origin);
<%elsif dbt_event.name.end_with?(STOP) %>
api_call[hpt_function_name_t(hostname,process_id, thread_id, "<%= dbt_event.name_striped %>")].stop(ns_from_origin);
<% if dbt_event.fields.key?('errcode_ret_val') %>
if (errcode_ret_val != 0)
api_call[hpt_function_name_t(hostname,process_id, thread_id, "<%= dbt_event.name_striped %>")].set_error();
<% end %>
<% end %>
<% end %>
<%#
|\/| _ ._ _ _ ._ _. _ _ _ _ _ _ _
| | (/_ | | | (_) | \/ (_| (_ (_ (/_ _> _> (/_ _>
/
%>
<%# To do handle Alloc and cl_mem_host_ptr %>
<%if dbt_event.name.include?("clEnqueue") and dbt_event.fields.key?("size") %>
memory_trafic[hpt_function_name_t(hostname,process_id, thread_id, "<%= dbt_event.name_striped %>")].delta(size);
<% end %>
<%#
_ _ _ __ _
|_) ._ _ _|_ o | o ._ _ o | \ _ o _ _ _. ._ _| (_ |_ | \ _ o _ _
| | (_) | | | | | | (_| o |_/ (/_ \/ | (_ (/_ (_| | | (_| __) |_| |_) |_/ (/_ \/ | (_ (/_
_|
Map [ Tuple [ Hostnane, process, cl_command_queue ], Tuple [ device, subdevice] ]
%>
<%# Map [ Tuple [hostname, process, device_or_subdevice], device] ] %>
<% if dbt_event.name_unsanitized == "lttng_ust_opencl:clGetDeviceIDs_#{STOP}" %>
if (devices_vals != nullptr) {
for (unsigned int i=0; i < num_devices_val; i++ ) {
const thapi_device_id d = (thapi_device_id) devices_vals[i];
device_to_rootdevice[hp_device_t(hostname,process_id, d) ] = d;
}
}
<% elsif dbt_event.name_unsanitized == "lttng_ust_opencl:clCreateSubDevices_#{START}" %>
start_device[hpt_t(hostname,process_id,thread_id) ] = (thapi_device_id) in_device;
<% elsif dbt_event.name_unsanitized == "lttng_ust_opencl:clCreateSubDevices_#{STOP}" %>
const thapi_device_id device = start_device[hpt_t(hostname,process_id,thread_id) ];
const thapi_device_id root_device = device_to_rootdevice[hp_device_t(hostname,process_id, device) ];
if (out_devices_vals != nullptr) {
for (unsigned int i=0; i < num_devices_ret_val; i++ ) {
const thapi_device_id d = (thapi_device_id) out_devices_vals[i];
device_to_rootdevice[hp_device_t(hostname,process_id, d) ] = root_device;
}
}
<% end%>
<%# Map [ Tuple [ Hostnane, process, cl_command_queue ], Tuple [ device, subdevice] ] %>
<% if dbt_event.name.end_with?(START) and dbt_event.name.include?('clCreateCommandQueue') %>
start_device[hpt_t(hostname,process_id, thread_id) ] = (thapi_device_id) device;
<%elsif dbt_event.name.end_with?(STOP) and dbt_event.name.include?('clCreateCommandQueue') %>
const thapi_device_id device = start_device[hpt_t(hostname,process_id, thread_id) ];
const thapi_device_id root_device = device_to_rootdevice[hp_device_t(hostname,process_id, device) ];
command_queue_to_device[hp_command_queue_t(hostname,process_id,command_queue)] = dsd_t(root_device, device) ;
<% elsif dbt_event.name_unsanitized == "lttng_ust_opencl_devices:device_name" %>
const std::string hostname = borrow_hostname(bt_evt);
const process_id_t process_id = borrow_process_id(bt_evt);
device_to_name[hp_device_t(hostname,process_id,(thapi_device_id) device)] = std::string{name};
<% end %>
<%#
_ _ _
|_) ._ _ _|_ o | o ._ _ o |_ ._ _ _|_ o _ ._ ._ _. ._ _ _
| | (_) | | | | | | (_| o | |_| | | (_ |_ | (_) | | | | (_| | | | (/_
_|
Map [ Tuple [ Hostnane, process, thread, function_name], Tuple [ device, subdevice] ]
%>
<% if dbt_event.name_unsanitized == "lttng_ust_opencl_arguments:kernel_info" %>
const std::string hostname = borrow_hostname(bt_evt);
const process_id_t process_id = borrow_process_id(bt_evt);
kernel_to_name[hp_kernel_t(hostname,process_id,kernel)] = std::string{function_name};
<% elsif dbt_event.name.end_with?(START) and dbt_event.fields['command_queue'] %>
<% if dbt_event.fields['kernel'] %>
const thapi_function_name name = kernel_to_name[hp_kernel_t(hostname,process_id,kernel)];
<% else %>
constexpr char name[] = "<%= dbt_event.name_striped %>";
<% end %>
profiled_function_name[hpt_t(hostname,process_id,thread_id)] = name;
function_name_to_dsd[hpt_function_name_t(hostname,process_id,thread_id,name)] = command_queue_to_device[hp_command_queue_t(hostname,process_id,command_queue)];
<% end %>
<%#
_ _ _ ___
|_) ._ _ _|_ o | o ._ _ o |_ | _. ._ _ _ _| | o ._ _ _ _
| | (_) | | | | | | (_| o |_ | (_| |_) _> (/_ (_| | | | | | (/_ _>
_| |
Map [ Tuple[hostname, process, device, subdevice, cl_function_name], elapsed_time ]
%>
<% if dbt_event.name_unsanitized == "lttng_ust_opencl_profiling:event_profiling" %>
const hostname_t hostname = borrow_hostname(bt_evt);
const process_id_t process_id = borrow_process_id(bt_evt);
const thread_id_t thread_id = borrow_thread_id(bt_evt);
const hp_event_t hp_event{hostname,process_id, event};
const thapi_function_name function_name = profiled_function_name[hpt_t(hostname,process_id,thread_id)];
if (!event_to_function_name.count(hp_event)){
event_to_function_name[hp_event] = t_function_name_t(thread_id, function_name);
} else {
const uint64_t delta = event_result_to_delta[hp_event];
const auto [device,subdevice] = function_name_to_dsd[hpt_function_name_t(hostname,process_id,thread_id, function_name)];
if (delta != 0)
device_id_result[hpt_device_function_name_t(hostname,process_id,thread_id, device, subdevice, function_name)].delta(delta);
event_to_function_name.erase(hp_event);
}
<% elsif dbt_event.name_unsanitized == "lttng_ust_opencl_profiling:event_profiling_results" %>
const std::string hostname = borrow_hostname(bt_evt);
const process_id_t process_id = borrow_process_id(bt_evt);
const hp_event_t hp_event{hostname,process_id, event};
uint64_t delta = end - start;
if (queued_status != 0 or submit_status != 0 or start_status != 0) {
std::cerr << "Warning: 'lttng_ust_opencl_profiling:event_profiling_results' for event "
<< std::hex << std::showbase << std::internal << std::setfill('0') << event
<< " returned invalid status" << std::endl;
delta = 0;
} else {
delta = end - start;
}
if (event_to_function_name.count(hp_event)) {
const auto [thread_id,function_name] = event_to_function_name[hp_event];
const auto [device,subdevice] = function_name_to_dsd[hpt_function_name_t(hostname,process_id,thread_id, function_name)];
if (delta != 0)
device_id_result[hpt_device_function_name_t(hostname,process_id,thread_id, device, subdevice, function_name)].delta(delta);
event_to_function_name.erase(hp_event);
} else {
const thread_id_t thread_id = borrow_thread_id(bt_evt);
const thapi_function_name function_name = profiled_function_name[hpt_t(hostname,process_id,thread_id)];
event_result_to_delta[hp_event]= delta;
event_to_function_name[hp_event] = t_function_name_t(thread_id, function_name);
}
<% end %>
}
<% end %>
<%#
___
| ._ o _|_ o _. | o _ _
_|_ | | | |_ | (_| | | /_ (/_
%>
void init_cl_callbacks(struct cl_dispatch *opencl_dispatch) {
<% $dbt_events.each do | dbt_event| %>
cl_register_callback(opencl_dispatch, "<%= dbt_event.name_unsanitized %>", (void *) &clprof_<%= dbt_event.name %>_callback);
<% end %>
}
<%#
_
|_ o ._ _. | o _ _
| | | | (_| | | /_ (/_
%>
void finalize_cl_callbacks() {
<% if $sink_type == 'testing' %>
std::string test_path {bt_value_string_get(test_type_value)};
<% $l_test.each do | test | %>
if (test_path == "<%= test.name %>") {
std :: cout << "testing <%= test.name %>" << std::endl;
<% test.device_id_result.each do |assert| %>
<% assert[0][-2] = "(thapi_device_id) #{assert[0][-2]}" %>
<% assert[0][-3] = "(thapi_device_id) #{assert[0][-3]}" %>
assert(device_id_result[hpt_device_function_name_t(<%= assert[0].join(',') %>)]._time == <%= assert[1] %>);
<% end %>
<% test.device_to_name.each do |assert| %>
<% assert[0][-1] = "(thapi_device_id) #{assert[0][-1]}" %>
assert(device_to_name[hp_device_t(<%= assert[0].join(',') %>)] == <%= assert[1] %>);
<% end %>
<% test.kernel_to_name.each do |assert| %>
<% assert[0][-1] = "(cl_kernel) #{assert[0][-1]}" %>
assert(kernel_to_name[hp_kernel_t(<%= assert[0].join(',') %>)] == <%= assert[1] %>);
<% end %>
<% test.api_call.each do |assert| %>
assert(api_call[hpt_function_name_t(<%= assert[0].join(',') %>)]._count == <%= assert[1][0] %>);
assert(api_call[hpt_function_name_t(<%= assert[0].join(',') %>)]._min == <%= assert[1][1] %>);
assert(api_call[hpt_function_name_t(<%= assert[0].join(',') %>)]._max == <%= assert[1][2] %>);
<% end %>
}