Skip to content

Commit

Permalink
[VMEC] Update dependency versions (#5184)
Browse files Browse the repository at this point in the history
* No longer need to fix the versioning of dependencies

* Change dependencies to MPItrampoline and libblastrampoline

* Remove empty Windows build, builds with MPItrampoline

* Fix sha256 to v1.2.0

* Per #5167, scalapack can't use libblastrampoline, revert back to mkl and openblas and julia1.6

* Re-enable empty windows lib for dependency purposes

* Fixed issue where MPI version is not added to artifact

* Added patch to fix compilation errors with MPItrampoline

* Fix hold-over from testing

* Fixed holdover from testing preventing MKL library from building
  • Loading branch information
benjaminfaber authored Jul 25, 2022
1 parent 3eeee3a commit 4cb8a36
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 31 deletions.
102 changes: 71 additions & 31 deletions V/VMEC/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -1,47 +1,84 @@
using BinaryBuilder, Pkg
using Base.BinaryPlatforms
const YGGDRASIL_DIR = "../.."
include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl"))

name = "VMEC"
upstream_version = v"1.1.0"
upstream_version = v"1.2.0"
version_patch_offset = 0
version = VersionNumber(upstream_version.major,
upstream_version.minor,
upstream_version.patch * 100 + version_patch_offset)

sources = [
ArchiveSource("https://gitlab.com/wistell/VMEC2000/-/archive/v$(upstream_version).tar",
"98a09a9436e98411960a34d642ea808f72d596e408004ea4c0ea475cc614f7f5"),
"58a99cd0e7b4add481124e75ed7b8ccd5452e83b07230aefe4c4334de020b1cf"),
DirectorySource("./bundled"),
]

script = raw"""
cd ${WORKSPACE}/srcdir/VMEC*
# From the SCALAPACK build_tarballs with MPItrampoline
# We need to specify the MPI libraries explicitly because the
# CMakeLists.txt doesn't properly add them when linking
MPILIBS=()
if grep -q MSMPI_VER "${prefix}/include/mpi.h"; then
MPILIBS=(-lmsmpifec64 -lmsmpi64)
elif grep -q MPICH "${prefix}/include/mpi.h"; then
MPILIBS=(-lmpifort -lmpi)
elif grep -q MPItrampoline "${prefix}/include/mpi.h"; then
MPILIBS=(-lmpitrampoline)
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/mpi_inc.patch
MPIF_PATH=$(find ${libdir} -name 'mpif.h')
MPIF_PATH=$(sed "s:\/:\\\/:g" <<< "$MPIF_PATH")
sed "s/INCLUDE \'mpif.h\'/INCLUDE \'${MPIF_PATH}\'/" Sources/LIBSTELL_minimal/mpi_inc.f | cat > Sources/LIBSTELL_minimal/mpi_inc.patched
mv Sources/LIBSTELL_minimal/mpi_inc.patched Sources/LIBSTELL_minimal/mpi_inc.f
elif grep -q OMPI_MAJOR_VERSION "$prefix/include/mpi.h"; then
MPILIBS=(-lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi)
fi
F_FLAGS=(-O3)
# Add `-fallow-argument-mismatch` if supported
: >empty.f
if gfortran -c -fallow-argument-mismatch empty.f >/dev/null 2>&1; then
F_FLAGS+=(-fallow-argument-mismatch)
fi
rm -f empty.*
if [[ ${target} == *mingw* ]]; then
sed "s/LT_INIT/LT_INIT(win32-dll)/" configure.ac | cat > configure.ac.2
mv configure.ac.2 configure.ac
./autogen.sh
./configure CC=gcc FC=gfortran F77=gfortran --build=${MACHTYPE} --with-mkl --host=${target} --target=${target} --prefix=${prefix}
# Deal with the issue that gcc doesn't accept -no-undefined at configure step
sed "s/AM_LDFLAGS =/AM_LDFLAGS =-no-undefined/" Makefile | cat > Makefile.2
mv Makefile.2 Makefile
make && make install && make clean
./configure CC=gcc FC=gfortran F77=gfortran --build=${MACHTYPE} --host=${target} --target=${target} --prefix=${prefix}
# Deal with the issue that gcc doesn't accept -no-undefined at configure step
sed "s/AM_LDFLAGS =/AM_LDFLAGS =-no-undefined/" Makefile | cat > Makefile.2
mv Makefile.2 Makefile
make && make install && make clean
sed "s/LT_INIT/LT_INIT(win32-dll)/" configure.ac | cat > configure.ac.2
mv configure.ac.2 configure.ac
./autogen.sh
./configure CC=gcc FC=gfortran F77=gfortran --build=${MACHTYPE} --with-mkl --host=${target} --target=${target} --prefix=${prefix}
# Deal with the issue that gcc doesn't accept -no-undefined at configure step
sed "s/AM_LDFLAGS =/AM_LDFLAGS =-no-undefined/" Makefile | cat > Makefile.2
mv Makefile.2 Makefile
make && make install && make clean
./configure CC=gcc FC=gfortran F77=gfortran --build=${MACHTYPE} --host=${target} --target=${target} --prefix=${prefix}
# Deal with the issue that gcc doesn't accept -no-undefined at configure step
sed "s/AM_LDFLAGS =/AM_LDFLAGS =-no-undefined/" Makefile | cat > Makefile.2
mv Makefile.2 Makefile
make && make install && make clean
else
# Configure with MKL provided ScaLAPACK
./autogen.sh
./configure CC=mpicc FC=mpifort F77=mpifort FFLAGS=-O3 FCFLAGS=-O3 --with-mkl --build=${MACHTYPE} --host=${target} --target=${target} --prefix=${prefix}
make && make install && make clean
# Configure with OpenBLAS and ScaLAPACK from SCALAPACK_jll
./configure CC=mpicc FC=mpifort F77=mpifort FFLAGS=-O3 FCFLAGS=-O3 --build=${MACHTYPE} --host=${target} --target=${target} --prefix=${prefix}
make && make install && make clean
./autogen.sh
./configure CC=mpicc FC=mpifort F77=mpifort FFLAGS="${F_FLAGS[*]}" FCFLAGS="${F_FLAGS}" LIBS="${MPILIBS[*]}" --with-mkl --build=${MACHTYPE} --host=${target} --target=${target} --prefix=${prefix}
make && make install && make clean
./configure CC=mpicc FC=mpifort F77=mpifort FFLAGS="${F_FLAGS[*]}" FCFLAGS="${F_FLAGS[*]}" LIBS="${MPILIBS[*]}" --build=${MACHTYPE} --host=${target} --target=${target} --prefix=${prefix}
make && make install && make clean
fi
"""

# This is for MPItrampoline implementation
augment_platform_block = """
using Base.BinaryPlatforms
$(MPI.augment)
function augment_platform!(platform::Platform)
augment_mpi!(platform)
end
"""

platforms = expand_gfortran_versions(supported_platforms())

# Filter out libgfortran_version = 3.0.0 which is incompatible with VMEC
Expand All @@ -58,20 +95,23 @@ filter!(p -> libc(p) != "musl", platforms)
# Don't automatically dl_open so that the appropriate
# library can be loaded on intiation of VMEC.jl
products = [
LibraryProduct("libvmec_mkl", :libvmec_mkl, dont_dlopen = true),
LibraryProduct("libvmec_openblas", :libvmec_openblas, dont_dlopen = true),
LibraryProduct("libvmec_mkl", :libvmec_mkl, dont_dlopen=true),
LibraryProduct("libvmec_openblas", :libvmec_openblas, dont_dlopen=true),
]

# Dependencies that must be installed before this package can be built
dependencies = [
# MbedTLS is an indirect dependency, fix the version for building
BuildDependency(PackageSpec(name = "MbedTLS_jll", version = v"2.24.0")),
Dependency("MPICH_jll"; platforms=filter(!Sys.iswindows, platforms)),
BuildDependency(PackageSpec(name = "MbedTLS_jll")),
Dependency("SCALAPACK_jll"),
Dependency("OpenBLAS_jll"),
Dependency("SCALAPACK_jll"; platforms=filter(!Sys.iswindows, platforms)),
Dependency("MKL_jll", v"2020.1.216"),
Dependency("MKL_jll"),
Dependency("CompilerSupportLibraries_jll")
]

# Needed from MPItrampoline
all_platforms, platform_dependencies = MPI.augment_platforms(platforms)
append!(dependencies, platform_dependencies)

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat = "1.6")
build_tarballs(ARGS, name, version, sources, script, all_platforms, products, dependencies; julia_compat = "1.6", augment_platform_block)
25 changes: 25 additions & 0 deletions V/VMEC/bundled/patches/mpi_inc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/Sources/LIBSTELL_minimal/mpi_inc.f b/Sources/LIBSTELL_minimal/mpi_inc.f
index 9087aae..c0d1b64 100644
--- a/Sources/LIBSTELL_minimal/mpi_inc.f
+++ b/Sources/LIBSTELL_minimal/mpi_inc.f
@@ -10,14 +10,14 @@

MODULE mpi_inc
USE mpi_params, ONLY: MPI_COMM_PARVMEC
-#if defined (MPI_OPT)
- USE mpi
-#endif
+!#if defined (MPI_OPT)
+! USE mpi
+!#endif

IMPLICIT NONE

-!#if defined(MPI_OPT)
-! INCLUDE 'mpif.h'
-!#endif
+#if defined(MPI_OPT)
+ INCLUDE 'mpif.h'
+#endif

END MODULE

0 comments on commit 4cb8a36

Please sign in to comment.