-
Notifications
You must be signed in to change notification settings - Fork 297
/
run_perftest_multi_devices
executable file
·182 lines (155 loc) · 4.25 KB
/
run_perftest_multi_devices
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
174
175
176
177
178
179
180
181
182
#!/usr/bin/env bash
# Script to launch a multi device test on seperate processes.
GET_HELP=0
HAVE_CORES=0
HAVE_DEVICES=0
HAVE_IB_PORTS=0
HAVE_GID_INDEXES=0
HAVE_REMOTE_HOST=0
HAVE_CMD=0
BASE_TCP_PORT=15000
function force_dependencies {
if [[ $GET_HELP -eq 1 ]]
then
print_usage
exit
fi
#mandatory flags
if [[ $HAVE_DEVICES -eq 0 ]]
then
echo "-d/--devices flag is mandatory"
exit
fi
if [[ $HAVE_CMD -eq 0 ]]
then
echo "-C/--cmd flag is mandatory"
exit
fi
#optional flags
#check that all arguments have enough params.
if [[ $HAVE_CORES -eq 1 ]]
then
if [[ ${#CORES_LIST[@]} -ne $EXPECTED_PARAMS ]]
then
echo "number of cores should be equal to number of devices (cores for each device)"
exit
fi
fi
if [[ $HAVE_IB_PORTS -eq 1 ]]
then
if [[ ${#IB_PORTS_LIST[@]} -ne $EXPECTED_PARAMS ]]
then
echo "number of ib ports should be equal to number of devices (ib_port for each device)"
exit
fi
fi
if [[ $HAVE_GID_INDEXES -eq 1 ]]
then
if [[ ${#GID_INDEXES_LIST[@]} -ne $EXPECTED_PARAMS ]]
then
echo "number of gid indexes should be equal to number of devices (gid_index for each device)"
exit
fi
fi
}
function run_commands {
for (( I=0 ; I < $EXPECTED_PARAMS ; I++ ))
do
cmd=""
if [[ $HAVE_CORES -eq 1 ]]
then
cmd="taskset -c ${CORES_LIST[$I]}"
fi
#mandatory:
cmd="$cmd $TEST_CMD -d ${DEVICE_LIST[$I]} -p $(($BASE_TCP_PORT+I))"
#optional:
if [[ $HAVE_IB_PORTS -eq 1 ]]
then
cmd="$cmd -i ${IB_PORTS_LIST[$I]}"
fi
if [[ $HAVE_GID_INDEXES -eq 1 ]]
then
cmd="$cmd -x ${GID_INDEXES_LIST[$I]}"
fi
if [[ $HAVE_REMOTE_HOST -eq 1 ]]
then
cmd="$cmd $REMOTE_HOST"
fi
if [[ $I -ne $(($EXPECTED_PARAMS-1)) ]]
then
cmd="$cmd &"
fi
eval $cmd
done
}
function print_usage {
echo -e "\nUsage:"
echo " Server side: run_perftest_multi_device --devices dev1,dev2 --cmd \"<perftest command>\" [optional_flags]"
echo " Client side: run_perftest_multi_device --devices dev1,dev2 --cmd \"<perftest command>\" --remote <server_name> [optional_flags]"
echo ""
echo " ** Please make sure that <perftest command> does not include the <server_name> on both sides. **"
echo " This should be added only by --remote flag on the Client side."
echo -e "\nMandatory flags:"
echo " -d, --devices List of IB devices, seperated by comma. This will override '-d, --ib-dev' flag if existed in the perftest command."
echo " i.e. --devices dev1,dev2"
echo " -C, --cmd A valid perftest command."
echo " i.e. --cmd \"ib_write_bw --size 64 --duration 3\""
echo -e "\nOptional flags:"
echo " -c, --cores Pin each device to a specific core using taskset"
echo " i.e. --cores 0,1 - This will pin dev1 command to core 0 and dev2 command to core 1"
echo " -i, --ib_ports Choose ib_port for each device. This will override '-i, --ib-port' flag if existed in the perftest command."
echo " i.e. --ib_ports 1,2 - dev1 will work with port 1 and dev2 will work with port 2"
echo " -x, --gid_indexes Choose gid_index for each device. This will override '-x, --gid-index' flag if existed in the perftest command."
echo " i.e. --gid_indexes 3,7 - dev1 will work with gid_index 3 and dev2 will work with gid_index 7"
echo " -r, --remote Sets the remote host to connect. This will set it as the client side."
echo " i.e. --remote <server_host_name> , or --remote <server_ip>."
}
#parser
while [[ $# -ge 1 ]]
do
key="$1"
case $key in
-h|--help)
GET_HELP=1
shift
;;
-c|--cores)
CORES_LIST=($(echo "$2" | tr "," " "))
HAVE_CORES=1
shift # past argument
;;
-d|--devices)
DEVICE_LIST=($(echo "$2" | tr "," " "))
HAVE_DEVICES=1
EXPECTED_PARAMS=${#DEVICE_LIST[@]}
shift # past argument
;;
-i|--ib_ports)
IB_PORTS_LIST=($(echo "$2" | tr "," " "))
HAVE_IB_PORTS=1
shift # past argument
;;
-x|--gid_indexes)
GID_INDEXES_LIST=($(echo "$2" | tr "," " "))
HAVE_GID_INDEXES=1
shift
;;
-C|--cmd)
TEST_CMD="$2"
HAVE_CMD=1
shift
;;
-r|--remote)
REMOTE_HOST="$2"
HAVE_REMOTE_HOST=1
shift
;;
*)
# unknown option - ignore
;;
esac
shift
done
force_dependencies
run_commands
exit