-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathsingularity.def
97 lines (86 loc) · 3.55 KB
/
singularity.def
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
Bootstrap: docker
From: rockylinux:9
%help
This container contains Palace compiled with all dependencies.
`singularity run palace.sif <ARGS...>` is equivalent to `palace <ARGS...>`.
%labels
org.opencontainers.image.title Palace
org.opencontainers.image.source https://github.com/awslabs/palace
org.opencontainers.image.vendor AWS Labs
org.opencontainers.image.base.name docker.io/library/rockylinux:9
%environment
if [[ -d /usr/lib64/mpich ]]; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/mpich/lib"
export PATH="$PATH:/usr/lib64/mpich/bin"
fi
export PATH="$PATH:/opt/palace/bin"
%runscript
exec palace "$@"
%setup
# When building the container, bind the Palace source directory to /opt/palace-src with
# `singularity build --bind <SOURCE_DIR>:/opt/palace-src`.
mkdir $SINGULARITY_ROOTFS/opt/palace-src
%post -c /bin/bash
# CPU architecture for compilation, see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
export MARCH="native"
export OPT_FLAGS="-O3 -ffp-contract=fast -funroll-loops -march=$MARCH"
# Install dependencies
dnf install -y dnf-plugins-core && dnf config-manager --enable crb
dnf install -y epel-release
dnf update -y
dnf groupinstall -y "Development Tools"
dnf install -y curl-minimal gcc-gfortran git libunwind-devel openblas-devel \
pkg-config python3 wget zlib
# Install CMake (STRUMPACK requires >= 3.21)
CMAKE_VERSION=3.31.0
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-$(uname -m).sh
/bin/bash cmake-$CMAKE_VERSION-* --skip-license --prefix=/usr
rm -rf cmake-*
# Install MPICH
# If the environment variable `MPICH4` is defined, MPICH v4.0 will be compiled from
# source. This may be passed to singularity using `singularity build --env MPICH4=1`.
if [[ -v MPICH4 ]]; then
MPICH_VERSION=4.0.2
wget http://www.mpich.org/static/downloads/$MPICH_VERSION/mpich-$MPICH_VERSION.tar.gz
tar -xzf mpich-$MPICH_VERSION.tar.gz && cd mpich-$MPICH_VERSION
./configure --enable-fast=all,O3 --prefix=/usr FFLAGS="-std=legacy" FCFLAGS="-std=legacy"
make -j"$(nproc)"
make install
ldconfig
cd .. && rm -rf mpich-*
else
dnf -y install mpich-devel
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/mpich/lib"
export PATH="$PATH:/usr/lib64/mpich/bin"
fi
# Show compiler information
mpicc -v
mpif90 -v
# Build and install Palace
if [[ -z "$(ls -A /opt/palace-src)" ]]; then
git clone https://github.com/awslabs/palace.git /opt/palace-src
fi
mkdir /opt/palace-build && cd /opt/palace-build
cmake /opt/palace-src \
-DCMAKE_INSTALL_PREFIX=/opt/palace \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_CXX_FLAGS="$OPT_FLAGS" \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_C_FLAGS="$OPT_FLAGS" \
-DCMAKE_Fortran_COMPILER=gfortran \
-DCMAKE_Fortran_FLAGS="$OPT_FLAGS" \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DPALACE_WITH_64BIT_INT:BOOL=OFF \
-DPALACE_WITH_OPENMP:BOOL=ON \
-DPALACE_WITH_CUDA:BOOL=OFF \
-DPALACE_WITH_HIP:BOOL=OFF \
-DPALACE_WITH_SUPERLU:BOOL=ON \
-DPALACE_WITH_STRUMPACK:BOOL=ON \
-DPALACE_WITH_MUMPS:BOOL=ON \
-DPALACE_WITH_SLEPC:BOOL=ON \
-DPALACE_WITH_ARPACK:BOOL=ON \
-DPALACE_WITH_LIBXSMM:BOOL=ON \
-DPALACE_WITH_MAGMA:BOOL=ON \
-DPALACE_WITH_GSLIB:BOOL=ON
make -j"$(nproc)"
cd .. && rm -rf palace-build