Commit db57467b authored by Brice Videau's avatar Brice Videau
Browse files

Added ze to build system.

parent 6e0c5141
Pipeline #11493 canceled with stage
......@@ -18,3 +18,9 @@ tags
# Persistent undo
[._]*.un~
build
autom4te.cache
m4
aclocal.m4
configure
Makefile.in
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = utils opencl #ze cuda
SUBDIRS = utils opencl ze #cuda
EXTRA_DIST = autogen.sh README.md
......@@ -70,10 +70,13 @@ AC_CHECK_FUNCS([atexit clock_gettime ftruncate memmove memset strdup strstr strt
AC_CONFIG_FILES([Makefile
utils/Makefile
opencl/Makefile])
opencl/Makefile
ze/Makefile])
# cuda/Makefile])
AC_CONFIG_FILES([opencl/tracer_opencl.sh], [chmod +x opencl/tracer_opencl.sh])
AC_CONFIG_FILES([opencl/clprof.sh], [chmod +x opencl/clprof.sh])
AC_CONFIG_FILES([opencl/babeltrace_opencl], [chmod +x opencl/babeltrace_opencl])
# ze/Makefile
# cuda/Makefile])
AC_CONFIG_FILES([ze/babeltrace_ze], [chmod +x ze/babeltrace_ze])
AC_CONFIG_FILES([ze/tracer_ze.sh], [chmod +x ze/tracer_ze.sh])
AC_CONFIG_FILES([ze/zeprof.sh], [chmod +x ze/zeprof.sh])
AC_OUTPUT
......@@ -101,10 +101,9 @@ libTracerOpenCL_la_DEPENDS = $(srcdir)/tracer_opencl.map
libTracerOpenCL_la_LIBADD = libtracepoints.la
install-exec-hook::
$(RM) -r $(pkglibdir)
mkdir -p $(pkglibdir)
ln -s $(libdir)/libTracerOpenCL.so.1.0.0 $(pkglibdir)/libOpenCL.so.1.0.0
ln -s $(pkglibdir)/libOpenCL.so.1.0.0 $(pkglibdir)/libOpenCL.so.1
$(RM) $(pkglibdir)/libOpenCL.so.1 $(pkglibdir)/libOpenCL.so
ln -s $(libdir)/libTracerOpenCL.so.1.0.0 $(pkglibdir)/libOpenCL.so.1
ln -s $(pkglibdir)/libOpenCL.so.1 $(pkglibdir)/libOpenCL.so
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
......@@ -125,7 +124,7 @@ nodist_libCLProf_la_SOURCES = \
tracer_opencl.h \
babeltrace_cl_dispatchers.c
libCLProf_la_SOURCES = \
clprof.h
babeltrace_cl.h
libCLProf_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(srcdir)/include -I./
libCLProf_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
......@@ -173,7 +172,7 @@ testing_clprof_callbacks.cpp testing_clprof_callbacks.h: testing_clprof.c
@if test -f $@; then \
touch $@; \
else \
rm -f clprof.c; \
rm -f testing_clprof.c; \
$(MAKE) $(AM_MAKEFLAGS) testing_clprof.c; \
fi
......
#include "clprof.h"
#include "babeltrace_cl.h"
<% if $sink_type == 'production' %>
#include "clprof_callbacks.h"
const bt_value *display_mode;
......
#ifndef _BABELTRACE_CL_H
#define _BABELTRACE_CL_H
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <babeltrace2/babeltrace.h>
#include "uthash.h"
#include "utarray.h"
#ifdef __cplusplus
extern "C" {
#endif
struct opencl_dispatch;
struct opencl_callbacks;
extern void init_dispatchers(struct opencl_dispatch *opencl_dispatch);
typedef void (opencl_dispatcher_t)
(struct opencl_dispatch *opencl_dispatch,
struct opencl_callbacks *callbacks,
const bt_event *message,
const bt_clock_snapshot *clock);
struct opencl_unique_id {
uint64_t class_id;
uint64_t stream_id;
};
struct opencl_callbacks {
struct opencl_unique_id id;
opencl_dispatcher_t *dispatcher;
UT_array *callbacks;
UT_hash_handle hh;
};
struct opencl_event_callbacks {
const char *name;
opencl_dispatcher_t *dispatcher;
UT_array *callbacks;
UT_hash_handle hh;
};
/* Sink component's private data */
struct opencl_dispatch {
/* Upstream message iterator (owned by this) */
bt_message_iterator *message_iterator;
/* Hash table */
struct opencl_callbacks *callbacks;
/* Hash table by name */
struct opencl_event_callbacks *event_callbacks;
};
extern void
opencl_register_dispatcher(struct opencl_dispatch *opencl_dispatch,
const char *name,
opencl_dispatcher_t *dispatcher);
extern void
opencl_register_callback(struct opencl_dispatch *opencl_dispatch,
const char *name,
void *func);
#ifdef __cplusplus
}
#endif
#endif
......@@ -42,18 +42,23 @@ trace() {
export LD_LIBRARY_PATH=$pkglibdir:$LD_LIBRARY_PATH
lttng $quiet start
LD_PRELOAD=${libdir}/libTracerOpenCL.so "$@"
lttng $quiet stop
lttng $quiet destroy
trap 'trace_epilogue' EXIT SIGABRT SIGSEGV
"$@"
}
trace_epilogue() {
lttng $quiet stop
lttng $quiet destroy
summary
}
summary() {
if [ -z $path ]
then
lltng_last_session=$(ls -dt $HOME/lttng-traces/* | head -1)
if [ -z "$path" ]; then
lltng_last_session=$(ls -dt $HOME/lttng-traces/clprof* | head -1)
echo "Trace location " $lltng_last_session
echo
else
lltng_last_session=$1
lltng_last_session=$path
fi
babeltrace2 --plugin-path=$libdir --component=sink.clprof.dispatch --params="display=$display" ${lltng_last_session}
}
......@@ -63,25 +68,17 @@ summary() {
# | (_| | _> | | | (_| /--\ | (_| \/
# _| _|
display="compact"
replay=false
while (( "$#" )); do
case "$1" in
-e|--extented)
display="extended"; shift;
;;
-r|--replay)
shift; path=$@; replay=true;
;;
-- ) shift; break ;;
*)
break
;;
-e | --extented) shift; display="extended" ;;
-r | --replay) shift; path=$@; replay=true ;;
-- ) shift; break ;;
*) break ;;
esac
done
if [ $replay == false ]; then
if [ -z "$replay" ]; then
trace "$@"
fi
summary $path
fi
summary $path
#include "babeltrace2/babeltrace.h"
#include "babeltrace_cl.h"
#include "clprof.h"
#include "xprof_utils.h"
#include <iomanip>
#include <vector>
......
......@@ -81,6 +81,15 @@ export LTTNG_UST_ALLOW_BLOCKING=1
export LD_PRELOAD=$libdir/libTracerOpenCL.so:$LD_PRELOAD
export LD_LIBRARY_PATH=$pkglibdir:$LD_LIBRARY_PATH
lttng start
ctrl_c() {
lttng stop
lttng destroy
exit
}
trap ctrl_c INT
if [ ! -z "$lttng_view" ]
then
lttng view &
......
lttng/tracepoint_gen.h
config.h.in
......@@ -9,4 +9,4 @@ xprof_utils.h: $(srcdir)/xprof_utils.h.erb
$(ERB) $(srcdir)/xprof_utils.h.erb > xprof_utils.h
CLEANFILES = lttng/tracepoint_gen.h xprof_utils.h
EXTRA_DIST = LTTng.rb tracepoint_gen.rb xprof_utils.h.erb
EXTRA_DIST = LTTng.rb tracepoint_gen.rb yaml_ast.rb xprof_utils.h.erb
.DELETE_ON_ERROR:
LTTNG_FLAGS=-fPIC -Wall -Wextra -Wno-unused-parameter -Wno-type-limits -Wno-sign-compare -Werror -I$(top_srcdir)/utils -I$(srcdir)/include -I../utils -I./
ZE_PROBES_TP = \
ze_tracepoints.tp \
zet_tracepoints.tp \
zes_tracepoints.tp
ZE_PROBES_INCL = \
ze_tracepoints.h \
zet_tracepoints.h \
zes_tracepoints.h
ZE_PROBES_SRC = \
ze_tracepoints.c \
zet_tracepoints.c \
zes_tracepoints.c
ZE_STATIC_PROBES_TP = \
ze_profiling.tp \
ze_properties.tp
ZE_STATIC_PROBES_INCL = \
ze_profiling.h \
ze_properties.h
ZE_STATIC_PROBES_SRC = \
ze_profiling.c \
ze_properties.c
CLEANFILES = \
$(ZE_PROBES_TP) \
$(ZE_PROBES_INCL) \
$(ZE_PROBES_SRC) \
$(ZE_STATIC_PROBES_TP) \
$(ZE_STATIC_PROBES_INCL) \
$(ZE_STATIC_PROBES_SRC)
ML_FILES = \
$(srcdir)/ze_meta_parameters.yaml \
$(srcdir)/zes_meta_parameters.yaml \
$(srcdir)/zet_meta_parameters.yaml
EXTRA_DIST = $(ML_FILES)
EXTRA_DIST += ze_events.yaml
ZE_EXTRACT = \
$(srcdir)/extract_base.rb
EXTRA_DIST += extract_base.rb
ZE_EXTRACTED = \
ze_api.yaml \
zet_api.yaml \
zes_api.yaml
CLEANFILES += $(ZE_EXTRACTED)
ZE_MODEL = \
$(srcdir)/ze_model.rb \
$(ML_FILES) \
$(srcdir)/ze_events.yaml \
$(ZE_EXTRACTED) \
$(srcdir)/../utils/yaml_ast.rb \
$(srcdir)/../utils/LTTng.rb
EXTRA_DIST += \
ze_model.rb \
ze_events.yaml
ZE_EXTRA_HDR = \
$(srcdir)/include/ze_ddi.h \
$(srcdir)/include/zes_api.h \
$(srcdir)/include/zes_ddi.h \
$(srcdir)/include/zet_api.h \
$(srcdir)/include/zet_ddi.h
ZE_HDR = \
$(srcdir)/include/ze_api.h \
$(ZE_EXTRA_HDR)
MODIFIED_EXTRA_HDR = \
modified_include/ze_ddi.h \
modified_include/zes_api.h \
modified_include/zes_ddi.h \
modified_include/zet_api.h \
modified_include/zet_ddi.h
MODIFIED_ZE_HDR = \
modified_include/ze_api.h \
$(MODIFIED_EXTRA_HDR)
modified_include/ze_api.h: $(ZE_HDR) $(srcdir)/headers.patch
$(RM) -r modified_include/
cp -r $(srcdir)/include/ modified_include/
cat $(srcdir)/headers.patch | patch -i - -d modified_include/ -s -p1
$(MODIFIED_EXTRA_HDR): modified_include/ze_api.h
@if test -f $@; then \
touch $@; \
else \
$(RM) modified_include/ze_api.h; \
$(MAKE) $(AM_MAKEFLAGS) modified_include/ze_api.h; \
fi
clean-local:
$(RM) -r modified_include
EXTRA_DIST += $(srcdir)/include headers.patch
ze_api.yaml: $(MODIFIED_ZE_HDR) $(ZE_EXTRACT) $(srcdir)/extract_ze.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/extract_ze.rb
zet_api.yaml: $(MODIFIED_ZE_HDR) $(ZE_EXTRACT) $(srcdir)/extract_zet.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/extract_zet.rb
zes_api.yaml: $(MODIFIED_ZE_HDR) $(ZE_EXTRACT) $(srcdir)/extract_zes.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/extract_zes.rb
EXTRA_DIST += \
extract_ze.rb \
extract_zet.rb \
extract_zes.rb
ze_tracepoints.tp: $(srcdir)/gen_ze_tracepoints.rb $(ZE_MODEL) $(srcdir)/gen_probe_base.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_ze_tracepoints.rb > $@
zet_tracepoints.tp: $(srcdir)/gen_zet_tracepoints.rb $(ZE_MODEL) $(srcdir)/gen_probe_base.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_zet_tracepoints.rb > $@
zes_tracepoints.tp: $(srcdir)/gen_zes_tracepoints.rb $(ZE_MODEL) $(srcdir)/gen_probe_base.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_zes_tracepoints.rb > $@
ze_profiling.tp: $(srcdir)/gen_ze_custom_probes.rb $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_ze_custom_probes.rb lttng_ust_ze_profiling > $@
ze_properties.tp: $(srcdir)/gen_ze_custom_probes.rb $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_ze_custom_probes.rb lttng_ust_ze_properties > $@
%.h %.c: %.tp
$(LTTNG_GEN_TP) $< -o $*.c -o $*.h
EXTRA_DIST += \
gen_ze_custom_probes.rb \
gen_ze_tracepoints.rb \
gen_zet_tracepoints.rb \
gen_zes_tracepoints.rb \
gen_probe_base.rb
BUILT_SOURCES = $(ZE_PROBES_INCL) $(ZE_STATIC_PROBES_INCL) babeltrace_ze_callbacks.h
tracer_ze.c: $(srcdir)/gen_ze.rb $(srcdir)/tracer_ze_helpers.include.c $(ZE_MODEL) $(ZE_PROBES_INCL) $(ZE_STATIC_PROBES_INCL)
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/gen_ze.rb > $@
CLEANFILES += tracer_ze.c
bin_SCRIPTS = tracer_ze.sh babeltrace_ze zeprof.sh
noinst_LTLIBRARIES = libzetracepoints.la
nodist_libzetracepoints_la_SOURCES = \
$(ZE_PROBES_INCL) \
$(ZE_STATIC_PROBES_INCL) \
$(ZE_PROBES_SRC) \
$(ZE_STATIC_PROBES_SRC)
libzetracepoints_la_CFLAGS = $(LTTNG_FLAGS) $(LTTNG_UST_CFLAGS)
libzetracepoints_la_LDFLAGS = $(LTTNG_UST_LIBS)
lib_LTLIBRARIES = libTracerZE.la libZEProf.la
nodist_libTracerZE_la_SOURCES = \
$(ZE_PROBES_INCL) \
$(ZE_STATIC_PROBES_INCL) \
tracer_ze.c
libTracerZE_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(srcdir)/include -I../utils -I./
libTracerZE_la_CFLAGS = -Wall -Wextra -Werror
libTracerZE_la_LDFLAGS = $(LTTNG_UST_LIBS) -ldl -lpthread $(LIBFFI_LIBS)
libTracerZE_la_LIBADD = libzetracepoints.la
install-exec-hook::
mkdir -p $(pkglibdir)
$(RM) $(pkglibdir)/libze_loader.so.1 $(pkglibdir)/libze_loader.so
ln -s $(libdir)/libTracerZE.so.1.0.0 $(pkglibdir)/libze_loader.so.1
ln -s $(pkglibdir)/libze_loader.so.1 $(pkglibdir)/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
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
CLEANFILES += \
zeprof.c \
zeprof_callbacks.cpp \
zeprof_callbacks.h
nodist_libZEProf_la_SOURCES = \
zeprof.c \
zeprof_callbacks.cpp \
zeprof_callbacks.h \
babeltrace_ze_dispatchers.c
libZEProf_la_SOURCES = \
babeltrace_ze.h
libZEProf_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(srcdir)/include -I./
libZEProf_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libZEProf_la_CXXFLAGS = -std=c++17 -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libZEProf_la_LDFLAGS = -lstdc++ $(BABELTRACE2_LIBS) -avoid-version -module
EXTRA_DIST += $(ZEPROF)
tmplibdir = $(libdir)/tmp
tmplib_LTLIBRARIES = libBabeltraceZE.la
install-data-hook::
$(RM) -r $(DESTDIR)$(tmplibdir)
ZE_LIB_GEN = \
$(srcdir)/gen_ze_library_base.rb \
$(srcdir)/gen_probe_base.rb
EXTRA_DIST += $(ZE_LIB_GEN)
babeltrace_ze_callbacks.h: $(srcdir)/gen_babeltrace_ze_callbacks.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
babeltrace_ze_dispatchers.c: $(srcdir)/gen_babeltrace_ze_dispatchers.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
EXTRA_DIST += \
gen_babeltrace_ze_callbacks.rb \
gen_babeltrace_ze_dispatchers.rb
nodist_libBabeltraceZE_la_SOURCES = \
babeltrace_ze_callbacks.h \
babeltrace_ze_dispatchers.c
libBabeltraceZE_la_SOURCES = \
babeltrace_ze.c \
babeltrace_ze.h
libBabeltraceZE_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(srcdir)/include -I./
libBabeltraceZE_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libBabeltraceZE_la_LDFLAGS = $(BABELTRACE2_LIBS) -avoid-version -module
ze_library.rb: $(srcdir)/gen_ze_library.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
babeltrace_ze_lib.rb: $(srcdir)/gen_babeltrace_ze_lib.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
ze_refinements.rb: $(srcdir)/gen_ze_refinements.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
ze_bindings.rb: $(srcdir)/gen_ze_bindings.rb $(ZE_LIB_GEN) $(ZE_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
ZE_BINDINGS = \
ze_library.rb \
babeltrace_ze_lib.rb \
ze_refinements.rb \
ze_bindings.rb
data_DATA = $(ZE_BINDINGS)
EXTRA_DIST += \
gen_ze_library.rb \
gen_babeltrace_ze_lib.rb \
gen_ze_refinements.rb \
gen_ze_bindings.rb
CLEANFILES += $(ZE_BINDINGS)
#!/usr/bin/env ruby
DATADIR = File.join("@prefix@", "share")
$:.unshift(DATADIR) if File::directory?(DATADIR)
$:.unshift("./")
require 'babeltrace'
require 'babeltrace/ctf'
require 'yaml'
require 'pp'
require_relative './babeltrace_ze_lib'
require 'babeltrace_ze_lib'
c = Babeltrace::Context::new
traces = c.add_traces(path: ARGV[0])
......
......@@ -114,7 +114,7 @@ $zes_commands.each { |c|
gen_event_callback.call(provider, c, :stop)
}
ze_events = YAML::load_file("ze_events.yaml")
ze_events = YAML::load_file(File.join(SRC_DIR,"ze_events.yaml"))
ze_events.each { |provider, es|
es["events"].each { |event|
......
......@@ -339,7 +339,7 @@ $zes_commands.each { |c|
gen_event_dispatcher.call(provider, c, :stop)
}
ze_events = YAML::load_file("ze_events.yaml")
ze_events = YAML::load_file(File.join(SRC_DIR,"ze_events.yaml"))
ze_events.each { |provider, es|
es["events"].each { |event|
......
......@@ -119,7 +119,7 @@ $zes_commands.each { |c|
gen_event_lambda.call(provider, c, :stop)
}
extra_events = YAML::load_file("ze_events.yaml")
extra_events = YAML::load_file(File.join(SRC_DIR,"ze_events.yaml"))
extra_events.each { |provider, h|
h["events"].each { |e|
......
......@@ -59,7 +59,7 @@ puts <<EOF
EOF
puts File::read("tracer_ze_helpers.include.c")
puts File::read(File.join(SRC_DIR,"tracer_ze_helpers.include.c"))
common_block = lambda { |c, provider|
params = c.parameters.collect(&:name)
......
......@@ -4,7 +4,7 @@ namespace = ARGV[0]
raise "No namespace provided!" unless namespace
h = YAML::load_file("ze_events.yaml")[namespace]
h = YAML::load_file(File.join(SRC_DIR,"ze_events.yaml"))[namespace]
raise "Invalid namespace!" unless h
......
......@@ -107,11 +107,8 @@ gen_extra_event_callback =lambda { |provider, event|
DBT_event.new(provider,event["name"], fields)
}
h = YAML::load_file("ze_events.yaml")
def write_file_via_template(file, testing = false)
template = File.read("#{file}.erb")
template = File.read(File.join(SRC_DIR,"#{file}.erb"))
template_rendered = ERB.new(template).result(binding).gsub(/^\s*$\n/,'')
if testing
......@@ -121,8 +118,6 @@ def write_file_via_template(file, testing = false)
end
end
provider = :lttng_ust_ze
$dbt_events = $ze_commands.map{ |c| gen_event_callback_name_fields.call(provider, c, :start) } +
$ze_commands.map{ |c| gen_event_callback_name_fields.call(provider, c, :stop) }
......@@ -135,7 +130,7 @@ provider = :lttng_ust_zes
$dbt_events += $zes_commands.map{ |c| gen_event_callback_name_fields.call(provider, c, :start) } +
$zes_commands.map{ |c| gen_event_callback_name_fields.call(provider, c, :stop) }
ze_events = YAML::load_file("ze_events.yaml")
ze_events = YAML::load_file(File.join(SRC_DIR,"ze_events.yaml"))
$dbt_events += ze_events.map{ |provider,es|
es['events'].map{ |event|
gen_extra_event_callback.call(provider, event)
......
Markdown is supported
0%