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'
|
2023-07-04 22:30:54 +01:00
|
|
|
|
|
|
|
# hdf5 and fftw depend on OpenMPI, which we install manually. To make sure this
|
|
|
|
# dependency is picked by spack, we specify the compiler here explicitly. For
|
|
|
|
# most other packages we dont really care about the compiler (i.e. system
|
|
|
|
# compiler versus ${gcc_spec})
|
|
|
|
hdf5_spec="hdf5@1.10.7+cxx+threadsafe%${gcc_spec}"
|
|
|
|
fftw_spec="fftw%${gcc_spec}"
|
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
|
2023-07-04 22:30:54 +01:00
|
|
|
echo 'config:
|
2023-01-13 19:19:40 +00:00
|
|
|
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
|
|
|
|
|
2023-07-04 22:30:54 +01:00
|
|
|
spack env create base
|
|
|
|
spack env activate base
|
2023-01-24 18:17:43 +00:00
|
|
|
spack compiler find --scope site
|
2023-01-13 19:19:40 +00:00
|
|
|
|
2023-07-04 22:30:54 +01:00
|
|
|
# install GCC, CUDA
|
|
|
|
spack add ${gcc_spec} ${cuda_spec}
|
|
|
|
spack concretize
|
|
|
|
spack env depfile -o Makefile.tmp
|
|
|
|
make -j128 -f Makefile.tmp
|
2023-01-13 19:19:40 +00:00
|
|
|
spack compiler find --scope site
|
|
|
|
|
|
|
|
# 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
|
|
|
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
|
2023-07-04 22:30:54 +01:00
|
|
|
make -j 128
|
|
|
|
make install
|
2023-01-13 19:19:40 +00:00
|
|
|
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
|
|
|
|
2023-07-04 22:30:54 +01:00
|
|
|
ucx_spec_gpu="ucx@1.12.0.GPU%${gcc_spec}"
|
|
|
|
ucx_spec_cpu="ucx@1.12.0.CPU%${gcc_spec}"
|
|
|
|
openmpi_spec_gpu="openmpi@4.1.1.GPU%${gcc_spec}"
|
|
|
|
openmpi_spec_cpu="openmpi@4.1.1.CPU%${gcc_spec}"
|
|
|
|
|
2023-01-13 19:19:40 +00:00
|
|
|
# Add externals to spack
|
|
|
|
echo "packages:
|
|
|
|
ucx:
|
|
|
|
externals:
|
2023-07-04 22:30:54 +01:00
|
|
|
- spec: \"${ucx_spec_gpu}\"
|
2023-01-24 18:17:43 +00:00
|
|
|
prefix: ${dir}/prefix/ucx_gpu
|
2023-07-04 22:30:54 +01:00
|
|
|
- spec: \"${ucx_spec_cpu}\"
|
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:
|
2023-07-04 22:30:54 +01:00
|
|
|
- spec: \"${openmpi_spec_gpu}\"
|
2023-01-24 18:17:43 +00:00
|
|
|
prefix: ${dir}/prefix/ompi_gpu
|
2023-07-04 22:30:54 +01:00
|
|
|
- spec: \"${openmpi_spec_cpu}\"
|
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-07-04 22:30:54 +01:00
|
|
|
spack env deactivate
|
2023-01-24 18:17:43 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
spack env create grid-gpu
|
|
|
|
spack env activate grid-gpu
|
2023-07-04 22:30:54 +01:00
|
|
|
spack compiler find --scope site
|
|
|
|
spack add ${gcc_spec} ${cuda_spec} ${ucx_spec_gpu} ${openmpi_spec_gpu}
|
|
|
|
spack add ${hdf5_spec} ${fftw_spec}
|
|
|
|
spack add openssl gmp mpfr c-lime "${dev_tools[@]}"
|
|
|
|
spack concretize
|
|
|
|
spack env depfile -o Makefile.tmp
|
|
|
|
make -j128 -f Makefile.tmp
|
2023-01-24 18:17:43 +00:00
|
|
|
spack env deactivate
|
|
|
|
|
|
|
|
spack env create grid-cpu
|
|
|
|
spack env activate grid-cpu
|
2023-07-04 22:30:54 +01:00
|
|
|
spack compiler find --scope site
|
|
|
|
spack add ${gcc_spec} ${ucx_spec_cpu} ${openmpi_spec_cpu}
|
|
|
|
spack add ${hdf5_spec} ${fftw_spec}
|
|
|
|
spack add openssl gmp mpfr c-lime "${dev_tools[@]}"
|
|
|
|
spack concretize
|
|
|
|
spack env depfile -o Makefile.tmp
|
|
|
|
make -j128 -f Makefile.tmp
|
2023-01-24 18:17:43 +00:00
|
|
|
spack env deactivate
|
2023-01-13 19:19:40 +00:00
|
|
|
|
|
|
|
# Final setup ##################################################################
|
|
|
|
spack clean
|
2023-07-04 22:30:54 +01:00
|
|
|
#spack gc -y # "spack gc" tends to get hung up for unknown reasons
|
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
|