-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·119 lines (105 loc) · 2.09 KB
/
build.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
#!/bin/bash
Clear() {
if [ -d _build ]; then
rm -rf _build
fi
}
while [[ $# -ge 1 ]]
do
key=$1
case $key in
-c|--compiler)
COMPILER=$2
shift
;;
-a|--arc)
ARCH=$2
shift
;;
-l|--lib)
LIB=$2
shift
;;
-f|--filename)
OUT_FILE=$2
shift
;;
-m|--mode)
BUILD_MODE=$2
shift
;;
-r|--rm)
Clear
shift
;;
*)
;;
esac
shift
done
case $COMPILER in
intel)
source /opt/intel/bin/compilervars.sh intel64
C_COMPILER="icc"
CXX_COMPILER="icpc"
;;
*)
C_COMPILER="gcc"
CXX_COMPILER="g++"
;;
esac
ARCH=cpu
if [ "$ARCH" == "gpu" ] || [ "$ARCH" == "fpga" ]
then
LIB=opencl
ARCH=gpu
elif [ "$ARCH" == "cpu" ] && [ "$LIB" == "mkl" ] && [ "$C_COMPILER" == "icc" ]
then
LIB=mkl
elif [ "$ARCH" == "cpu" ] && [ "$LIB" == "omp" ]
then
LIB=omp
elif [ "$ARCH" == "cpu" ] && [ "$LIB" == "avx" ]
then
LIB=avx
fi
if [ "$LIB" == "" ]; then
LIB=""
fi
if [ "$BUILD_MODE" == "debug" ]; then
BUILD_MODE="Debug"
else
BUILD_MODE="Release"
fi
if [ "$OUT_FILE" == "" ]
then
OUT_FILE="res"
fi
Build() {
if [ "$ARCH" = "fpga" ]; then
echo "Run with fpga"
source env_altera.sh
fi
root_dir="$( pwd )"
if [ ! -d _build ]; then
mkdir _build
fi
cd _build
if [ -f "CMakeCache.txt" ]; then
rm "CMakeCache.txt"
fi
echo "C_COMPILER = $C_COMPILER"
echo "CXX_COMPILER = $CXX_COMPILER"
cmake -DCMAKE_BUILD_TYPE=$BUILD_MODE -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER -DARCH=${ARCH} -DLIB=$LIB -DOUT_FILE=$OUT_FILE $root_dir
make -j2
cd $root_dir
}
BuildAltera() {
cd _build/modules/Kirill/src
aoc -march=emulator kernel.cl -o ./kernel.aocx --board a10soc --profile
# CL_CONTEXT_EMULATOR_DEVICE_ALTERA=1 ./Hello
}
Build
if [ "$ARCH" = "fpga" ]; then
BuildAltera
fi