Skip to content

Adding some diagnostic context and error message #80

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 19 additions & 7 deletions src/Interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,26 @@ function oids_are_equal(a::AbstractIndexSet,b::AbstractIndexSet)
view(a.lid_to_gid,a.oid_to_lid) == view(b.lid_to_gid,b.oid_to_lid)
end

function mismatched_oids(a::AbstractIndexSet,b::AbstractIndexSet)
symdiff(view(a.lid_to_gid,a.oid_to_lid), view(b.lid_to_gid,b.oid_to_lid))
end

function hids_are_equal(a::AbstractIndexSet,b::AbstractIndexSet)
view(a.lid_to_gid,a.hid_to_lid) == view(b.lid_to_gid,b.hid_to_lid)
end

function mismatched_hids(a::AbstractIndexSet,b::AbstractIndexSet)
symdiff(view(a.lid_to_gid,a.hid_to_lid), view(b.lid_to_gid,b.hid_to_lid))
end

function lids_are_equal(a::AbstractIndexSet,b::AbstractIndexSet)
a.lid_to_gid == b.lid_to_gid
end

function mismatched_lids(a::AbstractIndexSet,b::AbstractIndexSet)
symdiff(a.lid_to_gid, b.lid_to_gid)
end

function find_lid_map(a::AbstractIndexSet,b::AbstractIndexSet)
alid_to_blid = fill(Int32(-1),num_lids(a))
for blid in 1:num_lids(b)
Expand Down Expand Up @@ -1680,7 +1692,7 @@ function Base.similar(
end

function Base.copy!(a::PVector,b::PVector)
@check oids_are_equal(a.rows,b.rows)
@check oids_are_equal(a.rows,b.rows) "The entries of a and b must have the same owner | mismatched $(mismatched_oids(a.rows,b.rows))"
if a.rows.partition === b.rows.partition
map_parts(copy!,a.values,b.values)
else
Expand All @@ -1690,7 +1702,7 @@ function Base.copy!(a::PVector,b::PVector)
end

function Base.copyto!(a::PVector,b::PVector)
@check oids_are_equal(a.rows,b.rows)
@check oids_are_equal(a.rows,b.rows) "The entries of a and b must have the same owner | mismatched $(mismatched_oids(a.rows,b.rows))"
if a.rows.partition === b.rows.partition
map_parts(copyto!,a.values,b.values)
else
Expand Down Expand Up @@ -1757,7 +1769,7 @@ function Base.broadcasted(
args::Union{PVector,DistributedBroadcasted}...)

a1 = first(args)
@check all(ai->oids_are_equal(ai.rows,a1.rows),args)
@check all(ai->oids_are_equal(ai.rows,a1.rows),args) "Trying to broadcast on vectors with different owners"
owned_values_in = map(arg->arg.owned_values,args)
owned_values = map_parts((largs...)->Base.broadcasted(f,largs...),owned_values_in...)
if all(ai->ai.rows===a1.rows,args) && !any(ai->ai.ghost_values===nothing,args)
Expand Down Expand Up @@ -2314,9 +2326,9 @@ function LinearAlgebra.mul!(
α::Number,
β::Number)

@check oids_are_equal(c.rows,a.rows)
@check oids_are_equal(a.cols,b.rows)
@check hids_are_equal(a.cols,b.rows)
@check oids_are_equal(c.rows,a.rows) "Ownership of the output vector must match the matrix's row's ownership | mismatched $(mismatched_oids(c.rows,a.rows))"
@check oids_are_equal(a.cols,b.rows) "Ownership of the input vector must match the matrix's column's ownership | mismatched $(mismatched_oids(a.cols,b.rows))"
@check hids_are_equal(a.cols,b.rows) "Ghost layer of the input vector must match the matrix's row's ownership | mismatched $(mismatched_hids(a.cols,b.rows))"

# Start the exchange
t = async_exchange!(b)
Expand Down Expand Up @@ -2423,7 +2435,7 @@ function matrix_exchanger(values,row_exchanger,row_lids,col_lids)
li = row_lids.gid_to_lid[gi]
lj = col_lids.gid_to_lid[gj]
k = nzindex(values,li,lj)
@check k > 0 "The sparsity pattern of the ghost layer is inconsistent"
@check k > 0 "The sparsity pattern of the ghost layer is inconsistent on part $part | local index ($li,$lj) | global index ($gi, $gj)"
k_snd_data[p] = k
end
k_snd = Table(k_snd_data,ptrs)
Expand Down
2 changes: 1 addition & 1 deletion src/SequentialBackend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function async_exchange!(
j = first(findall(k->k==part_rcv,parts_snd.parts[part_snd]))
ptrs_rcv = data_rcv.parts[part_rcv].ptrs
ptrs_snd = data_snd.parts[part_snd].ptrs
@check ptrs_rcv[i+1]-ptrs_rcv[i] == ptrs_snd[j+1]-ptrs_snd[j]
@check ptrs_rcv[i+1]-ptrs_rcv[i] == ptrs_snd[j+1]-ptrs_snd[j] "Mismatch between received and send data. Expected $(ptrs_snd[j+1]-ptrs_snd[j]) but got $(ptrs_rcv[i+1]-ptrs_rcv[i])"
for p in 1:(ptrs_rcv[i+1]-ptrs_rcv[i])
p_rcv = p+ptrs_rcv[i]-1
p_snd = p+ptrs_snd[j]-1
Expand Down