-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·124 lines (100 loc) · 3.11 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·124 lines (100 loc) · 3.11 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
#!/bin/bash
set -e
#
# USAGE: ./run.sh [--tegra hostname]
#
SRC_DIR="$(realpath $(dirname $0))"
TEGRA_CMD="c63server"
TEGRA_ARGS=""
# Set this to use either the c variant or the CUDA variant
SUBDIR="src"
if [ ! -d $SRC_DIR/$SUBDIR ]; then
echo "Please set SUBDIR variable to c63-in-c or c63-in-cuda in $(realpath $0)"
exit 1
fi
PC_CMD="c63client"
PC_ARGS="/opt/Media/foreman.yuv -o output.c63 -w 352 -h 288 -f 100"
DATE=$(date -u +%Y%m%d-%H%M%S)
RSYNC_ARGS="-rt --exclude=logs/ --exclude=.*"
BUILD_DIR="/home/in5050-g03/kjetil/codec63-discrete-gpu-opt"
echo "Source dir: $SRC_DIR"
trap quit INT
function quit()
{
echo "Cleaning up"
ssh $TEGRA "pkill -u \$(whoami) $TEGRA_CMD" &> /dev/null || true
ssh $PC "pkill -u \$(whoami) $PC_CMD" &> /dev/null || true
echo "Logfiles:"
ls -lh logs/$DATE-*.log
}
mkdir -p logs
#Argument parsing
while [ $# -gt 0 ] ; do
arg=$1
shift
case $arg in
--clean)
CLEAN="clean"
;;
--args)
PC_ARGS=$1
shift
;;
--tegra)
TEGRA=$1
shift
;;
--pc)
PC=$1
shift
;;
--reverse) #For debugging only. Not required to work
T="$TEGRA_CMD"
TEGRA_CMD="$PC_CMD"
PC_CMD="$T"
T="$TEGRA_ARGS"
TEGRA_ARGS="$PC_ARGS"
PC_ARGS="$T"
;;
esac
done
if [ -z "$PC" ]; then
if [ "$TEGRA" == "tegra-1" ]; then
PC="in5050-2016-10"
TEGRA="tegra-1"
elif [ "$TEGRA" == "tegra-2" ]; then
PC="in5050-2016-10"
TEGRA="tegra-2"
elif [ "$TEGRA" == "tegra-3" ]; then
PC="in5050-2014-11"
TEGRA="tegra-3"
elif [ "$TEGRA" == "tegra-4" ]; then
PC="in5050-2014-11"
TEGRA="tegra-4"
else
echo "unknown tegra $TEGRA"
exit 1
fi
fi
TEGRA_NODE=$(/opt/DIS/sbin/disinfo get-nodeid -hostname ${TEGRA})
PC_NODE=$(/opt/DIS/sbin/disinfo get-nodeid -hostname ${PC})
echo "Using $TEGRA ($TEGRA_NODE) and $PC ($PC_NODE)"
echo "Syncing source"
rsync ${RSYNC_ARGS} ${SRC_DIR}/ $TEGRA:${BUILD_DIR}/
rsync ${RSYNC_ARGS} ${SRC_DIR}/ $PC:${BUILD_DIR}/
#Compile on tegra and pc
echo
echo "### Compiling on Tegra ###"
echo
ssh -t $TEGRA "export PATH=/usr/local/cuda-11.4/bin:\$PATH && rm -rf ${BUILD_DIR}/${SUBDIR}/build && mkdir -p ${BUILD_DIR}/$SUBDIR/build && cd $BUILD_DIR/$SUBDIR/build && cmake .. -DCMAKE_CUDA_COMPILER=/usr/local/cuda-11.4/bin/nvcc && make ${CLEAN} $TEGRA_CMD" || exit $?
echo
echo "### Compiling on PC ###"
echo
ssh -t $PC "export PATH=/usr/local/cuda/bin:\$PATH && mkdir -p ${BUILD_DIR}/${SUBDIR}/build && cd $BUILD_DIR/$SUBDIR/build && cmake .. && make ${CLEAN} $PC_CMD" || exit $?
#Launch on both nodes
echo "Running:"
stdbuf -oL -eL ssh $TEGRA "cd $BUILD_DIR/$SUBDIR/build && time stdbuf -oL -eL ./$TEGRA_CMD -r $PC_NODE $TEGRA_ARGS; echo Tegra exit code: \$?" |& tee logs/$DATE-tegra.log &
stdbuf -oL -eL ssh $PC "cd $BUILD_DIR/$SUBDIR/build && time stdbuf -oL -eL ./$PC_CMD -r $TEGRA_NODE $PC_ARGS; echo PC exit code: \$?" |& tee logs/$DATE-pc.log &
wait
echo "Done!"
quit