Skip to content

Commit

Permalink
[PETSc] v3.21.5 (JuliaPackaging#9335)
Browse files Browse the repository at this point in the history
* buildscript for 3.21.5

* drop support for HDF5

* typos

* deactivate mumps for a few systems

* deactivate mpich/openmpi and freebsd

* missing patches

* more mistakes in mpi-constants.patch

* update patch file

* bugfix

* add hypre

* no need for hypre on windows

* compile superlu_dist on 32bit systems as well

* fix MPItrampoline version and activate all other builds

* address comments by @eschnett

* incorporate requestes changes by @giordano

* add 32bit example to test correct implementation

---------

Co-authored-by: Viral B. Shah <[email protected]>
  • Loading branch information
2 people authored and avik-pal committed Oct 25, 2024
1 parent fe6509d commit fdd12d7
Show file tree
Hide file tree
Showing 2 changed files with 329 additions and 155 deletions.
131 changes: 108 additions & 23 deletions P/PETSc/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# PETSc 3.21.5 with OpenBLAS and static compilations of SuperLU_Dist, SuiteSparse, MUMPS, Hypre, triangle and TetGen on machines that support it
using BinaryBuilder, Pkg
using Base.BinaryPlatforms
const YGGDRASIL_DIR = "../.."
include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl"))

name = "PETSc"
version = v"3.20.5"
petsc_version = v"3.20.5"
version = v"3.21.5"
petsc_version = v"3.21.5"

MPItrampoline_compat_version="5.2.1"
MPItrampoline_compat_version="5.5.0"
MicrosoftMPI_compat_version="~10.1.4"
MPICH_compat_version="~4.1.2"

# Collection of sources required to build PETSc.
sources = [
ArchiveSource("https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-$(petsc_version).tar.gz",
"fb4e637758737af910b05f30a785245633916cd0a929b7b6447ad1028da4ea5a"),
"4eb1ec04c1a8988bd524f71f8d7d980dc1853d5be8791c0f19f3c09eef71fdd2"),
DirectorySource("./bundled"),
]

Expand All @@ -27,6 +28,11 @@ apk del cmake
cd $WORKSPACE/srcdir/petsc*
atomic_patch -p1 $WORKSPACE/srcdir/patches/petsc_name_mangle.patch
# TODO: MPITrampoline embeds the wrong CC. https://github.com/JuliaPackaging/Yggdrasil/issues/7420
export MPITRAMPOLINE_CC="$(which $CC)"
export MPITRAMPOLINE_CXX="$(which $CXX)"
export MPITRAMPOLINE_FC="$(which $FC)"
if [[ "${target}" == *-mingw* ]]; then
# On windows, it compiles fine but we obtain a following runtime error:
#
Expand Down Expand Up @@ -81,7 +87,7 @@ fi
atomic_patch -p1 $WORKSPACE/srcdir/patches/mingw-version.patch
atomic_patch -p1 $WORKSPACE/srcdir/patches/mpi-constants.patch
atomic_patch -p1 $WORKSPACE/srcdir/patches/sosuffix.patch
atomic_patch -p1 $WORKSPACE/srcdir/patches/sosuffix.patch
mkdir $libdir/petsc
build_petsc()
Expand All @@ -105,26 +111,58 @@ build_petsc()
# A SuperLU_DIST build is (now) available on most systems, but only works for double precision
USE_SUPERLU_DIST=0
if [ "${1}" == "double" ] && [ "${3}" == "Int64" ]; then
if [ "${1}" == "double" ]; then
USE_SUPERLU_DIST=1
fi
if [[ "${target}" == *-mingw* ]]; then
USE_SUPERLU_DIST=0
fi
# install suitesparse if available - note that this shipped with julia and therefore linked to specific julia versions
USE_SUITESPARSE=0
if [ "${1}" == "double" ]; then
USE_SUITESPARSE=1
fi
if [[ "${target}" == *-mingw* ]]; then
USE_SUITESPARSE=0
fi
# See if we can install MUMPS
USE_STATIC_MUMPS=0
USE_MUMPS=0
if [[ "${target}" == *-mingw* ]]; then
# try static
USE_STATIC_MUMPS=0
USE_MUMPS=0
elif [ "${1}" == "double" ] && [ "${2}" == "real" ]; then
USE_STATIC_MUMPS=1
USE_MUMPS=1
else
USE_STATIC_MUMPS=0
USE_MUMPS=0
fi
if [[ "${target}" == powerpc64le-linux-* ]] || [[ "${target}" == aarch64-linux-* ]] || [[ "${target}" == arm-linux-* ]]; then
USE_MUMPS=0
fi
LIBFLAGS="-L${libdir}"
if [[ "${target}" == *-mingw* ]]; then
LIBFLAGS="-L${libdir} -lssp -lmsmpi"
fi
# use LBT - to be activated @ a later stage
#if [[ "${target}" == aarch64-apple-* ]]; then
# LIBFLAGS="-L${libdir}"
# # Linking requires the function `__divdc3`, which is implemented in
# # `libclang_rt.osx.a` from LLVM compiler-rt.
# BLAS_LAPACK_LIB="${libdir}/libblastrampoline.${dlext}"
# CLINK_FLAGS="-L${libdir}/darwin -lclang_rt.osx"
#elif [[ "${target}" == *-mingw* ]]; then
# # BLAS_LAPACK_LIB="${libdir}/libblastrampoline-5.${dlext}"
# BLAS_LAPACK_LIB="${libdir}/libopenblas.${dlext}" # LBT doesn't seem to work on windows
# CLINK_FLAGS=""
#else
# BLAS_LAPACK_LIB="${libdir}/libblastrampoline.${dlext}"
# CLINK_FLAGS=""
#fi
BLAS_LAPACK_LIB="${libdir}/libopenblas.${dlext}"
if [ ${DEBUG_FLAG} == 1 ]; then
Expand All @@ -137,6 +175,12 @@ build_petsc()
_FOPTFLAGS='-O3'
fi
# hypre
USE_HYPRE=0
if [ "${1}" == "double" ] && [ "${2}" == "real" ]; then
USE_HYPRE=1
fi
MPI_CC=mpicc
MPI_FC=mpif90
MPI_CXX=mpicxx
Expand All @@ -150,22 +194,34 @@ build_petsc()
MPI_FC=${FC}
MPI_CXX=${CXX}
USE_SUPERLU_DIST=0
USE_STATIC_MUMPS=1
USE_MUMPS=1
elif [[ "${target}" == *-mingw* ]]; then
# since we don't use MPI on windows
MPI_CC=${CC}
MPI_FC=${FC}
MPI_CXX=${CXX}
USE_SUPERLU_DIST=0
USE_SUITESPARSE=0
USE_HYPRE=0
fi
if [[ "${target}" == powerpc64le-linux-* ]] || [[ "${target}" == aarch64-linux-* ]] || [[ "${target}" == arm-linux-* ]]; then
USE_STATIC_MUMPS=0
USE_MUMPS=0
fi
# triangle, tetgen
USE_TRIANGLE=0
USE_TETGEN=0
if [ "${1}" == "double" ] ; then
USE_TRIANGLE=1
USE_TETGEN=1
fi
echo "USE_SUPERLU_DIST="$USE_SUPERLU_DIST
echo "USE_SUITESPARSE="$USE_SUITESPARSE
echo "USE_STATIC_MUMPS="$USE_STATIC_MUMPS
echo "USE_MUMPS="$USE_MUMPS
echo "USE_HYPRE="$USE_HYPRE
echo "USE_TETGEN="$USE_TETGEN
echo "USE_TRIANGLE="$USE_TRIANGLE
echo "1="${1}
echo "2="${2}
echo "3="${3}
Expand All @@ -183,7 +239,8 @@ build_petsc()
echo "MPI_CXX="$MPI_CXX
mkdir $libdir/petsc/${PETSC_CONFIG}
# Step 1: build static libraries of external packages (happens during configure)
# Note that mpicc etc. should be indicated rather than ${CC} to compile external packages
./configure --prefix=${libdir}/petsc/${PETSC_CONFIG} \
Expand All @@ -210,12 +267,19 @@ build_petsc()
--with-scalar-type=${2} \
--with-pthread=0 \
--PETSC_ARCH=${target}_${PETSC_CONFIG} \
--with-scalapack-lib=${libdir}/libscalapack32.${dlext} \
--with-scalapack-include=${includedir} \
--download-suitesparse=${USE_SUITESPARSE} \
--download-suitesparse-shared=0 \
--download-superlu_dist=${USE_SUPERLU_DIST} \
--download-superlu_dist-shared=0 \
--download-mumps=${USE_STATIC_MUMPS} \
--download-hypre=${USE_HYPRE} \
--download-hypre-shared=0 \
--download-hypre-configure-arguments='--host --build' \
--download-mumps=${USE_MUMPS} \
--download-mumps-shared=0 \
--with-scalapack-lib=${libdir}/libscalapack32.${dlext} \
--with-scalapack-include=${includedir} \
--download-tetgen=${USE_TETGEN} \
--download-triangle=${USE_TRIANGLE} \
--SOSUFFIX=${PETSC_CONFIG} \
--with-shared-libraries=1 \
--with-clean=1
Expand All @@ -235,7 +299,6 @@ build_petsc()
# Remove PETSc.pc because petsc.pc also exists, causing conflicts on case-insensitive file-systems.
rm ${libdir}/petsc/${PETSC_CONFIG}/lib/pkgconfig/PETSc.pc
if [ "${1}" == "double" ] && [ "${2}" == "real" ] && [ "${3}" == "Int64" ] && [ "${4}" == "opt" ]; then
# Compile examples (to allow testing the installation).
Expand Down Expand Up @@ -294,6 +357,23 @@ build_petsc()
fi
if [ "${1}" == "double" ] && [ "${2}" == "real" ] && [ "${3}" == "Int32" ] && [ "${4}" == "opt" ]; then
# this is the example that PETSc uses to test the correct installation
# We compile it with debug flags (helpful to catch issues)
workdir=${libdir}/petsc/${PETSC_CONFIG}/share/petsc/examples/src/snes/tutorials/
make --directory=$workdir PETSC_DIR=${libdir}/petsc/${PETSC_CONFIG} PETSC_ARCH=${target}_${PETSC_CONFIG} ex19
file=${workdir}/ex19
if [[ "${target}" == *-mingw* ]]; then
if [[ -f "$file" ]]; then
mv $file ${file}${exeext}
fi
fi
mv ${file}${exeext} ${file}_int32${exeext}
install -Dvm 755 ${workdir}/ex19_int32${exeext} "${bindir}/ex19_int32${exeext}"
fi
# we don't particularly care about the other examples
rm -r ${libdir}/petsc/${PETSC_CONFIG}/share/petsc/examples
}
Expand Down Expand Up @@ -323,9 +403,8 @@ platforms = expand_gfortran_versions(supported_platforms(exclude=[Platform("i686
Platform("armv6l","linux"; libc="musl"),
Platform("armv7l","linux"; libc="musl"),
Platform("armv7l","linux"; libc="gnu"),
Platform("aarch64","linux"; libc="musl"),
Platform("aarch64","linux"; libc="musl"),
]))
Platform("aarch64","linux"; libc="musl")]))

# a few, but not all, platforms with libgfortran 3.0.0 are excluded
platforms, platform_dependencies = MPI.augment_platforms(platforms;
MPItrampoline_compat = MPItrampoline_compat_version,
Expand All @@ -342,15 +421,21 @@ platforms = filter(p -> !(p["mpi"] == "openmpi" && arch(p) == "armv7l" && libc(p
platforms = filter(p -> !(p["mpi"] == "openmpi" && arch(p) == "x86_64" && libc(p) == "musl"), platforms)
platforms = filter(p -> !(p["mpi"] == "openmpi" && arch(p) == "i686"), platforms)

# this excludes only aarch64-unknown-freebsd; can be removed once OpenMPI has been built for this platforms.
platforms = filter(p -> !(p["mpi"] == "openmpi" && Sys.isfreebsd(p) && arch(p) == "aarch64"), platforms)

# MPItrampoline
platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && libc(p) == "musl"), platforms)
platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && Sys.isfreebsd(p)), platforms)
platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && libc(p) == "musl" ), platforms)

# MPICH
platforms = filter(p -> !(p["mpi"] == "mpich" && Sys.isfreebsd(p) && arch(p) == "aarch64"), platforms) # can be removed once MPICH has been built for aarch64-unknown-freebsd

products = [
ExecutableProduct("ex4", :ex4)
ExecutableProduct("ex42", :ex42)
ExecutableProduct("ex19", :ex19)
ExecutableProduct("ex19_int64_deb", :ex19_int64_deb)
ExecutableProduct("ex19_int32", :ex19_int32)

# Current default build, equivalent to Float64_Real_Int32
LibraryProduct("libpetsc_double_real_Int64", :libpetsc, "\$libdir/petsc/double_real_Int64/lib")
Expand Down
Loading

0 comments on commit fdd12d7

Please sign in to comment.