-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·103 lines (90 loc) · 2.39 KB
/
run
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
#!/bin/bash
DIR=$(pwd)
PROGRAM="simulator"
OPTIND=1
BIRDS=512
FILE=""
CLUSTERS=0
RANKS=1
THREADS=1
SIZE=500
STEP=1
TIME=100
OUTDIR="tmp"
while getopts "hb:d:f:g:i:n:p:s:t:" opt; do
case "$opt" in
h) echo "Usage: ./run [options]"
echo " -b <number of birds to simulate>"
echo " -f <file with bird info>"
echo " -g <number of bird groups to create> (0 uses a uniform random distribution)"
echo " -i <step size, which iterations to show graphs for"
echo " -n <number of MPI ranks>"
echo " -p <number of pthreads per rank>"
echo " -s <size of the universe>"
echo " -t <number of iterations>"
exit 0
;;
b) BIRDS=$OPTARG
;;
d) OUTDIR=$OPTARG
;;
f) FILE=$OPTARG
;;
g) CLUSTERS=$OPTARG
;;
i) STEP=$OPTARG
;;
n) RANKS=$OPTARG
;;
p) THREADS=$OPTARG
;;
s) SIZE=$OPTARG
;;
t) TIME=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
echo groups = $CLUSTERS
if [ $CLUSTERS == 0 ]
then
# Run the simulation with a uniform random distribution of birds
echo "Running $PROGRAM with"
echo " RANKS=$RANKS, THREADS=$THREADS"
mpirun -N $RANKS "$DIR/$PROGRAM" -p $THREADS -b $BIRDS -s $SIZE -t $TIME
else
# Use n groups of birds
if [ "$FILE" == "" ]
then
# Generate birds if not provided with file
echo "Generating Birds"
python generateBirds.py $CLUSTERS $SIZE $BIRDS all.birds
FILE="all.birds"
fi
# Split birds up into a single input file per rank
echo "Splitting Birds into separate input files"
python splitInputFile.py $FILE $RANKS
# Run the simulation
echo "Running $PROGRAM with"
echo " RANKS=$RANKS, THREADS=$THREADS"
mpirun -N $RANKS "$DIR/$PROGRAM" -p $THREADS -b $BIRDS -s $SIZE -t $TIME -f
# Clean up
echo "Cleaning up input files"
rm *.birds
fi
#---------------Uncomment to visualize simulation output-----------------------
#
#
#echo "Generating Plots"
#mkdir $OUTDIR
#rm $OUTDIR/*.png
#rm $OUTDIR/Rplots.gif
#Rscript plot_birds.R $SIZE $OUTDIR $TIME --vanilla
#echo "Creating .gif"
#convert -delay 10x100 $OUTDIR/* $OUTDIR/Rplots.gif
#
#echo "Cleaning up"
#rm simout.csv
#----------------------------End commented section-----x-----------------------
echo "Finished!"