-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
138 lines (114 loc) · 3.93 KB
/
install.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# install.sh
# This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
echo "maks"
echo "This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License."
echo "Version: October 2021"
echo "Compiling for x64 architecture with Intel MKL"
echo
# Look for a compiler: either ICC or G++
COMPILER_ARRAY=("icc" "g++")
for COMPILER in "${COMPILER_ARRAY[@]}"; do
echo "Looking for $COMPILER..."
if ! type "$COMPILER" &> /dev/null; then
echo "$COMPILER not found."
else
echo "Found $COMPILER"
CXX=$COMPILER
break
fi
done
if [ "$CXX" != "icc" ] && [ "$CXX" != "g++" ]; then
echo "No compiler was found. Terminating"; return
else
echo
echo "Using the following compiler"
eval "$CXX --version"
fi
# -> EDIT LINE BELOW WITH YOUR EIGEN3 PATH <-
EIGEN_INCLUDE="/usr/local/include/eigen3"
if [ -d $EIGEN_INCLUDE ]; then
echo "Found Eigen3 in $EIGEN_INCLUDE"
echo
else
echo "User input required. Set the path to your Eigen3 root directory:"
read EIGEN_INCLUDE
if [ -d $EIGEN_INCLUDE ]; then
echo "Found $EIGEN_INCLUDE"
echo
else
echo "Could not find $EIGEN_INCLUDE. Terminating."
#return
fi
fi
# -> EDIT LINE BELOW WITH YOUR MKL /lib PATH <-
MKL_PATH_LIBS="/opt/intel/oneapi/mkl/latest/lib"
if [ -d $MKL_PATH_LIBS ]; then
echo "Found Intel MKL libraries in $MKL_PATH_LIBS"
echo
else
echo "User input required. Set the path to your Intel MKL /lib directory:"
read MKL_PATH_LIBS
if [ -d $MKL_PATH_LIBS ]; then
echo "Found Intel MKL libraries in $MKL_PATH_LIBS"
else
echo "Could not find $MKL_PATH_LIBS. Terminating."
#return
fi
fi
# -> EDIT LINE BELOW WITH YOUR MKL /include PATH <-
MKL_PATH_INCLUDE="/opt/intel/oneapi/mkl/latest/include"
if [ -d $MKL_PATH_INCLUDE ]; then
echo "Found MKL header files directory $MKL_PATH_INCLUDE"
echo
else
echo "User input required. Set the path to your Intel MKL /include directory:"
read MKL_PATH_INCLUDE
if [ -d $MKL_PATH_INCLUDE ]; then
echo "Found Intel MKL libraries in $MKL_PATH_INCLUDE"
else
echo "Could not find $MKL_PATH_INCLUDE. Terminating."
#return
fi
fi
# The actual MKL math stuff comes from libmkl_core
# For the MKL interface we need libmkl_intel_lp64
MKL_LIBS="-lmkl_intel_lp64 -lmkl_core"
# Runtime Threading Library (RTL) - An OpenMP implementation (libgomp in GNU or libiomp5 by Intel)
if [[ "$CXX" == "icc" ]]; then
MKL_LIBS="$MKL_LIBS -liomp5"
elif [[ "$CXX" == "g++" ]]; then
MKL_LIBS="$MKL_LIBS -lgomp"
fi
# The threading library from above will be used by the MKL threading library.
# It chooses according to the RTL from above
case ${CXX} in
icc) MKL_LIBS="$MKL_LIBS -lmkl_intel_thread";;
g++) MKL_LIBS="$MKL_LIBS -lmkl_gnu_thread";;
*) echo "${CXX} compiler not supported. Terminating"; return;;
esac
# Verbose
echo "MKL dynamic libraries:"
echo "$MKL_LIBS"
echo
# Optimization flags (CHANGE IF NEEDED ACCORDING TO YOUR COMPILER OF CHOICE)
case $CXX in
icc) OFLAGS="-O3 -march=native -ip -parallel -lstdc++ -std=c++11" ;;
g++) OFLAGS="-fopenmp -O3 -march=native -lstdc++ -std=c++11" ;;
*) echo "Compiler not supported. Terminating."; return;;
esac
# Verbose
echo "Optimization flags:"
echo "$OFLAGS"
echo
# Set preprocessor macros
echo "Preprocessor macros:"
MACROS="-DEIGEN_USE_MKL_ALL -DMKL_DIRECT_CALL -DNDEBUG"
echo "$MACROS"
echo
# Include path for header files
INCLUDE="./include"
# Source files
SRC="./src/ravess_example.cpp ./src/linalg.cpp ./src/ravg.cpp ./src/io.cpp"
echo "Creating executable..."
eval "$CXX $OFLAGS -o ravess_example $SRC -I$INCLUDE -I$EIGEN_INCLUDE -I$MKL_PATH_INCLUDE -L$MKL_PATH_LIBS -Wl,-rpath,$MKL_PATH_LIBS $MKL_LIBS -lpthread -lm -ldl $MACROS"
return