lattice-benchmarks/Grid/systems/tursa/spack-bootstrap.sh

204 lines
6.8 KiB
Bash
Raw Normal View History

2023-01-13 19:19:40 +00:00
#!/usr/bin/env bash
# shellcheck disable=SC2016
set -euo pipefail
2023-01-24 18:17:43 +00:00
gcc_spec='gcc@9.4.0'
cuda_spec='cuda@11.4.0'
hdf5_spec='hdf5@1.10.7'
2023-01-13 19:19:40 +00:00
if (( $# != 1 )); then
echo "usage: $(basename "$0") <env dir>" 1>&2
exit 1
fi
2023-01-24 18:17:43 +00:00
dir=$1
cwd=$(pwd -P)
cd "${dir}"
dir=$(pwd -P)
cd "${cwd}"
2023-01-13 19:19:40 +00:00
# General configuration ########################################################
# build with 128 tasks
echo 'config:
build_jobs: 128
build_stage:
- $spack/var/spack/stage
test_stage: $spack/var/spack/test
misc_cache: $spack/var/spack/cache' > jobs.yaml
spack config --scope site add -f jobs.yaml
rm jobs.yaml
# add lustre as external package
echo 'packages:
lustre:
externals:
- spec: "lustre@2.12.6_ddn36"
prefix: /usr' > external.yaml
spack config --scope site add -f external.yaml
rm external.yaml
2023-01-24 18:17:43 +00:00
# Base compilers ###############################################################
2023-01-13 19:19:40 +00:00
# configure system base
spack compiler find --scope site
2023-01-24 18:17:43 +00:00
# install GCC, CUDA & LLVM
spack install ${gcc_spec} ${cuda_spec} llvm
2023-01-13 19:19:40 +00:00
2023-01-24 18:17:43 +00:00
spack load llvm
spack compiler find --scope site
spack unload llvm
2023-01-13 19:19:40 +00:00
2023-01-24 18:17:43 +00:00
spack load ${gcc_spec}
2023-01-13 19:19:40 +00:00
spack compiler find --scope site
2023-01-24 18:17:43 +00:00
spack unload ${gcc_spec}
2023-01-13 19:19:40 +00:00
# Manual compilation of OpenMPI & UCX ##########################################
# set build directories
2023-01-24 18:17:43 +00:00
mkdir -p "${dir}"/build
cd "${dir}"/build
2023-01-13 19:19:40 +00:00
2023-01-24 18:17:43 +00:00
spack load ${gcc_spec} ${cuda_spec}
2023-01-13 19:19:40 +00:00
2023-01-24 18:17:43 +00:00
cuda_path=$(spack find --format "{prefix}" cuda)
gdrcopy_path=/mnt/lustre/tursafs1/apps/gdrcopy/2.3.1
2023-01-13 19:19:40 +00:00
# Install ucx 1.12.0
2023-01-24 18:17:43 +00:00
ucx_url=https://github.com/openucx/ucx/releases/download/v1.12.0/ucx-1.12.0.tar.gz
2023-01-13 19:19:40 +00:00
echo "-- building UCX from source"
2023-01-24 18:17:43 +00:00
wget ${ucx_url}
ucx_ar=$(basename ${ucx_url})
tar -xvf "${ucx_ar}"
cd "${ucx_ar%.tar.gz}"
2023-01-13 19:19:40 +00:00
# ucx gpu build
2023-01-24 18:17:43 +00:00
mkdir -p build_gpu; cd build_gpu
2023-01-13 19:19:40 +00:00
../configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu \
2023-01-24 18:17:43 +00:00
--disable-dependency-tracking --prefix="${dir}"/prefix/ucx_gpu \
2023-01-13 19:19:40 +00:00
--enable-devel-headers --enable-examples --enable-optimizations \
2023-01-24 18:17:43 +00:00
--with-gdrcopy=${gdrcopy_path} --with-verbs --disable-logging \
2023-01-13 19:19:40 +00:00
--disable-debug --disable-assertions --enable-cma \
--with-knem=/opt/knem-1.1.4.90mlnx1/ --with-rdmacm \
--without-rocm --without-ugni --without-java \
2023-01-24 18:17:43 +00:00
--enable-compiler-opt=3 --with-cuda="${cuda_path}" --without-cm \
2023-01-13 19:19:40 +00:00
--with-rc --with-ud --with-dc --with-mlx5-dv --with-dm \
2023-01-24 18:17:43 +00:00
--enable-mt --without-go LDFLAGS=-L${gdrcopy_path}/lib
2023-01-13 19:19:40 +00:00
make -j 128
make install
cd ..
# ucx cpu build
2023-01-24 18:17:43 +00:00
mkdir -p build_cpu; cd build_cpu
2023-01-13 19:19:40 +00:00
../configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu \
2023-01-24 18:17:43 +00:00
--disable-dependency-tracking --prefix="${dir}"/prefix/ucx_cpu \
2023-01-13 19:19:40 +00:00
--enable-devel-headers --enable-examples --enable-optimizations \
--with-verbs --disable-logging --disable-debug \
--disable-assertions --enable-mt --enable-cma \
--with-knem=/opt/knem-1.1.4.90mlnx1/ --with-rdmacm \
--without-rocm --without-ugni --without-java \
--enable-compiler-opt=3 --without-cm --without-ugni --with-rc \
2023-01-24 18:17:43 +00:00
--with-ud --with-dc --with-mlx5-dv --with-dm --enable-mt --without-go
2023-01-13 19:19:40 +00:00
make -j 128
make install
2023-01-24 18:17:43 +00:00
cd "${dir}"/build
2023-01-13 19:19:40 +00:00
2023-01-24 18:17:43 +00:00
# Install openmpi 4.1.1
ompi_url=https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.1.tar.gz
2023-01-13 19:19:40 +00:00
echo "-- building OpenMPI from source"
2023-01-24 18:17:43 +00:00
wget ${ompi_url}
ompi_ar=$(basename ${ompi_url})
tar -xvf "${ompi_ar}"
cd "${ompi_ar%.tar.gz}"
export AUTOMAKE_JOBS=128
./autogen.pl -f
2023-01-13 19:19:40 +00:00
# openmpi gpu build
mkdir build_gpu; cd build_gpu
2023-01-24 18:17:43 +00:00
../configure --prefix="${dir}"/prefix/ompi_gpu --without-xpmem \
--with-ucx="${dir}"/prefix/ucx_gpu \
--with-ucx-libdir="${dir}"/prefix/ucx_gpu/lib \
2023-01-13 19:19:40 +00:00
--with-knem=/opt/knem-1.1.4.90mlnx1/ \
--enable-mca-no-build=btl-uct \
2023-01-24 18:17:43 +00:00
--with-cuda="${cuda_path}" --disable-getpwuid \
2023-01-13 19:19:40 +00:00
--with-verbs --with-slurm --enable-mpi-fortran=all \
--with-pmix=internal --with-libevent=internal
make -j 128
make install
cd ..
# openmpi cpu build
mkdir build_cpu; cd build_cpu
2023-01-24 18:17:43 +00:00
../configure --prefix="${dir}"/prefix/ompi_cpu --without-xpmem \
--with-ucx="${dir}"/prefix/ucx_cpu \
--with-ucx-libdir="${dir}"/prefix/ucx_cpu/lib \
2023-01-13 19:19:40 +00:00
--with-knem=/opt/knem-1.1.4.90mlnx1/ \
--enable-mca-no-build=btl-uct --disable-getpwuid \
--with-verbs --with-slurm --enable-mpi-fortran=all \
--with-pmix=internal --with-libevent=internal
make -j 128
make install
2023-01-24 18:17:43 +00:00
cd "${dir}"
2023-01-13 19:19:40 +00:00
# Add externals to spack
echo "packages:
ucx:
externals:
- spec: \"ucx@1.12.0.GPU%gcc@9.4.0\"
2023-01-24 18:17:43 +00:00
prefix: ${dir}/prefix/ucx_gpu
2023-01-13 19:19:40 +00:00
- spec: \"ucx@1.12.0.CPU%gcc@9.4.0\"
2023-01-24 18:17:43 +00:00
prefix: ${dir}/prefix/ucx_cpu
2023-01-13 19:19:40 +00:00
buildable: False
openmpi:
externals:
- spec: \"openmpi@4.1.1.GPU%gcc@9.4.0\"
2023-01-24 18:17:43 +00:00
prefix: ${dir}/prefix/ompi_gpu
2023-01-13 19:19:40 +00:00
- spec: \"openmpi@4.1.1.CPU%gcc@9.4.0\"
2023-01-24 18:17:43 +00:00
prefix: ${dir}/prefix/ompi_cpu
2023-01-13 19:19:40 +00:00
buildable: False" > spack.yaml
spack config --scope site add -f spack.yaml
rm spack.yaml
2023-01-24 18:17:43 +00:00
spack install ucx@1.12.0.GPU%gcc@9.4.0 openmpi@4.1.1.GPU%gcc@9.4.0
spack install ucx@1.12.0.CPU%gcc@9.4.0 openmpi@4.1.1.CPU%gcc@9.4.0
cd "${cwd}"
# environments #################################################################
2023-01-27 17:56:10 +00:00
dev_tools=("autoconf" "automake" "libtool" "jq" "git")
2023-01-24 18:17:43 +00:00
ompi_gpu_hash=$(spack find --format "{hash}" openmpi@4.1.1.GPU)
ompi_cpu_hash=$(spack find --format "{hash}" openmpi@4.1.1.CPU)
spack env create grid-gpu
spack env activate grid-gpu
spack add ${gcc_spec} ${cuda_spec} "${dev_tools[@]}"
spack add ucx@1.12.0.GPU%gcc@9.4.0 openmpi@4.1.1.GPU%gcc@9.4.0
spack add ${hdf5_spec}+cxx+threadsafe ^/"${ompi_gpu_hash}"
spack add fftw ^/"${ompi_gpu_hash}"
spack add openssl gmp mpfr c-lime
spack install
spack env deactivate
spack env create grid-cpu
spack env activate grid-cpu
spack add llvm "${dev_tools[@]}"
spack add ucx@1.12.0.CPU%gcc@9.4.0 openmpi@4.1.1.CPU%gcc@9.4.0
spack add ${hdf5_spec}+cxx+threadsafe ^/"${ompi_cpu_hash}"
spack add fftw ^/"${ompi_cpu_hash}"
spack add openssl gmp mpfr c-lime
spack install
spack env deactivate
2023-01-13 19:19:40 +00:00
2023-01-27 17:56:10 +00:00
spack install jq git
2023-01-13 19:19:40 +00:00
# Final setup ##################################################################
spack clean
2023-01-24 18:17:43 +00:00
spack gc -y
2023-01-13 19:19:40 +00:00
# add more environment variables in module loading
2023-01-24 18:17:43 +00:00
spack config --scope site add 'modules:prefix_inspections:lib:[LD_LIBRARY_PATH,LIBRARY_PATH]'
spack config --scope site add 'modules:prefix_inspections:lib64:[LD_LIBRARY_PATH,LIBRARY_PATH]'
2023-01-13 19:19:40 +00:00
spack config --scope site add 'modules:prefix_inspections:include:[C_INCLUDE_PATH,CPLUS_INCLUDE_PATH,INCLUDE]'
spack module tcl refresh -y