Skip to content

Commit b40dcde

Browse files
committed
minor changes+some cleanup
1 parent cb2d5ef commit b40dcde

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

src/p_sparse_matrix.jl

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,12 +1528,11 @@ end
15281528
# New assemble
15291529
####################
15301530

1531-
function psparse_assemble_impl(
1532-
A,
1533-
::Type{T},
1534-
rows;
1535-
reuse=Val(false),
1536-
assembly_neighbors_options_cols=(;)) where T<:AbstractSplitMatrix
1531+
function psparse_assemble_impl(A::PSparseMatrix{V,B,C,D,Tv} where {V,B,C,D},
1532+
::Type{T},
1533+
rows;
1534+
reuse=Val(false),
1535+
assembly_neighbors_options_cols=(;)) where {T<:AbstractSplitMatrix, Tv}
15371536

15381537
function setup_cache_snd(A,parts_snd,rows_sa,cols_sa)
15391538
A_ghost_own = A.blocks.ghost_own
@@ -1554,7 +1553,6 @@ function psparse_assemble_impl(
15541553
ptrs[owner_to_p[owner]+1] += 1
15551554
end
15561555
length_to_ptrs!(ptrs)
1557-
Tv = eltype(A_ghost_own)
15581556
ndata = ptrs[end]-1
15591557
I_snd_data = zeros(Int,ndata)
15601558
J_snd_data = zeros(Int,ndata)
@@ -1642,7 +1640,6 @@ function psparse_assemble_impl(
16421640
n_ghost_rows = ghost_length(rows_fa)
16431641
n_ghost_cols = ghost_length(cols_fa)
16441642
Ti = indextype(A.blocks.own_own)
1645-
Tv = eltype(A.blocks.own_own)
16461643
own_own = compresscoo(TA,own_own_triplet...,n_own_rows,n_own_cols)
16471644
own_ghost = compresscoo(TA,own_ghost_triplet...,n_own_rows,n_ghost_cols)
16481645
ghost_own = compresscoo(TA,Ti[],Ti[],Tv[],n_ghost_rows,n_own_cols)
@@ -1652,12 +1649,12 @@ function psparse_assemble_impl(
16521649
nnz_own_own = nnz(own_own)
16531650
k_own_sa = precompute_nzindex(own_own,own_own_triplet[1:2]...)
16541651
k_ghost_sa = precompute_nzindex(own_ghost,own_ghost_triplet[1:2]...)
1655-
for p in 1:length(I_rcv_own)
1652+
for p in eachindex(I_rcv_own)
16561653
i = I_rcv_own[p]
16571654
j = J_rcv_own[p]
16581655
k_rcv_own[p] = nzindex(own_own,i,j)
16591656
end
1660-
for p in 1:length(I_rcv_ghost)
1657+
for p in eachindex(I_rcv_ghost)
16611658
i = I_rcv_ghost[p]
16621659
j = J_rcv_ghost[p]
16631660
k_rcv_ghost[p] = nzindex(own_ghost,i,j) + nnz_own_own
@@ -1687,7 +1684,7 @@ function psparse_assemble_impl(
16871684
t_I = exchange(I_snd,graph)
16881685
t_J = exchange(J_snd,graph)
16891686
t_V = exchange(V_snd,graph)
1690-
@fake_async begin
1687+
@sync begin
16911688
I_rcv = fetch(t_I)
16921689
J_rcv = fetch(t_J)
16931690
V_rcv = fetch(t_V)
@@ -1794,14 +1791,13 @@ end
17941791

17951792
# New consistent
17961793
####################
1797-
function psparse_consistent_impl(
1798-
A,
1799-
::Type{T},
1800-
rows_co;
1801-
reuse=Val(false)) where T<:AbstractSplitMatrix
1794+
function psparse_consistent_impl(A::PSparseMatrix{V,B,C,D,Tv} where {V,B,C,D},
1795+
::Type{T},
1796+
rows_co;
1797+
reuse=Val(false)) where {T<:AbstractSplitMatrix, Tv}
18021798

18031799
function consistent_setup_snd(A,parts_snd,lids_snd,rows_co,cols_fa)
1804-
own_to_local_row::UnitRange{Int32} = own_to_local(rows_co)
1800+
own_to_local_row = own_to_local(rows_co)
18051801
own_to_global_row = own_to_global(rows_co)
18061802
own_to_global_col = own_to_global(cols_fa)
18071803
ghost_to_global_col = ghost_to_global(cols_fa)
@@ -1829,7 +1825,6 @@ function psparse_consistent_impl(
18291825
li_to_ps = JaggedArray(li_to_ps_data,li_to_ps_ptrs)
18301826
ptrs = zeros(Int32,length(parts_snd)+1)
18311827
for (i,j,v) in nziterator(A.blocks.own_own)
1832-
# @show(typeof(own_to_local_row))
18331828
li = own_to_local_row[i]
18341829
for li_ptr in jagged_range(li_to_ps,li)
18351830
p = li_to_ps.data[li_ptr]
@@ -1846,7 +1841,6 @@ function psparse_consistent_impl(
18461841
end
18471842
length_to_ptrs!(ptrs)
18481843
ndata = ptrs[end]-1
1849-
Tv = eltype(A)
18501844
I_snd = JaggedArray(zeros(Int,ndata),ptrs)
18511845
J_snd = JaggedArray(zeros(Int,ndata),ptrs)
18521846
V_snd = JaggedArray(zeros(Tv,ndata),ptrs)
@@ -1892,7 +1886,7 @@ function psparse_consistent_impl(
18921886
J_rcv_data = cache_rcv.J_rcv.data
18931887
V_rcv_data = cache_rcv.V_rcv.data
18941888
global_to_own_col = global_to_own(cols_co)
1895-
global_to_ghost_col = global_to_ghost(cols_co)
1889+
# global_to_ghost_col = global_to_ghost(cols_co)
18961890
is_own_condition = k -> global_to_own_col[k]!=0
18971891
is_own = is_own_condition.(J_rcv_data)
18981892
I_rcv_own = I_rcv_data[is_own]
@@ -1937,7 +1931,6 @@ function psparse_consistent_impl(
19371931
rows_co;
19381932
reuse=Val(false)) where T<:AbstractSplitMatrix
19391933
@assert matching_own_indices(axes(A,1),PRange(rows_co))
1940-
rows_fa = partition(axes(A,1))
19411934
cols_fa = partition(axes(A,2))
19421935
# snd and rcv are swapped on purpose
19431936
parts_rcv,parts_snd = assembly_neighbors(rows_co)
@@ -1950,7 +1943,7 @@ function psparse_consistent_impl(
19501943
t_I = exchange(I_snd,graph)
19511944
t_J = exchange(J_snd,graph)
19521945
t_V = exchange(V_snd,graph)
1953-
@fake_async begin
1946+
@sync begin
19541947
I_rcv = fetch(t_I)
19551948
J_rcv = fetch(t_J)
19561949
V_rcv = fetch(t_V)
@@ -1967,11 +1960,8 @@ function psparse_consistent_impl(
19671960
end
19681961
end
19691962
end
1970-
19711963
_psparse_consistent_impl(A,T,rows_co;reuse)
19721964
end
1973-
1974-
19751965
# End new consistent
19761966
####################
19771967

0 commit comments

Comments
 (0)