Commit a115a35e authored by Brice Videau's avatar Brice Videau

Merge branch 'path-4' into 'master'

xprof template

See merge request !6
parents 554a9653 7ac2569b
Pipeline #12203 canceled with stage
......@@ -75,18 +75,16 @@ AC_CHECK_FUNCS([atexit clock_gettime ftruncate memmove memset strdup strstr strt
AC_CONFIG_FILES([Makefile
utils/Makefile
utils/xprof.sh.erb
opencl/Makefile
ze/Makefile
xprof/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])
AC_CONFIG_FILES([opencl/extract_enqueues], [chmod +x opencl/extract_enqueues])
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_CONFIG_FILES([ze/babeltrace_ze], [chmod +x ze/babeltrace_ze])
AC_CONFIG_FILES([cuda/babeltrace_cuda], [chmod +x cuda/babeltrace_cuda])
AC_CONFIG_FILES([cuda/tracer_cuda.sh], [chmod +x cuda/tracer_cuda.sh])
AC_CONFIG_FILES([xprof/iprof], [chmod +x xprof/iprof])
AC_OUTPUT
......@@ -70,6 +70,10 @@ opencl_devices.tp: $(srcdir)/gen_opencl_custom_probes.rb $(TRACEPOINT_GEN)
%.h %.c: %.tp
$(LTTNG_GEN_TP) $< -o $*.c -o $*.h
clprof.sh:
$(ERB) -T 1 languages=["opencl"] $(top_builddir)/utils/xprof.sh.erb > $@
chmod a+x $@
BUILT_SOURCES = $(OPENCL_PROBES_INCL) babeltrace_cl_callbacks.h clprof_callbacks.h clprof.c
tracer_opencl.c: $(srcdir)/gen_opencl.rb $(srcdir)/opencl_model.rb $(ML_FILES) cl.xml.patched $(srcdir)/tracer_opencl_helpers.include.c $(OPENCL_PROBES_INCL) tracer_opencl.h
......
#!/usr/bin/env bash
exec_prefix=@prefix@
libdir=@libdir@
bindir=@bindir@
pkglibdir=$libdir/@PACKAGE@
display_help() {
echo "$(basename $0): a tracer / summarizer of OpenCL and L0 Calls"
echo "Usage:"
echo " $(basename $0) -h | --help "
echo " $(basename $0) [option]... <application> <application-arguments>"
echo " $(basename $0) [option]... -r [<trace>]..."
echo
echo " -h, --help Show this screen"
echo " -e, --extended Print information for each Hostname / Process / Thread / Device"
echo " -t, --trace Display the trace"
echo " -a, --asm Dump in your current directory low level kernels informations (asm,isa,visa,...)."
echo " -r, --replay <application> <application-arguments> will be traited as pathes to traces folders ($HOME/lttng-traces/...)"
echo " If no arguments are provided, will use the latest trace available"
echo
echo " Example:"
echo " $(basename $0) ./a.out"
echo
echo "$(basename $0) will save the trace in $HOME/lttng-traces/"
echo " Please tidy up from time to time"
echo " __ "
echo "For complain, praise, bug repport please use: <(o )___"
echo " https://xgitlab.cels.anl.gov/heteroflow/tracer ( ._> /"
echo " or send email to {apl,bvideau}@anl.gov \`---'"
exit 1
}
# Find all location of a `.so`
whichlib() {
# Output of ldconfig:
#/usr/lib32:
# libstdc++.so.6 -> libstdc++.so.6.0.26
# After the awk:
# -> /usr/lib32/libstdc++.so.6
# In OpenSUSE ldconfig, is in '/sbin'.
PATH=$PATH:/sbin ldconfig -vNX $(echo $LD_LIBRARY_PATH | sed 's/:/ /g') 2>/dev/null |
awk -v p=$1 'match($1, ":") { header=substr($1, 1, length($1)-1)} \
match($1, "^lib") && match($1, p) { print header "/" $1}'
}
trace_and_summary() {
if [ -z "$@" ]; then
display_help
fi
lttng-sessiond $quiet --daemonize
lttng $quiet create thapi-opencl-session
#Using blocking more to trace event record loss
lttng $quiet enable-channel --userspace --blocking-timeout=inf blocking-channel
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_build:infos*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_profiling:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_arguments:kernel_info
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_devices:device_name
lttng $quiet add-context --userspace --channel=blocking-channel -t vpid -t vtid
#Preventing trace event record loss
if [ -z "$LTTNG_UST_OPENCL_LIBOPENCL" ]
then
export LTTNG_UST_OPENCL_LIBOPENCL=$(whichlib libOpenCL.so | head -n 1)
fi
#Preventing trace event record loss
export LTTNG_UST_ALLOW_BLOCKING=1
export LD_PRELOAD=$libdir/libTracerOpenCL.so:$LD_PRELOAD
export LD_LIBRARY_PATH=$pkglibdir/opencl:$LD_LIBRARY_PATH
lttng $quiet start
trap 'trace_epilogue' EXIT SIGABRT SIGSEGV
"$@"
}
trace_epilogue() {
lttng $quiet stop
lttng $quiet destroy
summary
}
summary() {
if [ -z "$@" ]; then
lltng_last_session=$(ls -dt $HOME/lttng-traces/thapi-opencl-session* | head -1)
echo "Trace location:" $lltng_last_session
echo
else
lltng_last_session=$@
fi
# Check that the argument are trace.
# We don't quote the $lltng_last_session, to be able to loop over hit.
# Should be cleaner to use bash arrays.
for f in $lltng_last_session; do
if [ ! -d "$f" ]; then
echo "$f is not a trace folder"
exit 1
fi
done
if [ -n "$trace" ]; then
# Todo filter direcly in the babeltrace
$bindir/babeltrace_opencl $lltng_last_session | grep lttng_ust_opencl
fi
ocl_output=$(babeltrace2 --plugin-path=$libdir --component=sink.clprof.dispatch --params="display=$display" ${lltng_last_session})
if [ -n "$ocl_output" ]; then
echo "== OpenCL == "
echo "$ocl_output"
fi
}
# _
# |_) _. ._ _ o ._ _ /\ ._ _
# | (_| | _> | | | (_| /--\ | (_| \/
# _| _|
display="compact";
if [[ $# -eq 0 ]]; then
display_help
fi
while (( "$#" )); do
case "$1" in
-h | --help) display_help; exit ;;
-e | --extented) shift; display="extended" ;;
-r | --replay) shift; replay=true ;;
-d | --debug) shift; debug=true ;;
-a | --asm) shift; asm=true ;;
-t | --trace) shift; trace=true ;;
--) shift; break ;;
*) break ;;
esac
done
if [ -n "$debug" ]; then
export LIBBABELTRACE2_INIT_LOG_LEVEL=WARNING
export BABELTRACE_CLI_LOG_LEVEL=WARNING
else
quiet="--quiet"
fi
if [ -n "$asm" ]; then
export IGC_ShaderDumpEnable=1
export IGC_DumpToCurrentDir=1
fi
if [ -n "$replay" ]; then
summary "$@"
else
trace_and_summary "$@"
fi
......@@ -5,7 +5,13 @@ bindir=@bindir@
pkglibdir=$libdir/@PACKAGE@
display_help() {
echo "$(basename $0): a tracer / summarizer of OpenCL and L0 Calls"
<% if languages.include?("opencl") and languages.include?("ze")%>
echo "$(basename $0): a tracer / summarizer of OpenCL and L0 calls"
<% elsif languages.include?("opencl") %>
echo "$(basename $0): a tracer / summarizer of OpenCL calls"
<% elsif languages.include?("ze") %>
echo "$(basename $0): a tracer / summarizer of L0 calls"
<% end %>
echo "Usage:"
echo " $(basename $0) -h | --help "
echo " $(basename $0) [option]... <application> <application-arguments>"
......@@ -50,37 +56,57 @@ trace_and_summary() {
fi
lttng-sessiond $quiet --daemonize
<% if languages.include?("opencl") and languages.include?("ze")%>
lttng $quiet create iprof
<% elsif languages.include?("opencl") %>
lttng $quiet create thapi-opencl-session
<% elsif languages.include?("ze") %>
lttng $quiet create thapi-ze-session
<% end %>
#Using blocking more to trace event record loss
lttng $quiet enable-channel --userspace --blocking-timeout=inf blocking-channel
<% if languages.include?("opencl") %>
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_build:infos*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_profiling:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_arguments:kernel_info
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_opencl_devices:device_name
<% end %>
<% if languages.include?("ze") %>
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_ze:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_zet:*
export LTTNG_UST_ZE_PROFILE=1
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_ze_profiling:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_ze_properties:*
<% end %>
lttng $quiet add-context --userspace --channel=blocking-channel -t vpid -t vtid
#Preventing trace event record loss
<% if languages.include?("opencl") %>
if [ -z "$LTTNG_UST_OPENCL_LIBOPENCL" ]
then
export LTTNG_UST_OPENCL_LIBOPENCL=$(whichlib libOpenCL.so | head -n 1)
fi
<% end %>
<% if languages.include?("ze") %>
if [ -z "$LTTNG_UST_ZE_LIBZE_LOADER" ]
then
export LTTNG_UST_ZE_LIBZE_LOADER=$(whichlib libze_loader.so | head -n 1)
fi
<% end %>
#Preventing trace event record loss
export LTTNG_UST_ALLOW_BLOCKING=1
export LD_PRELOAD=$libdir/libTracerOpenCL.so:$libdir/libTracerZE.so:$LD_PRELOAD
export LD_LIBRARY_PATH=$pkglibdir/opencl:$pkglibdir/ze:$LD_LIBRARY_PATH
<% if languages.include?("opencl") %>
export LD_PRELOAD=$libdir/libTracerOpenCL.so:$LD_PRELOAD
export LD_LIBRARY_PATH=$pkglibdir/opencl:$LD_LIBRARY_PATH
<% end %>
<% if languages.include?("ze") %>
export LD_PRELOAD=$libdir/libTracerZE.so:$LD_PRELOAD
export LD_LIBRARY_PATH=$pkglibdir/ze:$LD_LIBRARY_PATH
<% end %>
lttng $quiet start
trap 'trace_epilogue' EXIT SIGABRT SIGSEGV
......@@ -96,41 +122,52 @@ trace_epilogue() {
summary() {
if [ -z "$@" ]; then
lltng_last_session=$(ls -dt $HOME/lttng-traces/* | head -1)
echo "Trace location:" $lltng_last_session
<% if languages.include?("opencl") and languages.include?("ze")%>
lttng_last_session=$(ls -dt $HOME/lttng-traces/* | head -1)
<% elsif languages.include?("opencl") %>
lttng_last_session=$(ls -dt $HOME/lttng-traces/thapi-opencl-session* | head -1)
<% elsif languages.include?("ze") %>
lttng_last_session=$(ls -dt $HOME/lttng-traces/thapi-ze-session* | head -1)
<% end %>
echo "Trace location:" $lttng_last_session
echo
else
lltng_last_session=$@
lttng_last_session=$@
fi
# Check that the argument are trace.
# We don't quote the $lltng_last_session, to be able to loop over hit.
# We don't quote the $lttng_last_session, to be able to loop over hit.
# Should be cleaner to use bash arrays.
for f in $lltng_last_session; do
for f in $lttng_last_session; do
if [ ! -d "$f" ]; then
echo "$f is not a trace folder"
exit 1
fi
done
done
if [ -n "$trace" ]; then
# Todo filter direcly in the babeltrace
$bindir/babeltrace_opencl $lltng_last_session | grep lttng_ust_opencl
$bindir/babeltrace_ze $lltng_last_session | grep lttng_ust_ze
<% if languages.include?("opencl") %>
$bindir/babeltrace_opencl $lttng_last_session | grep lttng_ust_opencl
<% end %>
<% if languages.include?("ze") %>
$bindir/babeltrace_ze $lttng_last_session | grep lttng_ust_ze
<% end %>
fi
ocl_output=$(babeltrace2 --plugin-path=$libdir --component=sink.clprof.dispatch --params="display=$display" ${lltng_last_session})
<% if languages.include?("opencl") %>
ocl_output=$(babeltrace2 --plugin-path=$libdir --component=sink.clprof.dispatch --params="display=$display" ${lttng_last_session})
if [ -n "$ocl_output" ]; then
echo "== OpenCL == "
echo "$ocl_output"
fi
ze_output=$(babeltrace2 --plugin-path=$libdir --component=sink.zeprof.dispatch --params="display=$display" ${lltng_last_session})
<% end %>
<% if languages.include?("ze") %>
ze_output=$(babeltrace2 --plugin-path=$libdir --component=sink.zeprof.dispatch --params="display=$display" ${lttng_last_session})
if [ -n "$ze_output" ]; then
echo "== Level0 == "
echo "$ze_output"
fi
<% end %>
}
# _
......
bin_SCRIPTS = iprof
iprof:
$(ERB) -T 1 languages=["opencl","ze"] $(top_builddir)/utils/xprof.sh.erb > $@
chmod a+x $@
......@@ -164,6 +164,10 @@ EXTRA_DIST += \
gen_zel_tracepoints.rb \
gen_probe_base.rb
zeprof.sh:
$(ERB) -T 1 languages=["ze"] $(top_builddir)/utils/xprof.sh.erb > $@
chmod a+x $@
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)
......
#!/usr/bin/env bash
exec_prefix=@prefix@
libdir=@libdir@
bindir=@bindir@
pkglibdir=$libdir/@PACKAGE@
display_help() {
echo "$(basename $0): a tracer / summarizer of OpenCL and L0 Calls"
echo "Usage:"
echo " $(basename $0) -h | --help "
echo " $(basename $0) [option]... <application> <application-arguments>"
echo " $(basename $0) [option]... -r [<trace>]..."
echo
echo " -h, --help Show this screen"
echo " -e, --extended Print information for each Hostname / Process / Thread / Device"
echo " -t, --trace Display the trace"
echo " -a, --asm Dump in your current directory low level kernels informations (asm,isa,visa,...)."
echo " -r, --replay <application> <application-arguments> will be traited as pathes to traces folders ($HOME/lttng-traces/...)"
echo " If no arguments are provided, will use the latest trace available"
echo
echo " Example:"
echo " $(basename $0) ./a.out"
echo
echo "$(basename $0) will save the trace in $HOME/lttng-traces/"
echo " Please tidy up from time to time"
echo " __ "
echo "For complain, praise, bug repport please use: <(o )___"
echo " https://xgitlab.cels.anl.gov/heteroflow/tracer ( ._> /"
echo " or send email to {apl,bvideau}@anl.gov \`---'"
exit 1
}
# Find all location of a `.so`
whichlib() {
# Output of ldconfig:
#/usr/lib32:
# libstdc++.so.6 -> libstdc++.so.6.0.26
# After the awk:
# -> /usr/lib32/libstdc++.so.6
# In OpenSUSE ldconfig, is in '/sbin'.
PATH=$PATH:/sbin ldconfig -vNX $(echo $LD_LIBRARY_PATH | sed 's/:/ /g') 2>/dev/null |
awk -v p=$1 'match($1, ":") { header=substr($1, 1, length($1)-1)} \
match($1, "^lib") && match($1, p) { print header "/" $1}'
}
trace_and_summary() {
if [ -z "$@" ]; then
display_help
fi
lttng-sessiond $quiet --daemonize
lttng $quiet create thapi-ze-session
#Using blocking more to trace event record loss
lttng $quiet enable-channel --userspace --blocking-timeout=inf blocking-channel
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_ze:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_zet:*
export LTTNG_UST_ZE_PROFILE=1
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_ze_profiling:*
lttng $quiet enable-event --channel=blocking-channel --userspace lttng_ust_ze_properties:*
lttng $quiet add-context --userspace --channel=blocking-channel -t vpid -t vtid
#Preventing trace event record loss
if [ -z "$LTTNG_UST_ZE_LIBZE_LOADER" ]
then
export LTTNG_UST_ZE_LIBZE_LOADER=$(whichlib libze_loader.so | head -n 1)
fi
#Preventing trace event record loss
export LTTNG_UST_ALLOW_BLOCKING=1
export LD_PRELOAD=$libdir/libTracerZE.so:$LD_PRELOAD
export LD_LIBRARY_PATH=$pkglibdir/ze:$LD_LIBRARY_PATH
lttng $quiet start
trap 'trace_epilogue' EXIT SIGABRT SIGSEGV
"$@"
}
trace_epilogue() {
lttng $quiet stop
lttng $quiet destroy
summary
}
summary() {
if [ -z "$@" ]; then
lltng_last_session=$(ls -dt $HOME/lttng-traces/thapi-ze-session* | head -1)
echo "Trace location:" $lltng_last_session
echo
else
lltng_last_session=$@
fi
# Check that the argument are trace.
# We don't quote the $lltng_last_session, to be able to loop over hit.
# Should be cleaner to use bash arrays.
for f in $lltng_last_session; do
if [ ! -d "$f" ]; then
echo "$f is not a trace folder"
exit 1
fi
done
if [ -n "$trace" ]; then
# Todo filter direcly in the babeltrace
$bindir/babeltrace_ze $lltng_last_session | grep lttng_ust_ze
fi
ze_output=$(babeltrace2 --plugin-path=$libdir --component=sink.zeprof.dispatch --params="display=$display" ${lltng_last_session})
if [ -n "$ze_output" ]; then
echo "== Level0 == "
echo "$ze_output"
fi
}
# _
# |_) _. ._ _ o ._ _ /\ ._ _
# | (_| | _> | | | (_| /--\ | (_| \/
# _| _|
display="compact";
if [[ $# -eq 0 ]]; then
display_help
fi
while (( "$#" )); do
case "$1" in
-h | --help) display_help; exit ;;
-e | --extented) shift; display="extended" ;;
-r | --replay) shift; replay=true ;;
-d | --debug) shift; debug=true ;;
-a | --asm) shift; asm=true ;;
-t | --trace) shift; trace=true ;;
--) shift; break ;;
*) break ;;
esac
done
if [ -n "$debug" ]; then
export LIBBABELTRACE2_INIT_LOG_LEVEL=WARNING
export BABELTRACE_CLI_LOG_LEVEL=WARNING
else
quiet="--quiet"
fi
if [ -n "$asm" ]; then
export IGC_ShaderDumpEnable=1
export IGC_DumpToCurrentDir=1
fi
if [ -n "$replay" ]; then
summary "$@"
else
trace_and_summary "$@"
fi
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