-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test driver for remote BLACS locations
Remote matrix assembly and communication test. Add leadprocessor number to BLACS grid structure. scalafx_getremoteshape - Returns the shape of a remote part of a distributed array, with optional flag to return padded matrix (lda >= local row). scalafx_infog2p - Processor grid location of global matrix index element. Gives 2D info instead of separate row and column from scalafx_indxg2p. Note: scalafx_localindices behavior changed, to return actual values for .not.local calls, instead of returning 0 unless on local processor. Instead, return 0 when requested matrix indices are outside of global row/column sizes.
- Loading branch information
1 parent
d86bb1a
commit 3c2c500
Showing
4 changed files
with
235 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
!> Testing copy between matrix patterns | ||
program test_remoteelements | ||
use, intrinsic :: iso_fortran_env, stdout => output_unit, stdin => input_unit | ||
use test_common_module | ||
use libscalapackfx_module | ||
use blacsfx_module | ||
implicit none | ||
|
||
call main() | ||
|
||
contains | ||
|
||
subroutine main() | ||
type(blacsgrid) :: myGrid | ||
integer, allocatable :: AA(:,:), AAreceive(:,:), All(:,:) | ||
integer :: desc(DLEN_), nprow, npcol, mm, nn, mb, nb, iproc, nproc, ii, jj, kk, iGlob, jGlob | ||
integer :: iprow, ipcol, iLoc, jLoc, locrow, loccol | ||
logical :: isLocal | ||
|
||
! grid information | ||
call blacsfx_pinfo(iproc, nproc) | ||
|
||
! approximately square grid for group | ||
do npcol = floor(sqrt(real(nproc, dp))), nproc | ||
if (mod(nproc, npcol) == 0) then | ||
exit | ||
end if | ||
end do | ||
nprow = nproc / npcol | ||
call myGrid%initgrid(nprow, npcol) | ||
|
||
if (myGrid%lead) then | ||
write(stdout, "(A,2(1X,I0))") "# source processor grid:", nprow, npcol | ||
write(stdOut, "(A)")'# Matrix size to re-distrbute?' | ||
read(stdin, *) mm, nn | ||
write(stdout,"(A)")'# Block sizes of matrix?' | ||
read(stdin,*) mb, nb | ||
call blacsfx_gebs(myGrid, mm) | ||
call blacsfx_gebs(myGrid, nn) | ||
call blacsfx_gebs(myGrid, mb) | ||
call blacsfx_gebs(myGrid, nb) | ||
else | ||
call blacsfx_gebr(myGrid, mm) | ||
call blacsfx_gebr(myGrid, nn) | ||
call blacsfx_gebr(myGrid, mb) | ||
call blacsfx_gebr(myGrid, nb) | ||
end if | ||
|
||
call scalafx_creatematrix(myGrid, mm, nn, mb, nb, AA, desc) | ||
|
||
if (myGrid%lead) then | ||
do ii = 0, nproc-1 | ||
call scalafx_getremoteshape(myGrid, desc, ii, locrow, loccol) | ||
write(stdout, "(A,I0,A,1X,I0,1X,I0)") "# A block (data:",ii,"):", locrow, loccol | ||
call scalafx_getremoteshape(myGrid, desc, ii, locrow, loccol, .true.) | ||
write(stdout, "(T8,A,I0,A,1X,I0,1X,I0)") "(storage:",ii,"):", locrow, loccol | ||
end do | ||
|
||
do ii = 1, nn | ||
do jj = 1, mm | ||
call scalafx_infog2p(mygrid, desc, jj, ii, iprow, ipcol) | ||
write(stdout, "(A,I0,1X,I0,A,I0,1X,I0,A,I0)") "# Matrix elements (",jj, ii,& | ||
& ') stored on BLACS grid at ', iprow, ipcol, " proc. ",& | ||
& blacsfx_pnum(myGrid, iprow, ipcol) | ||
end do | ||
end do | ||
|
||
end if | ||
|
||
call blacsfx_barrier(myGrid) | ||
|
||
AA(:,:) = -1 | ||
call scalafx_getremoteshape(myGrid, desc, iProc, locrow, loccol, .true.) | ||
call blacsfx_pcoord(myGrid, iProc, iprow, ipcol) | ||
do ii = 1, loccol | ||
iGlob = scalafx_indxl2g(ii, desc(NB_), ipcol, desc(CSRC_), myGrid%ncol) | ||
do jj = 1, locrow | ||
jGlob = scalafx_indxl2g(jj, desc(MB_), iprow, desc(RSRC_), myGrid%nrow) | ||
AA(jj,ii) = jGlob + (iGlob-1) * mm | ||
end do | ||
end do | ||
write(stdout,*)iproc,':', AA(:locrow,:loccol) | ||
|
||
call blacsfx_barrier(myGrid) | ||
|
||
if (myGrid%lead) then | ||
|
||
allocate(All(mm,nn), source = 0) | ||
|
||
do kk = 0, nproc-1 | ||
|
||
if (kk /= myGrid%leadproc) then | ||
write(stdout,*)'Follow', kk | ||
|
||
call scalafx_getremoteshape(myGrid, desc, kk, locrow, loccol, .true.) | ||
allocate(AAreceive(locrow, loccol), source=-1) | ||
|
||
call blacsfx_pcoord(myGrid, kk, iprow, ipcol) | ||
write(*,*)kk, iprow, ipcol,'Expecting', shape(AAreceive) | ||
call blacsfx_gerv(myGrid, AAreceive, iprow, ipcol) | ||
|
||
else | ||
|
||
write(stdout,*)'Lead', kk | ||
call scalafx_getlocalshape(mygrid, desc, locrow, loccol) | ||
AAreceive = AA(:locrow,:loccol) | ||
|
||
end if | ||
|
||
call scalafx_getremoteshape(myGrid, desc, kk, locrow, loccol, .true.) | ||
call blacsfx_pcoord(myGrid, kk, iprow, ipcol) | ||
do ii = 1, loccol | ||
iGlob = scalafx_indxl2g(ii, desc(NB_), ipcol, desc(CSRC_), myGrid%ncol) | ||
do jj = 1, locrow | ||
jGlob = scalafx_indxl2g(jj, desc(MB_), iprow, desc(RSRC_), myGrid%nrow) | ||
write(stdout,*)'Proc',kk,',', iprow, ipcol,': (', jGlob,iGlob,')(',jj,ii,')' | ||
All(jGlob,iGlob) = AAreceive(jj,ii) | ||
end do | ||
end do | ||
|
||
deallocate(AAreceive) | ||
|
||
end do | ||
|
||
else | ||
|
||
write(*,*)iproc, myGrid%myrow, myGrid%mycol,'sending', shape(AA) | ||
call blacsfx_gesd(myGrid, AA, myGrid%leadrow, myGrid%leadcol) | ||
|
||
end if | ||
|
||
call blacsfx_barrier(myGrid) | ||
|
||
if (myGrid%lead) then | ||
do jj = 1, nn | ||
write(stdout,*)All(:,jj) | ||
end do | ||
end if | ||
|
||
! Finish blacs. | ||
call blacsfx_exit() | ||
|
||
end subroutine main | ||
|
||
end program test_remoteelements |