-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartgmr.sh
More file actions
executable file
·69 lines (66 loc) · 1.64 KB
/
startgmr.sh
File metadata and controls
executable file
·69 lines (66 loc) · 1.64 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
#!/bin/bash
#
# 节点个数, 从machinefile中获取
command="mpirun"
hostsfile="hosts"
hosts_num=0
algorithm="pagerank"
graphfile="rdmdual.graph"
partition="random"
if [ $# -lt 1 ]; then
echo "执行默认测试算法和示例数据"
mpirun -np 3 ./gmr
exit 0
fi
# 判断集群运行, 还是单节点运行
if [ "$1" = "cluster" ]; then
echo "cluster"
if [ $# -lt 2 ]; then
echo "./startgmr.sh cluster hosts algorithm partition graphfile"
exit 0
fi
if [ $# -gt 1 ]; then
hostsfile=$2
command="$command"" -machinefile $hostsfile"
# 判断提供的hostsfile文件是否存在
if [ ! -f "$hostsfile" ]; then
echo "提供的machinefile不存在"
exit 0
fi
# 遍历hosts文件中的节点个数
for i in `grep -v "#" $2`; do
hosts_num=`expr $hosts_num + 1`
done
command="$command"" -np $hosts_num"
fi
command=$command" ./gmr "
if [ $# -gt 2 ]; then
algorithm=$3
command="$command"" $algorithm"
fi
if [ $# -gt 3 ]; then
partition=$4
command="$command"" $partition"
fi
if [ $# -gt 4 ]; then
graphfile=$5
command="$command"" $graphfile"
fi
else
# ... ./gmr algorithm partition graphfile
command=$command" -np 3 gmr "
if [ $# -gt 0 ]; then
algorithm=$1
command="$command"" $algorithm"
fi
if [ $# -gt 1 ]; then
partition=$2
command="$command"" $partition"
fi
if [ $# -gt 2 ]; then
graphfile=$3
command="$command"" $graphfile"
fi
fi
echo "执行命令:"$command
eval $command