flow_global_dots_owned Subroutine

public subroutine flow_global_dots_owned(flow, n_dots, a, b, results)

Uses

  • proc~~flow_global_dots_owned~~UsesGraph proc~flow_global_dots_owned mod_mpi_flow::flow_global_dots_owned module~mod_profiler mod_profiler proc~flow_global_dots_owned->module~mod_profiler iso_fortran_env iso_fortran_env module~mod_profiler->iso_fortran_env module~mod_kinds mod_kinds module~mod_profiler->module~mod_kinds mpi_f08 mpi_f08 module~mod_profiler->mpi_f08 module~mod_kinds->iso_fortran_env

Computes multiple global dot products in a single MPI_Allreduce.

This batched version reduces MPI latency by combining n_dots synchronizations.

Arguments

Type IntentOptional Attributes Name
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: n_dots
real(kind=rk), intent(in) :: a(:,:)
real(kind=rk), intent(in) :: b(:,:)
real(kind=rk), intent(out) :: results(:)

Calls

proc~~flow_global_dots_owned~~CallsGraph proc~flow_global_dots_owned mod_mpi_flow::flow_global_dots_owned mpi_allreduce mpi_allreduce proc~flow_global_dots_owned->mpi_allreduce proc~check_mpi~2 mod_mpi_flow::check_mpi proc~flow_global_dots_owned->proc~check_mpi~2 proc~profiler_start mod_profiler::profiler_start proc~flow_global_dots_owned->proc~profiler_start proc~profiler_stop mod_profiler::profiler_stop proc~flow_global_dots_owned->proc~profiler_stop proc~fatal_error mod_kinds::fatal_error proc~check_mpi~2->proc~fatal_error mpi_wtime mpi_wtime proc~profiler_start->mpi_wtime proc~find_or_create_timer mod_profiler::find_or_create_timer proc~profiler_start->proc~find_or_create_timer proc~profiler_stop->mpi_wtime proc~profiler_stop->proc~find_or_create_timer proc~record_edge mod_profiler::record_edge proc~profiler_stop->proc~record_edge

Source Code

   subroutine flow_global_dots_owned(flow, n_dots, a, b, results)
      use mod_profiler, only : profiler_start, profiler_stop
      type(flow_mpi_t), intent(in) :: flow
      integer, intent(in) :: n_dots
      real(rk), intent(in) :: a(:,:)  ! (ncells, n_dots)
      real(rk), intent(in) :: b(:,:)  ! (ncells, n_dots)
      real(rk), intent(out) :: results(:) ! (n_dots)
      real(rk) :: local_dots(n_dots)
      integer :: c, i, ierr

      local_dots = zero
      do i = 1, n_dots
         do c = flow%first_cell, flow%last_cell
            local_dots(i) = local_dots(i) + a(c, i) * b(c, i)
         end do
      end do

      call profiler_start('MPI_Communication')
      call MPI_Allreduce(local_dots, results, n_dots, MPI_DOUBLE_PRECISION, MPI_SUM, flow%comm, ierr)
      call check_mpi(ierr, 'MPI_Allreduce batched dots')
      call profiler_stop('MPI_Communication')
   end subroutine flow_global_dots_owned