Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
THAPI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HeteroFlow
THAPI
Commits
a9f69503
Commit
a9f69503
authored
Jan 15, 2021
by
Thomas Applencourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge clprof{,testing} in the same pluging
parent
8bfa789c
Pipeline
#12297
failed with stage
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
184 additions
and
80 deletions
+184
-80
opencl/Makefile.am
opencl/Makefile.am
+21
-23
opencl/cldispatch.c.erb
opencl/cldispatch.c.erb
+63
-24
opencl/cldispatch.h.erb
opencl/cldispatch.h.erb
+44
-0
opencl/cldispatch_callbacks.cpp.erb
opencl/cldispatch_callbacks.cpp.erb
+19
-6
opencl/cldispatch_callbacks.h.erb
opencl/cldispatch_callbacks.h.erb
+9
-3
opencl/gen_cldispatch.rb
opencl/gen_cldispatch.rb
+1
-1
opencl/test_wrapper.sh
opencl/test_wrapper.sh
+2
-2
utils/xprof_utils.h.erb
utils/xprof_utils.h.erb
+25
-21
No files found.
opencl/Makefile.am
View file @
a9f69503
...
...
@@ -110,7 +110,7 @@ install-exec-hook::
ln
-s
$(libdir)
/libTracerOpenCL.so.1.0.0
$(pkglibdir)
/opencl/libOpenCL.so.1
ln
-s
$(pkglibdir)
/opencl/libOpenCL.so.1
$(pkglibdir)
/opencl/libOpenCL.so
cldispatch.c
:
$(srcdir)/cldispatch_callbacks.cpp.erb $(srcdir)/cldispatch_callbacks.h.erb $(srcdir)/cldispatch
.c
.erb $(srcdir)/gen_cldispatch.rb opencl_model.yaml babeltrace_cl_callbacks.h tracer_opencl.h
cldispatch.c
:
$(srcdir)/cldispatch_callbacks.cpp.erb $(srcdir)/cldispatch_callbacks.h.erb $(srcdir)/cldispatch
_callbacks.h.erb $(srcdir)/cldispatch.c.erb $(srcdir)/cldispatch.h
.erb $(srcdir)/gen_cldispatch.rb opencl_model.yaml babeltrace_cl_callbacks.h tracer_opencl.h
SRC_DIR
=
$(srcdir)
$(RUBY)
$(srcdir)
/gen_cldispatch.rb production
cldispatch_callbacks.cpp cldispatch_callbacks.h
:
cldispatch.c
...
...
@@ -121,19 +121,6 @@ cldispatch_callbacks.cpp cldispatch_callbacks.h: cldispatch.c
$(MAKE)
$(AM_MAKEFLAGS)
cldispatch.c
;
\
fi
nodist_libcldispatch_la_SOURCES
=
\
cldispatch.c
\
cldispatch_callbacks.cpp
\
cldispatch_callbacks.h
\
tracer_opencl.h
\
babeltrace_cl_dispatchers.c
libcldispatch_la_SOURCES
=
\
babeltrace_cl.h
libcldispatch_la_CPPFLAGS
=
-I
$(top_srcdir)
/utils
-I
$(srcdir)
/include
-I
./
libcldispatch_la_CFLAGS
=
-Wall
-Wextra
-Wno-unused-parameter
-Werror
$(BABELTRACE2_CFLAGS)
libcldispatch_la_CXXFLAGS
=
-std
=
c++17
-Wall
-Wextra
-Wno-unused-parameter
-Werror
$(BABELTRACE2_CFLAGS)
libcldispatch_la_LDFLAGS
=
$(BABELTRACE2_LIBS)
-avoid-version
-module
# Cannot use check_LTLIBRARIES because we need the shared version of those
# Thanks Vincent Danjean
...
...
@@ -141,7 +128,7 @@ libcldispatch_la_LDFLAGS = $(BABELTRACE2_LIBS) -avoid-version -module
# 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 libDust.la libTestingcldispatch.la
tmplib_LTLIBRARIES
=
libBabeltraceCL.la libDust.la
#
libTestingcldispatch.la
install-data-hook
::
$(RM)
-r
$(DESTDIR)$(tmplibdir)
...
...
@@ -180,19 +167,25 @@ testing_cldispatch_callbacks.cpp testing_cldispatch_callbacks.h: testing_cldispa
$(MAKE)
$(AM_MAKEFLAGS)
testing_cldispatch.c
;
\
fi
nodist_libTestingcldispatch_la_SOURCES
=
\
nodist_libcldispatch_la_SOURCES
=
\
clprof.c
\
cldispatch.h
\
cldispatch.c
\
cldispatch_callbacks.cpp
\
cldispatch_callbacks.h
\
testing_cldispatch.h
\
testing_cldispatch.c
\
testing_cldispatch_callbacks.cpp
\
testing_cldispatch_callbacks.h
\
tracer_opencl.h
\
babeltrace_cl_dispatchers.c
lib
Testing
cldispatch_la_SOURCES
=
\
libcldispatch_la_SOURCES
=
\
babeltrace_cl.h
lib
Testing
cldispatch_la_CPPFLAGS
=
-I
$(top_srcdir)
/utils
-I
$(srcdir)
/include
-I
./
lib
Testing
cldispatch_la_CFLAGS
=
-Wall
-Wextra
-Wno-unused-parameter
-Werror
$(BABELTRACE2_CFLAGS)
lib
Testing
cldispatch_la_CXXFLAGS
=
-std
=
c++17
-Wall
-Wextra
-Wno-unused-parameter
-Werror
$(BABELTRACE2_CFLAGS)
lib
Testing
cldispatch_la_LDFLAGS
=
$(BABELTRACE2_LIBS)
-avoid-version
-module
libcldispatch_la_CPPFLAGS
=
-I
$(top_srcdir)
/utils
-I
$(srcdir)
/include
-I
./
libcldispatch_la_CFLAGS
=
-Wall
-Wextra
-Wno-unused-parameter
-Werror
$(BABELTRACE2_CFLAGS)
libcldispatch_la_CXXFLAGS
=
-std
=
c++17
-Wall
-Wextra
-Wno-unused-parameter
-Werror
$(BABELTRACE2_CFLAGS)
libcldispatch_la_LDFLAGS
=
$(BABELTRACE2_LIBS)
-avoid-version
-module
TEST_FILES
=
\
profiling_normal.dust
\
...
...
@@ -237,7 +230,9 @@ EXTRA_DIST = \
gen_babeltrace_cl_callbacks.rb
\
dust.c.erb
\
gen_cldispatch.rb
\
cldispatch.h.erb
\
cldispatch_callbacks.cpp.erb
\
cldispatch_callbacks.h.erb
\
babeltrace_opencl.in
\
extract_enqueues
\
cldispatch.c.erb
\
...
...
@@ -248,17 +243,20 @@ CLEANFILES = \
$(OPENCL_PROBES_INCL)
\
$(OPENCL_PROBES_TP)
\
$(OPENCL_PROBES_SRC)
\
tracer_opencl.c
\
clprof.c
\
tracer_opencl.c
\
tracer_opencl.h
\
cl.xml.patched
\
opencl_model.yaml
\
babeltrace_cl_dispatchers.c
\
babeltrace_cl_callbacks.h
\
cldispatch.c
\
cldispatch_callbacks.cpp
\
cldispatch.h
\
cldispatch_callbacks.cpp
\
cldispatch_callbacks.h
\
dust.c
\
testing_cldispatch.c
\
testing_cldispatch.h
\
testing_cldispatch_callbacks.cpp
\
testing_cldispatch_callbacks.h
\
$(TEST_FILES)
opencl/cldispatch.c.erb
View file @
a9f69503
#include "babeltrace_cl.h"
<%
if
$sink_type
==
'production'
%>
#include "cldispatch
_callbacks
.h"
#include "cldispatch.h"
const bt_value *display_mode;
<%
elsif
$sink_type
==
'testing'
%>
#include "testing_cldispatch
_callbacks
.h"
#include "testing_cldispatch.h"
const bt_value *test_type_value;
<%
end
%>
<%
if
$sink_type
==
'production'
%>
struct opencl_event_callbacks * opencl_create_event_callbacks(const char *name) {
intptr_t mem = (intptr_t)calloc(1, sizeof(struct opencl_event_callbacks) + strlen(name) + 1);
struct opencl_event_callbacks * callbacks = (struct opencl_event_callbacks *)mem;
...
...
@@ -36,18 +36,48 @@ void opencl_register_callback(struct opencl_dispatch *opencl_dispatch, const cha
if (func)
utarray_push_back(callbacks->callbacks,
&func);
}
<%
elsif
$sink_type
==
'testing'
%>
struct opencl_event_callbacks * opencl_create_event_callbacks_testing(const char *name) {
intptr_t mem = (intptr_t)calloc(1, sizeof(struct opencl_event_callbacks) + strlen(name) + 1);
struct opencl_event_callbacks * callbacks = (struct opencl_event_callbacks *)mem;
callbacks->name = (const char *)(mem + sizeof(struct opencl_event_callbacks));
strcpy((char *)(callbacks->name), name);
utarray_new(callbacks->callbacks,
&ut_ptr_icd);
return callbacks;
}
void opencl_register_dispatcher_testing(struct opencl_dispatch *opencl_dispatch, const char *name, opencl_dispatcher_t *dispatcher) {
struct opencl_event_callbacks *callbacks = NULL;
HASH_FIND_STR(opencl_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = opencl_create_event_callbacks_testing(name);
HASH_ADD_KEYPTR(hh, opencl_dispatch->event_callbacks, callbacks->name, strlen(callbacks->name), callbacks);
}
callbacks->dispatcher = dispatcher;
}
void opencl_register_callback_testing(struct opencl_dispatch *opencl_dispatch, const char *name, void *func) {
struct opencl_event_callbacks *callbacks;
HASH_FIND_STR(opencl_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = opencl_create_event_callbacks_testing(name);
HASH_ADD_STR(opencl_dispatch->event_callbacks, name, callbacks);
}
if (func)
utarray_push_back(callbacks->callbacks,
&func);
}
<%
end
%>
/*
* Initializes the sink component.
*/
<%
if
$sink_type
==
'production'
%>
static
//
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)
<%
elsif
$sink_type
==
'testing'
%>
static
//
static
bt_component_class_initialize_method_status opencl_dispatch_testing_initialize(
bt_self_component_sink *self_component_sink,
bt_self_component_sink_configuration *configuration,
...
...
@@ -80,7 +110,13 @@ bt_component_class_initialize_method_status opencl_dispatch_testing_initialize(
"in", NULL, NULL);
init_dispatchers(opencl_dispatch);
<%
if
$sink_type
==
'production'
%>
init_callbacks(opencl_dispatch);
<%
elsif
$sink_type
==
'testing'
%>
init_callbacks_testing(opencl_dispatch);
<%
end
%>
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
}
...
...
@@ -88,14 +124,19 @@ bt_component_class_initialize_method_status opencl_dispatch_testing_initialize(
* Finalizes the sink component.
*/
<%
if
$sink_type
==
'production'
%>
static
//
static
void opencl_dispatch_finalize(bt_self_component_sink *self_component_sink)
<%
elsif
$sink_type
==
'testing'
%>
//static
void opencl_dispatch_testing_finalize(bt_self_component_sink *self_component_sink)
<%
end
%>
{
<%
if
$sink_type
==
'production'
%>
finalize_callbacks();
<%
elsif
$sink_type
==
'testing'
%>
finalize_callbacks_testing();
<%
end
%>
/* Retrieve our private data from the component's user data */
struct opencl_dispatch *opencl_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
...
...
@@ -123,11 +164,11 @@ void opencl_dispatch_testing_finalize(bt_self_component_sink *self_component_sin
*/
<%
if
$sink_type
==
'production'
%>
static
//
static
bt_component_class_sink_graph_is_configured_method_status
opencl_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
<%
elsif
$sink_type
==
'testing'
%>
static
//
static
bt_component_class_sink_graph_is_configured_method_status
opencl_dispatch_testing_graph_is_configured(bt_self_component_sink *self_component_sink)
<%
end
%>
...
...
@@ -154,11 +195,11 @@ opencl_dispatch_testing_graph_is_configured(bt_self_component_sink *self_compone
*/
<%
if
$sink_type
==
'production'
%>
static
//
static
bt_component_class_sink_consume_method_status opencl_dispatch_consume(
bt_self_component_sink *self_component_sink)
<%
elsif
$sink_type
==
'testing'
%>
static
//
static
bt_component_class_sink_consume_method_status opencl_dispatch_testing_consume(
bt_self_component_sink *self_component_sink)
<%
end
%>
...
...
@@ -234,29 +275,27 @@ end:
return status;
}
/* Mandatory */
BT_PLUGIN_MODULE();
//
BT_PLUGIN_MODULE();
/* Define the `clprof` plugin */
<%
if
$sink_type
==
'production'
%>
BT_PLUGIN(clprof);
//
BT_PLUGIN(clprof);
/* Define the `text` sink component class */
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch, opencl_dispatch_consume);
//
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);
//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);
<%
elsif
$sink_type
==
'testing'
%>
BT_PLUGIN(testing_clprof);
//
BT_PLUGIN(testing_clprof);
/* Define the `text` sink component class */
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch_testing, opencl_dispatch_testing_consume);
//
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch_testing, opencl_dispatch_testing_consume);
/* Set some of the `text` sink component class's optional methods */
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(dispatch_testing, opencl_dispatch_testing_initialize);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dispatch_testing, opencl_dispatch_testing_finalize);
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(dispatch_testing, opencl_dispatch_testing_graph_is_configured);
//
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(dispatch_testing, opencl_dispatch_testing_initialize);
//
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dispatch_testing, opencl_dispatch_testing_finalize);
//
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(dispatch_testing, opencl_dispatch_testing_graph_is_configured);
<%
end
%>
opencl/cldispatch.h.erb
0 → 100644
View file @
a9f69503
#include "babeltrace_cl.h"
<%
if
$sink_type
==
'production'
%>
#include "cldispatch_callbacks.h"
<%
elsif
$sink_type
==
'testing'
%>
#include "testing_cldispatch_callbacks.h"
<%
end
%>
<%
if
$sink_type
==
'production'
%>
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);
<%
elsif
$sink_type
==
'testing'
%>
bt_component_class_initialize_method_status opencl_dispatch_testing_initialize(
bt_self_component_sink *self_component_sink,
bt_self_component_sink_configuration *configuration,
const bt_value *params, void *initialize_method_data);
<%
end
%>
<%
if
$sink_type
==
'production'
%>
void opencl_dispatch_finalize(bt_self_component_sink *self_component_sink);
<%
elsif
$sink_type
==
'testing'
%>
void opencl_dispatch_testing_finalize(bt_self_component_sink *self_component_sink);
<%
end
%>
<%
if
$sink_type
==
'production'
%>
bt_component_class_sink_graph_is_configured_method_status
opencl_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink);
void opencl_register_callback(struct opencl_dispatch *opencl_dispatch, const char *name, void *func);
<%
elsif
$sink_type
==
'testing'
%>
bt_component_class_sink_graph_is_configured_method_status
opencl_dispatch_testing_graph_is_configured(bt_self_component_sink *self_component_sink);
void opencl_register_callback_testing(struct opencl_dispatch *opencl_dispatch, const char *name, void *func);
<%
end
%>
<%
if
$sink_type
==
'production'
%>
bt_component_class_sink_consume_method_status opencl_dispatch_consume(
bt_self_component_sink *self_component_sink);
<%
elsif
$sink_type
==
'testing'
%>
bt_component_class_sink_consume_method_status opencl_dispatch_testing_consume(
bt_self_component_sink *self_component_sink);
<%
end
%>
opencl/cldispatch_callbacks.cpp.erb
View file @
a9f69503
...
...
@@ -19,12 +19,12 @@ typedef std::tuple<hostname_t, process_id_t, cl_command_queue> hp_command_queue_
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;
st
atic st
d::unordered_map
<hp
_command_queue_t
,
dsd_t
>
command_queue_to_device;
st
atic st
d::unordered_map
<hpt
_function_name_t
,
cl_device_id
>
function_name_to_device;
st
atic st
d::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;
st
atic st
d::unordered_map
<hp
_event_t
,
uint64_t
>
event_result_to_delta;
st
atic st
d::unordered_map
<hp
_kernel_t
,
std::string
>
kernel_to_name;
<%
$dbt_events
.
each
do
|
dbt_event
|
%>
static void clprof_
<%=
dbt_event
.
name
%>
_callback(
...
...
@@ -196,10 +196,18 @@ static void clprof_<%= dbt_event.name %>_callback(
_|_ | | | |_ | (_| | | /_ (/_
%>
<%
if
$sink_type
==
'production'
%>
void
init_callbacks
(
struct
opencl_dispatch
*opencl_dispatch
)
{
<%
elsif
$sink_type
==
'testing'
%>
void
init_callbacks_testing
(
struct
opencl_dispatch
*opencl_dispatch
)
{
<%
end
%>
<%
$dbt_events
.
each
do
|
dbt_event
|
%>
<%
if
$sink_type
==
'production'
%>
opencl_register_callback
(
opencl_dispatch
,
"
<%=
dbt_event
.
name_unsanitized
%>
",
(
void
*
)
&
clprof_
<%=
dbt_event
.
name
%>
_callback
);
<%
elsif
$sink_type
==
'testing'
%>
opencl_register_callback_testing
(
opencl_dispatch
,
"
<%=
dbt_event
.
name_unsanitized
%>
",
(
void
*
)
&
clprof_
<%=
dbt_event
.
name
%>
_callback
);
<%
end
%>
<%
end
%>
}
...
...
@@ -210,7 +218,12 @@ void init_callbacks(struct opencl_dispatch *opencl_dispatch) {
%>
<%
if
$sink_type
==
'production'
%>
void
finalize_callbacks
()
{
<%
elsif
$sink_type
==
'testing'
%>
void
finalize_callbacks_testing
()
{
<%
end
%>
<%
if
$sink_type
==
'testing'
%>
std::string
test_path
{
bt_value_string_get
(
test_type_value
)};
<%
$l_test
.
each
do
|
test
|
%>
...
...
opencl/cldispatch_callbacks.h.erb
View file @
a9f69503
...
...
@@ -5,14 +5,20 @@
#ifdef __cplusplus
extern "C" {
#endif
<%
if
$sink_type
==
'testing'
%>
extern void
init_callbacks(struct opencl_dispatch *opencl_dispatch);
init_callbacks
_testing
(struct opencl_dispatch *opencl_dispatch);
extern void
finalize_callbacks();
<%
if
$sink_type
==
'testing'
%>
finalize_callbacks_testing();
extern const bt_value *test_type_value;
extern void opencl_register_callback_testing(struct opencl_dispatch *opencl_dispatch, const char *name, void *func);
<%
elsif
$sink_type
==
'production'
%>
extern void
init_callbacks(struct opencl_dispatch *opencl_dispatch);
extern void
finalize_callbacks();
extern const bt_value *display_mode;
extern void opencl_register_callback(struct opencl_dispatch *opencl_dispatch, const char *name, void *func);
<%
end
%>
#ifdef __cplusplus
}
...
...
opencl/gen_cldispatch.rb
View file @
a9f69503
...
...
@@ -274,7 +274,7 @@ def write_file_via_template(file, testing = false)
end
$sink_type
=
ARGV
[
0
]
$l_file_generated
=
[
'cldispatch_callbacks.cpp'
,
'cldispatch_callbacks.h'
,
'cldispatch.c'
]
$l_file_generated
=
[
'cldispatch_callbacks.cpp'
,
'cldispatch_callbacks.h'
,
'cldispatch.c'
,
'cldispatch.h'
]
$l_test
=
l_test_d
.
map
{
|
d
|
Test_clprof
.
new
(
d
)
}
if
$sink_type
==
'dust'
...
...
opencl/test_wrapper.sh
View file @
a9f69503
#!/usr/bin/env sh
name
=
"
$(
basename
$1
.dust
)
"
echo
babeltrace2
--plugin-path
=
./.libs
--component
=
source.dust.input
--params
=
"path=
\"
$1
\"
"
--component
=
sink.
testing_clprof.testing_dispatch
--params
=
"test=
\"
${
name
}
\"
"
babeltrace2
--plugin-path
=
./
--component
=
source.dust.input
--params
=
"path=
\"
$1
\"
"
--component
=
sink.
testing_
clprof.dispatch_testing
--params
=
"test=
\"
${
name
}
\"
"
echo
babeltrace2
--plugin-path
=
./.libs
--component
=
source.dust.input
--params
=
"path=
\"
$1
\"
"
--component
=
sink.
clprof.dispatch_testing
--params
=
"test=
\"
${
name
}
\"
"
babeltrace2
--plugin-path
=
./
--component
=
source.dust.input
--params
=
"path=
\"
$1
\"
"
--component
=
sink.clprof.dispatch_testing
--params
=
"test=
\"
${
name
}
\"
"
utils/xprof_utils.h.erb
View file @
a9f69503
...
...
@@ -81,27 +81,27 @@ namespace std{
/*
Utils function
*/
const hostname_t borrow_hostname(const bt_event *event){
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);
}
process_id_t borrow_process_id(const bt_event *event){
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);
}
thread_id_t borrow_thread_id(const bt_event *event){
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);
return bt_field_integer_unsigned_get_value(field);
}
template
<typename
T
>
std::string to_string_with_precision(const T a_value, const std::string extension, const int n = 2)
st
atic st
d::string to_string_with_precision(const T a_value, const std::string extension, const int n = 2)
{
std::ostringstream out;
out.precision(n);
...
...
@@ -110,7 +110,7 @@ std::string to_string_with_precision(const T a_value, const std::string extensio
}
template
<
typename
T
>
std::string format_byte(const T duration) {
st
atic st
d::string format_byte(const T duration) {
<%
[
[
'TB'
,
'1e+12'
],
[
'GB'
,
'1e+9'
],
[
'MB'
,
'1e+6'
],
...
...
@@ -126,7 +126,7 @@ std::string format_byte(const T duration) {
template
<typename
T
>
std::string format_time(const T duration) {
st
atic st
d::string format_time(const T duration) {
<%
[[
'h'
,
'3.6e+12'
],
[
'min'
,
'6e+10'
],
[
's'
,
'1e+9'
],
...
...
@@ -155,16 +155,17 @@ struct StatIprof_string {
std::string error;
};
// TODO: Inline manualy inside the struct / class
class StatIprof {
uint64_t _start;
public:
uint64_t _total_time{1};
void start(const int64_t);
void stop(const int64_t);
void delta(const uint64_t);
void merge(StatIprof);
void set_error(void);
inline
void start(const int64_t);
inline
void stop(const int64_t);
inline
void delta(const uint64_t);
inline
void merge(StatIprof);
inline
void set_error(void);
StatIprof_string to_string(const uint64_t);
//Used in merge
...
...
@@ -194,6 +195,7 @@ void StatIprof::stop(const int64_t stop) {
void StatIprof::set_error() {
_error++;
}
void StatIprof::delta(const uint64_t delta) {
_min = std::min(_min,delta);
_max = std::max(_max,delta);
...
...
@@ -230,16 +232,16 @@ class <%= n %>: public StatIprof {
<%# Glolbal variable %>
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;
st
atic st
d::unordered_map
<hpt
_device_function_name_t
,
StatTime
>
device_id_result;
st
atic st
d::unordered_map
<hpt
_function_name_t
,
StatTime
>
api_call;
st
atic st
d::unordered_map
<hpt
_function_name_t
,
StatByte
>
memory_trafic;
st
atic st
d::unordered_map
<hp
_device_t
,
std::string
>
device_to_name;
st
atic st
d::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;
st
atic st
d::unordered_map
<hpt
_t
,
thapi_device_id
>
start_device;
st
atic st
d::unordered_map
<hpt
_t
,
thapi_function_name
>
profiled_function_name;
std::unordered_map
<hpt
_function_name_t
,
dsd_t
>
function_name_to_dsd;
st
atic st
d::unordered_map
<hpt
_function_name_t
,
dsd_t
>
function_name_to_dsd;
<%#
_
|_) ._ o ._ _|_ /\ ._ ._ _.
...
...
@@ -251,7 +253,8 @@ std::unordered_map<hpt_function_name_t, dsd_t> function_name_to_dsd;
<%
d_headers
=
[
[
"StatTime"
,
"format_time"
,
[
'Name'
,
'Time'
,
'Time(%)'
,
'Calls'
,
'Average'
,
'Min'
,
'Max'
,
'Failed'
]
],
[
"StatByte"
,
"format_byte"
,
[
'Name'
,
'Byte'
,
'Byte(%)'
,
'Calls'
,
'Average'
,
'Min'
,
'Max'
,
'Failed'
]
]
]
%>
<%
d_headers
.
each
do
|
main_type
,
main_function
,
l_headers
|
%>
<%
d_headers
.
each
do
|
main_type
,
main_function
,
l_headers
|
%>
static inline
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
...
...
@@ -371,6 +374,7 @@ void print_array(std::unordered_map<thapi_function_name, <%= main_type %> > aggr
]
%>
<%
output
.
each
do
|
main_type
,
result
,
header
,
error
,
type
,
var
|
%>
static
inline
void
print_compact_
<%=
result
%>
(){
<%
var
.
each
do
|
t
,
n
,
_
|
%>
std::set
<
<%=
t
%>
>
s_
<%=
n
.
gsub
(
' '
,
'_'
)
%>
;
...
...
@@ -436,7 +440,7 @@ void print_compact_<%= result %>(){
[
'process_id_t'
,
'Processes'
,
'Process'
],
[
'thread_id_t'
,
'Threads'
,
'Thread'
]
]
],
]
%>
static
inline
void
print_extented_
<%=
result
%>
(){
<%
args
=
var
.
map
{
|
t
,
_
,
n
|
n
}.
join
(
','
)
%>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment