@@ -507,17 +507,17 @@ end
507
507
508
508
function Algebra. create_from_nz (a:: DistributedAllocationCOO{<:SubAssembledRows} )
509
509
f (x) = nothing
510
- A, = _sa_create_from_nz_with_callback (f,f,a)
510
+ A, = _sa_create_from_nz_with_callback (f,f,a, nothing )
511
511
return A
512
512
end
513
513
514
514
function Algebra. create_from_nz (a:: ArrayBlock{<:DistributedAllocationCOO{<:SubAssembledRows}} )
515
515
f (x) = nothing
516
- A, = _sa_create_from_nz_with_callback (f,f,a)
516
+ A, = _sa_create_from_nz_with_callback (f,f,a, nothing )
517
517
return A
518
518
end
519
519
520
- function _sa_create_from_nz_with_callback (callback,async_callback,a)
520
+ function _sa_create_from_nz_with_callback (callback,async_callback,a,b )
521
521
# Recover some data
522
522
I,J,V = get_allocations (a)
523
523
test_dofs_gids_prange = get_test_gids (a)
@@ -538,7 +538,10 @@ function _sa_create_from_nz_with_callback(callback,async_callback,a)
538
538
# Here we can overlap computations
539
539
# This is a good place to overlap since
540
540
# sending the matrix rows is a lot of data
541
- b = callback (rows)
541
+ if ! isa (b,Nothing)
542
+ bprange= _setup_prange_from_pvector_allocation (b)
543
+ b = callback (bprange)
544
+ end
542
545
543
546
# Wait the transfer to finish
544
547
wait (t)
@@ -701,18 +704,18 @@ end
701
704
702
705
function Algebra. create_from_nz (
703
706
a:: DistributedAllocationCOO{<:SubAssembledRows} ,
704
- c_fespace :: PVectorAllocationTrackOnlyValues{<:SubAssembledRows} )
707
+ b :: PVectorAllocationTrackTouchedAndValues )
705
708
706
709
function callback (rows)
707
- _rhs_callback (c_fespace ,rows)
710
+ _rhs_callback (b ,rows)
708
711
end
709
712
710
713
function async_callback (b)
711
714
# now we can assemble contributions
712
715
assemble! (b)
713
716
end
714
717
715
- A,b = _sa_create_from_nz_with_callback (callback,async_callback,a)
718
+ A,b = _sa_create_from_nz_with_callback (callback,async_callback,a,b )
716
719
return A,b
717
720
end
718
721
@@ -759,32 +762,39 @@ end
759
762
nothing
760
763
end
761
764
765
+
766
+ function _setup_touched_and_allocations_arrays (values)
767
+ touched = map (values) do values
768
+ fill! (Vector {Bool} (undef,length (values)),false )
769
+ end
770
+ allocations = map (values,touched) do values,touched
771
+ ArrayAllocationTrackTouchedAndValues (touched,values)
772
+ end
773
+ touched, allocations
774
+ end
775
+
762
776
function Arrays. nz_allocation (a:: DistributedCounterCOO{<:SubAssembledRows} ,
763
777
b:: PVectorCounter{<:SubAssembledRows} )
764
778
A = nz_allocation (a)
765
779
dofs = b. test_dofs_gids_prange
766
780
values = map (nz_allocation,b. counters)
767
- B = PVectorAllocationTrackOnlyValues (b. par_strategy,values,dofs)
781
+ touched,allocations= _setup_touched_and_allocations_arrays (values)
782
+ B = PVectorAllocationTrackTouchedAndValues (allocations,values,dofs)
768
783
return A,B
769
784
end
770
785
771
786
function Arrays. nz_allocation (a:: PVectorCounter{<:SubAssembledRows} )
772
787
dofs = a. test_dofs_gids_prange
773
788
values = map (nz_allocation,a. counters)
774
- touched = map (values) do values
775
- fill! (Vector {Bool} (undef,length (values)),false )
776
- end
777
- allocations = map (values,touched) do values,touched
778
- ArrayAllocationTrackTouchedAndValues (touched,values)
779
- end
789
+ touched,allocations= _setup_touched_and_allocations_arrays (values)
780
790
return PVectorAllocationTrackTouchedAndValues (allocations,values,dofs)
781
791
end
782
792
783
793
function local_views (a:: PVectorAllocationTrackTouchedAndValues )
784
794
a. allocations
785
795
end
786
796
787
- function Algebra . create_from_nz (a:: PVectorAllocationTrackTouchedAndValues )
797
+ function _setup_prange_from_pvector_allocation (a:: PVectorAllocationTrackTouchedAndValues )
788
798
test_dofs_prange = a. test_dofs_gids_prange # dof ids of the test space
789
799
ngrdofs = length (test_dofs_prange)
790
800
@@ -810,20 +820,21 @@ function Algebra.create_from_nz(a::PVectorAllocationTrackTouchedAndValues)
810
820
gids_ghost_to_global, gids_ghost_to_owner = map (
811
821
find_gid_and_owner,I_ghost_lids_to_dofs_ghost_lids,indices) |> tuple_of_arrays
812
822
813
- rows = _setup_prange_impl_ (ngrdofs,indices,gids_ghost_to_global,gids_ghost_to_owner)
823
+ _setup_prange_impl_ (ngrdofs,indices,gids_ghost_to_global,gids_ghost_to_owner)
824
+ end
825
+
826
+ function Algebra. create_from_nz (a:: PVectorAllocationTrackTouchedAndValues )
827
+ rows = _setup_prange_from_pvector_allocation (a)
814
828
b = _rhs_callback (a,rows)
815
829
t2 = assemble! (b)
816
-
817
830
# Wait the transfer to finish
818
831
if t2 != = nothing
819
832
wait (t2)
820
833
end
821
834
return b
822
835
end
823
836
824
-
825
837
# Common Assembly Utilities
826
-
827
838
function first_gdof_from_ids (ids)
828
839
if own_length (ids) == 0
829
840
return 1
0 commit comments