Skip to content

Commit ebf78d1

Browse files
committed
More changes to allow zero or negative indices in psparse
1 parent ac69c40 commit ebf78d1

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/p_range.jl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ function filter_ghost(indices,gids,owners)
208208
n_new_ghost = 0
209209
global_to_ghost_indices = global_to_ghost(indices)
210210
for (global_i,owner) in zip(gids,owners)
211+
if global_i < 1
212+
continue
213+
end
211214
if owner != part_owner
212215
ghost_i = global_to_ghost_indices[global_i]
213216
if ghost_i == 0 && !(global_i in set)
@@ -221,6 +224,9 @@ function filter_ghost(indices,gids,owners)
221224
new_ghost_i = 0
222225
set = Set{Int}()
223226
for (global_i,owner) in zip(gids,owners)
227+
if global_i < 1
228+
continue
229+
end
224230
if owner != part_owner
225231
ghost_i = global_to_ghost_indices[global_i]
226232
if ghost_i == 0 && !(global_i in set)
@@ -293,6 +299,9 @@ function map_x_to_y!(x_to_y,I,indices)
293299
local_to_global_indices = x_to_y(indices)
294300
for k in 1:length(I)
295301
Ik = I[k]
302+
if Ik < 1
303+
continue
304+
end
296305
I[k] = local_to_global_indices[Ik]
297306
end
298307
I
@@ -1251,9 +1260,20 @@ function find_owner(indices,global_ids,::Type{<:OwnAndGhostIndices{T}}) where T
12511260
if T == Nothing
12521261
error("Not enough data to perform this operation without communciation")
12531262
end
1254-
map(indices,global_ids) do indices,global_ids
1255-
indices.global_to_owner[global_ids]
1263+
map(global_ids,indices) do global_ids, indices
1264+
map_global_to_owner(global_ids,indices.global_to_owner)
1265+
end
1266+
end
1267+
1268+
function map_global_to_owner(I,global_to_owner)
1269+
Ti = eltype(global_to_owner)
1270+
function map_g_to_o(g)
1271+
if g<1
1272+
return zero(Ti)
1273+
end
1274+
global_to_owner[g]
12561275
end
1276+
map_g_to_o.(I)
12571277
end
12581278

12591279
part_id(a::OwnAndGhostIndices) = a.own.owner
@@ -1567,7 +1587,7 @@ function find_owner(indices,global_ids,::Type{<:LocalIndicesWithConstantBlockSiz
15671587
start
15681588
end
15691589
global_to_owner = BlockPartitionGlobalToOwner(start)
1570-
global_to_owner[global_ids]
1590+
map_global_to_owner(global_ids,global_to_owner)
15711591
end
15721592
end
15731593

@@ -1600,7 +1620,7 @@ function find_owner(indices,global_ids,::Type{<:LocalIndicesWithVariableBlockSiz
16001620
start = vcat(initial,[n+1])
16011621
end
16021622
global_to_owner = BlockPartitionGlobalToOwner(start)
1603-
global_to_owner[global_ids]
1623+
map_global_to_owner(global_ids,global_to_owner)
16041624
end
16051625
end
16061626

src/p_sparse_matrix.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,18 +1301,6 @@ function psparse_assemble_impl(
13011301
k_rcv = JaggedArray(k_rcv_data,I_rcv.ptrs)
13021302
(;I_rcv,J_rcv,V_rcv,k_rcv,parts_rcv)
13031303
end
1304-
function setup_touched_col_ids(A,cache_rcv,cols_sa)
1305-
J_rcv_data = cache_rcv.J_rcv.data
1306-
l1 = nnz(A.own_ghost)
1307-
l2 = length(J_rcv_data)
1308-
J_aux = zeros(Int,l1+l2)
1309-
ghost_to_global_col = ghost_to_global(cols_sa)
1310-
for (p,(_,j,_)) in enumerate(nziterator(A.own_ghost))
1311-
J_own_ghost[p] = ghost_to_global_col[j]
1312-
end
1313-
J_aux[l1.+(1:l2)] = J_rcv_data
1314-
J_aux
1315-
end
13161304
function setup_own_triplets(A,cache_rcv,rows_sa,cols_sa)
13171305
nz_own_own = findnz(A.blocks.own_own)
13181306
nz_own_ghost = findnz(A.blocks.own_ghost)

0 commit comments

Comments
 (0)