Find the partitions holding data on a given path
Using a binary search over the processes first and last elements.
Is the element in question a local or remote element? To look up a certain element by its treeID in the distributed list of elements, it is sufficient to know the splitting positions of all chunks. That is, the first and last treeID of each partition. With a binary search over the splitting positions any requested element can then be identified to be either outside the computational domain at all, or inside of one or several known partitions.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | depProc |
List of partitions |
||
integer, | intent(out) | :: | nDepProcs |
Number of partitions |
||
type(treelmesh_type), | intent(in) | :: | tree |
tree information |
||
type(tem_path_type), | intent(in) | :: | elemPath |
Element to look up |
||
type(tem_path_type), | intent(in) | :: | PathFirst(:) |
Left partition bounds |
||
type(tem_path_type), | intent(in) | :: | PathLast(:) |
Right partition bounds |
subroutine tem_find_depProc( depProc, nDepProcs, tree, elemPath, PathFirst, &
& PathLast )
! -------------------------------------------------------------------- !
!> List of partitions
integer, intent(out) :: depProc
!> Number of partitions
integer, intent(out) :: nDepProcs
!> tree information
type(treelmesh_type), intent(in) :: tree
!> Element to look up
type(tem_path_type), intent(in) :: elemPath
!> Left partition bounds
type(tem_path_type), intent(in) :: PathFirst(:)
!> Right partition bounds
type(tem_path_type), intent(in) :: PathLast(:)
! -------------------------------------------------------------------- !
integer :: p_lb, p_ub ! process lower and upper bound
integer :: relFirst, relLast
integer :: myRank
! -------------------------------------------------------------------- !
myRank = tree%global%myPart
nDepProcs = 0
! First check if this neighbor is in my local tree range
p_lb = 1
! rank starts from indice 0 where as fortran array pathFirst and
! pathLast starts from 1
relFirst = tem_PathComparison(elemPath, PathFirst(myRank+1))
relLast = tem_PathComparison(elemPath, PathLast(myRank+1))
if (relFirst < 0) then
! The searched element is definitely left of myself
! Do only search up to my own range
p_ub = myRank
else
p_ub = int( min( int(tree%global%nParts, kind=long_k), &
& tree%global%nElems ) )
if (relLast > 0) then
! The searched element is definitely right of myself
! Do only search beyond my own range
p_lb = myRank+2
else
! The element might be (partly) on my own partition
if (relLast < 0) then
! The element is at least left of my right border
! Set the upper bound to include myself
p_ub = myRank + 1
end if
if (relFirst > 0) then
! The element is at least right of my left border
! Set the lower bound to include myself
p_lb = myRank + 1
end if
end if ! relLast > 0
end if ! relFirst < 0
if ((p_lb == p_ub) .and. (p_lb == myRank+1)) then
! The element is local, do not go on to other processes
nDepProcs = 1
depProc = myRank+1
else
! Possibly NON-LOCAL Element...
! Every process COULD hold a part of the current neighbor element
call tem_find_depProc_globSearch( depProc = depProc, &
& nDepProcs = nDepProcs, &
& elemPath = elemPath, &
& p_lb = p_lb, &
& p_ub = p_ub, &
& PathFirst = PathFirst, &
& PathLast = PathLast )
end if ! local or non-local
end subroutine tem_find_depProc