diff --git a/base/internals/psi_crea_index.f90 b/base/internals/psi_crea_index.f90 index 5e9d76fd..fe5051d1 100644 --- a/base/internals/psi_crea_index.f90 +++ b/base/internals/psi_crea_index.f90 @@ -34,7 +34,9 @@ ! ! Subroutine: psb_crea_index ! Converts a list of data exchanges from build format to assembled format. -! See below for a description of the formats. +! See psi_desc_index for a description of the formats. +! Works by first finding a suitable ordering for the data exchanges, +! then doing the actual conversion. ! ! Arguments: ! desc_a - type(psb_desc_type) The descriptor; in this context only the index @@ -48,54 +50,6 @@ ! nsnd - integer Total send buffer size on the calling process ! nrcv - integer Total receive buffer size on the calling process ! -! -! The format of the index lists. Copied from base/modules/psb_desc_type -! -! 7. The data exchange is based on lists of local indices to be exchanged; all the -! lists have the same format, as follows: -! the list is composed of variable dimension blocks, one for each process to -! communicate with; each block contains indices of local elements to be -! exchanged. We do choose the order of communications: do not change -! the sequence of blocks unless you know what you're doing, or you'll -! risk a deadlock. NOTE: This is the format when the state is PSB_ASB_. -! See below for BLD. The end-of-list is marked with a -1. -! -! notation stored in explanation -! --------------- --------------------------- ----------------------------------- -! process_id index_v(p+proc_id_) identifier of process with which -! data is exchanged. -! n_elements_recv index_v(p+n_elem_recv_) number of elements to receive. -! elements_recv index_v(p+elem_recv_+i) indexes of local elements to -! receive. these are stored in the -! array from location p+elem_recv_ to -! location p+elem_recv_+ -! index_v(p+n_elem_recv_)-1. -! n_elements_send index_v(p+n_elem_send_) number of elements to send. -! elements_send index_v(p+elem_send_+i) indexes of local elements to -! send. these are stored in the -! array from location p+elem_send_ to -! location p+elem_send_+ -! index_v(p+n_elem_send_)-1. -! -! This organization is valid for both halo and overlap indices; overlap entries -! need to be updated to ensure that a variable at a given global index -! (assigned to multiple processes) has the same value. The way to resolve the -! issue is to exchange the data and then sum (or average) the values. See -! psb_ovrl subroutine. -! -! 8. When the descriptor is in the BLD state the INDEX vectors contains only -! the indices to be received, organized as a sequence -! of entries of the form (proc,N,(lx1,lx2,...,lxn)) with owning process, -! number of indices (most often N=1), list of local indices. -! This is because we only know the list of halo indices to be received -! as we go about building the sparse matrix pattern, and we want the build -! phase to be loosely synchronized. Thus we record the indices we have to ask -! for, and at the time we call PSB_CDASB we match all the requests to figure -! out who should be sending what to whom. -! However this implies that we know who owns the indices; if we are in the -! LARGE case (as described above) this is actually only true for the OVERLAP list -! that is filled in at CDALL time, and not for the HALO; thus the HALO list -! is rebuilt during the CDASB process (in the psi_ldsc_pre_halo subroutine). ! subroutine psi_crea_index(desc_a,index_in,index_out,glob_idx,nxch,nsnd,nrcv,info) diff --git a/base/internals/psi_desc_index.F90 b/base/internals/psi_desc_index.F90 index e9fc57c4..01924429 100644 --- a/base/internals/psi_desc_index.F90 +++ b/base/internals/psi_desc_index.F90 @@ -28,6 +28,75 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ +! +! +! File: psi_desc_index.f90 +! +! Subroutine: psi_desc_index +! Converts a list of data exchanges from build format to assembled format. +! See below for a description of the formats. +! +! Arguments: +! desc_a - type(psb_desc_type) The descriptor; in this context only the index +! mapping parts are used. +! index_in(:) - integer The index list, build format +! index_out(:) - integer, allocatable The index list, assembled format +! glob_idx - logical Whether the input indices are in local or global +! numbering; the global numbering is used when +! converting the overlap exchange lists. +! nxch - integer The number of data exchanges on the calling process +! nsnd - integer Total send buffer size on the calling process +! nrcv - integer Total receive buffer size on the calling process +! +! The format of the index lists. Copied from base/modules/psb_desc_type +! +! 7. The data exchange is based on lists of local indices to be exchanged; all the +! lists have the same format, as follows: +! the list is composed of variable dimension blocks, one for each process to +! communicate with; each block contains indices of local elements to be +! exchanged. We do choose the order of communications: do not change +! the sequence of blocks unless you know what you're doing, or you'll +! risk a deadlock. NOTE: This is the format when the state is PSB_ASB_. +! See below for BLD. The end-of-list is marked with a -1. +! +! notation stored in explanation +! --------------- --------------------------- ----------------------------------- +! process_id index_v(p+proc_id_) identifier of process with which +! data is exchanged. +! n_elements_recv index_v(p+n_elem_recv_) number of elements to receive. +! elements_recv index_v(p+elem_recv_+i) indexes of local elements to +! receive. these are stored in the +! array from location p+elem_recv_ to +! location p+elem_recv_+ +! index_v(p+n_elem_recv_)-1. +! n_elements_send index_v(p+n_elem_send_) number of elements to send. +! elements_send index_v(p+elem_send_+i) indexes of local elements to +! send. these are stored in the +! array from location p+elem_send_ to +! location p+elem_send_+ +! index_v(p+n_elem_send_)-1. +! +! This organization is valid for both halo and overlap indices; overlap entries +! need to be updated to ensure that a variable at a given global index +! (assigned to multiple processes) has the same value. The way to resolve the +! issue is to exchange the data and then sum (or average) the values. See +! psb_ovrl subroutine. +! +! 8. When the descriptor is in the BLD state the INDEX vectors contains only +! the indices to be received, organized as a sequence +! of entries of the form (proc,N,(lx1,lx2,...,lxn)) with owning process, +! number of indices (most often N=1), list of local indices. +! This is because we only know the list of halo indices to be received +! as we go about building the sparse matrix pattern, and we want the build +! phase to be loosely synchronized. Thus we record the indices we have to ask +! for, and at the time we call PSB_CDASB we match all the requests to figure +! out who should be sending what to whom. +! However this implies that we know who owns the indices; if we are in the +! LARGE case (as described above) this is actually only true for the OVERLAP list +! that is filled in at CDALL time, and not for the HALO; thus the HALO list +! is rebuilt during the CDASB process (in the psi_ldsc_pre_halo subroutine). +! +! subroutine psi_desc_index(desc,index_in,dep_list,& & length_dl,nsnd,nrcv,desc_index,isglob_in,info) use psb_descriptor_type @@ -85,7 +154,7 @@ subroutine psi_desc_index(desc,index_in,dep_list,& endif ! - ! first, find out the total sizes to be exchanged. + ! first, find out the sizes to be exchanged. ! note: things marked here as sndbuf/rcvbuf (for mpi) corresponds to things ! to be received/sent (in the final psblas descriptor). ! be careful of the inversion @@ -166,6 +235,9 @@ subroutine psi_desc_index(desc,index_in,dep_list,& goto 9999 end if + ! + ! Second build the lists of requests + ! i = 1 do if (i > ihinsz) then