Skip to content

Commit

Permalink
update to MPI.jl v0.19 (#749)
Browse files Browse the repository at this point in the history
See JuliaParallel/MPI.jl#485.
Closes #747; closes #748
  • Loading branch information
ranocha authored Aug 11, 2021
1 parent 77efe40 commit 071d014
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ForwardDiff = "0.10.18"
HDF5 = "0.14, 0.15"
LinearMaps = "2.7, 3.0"
LoopVectorization = "0.12.54"
MPI = "0.16, 0.17, 0.18"
MPI = "0.19"
Octavian = "0.3.1"
OffsetArrays = "1.3"
P4est = "0.2.2"
Expand Down
21 changes: 6 additions & 15 deletions src/auxiliary/mpi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ function init_mpi()
return nothing
end

if MPI.Initialized()
@assert MPI.Query_thread() >= MPI.THREAD_FUNNELED "MPI already initialized with insufficient threading support"
else
# MPI.THREAD_FUNNELED: Only main thread makes MPI calls
provided = MPI.Init_thread(MPI.THREAD_FUNNELED)
atexit(finalize_mpi) # register atexit hook
@assert provided >= MPI.THREAD_FUNNELED "MPI library with insufficient threading support"
end
# MPI.jl handles multiple calls to MPI.Init appropriately. Thus, we don't need
# any common checks of the form `if MPI.Initialized() ...`.
# threadlevel=MPI.THREAD_FUNNELED: Only main thread makes MPI calls
# finalize_atexit=true : MPI.jl will call call MPI.Finalize as `atexit` hook
provided = MPI.Init(threadlevel=MPI.THREAD_FUNNELED, finalize_atexit=true)
@assert provided >= MPI.THREAD_FUNNELED "MPI library with insufficient threading support"

# Initialize global MPI state
MPI_RANK[] = MPI.Comm_rank(MPI.COMM_WORLD)
Expand All @@ -37,13 +35,6 @@ function init_mpi()
end


function finalize_mpi()
if MPI.Initialized()
MPI.Finalize()
end
end


const MPI_INITIALIZED = Ref(false)
const MPI_RANK = Ref(-1)
const MPI_SIZE = Ref(-1)
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
Cassette = "0.3.5"
ForwardDiff = "0.10"
MPI = "0.16, 0.17, 0.18"
MPI = "0.19"
OrdinaryDiffEq = "5.60"
Plots = "1.16"

0 comments on commit 071d014

Please sign in to comment.