-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
executable file
·71 lines (58 loc) · 1.67 KB
/
make.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
#!/bin/bash
mkdir -p bin/
NVCC_FLAGS="-gencode=arch=compute_60,code=sm_60"
NVCC_FLAGS="$NVCC_FLAGS -gencode=arch=compute_70,code=sm_70"
NVCC_FLAGS="$NVCC_FLAGS --use_fast_math -Xptxas -v -Xcompiler -fopenmp -O3"
COMPILE ()
{
local input an5d_option regnum nvcc_option
input=$1
regnum=$2
if [[ $input =~ "2d" ]]; then
an5d_option="--bs1=128"
elif [[ $input =~ "3d" ]]; then
an5d_option="--bs1=32 --bs2=32"
fi
if [[ $input =~ [34]r ]]; then
an5d_option="--bt=2 $an5d_option"
else
an5d_option="--bt=4 $an5d_option"
fi
for sb_type in "float" "double"; do
if [ $regnum -gt 0 ]; then
outpath="$(pwd)/bin/${input%.*}.${sb_type}.reg${regnum}"
nvcc_option="--maxrregcount=${regnum} ${NVCC_FLAGS}"
else
outpath="$(pwd)/bin/${input%.*}.$sb_type"
nvcc_option="${NVCC_FLAGS}"
fi
if [ -f $outpath ] &&
[ $outpath -nt common.h ] &&
[ $outpath -nt make.sh ] &&
[ $outpath -nt $input ]; then
continue
fi
echo $outpath
mkdir -p tmp
cp common.h tmp
cp $input tmp/src.c
cd tmp
an5d -D SB_TYPE=$sb_type $an5d_option src.c
nvcc -D SB_TYPE=$sb_type $nvcc_option src_*.cu 2>/dev/null
cp a.out $outpath
cd ..
rm -rf tmp
done
}
cd $(dirname "$0")
if [[ "$#" != "1" && "$#" != "2" ]] ||
[[ ! -f $(basename $1) ]] ||
[[ "$#" == "2" && ! $2 =~ ^[0-9]+$ ]]; then
echo "Usage: $0 KERNEL_FILE [REGNUM]" >&2
exit -1
fi
if [ "$#" == "1" ]; then
COMPILE $(basename $1) 0
else
COMPILE $(basename $1) $2
fi