連結已複製
Dear Steve,
it is a transpose-free QMR solver. I want to use coarrays for parallelize the matrix-vector product.
Unfortunally, if I use more than one image the calculations slow down.
This is the matrix-vector product routine:
subroutine matvec(a,x,y)
type(coo_matrix), intent(in) :: a
complex(dp), dimension(:), intent(in) :: x
complex(dp), dimension(size(x,1)), intent(out) :: y
complex(dp), allocatable,dimension(:) :: tmp[:]
integer :: i, me, numi
me = this_image()
numi = num_images()
!allocate
allocate(tmp(a%n)And the sum function is:
function globalSum_serial(vec,n) result(this)
complex(dp), dimension(:), intent(inout) :: vecI compile this with ifort 15.0.1 using only -coarray.
When I use a big matrix the more images I use the matvec routine will slow down.
I did a basic hotspot analysis with vtune and it says that
ICAF_BARRIER and ICAF_UNLOC are the code segments which need the most time.
Thank you jan
What you are doing in your globalsum procedure is a cross-image reduction; while this is formally correct, it is quite inefficient. The statement that is particularly inefficient is the last communication statement
if(me /= 1) this(:) = vec(:)[1]
which oversubscribes the network link to image 1. The only "good" solution to this is using a collective call, which presently is not yet defined for coarray Fortran (but hopefully soon will be). For now, I think using MPI_Allreduce in its place should work (some MPI boilerplate may be needed). The alternative would be to implement the reduction manually, using all images (e.g. with a butterfly communication pattern) to reduce the amount of synchronization and avoid oversubscription.
Cheers
Reinhold