-
Notifications
You must be signed in to change notification settings - Fork 0
/
geom.sh
65 lines (51 loc) · 928 Bytes
/
geom.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
#!/bin/bash
if [ "$1" = "" ];
then
echo "1 1 1 1"
exit
fi
nCores=$1
if [ "$(echo "$nCores*2/2" | bc)" != "$nCores" ];
then
echo "nCores not an integer";
exit -1
fi
x=$(echo "l(${nCores})/l(2)" | bc -l);
if [ $(echo "$x-$x*2/2>.0000000000001" | bc) -eq 1 ]
then
echo "num cores not a power of 2"
exit -1
fi
c=3
while [ $c -ge 0 ];
do
x[$c]=1
c=$(echo "$c-1" | bc -l)
done
#simd layout is 1 2 2 2, and time direction is typically double spatial
#thus, balance the result
if [ "$nCores" = "2" ]; then
echo "1 1 1 2"
exit
fi
x[3]=2 #x
x[0]=2 #t
n=$(echo "$nCores/4" | bc)
while [ $n -gt 1 ]
do
c=$(echo "$c+1" | bc -l)
if [ $c -gt 3 ]; then
c=-1;
continue;
fi
x[$c]=$(echo "${x[$c]}*2" | bc -l);
n=$(echo "${n}/2" | bc);
done
c=3
while [ $c -gt 0 ];
do
geom+="${x[$c]} "
c=$(echo "$c-1" | bc -l)
done
geom+="${x[0]}"
echo $geom