Skip to content

Commit e26edcc

Browse files
committed
Merge branch 'compilationFixes' of https://bitbucket.org/dftfedevelopers/dftfe into MinvHX_GernalisedEigenSolve
1 parent c3a79e4 commit e26edcc

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

setupDevelopPetscMATRIX.sh

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#!/bin/bash
2+
# script to setup and build DFT-FE.
3+
4+
set -e
5+
set -o pipefail
6+
7+
if [ -s CMakeLists.txt ]; then
8+
echo "This script must be run from the build directory!"
9+
exit 1
10+
fi
11+
12+
# Path to project source
13+
SRC=`dirname $0` # location of source directory
14+
15+
########################################################################
16+
#Provide paths below for external libraries, compiler options and flags,
17+
# and optimization flag
18+
19+
#Paths for required external libraries
20+
dealiiPetscRealDir="/storage/dftfeDependencies/dealii/installReal"
21+
dealiiPetscComplexDir="/storage/dftfeDependencies/dealii/installComplex"
22+
alglibDir="/storage/dftfeDependencies/alglib/install"
23+
libxcDir="/storage/dftfeDependencies/libxc/install"
24+
spglibDir="/storage/dftfeDependencies/spglib/install"
25+
xmlIncludeDir="/usr/include/libxml2"
26+
xmlLibDir="/usr/lib/x86_64-linux-gnu"
27+
ELPA_PATH="/storage/dftfeDependencies/elpa/install"
28+
dftdpath="/storage/dftfeDependencies/dftd/install"
29+
numdiffdir="/storage/dftfeDependencies/numdiff/install"
30+
31+
32+
#Paths for optional external libraries
33+
# path for NCCL/RCCL libraries
34+
DCCL_PATH="/apps/softwares/spack/opt/spack/linux-ubuntu24.04-cascadelake/gcc-13.3.0/nccl-2.23.4-1-xyspmp23glxb4slgne4xpemahjrkuyrj"
35+
mdiPath=""
36+
torchDir=""
37+
38+
#Toggle GPU compilation
39+
withGPU=ON
40+
gpuLang="cuda" # Use "cuda"/"hip"
41+
gpuVendor="nvidia" # Use "nvidia/amd"
42+
withGPUAwareMPI=OFF #Please use this option with care
43+
#Only use if the machine supports
44+
#device aware MPI and is profiled
45+
#to be fast
46+
47+
#Option to link to DCCL library (Only for GPU compilation)
48+
withDCCL=OFF
49+
withMDI=OFF
50+
withTorch=OFF
51+
withCustomizedDealii=OFF
52+
53+
#Compiler options and flags
54+
cxx_compiler=mpicxx #sets DCMAKE_CXX_COMPILER
55+
cxx_flags="-std=c++17 -march=native -fopenmp -fPIC" #sets DCMAKE_CXX_FLAGS
56+
cxx_flagsRelease="-O2" #sets DCMAKE_CXX_FLAGS_RELEASE
57+
device_flags="-arch=sm_70 -ccbin=mpicxx" # set DCMAKE_CXX_CUDA_FLAGS
58+
#(only applicable for withGPU=ON)
59+
device_architectures="70" # set DCMAKE_CXX_CUDA_ARCHITECTURES
60+
#(only applicable for withGPU=ON)
61+
62+
63+
#Option to compile with default or higher order quadrature for storing pseudopotential data
64+
#ON is recommended for MD simulations with hard pseudopotentials
65+
withHigherQuadPSP=OFF
66+
67+
# build type: "Release" or "Debug"
68+
build_type=Release
69+
70+
testing=ON
71+
minimal_compile=ON
72+
###########################################################################
73+
#Usually, no changes are needed below this line
74+
#
75+
76+
#if [[ x"$build_type" == x"Release" ]]; then
77+
# c_flags="$c_flagsRelease"
78+
# cxx_flags="$c_flagsRelease"
79+
#else
80+
#fi
81+
out=`echo "$build_type" | tr '[:upper:]' '[:lower:]'`
82+
83+
function cmake_configure() {
84+
if [ "$gpuLang" = "cuda" ]; then
85+
cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=$cxx_compiler\
86+
-DCMAKE_CXX_FLAGS="$cxx_flags"\
87+
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
88+
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiDir \
89+
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
90+
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
91+
-DXML_INCLUDE_DIR=$xmlIncludeDir\
92+
-DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch -DTORCH_DIR=$torchDir\
93+
-DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\
94+
-DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH;$dftdpath;$numdiffdir"\
95+
-DWITH_COMPLEX=$withComplex -DWITH_GPU=$withGPU -DGPU_LANG=$gpuLang -DGPU_VENDOR=$gpuVendor -DWITH_GPU_AWARE_MPI=$withGPUAwareMPI -DCMAKE_CUDA_FLAGS="$device_flags" -DCMAKE_CUDA_ARCHITECTURES="$device_architectures"\
96+
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\
97+
-DHIGHERQUAD_PSP=$withHigherQuadPSP $1
98+
elif [ "$gpuLang" = "hip" ]; then
99+
cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=$cxx_compiler\
100+
-DCMAKE_CXX_FLAGS="$cxx_flags"\
101+
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
102+
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiDir \
103+
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
104+
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
105+
-DXML_INCLUDE_DIR=$xmlIncludeDir\
106+
-DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch -DTORCH_DIR=$torchDir\
107+
-DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\
108+
-DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH;$dftdpath;$numdiffdir"\
109+
-DWITH_COMPLEX=$withComplex -DWITH_GPU=$withGPU -DGPU_LANG=$gpuLang -DGPU_VENDOR=$gpuVendor -DWITH_GPU_AWARE_MPI=$withGPUAwareMPI -DCMAKE_HIP_FLAGS="$device_flags" -DCMAKE_HIP_ARCHITECTURES="$device_architectures"\
110+
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\
111+
-DHIGHERQUAD_PSP=$withHigherQuadPSP $1
112+
else
113+
cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=$cxx_compiler\
114+
-DCMAKE_CXX_FLAGS="$cxx_flags"\
115+
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
116+
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiDir \
117+
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
118+
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
119+
-DXML_INCLUDE_DIR=$xmlIncludeDir\
120+
-DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch -DTORCH_DIR=$torchDir\
121+
-DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\
122+
-DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH;$dftdpath;$numdiffdir"\
123+
-DWITH_COMPLEX=$withComplex \
124+
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\
125+
-DHIGHERQUAD_PSP=$withHigherQuadPSP $1
126+
fi
127+
}
128+
129+
RCol='\e[0m'
130+
Blu='\e[0;34m';
131+
if [ -d "$out" ]; then # build directory exists
132+
echo -e "${Blu}$out directory already present${RCol}"
133+
else
134+
rm -rf "$out"
135+
echo -e "${Blu}Creating $out ${RCol}"
136+
mkdir -p "$out"
137+
fi
138+
139+
cd $out
140+
141+
withComplex=OFF
142+
dealiiDir=$dealiiPetscRealDir
143+
echo -e "${Blu}Building Real executable in $build_type mode...${RCol}"
144+
mkdir -p real && cd real
145+
cmake_configure "$SRC" && make -j8
146+
cd ..
147+
148+
withComplex=ON
149+
dealiiDir=$dealiiPetscComplexDir
150+
echo -e "${Blu}Building Complex executable in $build_type mode...${RCol}"
151+
mkdir -p complex && cd complex
152+
cmake_configure "$SRC" && make -j8
153+
cd ..
154+
155+
echo -e "${Blu}Build complete.${RCol}"

0 commit comments

Comments
 (0)