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

In machine_setup.sh on macOS, prompt for MPI library path #201

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all 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
41 changes: 38 additions & 3 deletions machines/shared/add_dependencies_to_project.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Pkg, TOML

if abspath(PROGRAM_FILE) == @__FILE__
prompt_for_hdf5 = true
prompt_for_lib_paths = true
repo_dir = dirname(Pkg.project().path)
project_dir = repo_dir
local_preferences_filename = joinpath(repo_dir, "LocalPreferences.toml")
local_preferences = TOML.parsefile(local_preferences_filename)
mk_preferences = local_preferences["moment_kinetics"]
else
prompt_for_hdf5 = false
prompt_for_lib_paths = false
end

machine = mk_preferences["machine"]
Expand Down Expand Up @@ -90,6 +90,41 @@ using MPIPreferences
if "mpi_library_names" ∈ keys(machine_settings) || "mpiexec" ∈ keys(machine_settings)
MPIPreferences.use_system_binary(library_names=machine_settings["mpi_library_names"],
mpiexec=machine_settings["mpiexec"])
elseif Sys.isapple()
# On macOS, MPIPreferences.use_system_binary() does not automatically find the MPI
# library when MPI was installed with homebrew, so prompt the user for the library
# path instead.
# ?? Could we attempt to auto-detect the MPI library before prompting the user??
if prompt_for_lib_paths
try
# See if MPIPreferences can auto-detect the system MPI library path
MPIPreferences.use_system_binary()
catch
println("Failed to auto-detect path of MPI library...")
default_mpi_library_path = get(mk_preferences, "mpi_library_path", "")
mpi_library_path = get_input_with_path_completion(
"\nEnter the full path to your MPI library (e.g. something like "
* "'libmpi.dylib'): [$default_mpi_library_path]")
if mpi_library_path == ""
mpi_library_path = default_mpi_library_path
end

MPIPreferences.use_system_binary(library_names=mpi_library_path)
end

# Just got the value for the setting, now write it to LocalPreferences.toml
mk_preferences["mpi_library_path"] = mpi_library_path
open(local_preferences_filename, "w") do io
TOML.print(io, local_preferences, sorted=true)
end
# Re-read local_preferences file, so we can modify it again below, keeping the
# changes here
local_preferences = TOML.parsefile(local_preferences_filename)
mk_preferences = local_preferences["moment_kinetics"]
else
mpi_library_path = mk_preferences["mpi_library_path"]
MPIPreferences.use_system_binary(library_names=mpi_library_path)
end
else
# If settings for MPI library are not given explicitly, then auto-detection by
# MPIPreferences.use_system_binary() should work.
Expand Down Expand Up @@ -122,7 +157,7 @@ elseif machine_settings["hdf5_library_setting"] == "prompt"
hdf5_dir = local_hdf5_install_dir
hdf5_lib = joinpath(local_hdf5_install_dir, "libhdf5.so")
hdf5_lib_hl = joinpath(local_hdf5_install_dir, "libhdf5_hl.so")
elseif !prompt_for_hdf5
elseif !prompt_for_lib_paths
hdf5_dir = mk_preferences["hdf5_dir"]
if hdf5_dir != "default"
hdf5_lib = joinpath(hdf5_dir, "libhdf5.so")
Expand Down
Loading