Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.5'
- '1.6'
os:
- ubuntu-latest
arch:
Expand Down
37 changes: 28 additions & 9 deletions src/MPIBackend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,32 @@ function prun(driver::Function,b::MPIBackend,nparts)
if !MPI.Initialized()
MPI.Init()
end
#try
part = get_part_ids(b,nparts)
driver(part)
#finally
# MPI.Finalize()
#end
try
part = get_part_ids(b,nparts)
driver(part)
catch e
@error "" exception=(e, catch_backtrace())
if MPI.Initialized() && !MPI.Finalized()
MPI.Abort(MPI.COMM_WORLD,0)
end
end
# We are NOT invoking MPI.Finalize() here because we rely on
# MPI.jl, which registers MPI.Finalize() in atexit()
end

# Useful to debug an MPI program when executed interactively
# on the REPL, i.e., with a single MPI task
function prun_debug(driver::Function,b::MPIBackend,nparts)
if !MPI.Initialized()
MPI.Init()
end
if (length(nparts) != 1)
MPI.Abort(MPI.COMM_WORLD,0)
end
part = get_part_ids(b,nparts)
driver(part)
# We are NOT invoking MPI.Finalize() here because we rely on
# MPI.jl, which registers MPI.Finalize() in atexit()
end

struct MPIData{T,N} <: AbstractPData{T,N}
Expand Down Expand Up @@ -156,7 +176,7 @@ function scatter(snd::MPIData)
MPI.Scatter!(MPI.UBuffer(snd.part,1),MPI.IN_PLACE,MAIN-1,snd.comm)
else
rcv = Vector{eltype(snd.part)}(undef,1)
MPI.Scatter!(nothing,rcv,MAIN-1,snd.comm)
MPI.Scatter!(nothing,rcv,MAIN-1,snd.comm)
part = rcv[1]
end
MPIData(part,snd.comm,snd.size)
Expand All @@ -171,7 +191,7 @@ function scatter(snd::MPIData{<:Table})
rcv = snd.part[MAIN]
else
rcv = eltype(snd.part)(undef,counts_scat.part)
MPI.Scatterv!(nothing,rcv,MAIN-1,snd.comm)
MPI.Scatterv!(nothing,rcv,MAIN-1,snd.comm)
end
MPIData(rcv,snd.comm,snd.size)
end
Expand Down Expand Up @@ -282,4 +302,3 @@ function async_exchange!(
t_out = MPIData(t2,comm,s)
t_out
end

2 changes: 1 addition & 1 deletion src/PartitionedArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import IterativeSolvers
import Distances

export AbstractBackend
export prun
export prun, prun_debug
export AbstractPData
export SequentialData
export MPIData
Expand Down
4 changes: 4 additions & 0 deletions src/SequentialBackend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function get_part_ids(b::SequentialBackend,nparts::Tuple)
SequentialData(parts)
end

function prun_debug(driver::Function,b::SequentialBackend,nparts)
prun(driver,b,nparts)
end

struct SequentialData{T,N} <: AbstractPData{T,N}
parts::Array{T,N}
end
Expand Down
6 changes: 6 additions & 0 deletions test/mpi/ExceptionTests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module ExceptionTests

include("mpiexec.jl")
run_mpi_driver(procs=8,file="driver_exception.jl")

end # module
3 changes: 3 additions & 0 deletions test/mpi/driver_exception.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include("../test_exception.jl")
nparts = (2,2,2)
prun(test_exception,mpi,nparts)
3 changes: 3 additions & 0 deletions test/mpi/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ using Test

@testset "PTimers" begin include("PTimersTests.jl") end

@testset "ExceptionTests" begin include("ExceptionTests.jl") end


end
4 changes: 2 additions & 2 deletions test/sequential/FDMTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module FDMTests
include("../test_fdm.jl")

nparts = (2,2,2)
prun(test_fdm,sequential,nparts)
prun_debug(test_fdm,sequential,nparts)

nparts = 4
prun(test_fdm,sequential,nparts)
prun_debug(test_fdm,sequential,nparts)

end # module
13 changes: 13 additions & 0 deletions test/test_exception.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

using PartitionedArrays

function throw_assert(parts)
nparts=length(parts)
map_parts(parts) do part
@assert rand(1:nparts) != part
end
end

function test_exception(parts)
throw_assert(parts)
end