-
Notifications
You must be signed in to change notification settings - Fork 5
/
parallel_experiments.sh
executable file
·95 lines (79 loc) · 2.02 KB
/
parallel_experiments.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
#!/bin/bash
# Argument = -j jar -c configuration -o outputfile -s sshlogin -v verbose
usage()
{
cat << EOF
usage: $0 options
This script runs given jar file with given configurations in parallel locally or on remote server. Arguments in configuration file have to be separated by spaces.
OPTIONS:
-h Help
-j [file] Jar file*
-c [file] Input configurations*
-o [file] Output file (stdo if empty)
-f [file/folder] Additional file/folder to copy to server
-s [list] SSH logins separated by commas (':' for local),
for n tasks running at once on host use n/login
-m Each output to single file
-v Progress informations
* required
Examples:
Use two threads on local machine
parallelize_jar -j exp.jar -o data.out -c config.in -s 2/:
Take over all resources on host PC
parallelize_jar -j exp.jar -o data.out -c config.in -s user@host
Run one task in parallel on local machine, 4 on hostA and 6 on hostB
parallelize_jar -j exp.jar -o data.out -c config.in -s 1/:,4/loginA,6/loginB
EOF
}
while getopts “hj:c:o:f:ms:n:v” OPTION
do
case $OPTION in
h)
usage
exit
;;
j)
JAR_FILE=$OPTARG
;;
c)
CONFIG_FILE=$OPTARG
;;
o)
OUTPUT_FILE=$OPTARG
;;
f)
TRANSFER_FILE=$OPTARG
;;
m)
FILES_ARG="--files"
;;
s)
SSH_LOGIN=$OPTARG
;;
v)
V_ARG="--progress"
;;
?)
usage
exit 1
;;
esac
done
if [ -z $JAR_FILE ] || [ -z $CONFIG_FILE ]; then
usage
exit
fi
if [ $V_ARG ] && [ -z $OUTPUT_FILE ]; then
V_ARG=""
fi
if [ $TRANSFER_FILE ]; then
TRANSFER_ARG="--bf ${TRANSFER_FILE}"
fi
if [ $SSH_LOGIN ]; then
SSH_ARG="--sshlogin ${SSH_LOGIN} --bf ${JAR_FILE}"
fi
if [ $OUTPUT_FILE ]; then
parallel --gnu $V_ARG $SSH_ARG $TRANSFER_ARG $FILES_ARG -a $CONFIG_FILE --cleanup --colsep ' ' "java -Dlog4j.configuration=\"file:$PWD/log4j.custom\" -XX:+UseSerialGC -jar $JAR_FILE" > ./$OUTPUT_FILE
else
parallel --gnu $V_ARG $SSH_ARG $TRANSFER_ARG $FILES_ARG -a $CONFIG_FILE --cleanup --colsep ' ' "java -Dlog4j.configuration=\"file:$PWD/log4j.custom\" -XX:+UseSerialGC -jar $JAR_FILE"
fi