-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasures.sh
executable file
·210 lines (161 loc) · 6.53 KB
/
measures.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
# Course: High Performance Computing 2022/2023
#
# Lecturer: Francesco Moscato fmoscato@unisa.it
#
# Group:
# Ferrara Grazia 0622701901 g.ferrara75@studenti.unisa.it
# Franco Paolo 0622701993 p.franco9@studenti.unisa.it
#
# Copyright (C) 2023 - All Rights Reserved
#
# This file is part of Project Assignment 2022/2023.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Project Assignment 2022/2023. If not, see http://www.gnu.org/licenses/.
#
# Requirements of the assignment:
# Provide a parallell version of the Tarjan's algorithm to find Strongly Connected Components in a Graph.
# The implementation MUST use a message passing paradigm, and has to be implemented by using MPI.
# Students MUST store and load the input graph FROM FILES. The whole graph MUST be distributed on files
# on each node (i.e.: the whole graph cannot be stored on a single (even replicated) file). Good Graph
# dimensions are greater than 4GB of data. Students have to choose the proper data structure to
# represent the graph in memory.
#
# Purpose of the file:
# This file contains the script used to make the measures
#!/bin/bash
TIME_STAMP=$(date +%s)
NMEASURES=10
MAX_PROC=4
ARRAY_SZ=(400 800 1200 1600 2000 2400 2800 3200 3600 4000)
#ARRAY_SZ=(400)
ARRAY_proc=(0 1 2 4 8)
# edges shrink factor
ARRAY_SHRINK=(1 2 4) # try with all the edges, then with the half and then with the quarter
trap "exit" INT
# Get script path
SCRIPTPATH=$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )
for shrink in "${ARRAY_SHRINK[@]}"; do
for size in "${ARRAY_SZ[@]}"; do
for proc in "${ARRAY_proc[@]}"; do
proc_str=$(printf "%02d" $proc)
OUT_FILE=$SCRIPTPATH/Measures/Tarjan/SIZE-$size-E-$shrink/SIZE-$size-NP-$proc_str-E-$shrink.csv
OUT_FILE2=$SCRIPTPATH/Measures/Kosaraju/SIZE-$size-E-$shrink/SIZE-$size-NP-$proc_str-E-$shrink.csv
mkdir -p $(dirname $OUT_FILE) 2> /dev/null
mkdir -p $(dirname $OUT_FILE2) 2> /dev/null
echo $(basename $OUT_FILE)
if [[ $ver -gt 1 && $proc -eq 0 ]]; then
OLD_OUT_FILE=$SCRIPTPATH/Measures/Tarjan/SIZE-$size-E-$shrink/SIZE-$size-NP-$proc_str-E-$shrink.csv
ln -srf -T $OLD_OUT_FILE $OUT_FILE
echo Created symbolic link to $(basename $OLD_OUT_FILE)
OLD_OUT_FILE2=$SCRIPTPATH/Measures/Kosaraju/SIZE-$size-E-$shrink/SIZE-$size-NP-$proc_str-E-$shrink.csv
ln -srf -T $OLD_OUT_FILE2 $OUT_FILE2
echo Created symbolic link to $(basename $OLD_OUT_FILE2)
continue
fi
echo "size,processes,read,SCC,elapsed" >$OUT_FILE
echo "size,processes,read,SCC,elapsed" >$OUT_FILE2
for ((i = 0 ; i < $NMEASURES; i++)); do
if [[ $proc -eq 0 ]]; then
# serial
./Source/updateConstants.sh $(($size/$MAX_PROC)) $(($size/$shrink)) $(($size/$shrink))
make -B
make cleanBin
make cleanTxt
# write graphs
mpirun -np $MAX_PROC ./Build/wg.o
# read graphs and write on file th whole matrix
mpirun -np $MAX_PROC ./Build/rg.o
#execute serial
echo $size,$proc,$(./Build/s.o) >> $OUT_FILE
echo $size,$proc,$(./Build/s_k.o) >> $OUT_FILE2
printf "\r> %d/%d %3.1d%% " $(expr $i + 1) $NMEASURES $(expr \( \( $i + 1 \) \* 100 \) / $NMEASURES)
else
# parallel
new=$(($size/$proc))
./Source/updateConstants.sh $new $(($size/$shrink)) $(($size/$shrink))
make -B
make cleanBin
make cleanTxt
# write graphs
mpirun -np $proc ./Build/wg.o
#execute parallel
echo $size,$proc,$(mpirun -np $proc ./Build/p.o) >> $OUT_FILE
echo $size,$proc,$(mpirun -np $proc ./Build/p_k.o) >> $OUT_FILE2
printf "\r> %d/%d %3.1d%% " $(expr $i + 1) $NMEASURES $(expr \( \( $i + 1 \) \* 100 \) / $NMEASURES)
fi
done
printf "\n"
done
done
done
# we choose a size on which test the optimization levels
TEST_SIZE=2000
ARRAY_OPT=(1 2 3)
SHRINK=1
for level in "${ARRAY_OPT[@]}"; do
opt=$(printf "%d" $level)
opt="optimize"$opt
echo $opt
for proc in "${ARRAY_proc[@]}"; do
proc_str=$(printf "%02d" $proc)
OUT_FILE=$SCRIPTPATH/Measures/Tarjan/SIZE-$TEST_SIZE-O-$level/SIZE-$TEST_SIZE-NP-$proc_str-O-$level.csv
OUT_FILE2=$SCRIPTPATH/Measures/Kosaraju/SIZE-$TEST_SIZE-O-$level/SIZE-$TEST_SIZE-NP-$proc_str-O-$level.csv
mkdir -p $(dirname $OUT_FILE) 2> /dev/null
mkdir -p $(dirname $OUT_FILE2) 2> /dev/null
echo $(basename $OUT_FILE)
if [[ $ver -gt 1 && $proc -eq 0 ]]; then
OLD_OUT_FILE=$SCRIPTPATH/Measures/Tarjan/SIZE-$TEST_SIZE-O-$level/SIZE-$TEST_SIZE-NP-$proc_str-O-$level.csv
ln -srf -T $OLD_OUT_FILE $OUT_FILE
echo Created symbolic link to $(basename $OLD_OUT_FILE)
OLD_OUT_FILE2=$SCRIPTPATH/Measures/Kosaraju/SIZE-$TEST_SIZE-O-$level/SIZE-$TEST_SIZE-NP-$proc_str-O-$level.csv
ln -srf -T $OLD_OUT_FILE2 $OUT_FILE2
echo Created symbolic link to $(basename $OLD_OUT_FILE2)
continue
fi
echo "size,processes,read,SCC,elapsed" >$OUT_FILE
echo "size,processes,read,SCC,elapsed" >$OUT_FILE2
for ((i = 0 ; i < $NMEASURES; i++)); do
if [[ $proc -eq 0 ]]; then
# serial
./Source/updateConstants.sh $(($TEST_SIZE/$MAX_PROC)) $(($TEST_SIZE/$SHRINK)) $(($TEST_SIZE/$SHRINK))
make $opt -B
make cleanBin
make cleanTxt
# write graphs
mpirun -np $MAX_PROC ./Build/wg.o
# read graphs and write on file th whole matrix
mpirun -np $MAX_PROC ./Build/rg.o
#execute serial
echo $TEST_SIZE,$proc,$(./Build/s.o) >> $OUT_FILE
echo $TEST_SIZE,$proc,$(./Build/s_k.o) >> $OUT_FILE2
printf "\r> %d/%d %3.1d%% " $(expr $i + 1) $NMEASURES $(expr \( \( $i + 1 \) \* 100 \) / $NMEASURES)
else
# parallel
new=$(($TEST_SIZE/$proc))
./Source/updateConstants.sh $new $(($TEST_SIZE/$SHRINK)) $(($TEST_SIZE/$SHRINK))
make $opt -B
make cleanBin
make cleanTxt
# write graphs
mpirun -np $proc ./Build/wg.o
#execute parallel
echo $TEST_SIZE,$proc,$(mpirun -np $proc ./Build/p.o) >> $OUT_FILE
echo $TEST_SIZE,$proc,$(mpirun -np $proc ./Build/p_k.o) >> $OUT_FILE2
printf "\r> %d/%d %3.1d%% " $(expr $i + 1) $NMEASURES $(expr \( \( $i + 1 \) \* 100 \) / $NMEASURES)
fi
done
printf "\n"
done
done