-
Notifications
You must be signed in to change notification settings - Fork 34
/
setupUserPetsc.sh
executable file
·155 lines (132 loc) · 5.55 KB
/
setupUserPetsc.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# script to setup and build DFT-FE.
set -e
set -o pipefail
if [ -s CMakeLists.txt ]; then
echo "This script must be run from the build directory!"
exit 1
fi
# Path to project source
SRC=`dirname $0` # location of source directory
########################################################################
#Provide paths below for external libraries, compiler options and flags,
# and optimization flag
#Paths for required external libraries
dealiiPetscRealDir="/home/vikramg/DFT-softwares-gcc/dealii/install_real_cpu"
dealiiPetscComplexDir="/home/vikramg/DFT-softwares-gcc/dealii/install_complex_cpu"
alglibDir="/home/vikramg/DFT-softwares-gcc/alglib/alglib-cpp/src"
libxcDir="/home/vikramg/DFT-softwares-gcc/libxc/install_libxc5.2.3"
spglibDir="/home/vikramg/DFT-softwares-gcc/spglib/install"
xmlIncludeDir="/usr/include/libxml2"
xmlLibDir="/usr/lib64"
ELPA_PATH="/home/vikramg/DFT-softwares-gcc/elpa/install"
#Paths for optional external libraries
# path for NCCL/RCCL libraries
DCCL_PATH=""
mdiPath=""
#Toggle GPU compilation
withGPU=OFF
gpuLang="cuda" # Use "cuda"/"hip"
gpuVendor="nvidia" # Use "nvidia/amd"
withGPUAwareMPI=OFF #Please use this option with care
#Only use if the machine supports
#device aware MPI and is profiled
#to be fast
#Option to link to DCCL library (Only for GPU compilation)
withDCCL=OFF
withMDI=OFF
withTorch=OFF
withCustomizedDealii=OFF
#Compiler options and flags
cxx_compiler=mpic++ #sets DCMAKE_CXX_COMPILER
cxx_flags="-fPIC" #sets DCMAKE_CXX_FLAGS
cxx_flagsRelease="-O2" #sets DCMAKE_CXX_FLAGS_RELEASE
device_flags="-arch=sm_70" # set DCMAKE_CXX_CUDA/HIP_FLAGS
#(only applicable for withGPU=ON)
device_architectures="70" # set DCMAKE_CXX_CUDA/HIP_ARCHITECTURES
#(only applicable for withGPU=ON)
#Option to compile with default or higher order quadrature for storing pseudopotential data
#ON is recommended for MD simulations with hard pseudopotentials
withHigherQuadPSP=OFF
# build type: "Release" or "Debug"
build_type=Release
testing=OFF
minimal_compile=ON
###########################################################################
#Usually, no changes are needed below this line
#
#if [[ x"$build_type" == x"Release" ]]; then
# c_flags="$c_flagsRelease"
# cxx_flags="$c_flagsRelease"
#else
#fi
out=`echo "$build_type" | tr '[:upper:]' '[:lower:]'`
function cmake_configure() {
mkdir -p complex && cd complex
if [ "$gpuLang" = "cuda" ]; then
cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=$cxx_compiler\
-DCMAKE_CXX_FLAGS="$cxx_flags"\
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiDir \
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
-DXML_INCLUDE_DIR=$xmlIncludeDir\
-DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch \
-DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\
-DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH"\
-DWITH_COMPLEX=ON -DWITH_GPU=$withGPU -DGPU_LANG=$gpuLang -DGPU_VENDOR=$gpuVendor -DWITH_GPU_AWARE_MPI=$withGPUAwareMPI -DCMAKE_CUDA_FLAGS="$device_flags" -DCMAKE_CUDA_ARCHITECTURES="$device_architectures"\
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\
-DHIGHERQUAD_PSP=$withHigherQuadPSP $1
elif [ "$gpuLang" = "hip" ]; then
cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=$cxx_compiler\
-DCMAKE_CXX_FLAGS="$cxx_flags"\
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiDir \
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
-DXML_INCLUDE_DIR=$xmlIncludeDir\
-DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch \
-DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\
-DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH"\
-DWITH_COMPLEX=ON -DWITH_GPU=$withGPU -DGPU_LANG=$gpuLang -DGPU_VENDOR=$gpuVendor -DWITH_GPU_AWARE_MPI=$withGPUAwareMPI -DCMAKE_HIP_FLAGS="$device_flags" -DCMAKE_HIP_ARCHITECTURES="$device_architectures"\
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\
-DHIGHERQUAD_PSP=$withHigherQuadPSP $1
else
cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=$cxx_compiler\
-DCMAKE_CXX_FLAGS="$cxx_flags"\
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiDir \
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
-DXML_INCLUDE_DIR=$xmlIncludeDir\
-DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch \
-DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\
-DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH"\
-DWITH_COMPLEX=ON \
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\
-DHIGHERQUAD_PSP=$withHigherQuadPSP $1
fi
}
RCol='\e[0m'
Blu='\e[0;34m';
if [ -d "$out" ]; then # build directory exists
echo -e "${Blu}$out directory already present${RCol}"
else
rm -rf "$out"
echo -e "${Blu}Creating $out ${RCol}"
mkdir -p "$out"
fi
cd $out
withComplex=OFF
dealiiDir=$dealiiPetscRealDir
echo -e "${Blu}Building Real executable in $build_type mode...${RCol}"
mkdir -p real && cd real
cmake_configure "$SRC" && make -j8
cd ..
withComplex=ON
dealiiDir=$dealiiPetscComplexDir
echo -e "${Blu}Building Complex executable in $build_type mode...${RCol}"
mkdir -p complex && cd complex
cmake_configure "$SRC" && make -j8
cd ..
echo -e "${Blu}Build complete.${RCol}"