-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_sgemm.sh
executable file
·107 lines (88 loc) · 1.72 KB
/
build_sgemm.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
#!/bin/bash
CXX=${CXX:-clang++}
CXXFLAGS=(
-std=c++11
-O3
-fstrict-aliasing
-fno-rtti
-fno-exceptions
)
CXX_FILENAME=${CXX##*/}
if [[ $CXX_FILENAME == *clang++* ]]; then
CXXFLAGS+=(
-ffp-contract=fast
)
elif [[ $CXX_FILENAME == *g++* ]]; then
CXXFLAGS+=(
-ffast-math
)
elif [[ $CXX_FILENAME == *icpc* ]]; then
CXXFLAGS+=(
-fp-model fast=2
-opt-prefetch=0
-opt-streaming-cache-evict=0
)
fi
if [[ $MACHTYPE == *-pc-msys ]]; then
# nothing mingw-specific, yet
LFLAGS=()
elif [[ $MACHTYPE == *-apple-darwin* ]]; then
# nothing darwin-specific, yet
LFLAGS=()
elif [[ $MACHTYPE == *-linux-* ]]; then
LFLAGS=(
-lrt
)
else
echo Unknown platform
exit 255
fi
CXXFLAGS+=(
-DSGEMM_PAGE_SIZE=`getconf PAGE_SIZE`
)
source cxx_util.sh
# use the machine name to detect armv8 devices with aarch64 kernels and armv7 userspaces
UNAME_MACHINE=`uname -m`
if [[ $UNAME_MACHINE == "aarch64" ]]; then
cxx_uarch_arm
elif [[ $UNAME_MACHINE == "arm64" ]]; then
CXXFLAGS+=(
-DCACHELINE_SIZE=`sysctl hw.cachelinesize | sed 's/^hw.cachelinesize: //g'`
-march=armv8.4-a
-mtune=native
)
elif [[ $HOSTTYPE == "i686" ]]; then
CXXFLAGS+=(
-DCACHELINE_SIZE=32
-march=native
-mtune=native
)
elif [[ $HOSTTYPE == "x86_64" ]]; then
CXXFLAGS+=(
-DCACHELINE_SIZE=64
-march=native
-mtune=native
)
elif [[ $HOSTTYPE == "powerpc64" || $HOSTTYPE == "ppc64" ]]; then
CXXFLAGS+=(
-DCACHELINE_SIZE=64
-mpowerpc64
-mcpu=powerpc64
-mtune=power6
-maltivec
-mvrsave
)
elif [[ $HOSTTYPE == "mipsel" ]]; then
CXXFLAGS+=(
-DCACHELINE_SIZE=32
-march=mips32r5
-mtune=p5600
-mfp64
-mhard-float
-mmadd4
-mmsa
)
fi
BUILD_CMD="-o sgemm "${CXXFLAGS[@]}" sgemm.cpp "${LFLAGS[@]}" "${@}
echo $CXX $BUILD_CMD
$CXX $BUILD_CMD