Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MPI platform tag and have LAMMPS use it #4540

Merged
merged 6 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions L/LAMMPS/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg
using Base.BinaryPlatforms
const YGGDRASIL_DIR = "../.."
include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl"))

name = "LAMMPS"
version = v"2.2.0" # Equivalent to 29Sep2021_update2
version = v"2.2.1" # Equivalent to 29Sep2021_update2

# Version table
# 1.0.0 -> https://github.com/lammps/lammps/releases/tag/stable_29Oct2020
Expand Down Expand Up @@ -44,6 +47,14 @@ if [[ "${target}" == *mingw* ]]; then
fi
"""

augment_platform_block = """
using Base.BinaryPlatforms
$(MPI.augment)
function augment_platform!(platform::Platform)
augment_mpi!(platform)
end
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
# platforms = supported_platforms(; experimental=true)
Expand All @@ -69,9 +80,12 @@ products = [
# Dependencies that must be installed before this package can be built
dependencies = [
Dependency(PackageSpec(name="CompilerSupportLibraries_jll")),
Dependency(PackageSpec(name="MPItrampoline_jll"); compat="2", platforms=filter(!Sys.iswindows, platforms)),
Dependency(PackageSpec(name="MicrosoftMPI_jll"); platforms=filter(Sys.iswindows, platforms)),
]

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", preferred_gcc_version=v"8")
build_tarballs(ARGS, name, version, sources, script, all_platforms, products, dependencies;
julia_compat="1.6", preferred_gcc_version=v"8",
augment_platform_block, lazy_artifacts=true) # Change lazy_artifacts after https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/1179
59 changes: 59 additions & 0 deletions platforms/mpi.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module MPI

const tag_name = "mpi"

const augment = raw"""
# Can't use Preferences since we might be running this very early with a non-existing Manifest
MPIPreferences_UUID = Base.UUID("3da0fdf6-3ccc-4f1b-acd9-58baa6c99267")
const preferences = Base.get_preferences(MPIPreferences_UUID)

# Keep logic in sync with MPIPreferences.jl
const binary = get(preferences, "binary", Sys.iswindows() ? "MicrosoftMPI_jll" : "MPICH_jll")

const abi = if binary == "system"
get(preferences, "abi")
elseif binary == "MicrosoftMPI_jll"
"MicrosoftMPI"
elseif binary == "MPICH_jll"
"MPICH"
elseif binary == "OpenMPI_jll"
"OpenMPI"
elseif binary == "MPItrampoline_jll"
"MPIwrapper"
else
error("Unknown binary: $binary")
end

function augment_mpi!(platform)
if !haskey(platform, "mpi")
platform["mpi"] = abi
end
return platform
end
"""

using BinaryBuilder, Pkg
using Base.BinaryPlatforms

mpi_abis = (
("MPICH", PackageSpec(name="MPICH_jll"), "", !Sys.iswindows) ,
("OpenMPI", PackageSpec(name="OpenMPI_jll"), "", !Sys.iswindows),
("MicrosoftMPI", PackageSpec(name="MicrosoftMPI_jll"), "", Sys.iswindows),
("MPIwrapper", PackageSpec(name="MPItrampoline_jll"), "3", !Sys.iswindows)
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
)

function augment_platforms(platforms)
all_platforms = AbstractPlatform[]
dependencies = []
for (abi, pkg, compat, f) in mpi_abis
pkg_platforms = deepcopy(filter(f, platforms))
foreach(pkg_platforms) do p
p[tag_name] = abi
end
append!(all_platforms, pkg_platforms)
push!(dependencies, Dependency(pkg; compat, platforms=pkg_platforms))
end
return all_platforms, dependencies
end

end