Skip to content

Commit

Permalink
change how we call MPI
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskaus committed Oct 8, 2024
1 parent 1eb6af1 commit 7ca342a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
19 changes: 18 additions & 1 deletion src/Run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ include("run_lamem.jl")
include("run_lamem_save_grid.jl")
include("utils_Run.jl")

const mpiexec = MPI.mpiexec()
#setup MPI
if isdefined(LaMEM_jll,:MPICH_jll)
const mpiexec = LaMEM_jll.MPICH_jll.mpiexec()
const MPI_LIBPATH = LaMEM_jll.MPICH_jll.LIBPATH
elseif isdefined(LaMEM_jll,:MicrosoftMPI_jll)
const mpiexec = LaMEM_jll.MicrosoftMPI_jll.mpiexec()
const MPI_LIBPATH = LaMEM_jll.MicrosoftMPI_jll.LIBPATH
elseif isdefined(LaMEM_jll,:OpenMPI_jll)
const mpiexec = LaMEM_jll.OpenMPI_jll.mpiexec()
const MPI_LIBPATH = LaMEM_jll.OpenMPI_jll.LIBPATH
elseif isdefined(LaMEM_jll,:MPItrampoline_jll)
const mpiexec = LaMEM_jll.MPItrampoline_jll.mpiexec()
const MPI_LIBPATH = LaMEM_jll.MPItrampoline_jll.LIBPATH
else
println("Be careful! No MPI library detected; parallel runs won't work")
const mpiexec = nothing
const MPI_LIBPATH = Ref{String}("")
end


end
13 changes: 12 additions & 1 deletion src/run_lamem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ function deactivate_multithreading(cmd::Cmd)
return cmd
end

# Shamelessly stolen from the tests of LBT
if Sys.iswindows()
pathsep = ';'
elseif Sys.isapple()
pathsep = ':'
else
pathsep = ':'
end

"""
run_lamem(ParamFile::String, cores::Int64=1, args:String=""; wait=true, deactivate_multithreads=true)
Expand Down Expand Up @@ -56,7 +64,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.LaMEM().env);
#mpirun = setenv(mpiexec, LaMEM_jll.LaMEM().env);
key = LaMEM_jll.JLLWrappers.JLLWrappers.LIBPATH_env
mpirun = addenv(mpiexec, key=>join((LaMEM_jll.LIBPATH[], MPI_LIBPATH[]), pathsep));


# create command-line object
cmd = `$(mpirun) -n $cores_compute $(LaMEM_jll.LaMEM().exec) -ParamFile $(ParamFile) $args`
Expand Down
4 changes: 2 additions & 2 deletions test/test_julia_setups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using GeophysicalModelGenerator
model = Model(Grid(nel=(16,16,16), x=[-2,2], coord_y=[-1,1], coord_z=[-1,1]),
Time(nstep_max=2, dt=1, dt_max=10),
Solver(SolverType="multigrid", MGLevels=2),
Output(out_dir="example_1"))
Output(out_dir="example_1", out_dev_stress=1))

# Specify material properties
matrix = Phase(ID=0,Name="matrix",eta=1e20,rho=3000)
Expand All @@ -27,7 +27,7 @@ using GeophysicalModelGenerator

# read last timestep
data,time = read_LaMEM_timestep(model,last=true);

@test sum(data.fields.velocity[3][:,:,:]) 0.10747005f0 rtol=1e-1 # check Vz
# @test sum(data.fields.velocity[3][:,:,:]) ≈ 0.10866211f0 # check Vz

Expand Down

0 comments on commit 7ca342a

Please sign in to comment.