layout_runs Subroutine

public subroutine layout_runs(n, pe_of, key_of, size_of, off_of, npeer, peer, peer_off, peer_len)

Uses

  • proc~~layout_runs~~UsesGraph proc~layout_runs layout_runs module~mod_global_parameters mod_global_parameters proc~layout_runs->module~mod_global_parameters module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

Give every peer one contiguous run of the exchange buffer, with the chunks inside a run ordered by the key. Both ranks compute the same key for the same chunk, so sorting by it makes the sender's run and the receiver's run agree element for element without any handshake.

size_of(k) is the extent of chunk k in buffer elements; peers come out ascending, peer_off/peer_len delimit their runs, and off_of(k) is where chunk k starts.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(in) :: pe_of(:)
integer, intent(in) :: key_of(:)
integer, intent(in) :: size_of(:)
integer, intent(out) :: off_of(:)
integer, intent(out) :: npeer
integer, intent(out) :: peer(:)
integer, intent(out) :: peer_off(:)
integer, intent(out) :: peer_len(:)

Calls

proc~~layout_runs~~CallsGraph proc~layout_runs layout_runs proc~rank_keys rank_keys proc~layout_runs->proc~rank_keys

Called by

proc~~layout_runs~~CalledByGraph proc~layout_runs layout_runs proc~build_message_layout build_message_layout proc~build_message_layout->proc~layout_runs proc~exchange_coarsened_blocks exchange_coarsened_blocks proc~exchange_coarsened_blocks->proc~layout_runs proc~exchange_migrated_blocks exchange_migrated_blocks proc~exchange_migrated_blocks->proc~layout_runs proc~amr_coarsen_refine amr_coarsen_refine proc~amr_coarsen_refine->proc~exchange_coarsened_blocks proc~load_balance load_balance proc~amr_coarsen_refine->proc~load_balance proc~init_comm_fix_conserve init_comm_fix_conserve proc~init_comm_fix_conserve->proc~build_message_layout proc~load_balance->proc~exchange_migrated_blocks proc~advect advect proc~advect->proc~init_comm_fix_conserve proc~recalculateb recalculateB proc~recalculateb->proc~init_comm_fix_conserve proc~resettree resettree proc~resettree->proc~amr_coarsen_refine proc~resettree_convert resettree_convert proc~resettree_convert->proc~amr_coarsen_refine proc~settree settree proc~settree->proc~amr_coarsen_refine proc~advance advance proc~advance->proc~advect proc~improve_initial_condition improve_initial_condition proc~improve_initial_condition->proc~recalculateb proc~main main proc~main->proc~resettree_convert proc~main->proc~settree proc~main->proc~improve_initial_condition proc~timeintegration timeintegration proc~main->proc~timeintegration proc~timeintegration->proc~resettree proc~timeintegration->proc~advance program~agile agile program~agile->proc~main

Source Code

  subroutine layout_runs(n, pe_of, key_of, size_of, off_of, npeer, peer,&
     peer_off, peer_len)
    use mod_global_parameters, only: npe

    integer, intent(in)  :: n, pe_of(:), key_of(:), size_of(:)
    integer, intent(out) :: off_of(:), npeer, peer(:), peer_off(:), peer_len(:)

    integer :: k, p, j
    integer :: nper(0:npe-1), cursor(0:npe-1)
    integer, allocatable :: perm(:)

    npeer = 0
    if (n == 0) return

    ! how long each peer's run is, in buffer elements
    nper = 0
    do k = 1, n
      nper(pe_of(k)) = nper(pe_of(k)) + size_of(k)
    end do

    ! peers ascending, each run following the previous one
    j = 1
    do p = 0, npe-1
      if (nper(p) == 0) cycle
      npeer           = npeer + 1
      peer(npeer)     = p
      peer_off(npeer) = j
      peer_len(npeer) = nper(p)
      cursor(p)       = j
      j               = j + nper(p)
    end do

    ! walk the chunks in ascending key order and hand each one the next slot
    ! in its peer's run, so the two ranks fill a run identically
    allocate(perm(n))
    call rank_keys(n, key_of, perm)
    do k = 1, n
      j         = perm(k)
      p         = pe_of(j)
      off_of(j) = cursor(p)
      cursor(p) = cursor(p) + size_of(j)
    end do
    deallocate(perm)

  end subroutine layout_runs