Repository navigation
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·146 lines (130 loc) · 6.04 KB
/
Copy pathlaunch.sh
File metadata and controls
executable file
·146 lines (130 loc) · 6.04 KB
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
#!/bin/bash
# --------------------------------------------------------------------
# This script connects to the remote machine, gets the code from the
# remote repository, compiles the application code, sends the json file
# for the experiment and executes it. Notice that if you want to use
# SCHED_DEADLINE, you may need to disable the admission controller, by
# running
# echo -1 > /proc/sys/kernel/sched_rt_runtime_us
# on the remote machine, before running the script.
# --------------------------------------------------------------------
# Variable declarations
APP_binary="./bin/application"
RESULT_dir="./results"
REMOTE_ip=$1
REMOTE_port=$2
REMOTE_username=$3
REFERENCE_run=$4
REFERENCE_trace=$5
LISTENING_PORT="23958"
LISTENER_IP=$(ip addr | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
TRACE_CMD_COMMAND="trace-cmd"
# --------------------------------------------------------------------
NUM_args=$#
if [ "$#" -ne 5 ]; then
echo "[LAUNCH] parameters needed:"
echo " #1: remote ip"
echo " #2: remote port"
echo " #3: remote username"
echo " #4: json configuration file (on local machine)"
echo " #5: experiment name"
echo " TRACE_CMD_COMMAND can be set as an environment variable"
echo " to replace the original trace-cmd: it should be set as the"
echo " location of the binary for trace-cmd on the remote machine"
exit
fi
# ------------------------------------------------------------
# ------------------------------------------------------------
# Making sure that it is possible to execute rt-bench on the
# remote host, via eventually git pull and compilation of
# benchmark.
# ------------------------------------------------------------
printf "[LAUNCH] Checking rt-bench presence on remote host ..."
ssh -p ${REMOTE_port} ${REMOTE_username}@${REMOTE_ip} \
'if [ ! -d "rt-bench" ]; then git clone https://github.com/zdemeter/rt-bench.git &>/dev/null; fi'
printf " done\n"
printf "[LAUNCH] Checking rt-bench compilation on remote host ..."
ssh -p ${REMOTE_port} ${REMOTE_username}@${REMOTE_ip} \
"cd rt-bench; if [ ! -f $APP_binary ]; then \
make &> /dev/null; \
fi"
printf " done\n"
# ------------------------------------------------------------
# Executing benchmark on local and remote machine with
# UDP socket listening. Setup of platform via sending json
# file from local to remote machine. Creation of result
# directories both on local and on remote machine. Starting
# the listener on local machine and executing the program on
# remote machine.
# ------------------------------------------------------------
printf "[LAUNCH] Sending json file ..."
scp -P ${REMOTE_port} ${REFERENCE_run} \
${REMOTE_username}@${REMOTE_ip}:~/rt-bench/input/${REFERENCE_trace}.json \
&> /dev/null
printf " done\n"
printf "[LAUNCH] Creating results directories ..."
mkdir -p ${RESULT_dir}
mkdir -p ${RESULT_dir}/${REFERENCE_trace}
ssh -p ${REMOTE_port} ${REMOTE_username}@${REMOTE_ip} \
"mkdir -p rt-bench/${RESULT_dir}"
ssh -p ${REMOTE_port} ${REMOTE_username}@${REMOTE_ip} \
"mkdir -p rt-bench/${RESULT_dir}/${REFERENCE_trace}"
printf " done\n"
printf "[LAUNCH] Starting listener ..."
rm -f *.dat
trace-cmd listen -p ${LISTENING_PORT} &>/dev/null &
LISTENER_PID=$!
printf " done\n"
echo "[LAUNCH] Connecting to remote machine and executing ..."
# -e 'sched_migrate*' # monitor migrations
# -e 'sched_wakeup*' # monitor scheduling wakeups
# -e sched_switch # monitoring switch
ssh -t -t -p ${REMOTE_port} ${REMOTE_username}@${REMOTE_ip} \
"cd rt-bench && \
sudo $TRACE_CMD_COMMAND record -N ${LISTENER_IP}:${LISTENING_PORT} \
-e 'sched_migrate*' \
~/rt-bench/$APP_binary ~/rt-bench/input/${REFERENCE_trace}.json \
&> ${RESULT_dir}/${REFERENCE_trace}/output_${REFERENCE_trace}.txt"
kill -2 $LISTENER_PID
wait $LISTENER_PID
printf "[LAUNCH] Extracting data for ${REFERENCE_run} ..."
FILENAME=`ls trace*.dat`
cp $FILENAME \
${RESULT_dir}/${REFERENCE_trace}/${REFERENCE_trace}.dat
$TRACE_CMD_COMMAND report $FILENAME > ${RESULT_dir}/${REFERENCE_trace}/${REFERENCE_trace}.txt
rm $FILENAME
#echo "# Time, Thread number, Job number, CPU" > $RESULT_dir/${REFERENCE_trace}/${REFERENCE_trace}.csv
grep 'begins job' $RESULT_dir/${REFERENCE_trace}/${REFERENCE_trace}.txt | \
awk 'BEGIN {OFS = ", ";} { gsub(":", "", $3); gsub("\\[", "",$6); gsub("\\]", "",$6); gsub("\\[", "",$2); gsub("\\]", "",$2); print $3,$6,$9,$2}' \
> $RESULT_dir/${REFERENCE_trace}/${REFERENCE_trace}.csv
cp ${REFERENCE_run} ${RESULT_dir}/${REFERENCE_trace}/${REFERENCE_trace}.json
printf ' done\n'
printf "[LAUNCH] Removing unnecessary files ..."
ssh -p ${REMOTE_port} ${REMOTE_username}@${REMOTE_ip} \
"rm -f rt-bench/*.log"
printf " done\n"
ANALYSIS_DIR="../../analysis/"
cd ${RESULT_dir}/${REFERENCE_trace}
cp ${ANALYSIS_DIR}/analysis.m .
cp ${ANALYSIS_DIR}/plotSupply.m .
GENERATED_OCTAVE_SCRIPT="${REFERENCE_trace}.m"
echo "% ----------------------------------------" > $GENERATED_OCTAVE_SCRIPT
echo "clear;" >> $GENERATED_OCTAVE_SCRIPT
echo "experiment_name='$REFERENCE_trace';" >> $GENERATED_OCTAVE_SCRIPT
echo "% ----------------------------------------" >> $GENERATED_OCTAVE_SCRIPT
echo "addpath('$ANALYSIS_DIR');" >> $GENERATED_OCTAVE_SCRIPT
echo "addpath('${ANALYSIS_DIR}jsonlab/');" >> $GENERATED_OCTAVE_SCRIPT
echo "process(experiment_name);" >> $GENERATED_OCTAVE_SCRIPT
echo "analysis;" >> $GENERATED_OCTAVE_SCRIPT
octave -q --no-window-system $GENERATED_OCTAVE_SCRIPT
# Removing the generated script file, as running it again may only
# erase data
rm $GENERATED_OCTAVE_SCRIPT
printf "[LAUNCH] Default analysis completed!\n"
printf "[LAUNCH] To perform the analysis just run the Octave/Matlab script\n"
printf "[LAUNCH] analysis.m in the directory ${RESULT_dir}/${REFERENCE_trace}/\n"
printf "[LAUNCH] Costumized analysis can be performed by modifying\n"
printf "[LAUNCH] experiment_data.m, with experiment dependent data, and\n"
printf "[LAUNCH] analysis.m, which performs the actual analysis.\n"
printf "[LAUNCH] These files are located in ${RESULT_dir}/${REFERENCE_trace}/\n"
cd ../..