-
Notifications
You must be signed in to change notification settings - Fork 744
/
sycl-perf.sh
executable file
·173 lines (151 loc) · 5.49 KB
/
sycl-perf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
############################################################################################
#
# Script to launch a SYCL executable and collect information regarding the run
#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#
############################################################################################
# Set the color variable
green='\033[0;32m'
yellow='\033[0;33m'
cyan='\033[0;36m'
red='\033[0;31m'
# Clear the color after that
clear='\033[0m'
help()
{
echo -e "Usage: sycl-perf.sh [-f,--format] ${yellow}<Value1> ${clear}[-i,--ignore] ${yellow}<Value2> ${clear}[-p,--projection] ${yellow}<Value3> ${clear}[-c,--color] [-s,--streams] ${yellow}<Value4> ${clear}[-h,--help] [-v, --verbose] [-d, --debug] -- <executable> <arguments>"
echo -e " ${green}-f,--format Allowed values for ${yellow}<Value1>${green} are ${yellow}json,table,stack,all,none${green}"
echo " -i,--ignore First time execution of certain calls take an order of magnitude more"
echo -e " time than subsequent calls listed in ${yellow}<Value2>${green}"
echo -e " Example:- ${yellow}piPlatformGet,piProgramBuild ${green}"
echo " -p,--projection Sequence of comma separated instrumentation costs in nanoseconds that will be"
echo -e " used to simulate and project the impact of the overhead due to instrumentation"
echo -e " as provided in ${yellow}<Value3>${green}"
echo -e " Example:- ${yellow}10,50,150 ${green}"
echo " -c,--color Boolean option, if provided will display output in color for stack data"
echo " -s,--streams Streams to monitor in the SYCL runtime. Multiple streams can be provided"
echo -e " as comma separated values for ${yellow}<Value4>${green}"
echo -e " Example:- ${yellow}sycl,sycl.pi,sycl.perf ${clear}${green}"
echo " -e,--calibrate Boolean option, if provided will run the application with an empty collector."
echo " -v,--verbose Boolean option, if provided will display verbose output of the collector status"
echo " -d,--debug Boolean option, if provided will display debug output, including saved record information."
echo " "
echo -e " The script requires you to set the environment variable XPTI_PERF_DIR"
echo -e " before executing this script."
echo -e " Example: ${cyan}export XPTI_PERF_DIR=/path/to/xptifw/lib/RelWithDebInfo${clear}"
echo " "
echo " "
exit 2
}
export XPTI_TRACE_ENABLE=1
if [ -v XPTI_PERF_DIR ]; then
export XPTI_FRAMEWORK_DISPATCHER="$XPTI_PERF_DIR""/libxptifw.so"
export XPTI_SUBSCRIBERS="$XPTI_PERF_DIR""/libsycl_perf_collector.so"
else
echo -e "${red}Environment variable XPTI_PERF_DIR is not set${clear}"
help
fi
if [ "$#" -eq 0 ]; then
help
fi
############################################################################################
#
# Argument capture
#
############################################################################################
# Default color is normal text and we change the colors only when the option is provided
color=0
calibrate_flag=0
verbose_flag=0
debug_flag=0
SHORT=f:,s:,i:,p:,h,c,e,v,d
LONG=format:,streams:,ignore:,projection:,help,color,calibrate,verbose,debug
OPTS=$(getopt -a -n sycl-perf --options $SHORT --longoptions $LONG -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi
eval set -- "$OPTS"
while [ : ]; do
case "$1" in
-f | --format)
format="$2"
shift 2
;;
-i | --ignore)
ignore_list="$2"
shift 2
;;
-p | --projection)
projection="$2"
shift 2
;;
-c | --color)
color=1
shift;
;;
-e | --calibrate)
calibrate_flag=1
shift;
;;
-v | --verbose)
verbose_flag=1
shift;
;;
-d | --debug)
debug_flag=1
shift;
;;
-s | --streams)
streams="$2"
shift 2
;;
-h | --help)
help
;;
--)
shift;
break
;;
esac
done
############################################################################################
#
# Argument validation and environment setup
#
############################################################################################
if [[ -n $format ]]; then
export XPTI_SYCL_PERF_OUTPUT=$format
fi
if [[ -n "$ignore_list" ]]; then
export XPTI_IGNORE_LIST=$ignore_list
fi
if [[ -n "$projection" ]]; then
export XPTI_SIMULATION=$projection
fi
if [[ -n "$streams" ]]; then
export XPTI_STREAMS=$streams
fi
if [[ $color == 1 || $color == 0 ]]; then
export XPTI_STDOUT_USE_COLOR=$color
fi
if [[ $calibrate_flag == 1 || $calibrate_flag == 0 ]]; then
export XPTI_CALIBRATE=$calibrate_flag
fi
if [[ $verbose_flag == 1 || $verbose_flag == 0 ]]; then
export XPTI_VERBOSE=$verbose_flag
fi
if [[ $debug_flag == 1 || $debug_flag == 0 ]]; then
export XPTI_DEBUG=$debug_flag
fi
############################################################################################
#
# Executing the SYCL program to get the telemetry data from
#
############################################################################################
$@