Skip to content

Commit

Permalink
More changes to allow zero or negative indices in psparse
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Feb 9, 2024
1 parent ac69c40 commit ebf78d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
28 changes: 24 additions & 4 deletions src/p_range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ function filter_ghost(indices,gids,owners)
n_new_ghost = 0
global_to_ghost_indices = global_to_ghost(indices)
for (global_i,owner) in zip(gids,owners)
if global_i < 1
continue
end
if owner != part_owner
ghost_i = global_to_ghost_indices[global_i]
if ghost_i == 0 && !(global_i in set)
Expand All @@ -221,6 +224,9 @@ function filter_ghost(indices,gids,owners)
new_ghost_i = 0
set = Set{Int}()
for (global_i,owner) in zip(gids,owners)
if global_i < 1
continue
end
if owner != part_owner
ghost_i = global_to_ghost_indices[global_i]
if ghost_i == 0 && !(global_i in set)
Expand Down Expand Up @@ -293,6 +299,9 @@ function map_x_to_y!(x_to_y,I,indices)
local_to_global_indices = x_to_y(indices)
for k in 1:length(I)
Ik = I[k]
if Ik < 1
continue
end
I[k] = local_to_global_indices[Ik]
end
I
Expand Down Expand Up @@ -1251,9 +1260,20 @@ function find_owner(indices,global_ids,::Type{<:OwnAndGhostIndices{T}}) where T
if T == Nothing
error("Not enough data to perform this operation without communciation")
end
map(indices,global_ids) do indices,global_ids
indices.global_to_owner[global_ids]
map(global_ids,indices) do global_ids, indices
map_global_to_owner(global_ids,indices.global_to_owner)
end
end

function map_global_to_owner(I,global_to_owner)
Ti = eltype(global_to_owner)
function map_g_to_o(g)
if g<1
return zero(Ti)
end
global_to_owner[g]
end
map_g_to_o.(I)
end

part_id(a::OwnAndGhostIndices) = a.own.owner
Expand Down Expand Up @@ -1567,7 +1587,7 @@ function find_owner(indices,global_ids,::Type{<:LocalIndicesWithConstantBlockSiz
start
end
global_to_owner = BlockPartitionGlobalToOwner(start)
global_to_owner[global_ids]
map_global_to_owner(global_ids,global_to_owner)
end
end

Expand Down Expand Up @@ -1600,7 +1620,7 @@ function find_owner(indices,global_ids,::Type{<:LocalIndicesWithVariableBlockSiz
start = vcat(initial,[n+1])
end
global_to_owner = BlockPartitionGlobalToOwner(start)
global_to_owner[global_ids]
map_global_to_owner(global_ids,global_to_owner)
end
end

Expand Down
12 changes: 0 additions & 12 deletions src/p_sparse_matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1301,18 +1301,6 @@ function psparse_assemble_impl(
k_rcv = JaggedArray(k_rcv_data,I_rcv.ptrs)
(;I_rcv,J_rcv,V_rcv,k_rcv,parts_rcv)
end
function setup_touched_col_ids(A,cache_rcv,cols_sa)
J_rcv_data = cache_rcv.J_rcv.data
l1 = nnz(A.own_ghost)
l2 = length(J_rcv_data)
J_aux = zeros(Int,l1+l2)
ghost_to_global_col = ghost_to_global(cols_sa)
for (p,(_,j,_)) in enumerate(nziterator(A.own_ghost))
J_own_ghost[p] = ghost_to_global_col[j]
end
J_aux[l1.+(1:l2)] = J_rcv_data
J_aux
end
function setup_own_triplets(A,cache_rcv,rows_sa,cols_sa)
nz_own_own = findnz(A.blocks.own_own)
nz_own_ghost = findnz(A.blocks.own_ghost)
Expand Down

0 comments on commit ebf78d1

Please sign in to comment.