forked from stilgar/Radix-Sort
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdati
More file actions
executable file
·92 lines (85 loc) · 2.13 KB
/
dati
File metadata and controls
executable file
·92 lines (85 loc) · 2.13 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#defaults
t=s
i=1000000
e=2000000
s=100000
k=10
d=0
c=100
ARCH=`uname -m`
function helps {
echo -n "USAGE: $0 <-t radixSortType> <-i number> <-e number> "
echo "<-s number> <-k number> <-c number> <-d debug>"
echo "USAGE: $0 <-h>"
echo " -t : radix sort type (def: '$t') <'s'=serial|'p'=parallel>"
echo -n " -i : initial number of iterations (def: "
echo -n $i | sed -r ':L;s=\b([0-9]+)([0-9]{3})\b=\1,\2=g;t L'
echo ") <N_min>"
echo -n " -e : end number of iterations (def: "
echo -n $e | sed -r ':L;s=\b([0-9]+)([0-9]{3})\b=\1,\2=g;t L'
echo ") <N_max>"
echo -n " -s : step number of iterations (def: "
echo -n $s | sed -r ':L;s=\b([0-9]+)([0-9]{3})\b=\1,\2=g;t L'
echo ") <N_step>"
echo " -k : maximum digit of each iteration (def: $k) <1 < K < 10>"
echo " -c : chunksize in parallel mode (def: $c)"
echo " -d : debug level (def: $d) <D >= 0>"
echo -e "\tThis program loops radix sort program in a for indicated by"
echo -e "\tparameters for N with same K"
exit 0
}
function test {
t="serial"
[ $1 == "p" ] && t="parallel"
echo "Type = $t radix sort"
echo " N = from $2 to $3 each $4 step"
echo " K = $5"
echo " D = $6"
echo " C = $7"
for (( i=$2; i<=$3; i=i+$4 )); do
nice -n 19 ./${ARCH}/radix_sort_$t $i $5 $6 $7
done
exit 0
}
function is_int() {
return $(test “$@” -eq “$@” > /dev/null 2>&1);
}
FOUND=0
while getopts "ht:i:e:s:k:c:d:" optname; do
case "$optname" in
"h"|"?")
helps
;;
"t")
case "$OPTARG" in
"p"|"s")
t=$OPTARG
FOUND=1
;;
esac
;;
"i"|"e"|"s"|"k"|"c"|"d")
[ -z $OPTARG ] && echo "ERROR: No input value for '$optname' parameter" && exit 1
if [[ "$OPTARG" = *[![:digit:]]* ]]; then
echo "ERROR: Positive integer required for '$optname' parameter"
exit 1
else
let ${optname}=$OPTARG
FOUND=1
fi
([ $c -lt 1 ] ) && echo "ERROR: C ain't to be lesser than 1" && exit 1
([ $k -gt 10 ] || [ $k -lt 1 ] ) && echo "ERROR: K ain't to be greater than 10 or lesser than 1" && exit 1
;;
*)
# Should not occur
echo "ERROR: Unknown error while processing options"
exit 1
;;
esac
done
if [ $FOUND -gt 0 ]; then
test $t $i $e $s $k $d $c
else
helps
fi