Skip to content

Commit ef77eea

Browse files
committed
Fixing PVector with split_format
1 parent 48ca58d commit ef77eea

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/p_vector.jl

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ struct SplitVectorAssemblyCache{A,B,C,D}
527527
buffer_snd::C # NB
528528
buffer_rcv::C
529529
exchange_setup::D
530+
reversed::Bool
530531
end
531532
function Base.reverse(a::SplitVectorAssemblyCache)
532533
SplitVectorAssemblyCache(
@@ -537,6 +538,7 @@ function Base.reverse(a::SplitVectorAssemblyCache)
537538
a.buffer_rcv,
538539
a.buffer_snd,
539540
a.exchange_setup,
541+
!(a.reversed),
540542
)
541543
end
542544
function copy_cache(a::SplitVectorAssemblyCache)
@@ -549,23 +551,29 @@ function copy_cache(a::SplitVectorAssemblyCache)
549551
a.own_indices_rcv,
550552
buffer_snd,
551553
buffer_rcv,
552-
a.exchange_setup
554+
a.exchange_setup,
555+
a.reversed,
553556
)
554557
end
555558

556559
function p_vector_cache_impl(::Type{<:SplitVector},vector_partition,index_partition)
557560
neighbors_snd,neighbors_rcv= assembly_neighbors(index_partition)
558561
indices_snd,indices_rcv = assembly_local_indices(index_partition,neighbors_snd,neighbors_rcv)
559-
map(indices_snd,indices_rcv,index_partition) do ids_snd,ids_rcv,myids
562+
ghost_indices_snd = map(indices_snd) do ids
563+
JaggedArray(copy(ids.data),ids.ptrs)
564+
end
565+
own_indices_rcv = map(indices_rcv) do ids
566+
JaggedArray(copy(ids.data),ids.ptrs)
567+
end
568+
foreach(ghost_indices_snd,own_indices_rcv,index_partition) do ids_snd,ids_rcv,myids
560569
map_local_to_ghost!(ids_snd.data,myids)
561570
map_local_to_own!(ids_rcv.data,myids)
562571
end
563-
ghost_indices_snd = indices_snd
564-
own_indices_rcv = indices_rcv
565-
buffers_snd,buffers_rcv = map(assembly_buffers,vector_partition,indices_snd,indices_rcv) |> tuple_of_arrays
572+
buffers_snd,buffers_rcv = map(assembly_buffers,vector_partition,ghost_indices_snd,own_indices_rcv) |> tuple_of_arrays
566573
graph = ExchangeGraph(neighbors_snd,neighbors_rcv)
567574
exchange_setup = setup_exchange(buffers_rcv,buffers_snd,graph)
568-
SplitVectorAssemblyCache(neighbors_snd,neighbors_rcv,ghost_indices_snd,own_indices_rcv,buffers_snd,buffers_rcv,exchange_setup)
575+
reversed = false
576+
SplitVectorAssemblyCache(neighbors_snd,neighbors_rcv,ghost_indices_snd,own_indices_rcv,buffers_snd,buffers_rcv,exchange_setup,reversed)
569577
end
570578

571579
function p_vector_cache_impl(::Type{<:SplitVector{<:JaggedArray}},vector_partition,index_partition)
@@ -610,6 +618,7 @@ function assemble_impl!(f,vector_partition,cache::JaggedArrayAssemblyCache)
610618
end
611619

612620
function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
621+
reversed = cache.reversed
613622
ghost_indices_snd=cache.ghost_indices_snd
614623
own_indices_rcv=cache.own_indices_rcv
615624
neighbors_snd=cache.neighbors_snd
@@ -618,7 +627,11 @@ function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
618627
buffer_rcv=cache.buffer_rcv
619628
exchange_setup=cache.exchange_setup
620629
foreach(vector_partition,ghost_indices_snd,buffer_snd) do values,ghost_indices_snd,buffer_snd
621-
ghost_vals = values.blocks.ghost
630+
if reversed
631+
ghost_vals = values.blocks.own
632+
else
633+
ghost_vals = values.blocks.ghost
634+
end
622635
for (p,hid) in enumerate(ghost_indices_snd.data)
623636
buffer_snd.data[p] = ghost_vals[hid]
624637
end
@@ -629,7 +642,11 @@ function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
629642
@fake_async begin
630643
wait(t)
631644
foreach(vector_partition,own_indices_rcv,buffer_rcv) do values,own_indices_rcv,buffer_rcv
632-
own_vals = values.blocks.own
645+
if reversed
646+
own_vals = values.blocks.ghost
647+
else
648+
own_vals = values.blocks.own
649+
end
633650
for (p,oid) in enumerate(own_indices_rcv.data)
634651
own_vals[oid] = f(own_vals[oid],buffer_rcv.data[p])
635652
end

0 commit comments

Comments
 (0)