-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcompile_gprat.sh
More file actions
executable file
·144 lines (133 loc) · 4.44 KB
/
compile_gprat.sh
File metadata and controls
executable file
·144 lines (133 loc) · 4.44 KB
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
138
139
140
141
142
143
144
#!/bin/bash
# $1: python/cpp
# $2: cpu/gpu
# $3: mkl
################################################################################
set -e # Exit immediately if a command exits with a non-zero status.
################################################################################
# Configurations
################################################################################
# Bindings
if [[ "$1" == "python" ]]
then
BINDINGS=ON
INSTALL_DIR=$(pwd)/examples/gprat_python
elif [[ "$1" == "cpp" ]]
then
BINDINGS=OFF
INSTALL_DIR=$(pwd)/examples/gprat_cpp
else
echo "Please specify input parameter: python/cpp"
exit 1
fi
# Select CMake preset
if [[ "$2" == "cpu" ]]; then
# Release:
PRESET=release-linux
# Debug:
#PRESET=dev-linux
elif [[ "$2" == "gpu" ]]; then
# Release:
PRESET=release-linux-gpu
# Debug:
#PRESET=dev-linux-gpu
elif [[ "$2" != "cpu" ]]; then
echo "Input parameter is missing. Using default: Run computations on CPU in Release mode"
PRESET=release-linux
fi
# Select BLAS library
if [[ "$3" == "mkl" ]]
then
USE_MKL=ON
else
USE_MKL=OFF
fi
# Select APEX profiling option
if [[ "$4" == "steps" ]]; then
GPRAT_APEX_STEPS=ON
GPRAT_APEX_CHOLESKY=OFF
elif [[ "$4" == "cholesky" ]]; then
GPRAT_APEX_STEPS=OFF
GPRAT_APEX_CHOLESKY=ON
else
GPRAT_APEX_STEPS=OFF
GPRAT_APEX_CHOLESKY=OFF
fi
if command -v spack &> /dev/null; then
echo "Spack command found, checking for environments..."
# Get current hostname
HOSTNAME=$(hostname -s)
if [[ "$HOSTNAME" == "ipvs-epyc1" ]]; then
# Check if the gprat_cpu_gcc environment exists
if spack env list | grep -q "gprat_cpu_gcc"; then
echo "Found gprat_cpu_gcc environment, activating it."
module load gcc/14.2.0
export CXX=g++
export CC=gcc
spack env activate gprat_cpu_gcc
GPRAT_WITH_CUDA=OFF # whether GPRAT_WITH_CUDA is ON of OFF is irrelevant for this example
fi
elif [[ "$HOSTNAME" == "sven0" || "$HOSTNAME" == "sven1" ]]; then
#module load gcc/13.2.1
spack load openblas arch=linux-fedora38-riscv64
HPX_CMAKE=$HOME/git_workspace/build-scripts/build/hpx/lib64/cmake/HPX
USE_MKL=OFF
elif [[ $(uname -i) == "aarch64" ]]; then
spack load gcc@14.2.0
# Check if the gprat_cpu_arm environment exists
if spack env list | grep -q "gprat_cpu_arm"; then
echo "Found gprat_cpu_arm environment, activating it."
spack env activate gprat_cpu_arm
fi
USE_MKL=OFF
elif [[ "$HOSTNAME" == "simcl1n1" || "$HOSTNAME" == "simcl1n2" ]]; then
# Check if the gprat_gpu_clang environment exists
if spack env list | grep -q "gprat_gpu_clang"; then
echo "Found gprat_gpu_clang environment, activating it."
module load clang/17.0.1
export CXX=clang++
export CC=clang
module load cuda/12.0.1
spack env activate gprat_gpu_clang
GPRAT_WITH_CUDA=ON
fi
else
echo "Hostname is $HOSTNAME — no action taken."
fi
else
echo "Spack command not found. Building example without Spack."
# Assuming that Spack is not required on given system
fi
if [[ $PRESET == "release-linux" || $PRESET == "dev-linux" ]]; then
cmake --preset $PRESET \
-DGPRAT_BUILD_BINDINGS=$BINDINGS \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DHPX_IGNORE_BOOST_COMPATIBILITY=ON \
-DHPX_DIR=$HPX_CMAKE \
-DGPRAT_ENABLE_FORMAT_TARGETS=OFF \
-DGPRAT_ENABLE_MKL=$USE_MKL \
-DGPRAT_APEX_STEPS=${GPRAT_APEX_STEPS} \
-DGPRAT_APEX_CHOLESKY=${GPRAT_APEX_CHOLESKY}
elif [[ $PRESET == "release-linux-gpu" || $PRESET == "dev-linux-gpu" ]]; then
CUDA_ARCH=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | awk -F '.' '{print $1$2}')
cmake --preset $PRESET \
-DGPRAT_BUILD_BINDINGS=$BINDINGS \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DHPX_IGNORE_BOOST_COMPATIBILITY=ON \
-DGPRAT_ENABLE_FORMAT_TARGETS=OFF \
-DGPRAT_ENABLE_MKL=$USE_MKL \
-DGPRAT_APEX_STEPS=${GPRAT_APEX_STEPS} \
-DGPRAT_APEX_CHOLESKY=${GPRAT_APEX_CHOLESKY} \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_CUDA_COMPILER=$(which clang++) \
-DCMAKE_CUDA_FLAGS=--cuda-path=${CUDA_HOME} \
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCH}
fi
################################################################################
# Compile code
################################################################################
cmake --build --preset $PRESET -- -j
cmake --install build/$PRESET
cd build/$PRESET
ctest --output-on-failure --no-tests=ignore -C Release -j 2