Skip to content

Commit

Permalink
Merge pull request #63 from JuliaGeodynamics/bk-mpi-changes
Browse files Browse the repository at this point in the history
Update calling of MPI
  • Loading branch information
boriskaus authored Sep 18, 2024
2 parents 5349e35 + e2afb90 commit 1eb6af1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
18 changes: 3 additions & 15 deletions src/Run.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
module Run
# module to run LaMEM_jll
using LaMEM_jll,Glob
using LaMEM_jll,Glob, MPI

export run_lamem, run_lamem_save_grid, mpiexec
export run_lamem, run_lamem_save_grid
export remove_popup_messages_mac, show_paths_LaMEM

include("run_lamem.jl")
include("run_lamem_save_grid.jl")
include("utils_Run.jl")

# load the correct MPI
const mpiexec = if isdefined(LaMEM_jll,:MPICH_jll)
LaMEM_jll.MPICH_jll.mpiexec()
elseif isdefined(LaMEM_jll,:MicrosoftMPI_jll)
LaMEM_jll.MicrosoftMPI_jll.mpiexec()
elseif isdefined(LaMEM_jll,:OpenMPI_jll)
LaMEM_jll.OpenMPI_jll.mpiexec()
elseif isdefined(LaMEM_jll,:MPItrampoline_jll)
LaMEM_jll.MPItrampoline_jll.mpiexec()
else
println("Be careful! No MPI library detected; parallel runs won't work")
nothing
end
const mpiexec = MPI.mpiexec()


end
5 changes: 2 additions & 3 deletions src/run_lamem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function deactivate_multithreading(cmd::Cmd)
# does not work well. Switch that off:
cmd = addenv(cmd,"OMP_NUM_THREADS"=>1)
cmd = addenv(cmd,"VECLIB_MAXIMUM_THREADS"=>1)

return cmd
end

Expand Down Expand Up @@ -57,10 +56,10 @@ function run_lamem(ParamFile::String, cores::Int64=1, args::String=""; wait=true
run(cmd, wait=wait);
else
# set correct environment
mpirun = setenv(mpiexec, LaMEM_jll.JLLWrappers.JLLWrappers.LIBPATH_env=>LaMEM_jll.LIBPATH[]);
mpirun = setenv(mpiexec, LaMEM_jll.LaMEM().env);

# create command-line object
cmd = `$(mpirun) -n $cores_compute $(LaMEM_jll.LaMEM_path) -ParamFile $(ParamFile) $args`
cmd = `$(mpirun) -n $cores_compute $(LaMEM_jll.LaMEM().exec) -ParamFile $(ParamFile) $args`
if deactivate_multithreads
cmd = deactivate_multithreading(cmd)
end
Expand Down

0 comments on commit 1eb6af1

Please sign in to comment.