handle_local_worker_results Subroutine

private subroutine handle_local_worker_results(resources, worker_term_map, results, results_received, coord_timer, n_pie_terms)

Uses

  • proc~~handle_local_worker_results~2~~UsesGraph proc~handle_local_worker_results~2 handle_local_worker_results module~mqc_resources mqc_resources proc~handle_local_worker_results~2->module~mqc_resources module~mqc_mpi_comms mqc_mpi_comms module~mqc_resources->module~mqc_mpi_comms pic_mpi_lib pic_mpi_lib module~mqc_mpi_comms->pic_mpi_lib

Arguments

Type IntentOptional Attributes Name
type(resources_t), intent(in) :: resources
integer(kind=int64), intent(inout) :: worker_term_map(:)
type(calculation_result_t), intent(inout) :: results(:)
integer(kind=int64), intent(inout) :: results_received
type(timer_type), intent(in) :: coord_timer
integer(kind=int64), intent(in) :: n_pie_terms

Calls

proc~~handle_local_worker_results~2~~CallsGraph proc~handle_local_worker_results~2 handle_local_worker_results abort_comm abort_comm proc~handle_local_worker_results~2->abort_comm error error proc~handle_local_worker_results~2->error get_elapsed_time get_elapsed_time proc~handle_local_worker_results~2->get_elapsed_time info info proc~handle_local_worker_results~2->info iprobe iprobe proc~handle_local_worker_results~2->iprobe proc~error_get_message error_t%error_get_message proc~handle_local_worker_results~2->proc~error_get_message proc~result_irecv result_irecv proc~handle_local_worker_results~2->proc~result_irecv to_char to_char proc~handle_local_worker_results~2->to_char irecv irecv proc~result_irecv->irecv recv recv proc~result_irecv->recv

Called by

proc~~handle_local_worker_results~2~~CalledByGraph proc~handle_local_worker_results~2 handle_local_worker_results proc~gmbe_pie_coordinator gmbe_pie_coordinator proc~gmbe_pie_coordinator->proc~handle_local_worker_results~2 proc~gmbe_run_distributed gmbe_context_t%gmbe_run_distributed proc~gmbe_run_distributed->proc~gmbe_pie_coordinator

Variables

Type Visibility Attributes Name Initial
logical, private :: has_pending
type(MPI_Status), private :: local_status
type(request_t), private :: req
integer, private :: worker_source

Source Code

   subroutine handle_local_worker_results(resources, worker_term_map, results, results_received, coord_timer, n_pie_terms)
      use mqc_resources, only: resources_t
      type(resources_t), intent(in) :: resources
      integer(int64), intent(inout) :: worker_term_map(:)
      type(calculation_result_t), intent(inout) :: results(:)
      integer(int64), intent(inout) :: results_received
      type(timer_type), intent(in) :: coord_timer
      integer(int64), intent(in) :: n_pie_terms

      type(MPI_Status) :: local_status
      logical :: has_pending
      integer :: worker_source
      type(request_t) :: req

      if (resources%mpi_comms%node_comm%size() <= 1) return

      do
         call iprobe(resources%mpi_comms%node_comm, MPI_ANY_SOURCE, TAG_WORKER_SCALAR_RESULT, has_pending, local_status)
         if (.not. has_pending) exit

         worker_source = local_status%MPI_SOURCE
         if (worker_term_map(worker_source) == 0) then
            call logger%error("Received result from worker "//to_char(worker_source)// &
                              " but no term was assigned!")
            call abort_comm(resources%mpi_comms%world_comm, 1)
         end if

         call result_irecv(results(worker_term_map(worker_source)), resources%mpi_comms%node_comm, worker_source, &
                           TAG_WORKER_SCALAR_RESULT, req)
         call wait(req)

         if (results(worker_term_map(worker_source))%has_error) then
            call logger%error("PIE term "//to_char(worker_term_map(worker_source))// &
                              " calculation failed: "// &
                              results(worker_term_map(worker_source))%error%get_message())
            call abort_comm(resources%mpi_comms%world_comm, 1)
         end if

         worker_term_map(worker_source) = 0
         results_received = results_received + 1
         if (mod(results_received, max(1_int64, n_pie_terms/10_int64)) == 0 .or. &
             results_received == n_pie_terms) then
            call logger%info("  Processed "//to_char(results_received)//"/"// &
                             to_char(n_pie_terms)//" PIE terms ["// &
                             to_char(coord_timer%get_elapsed_time())//" s]")
         end if
      end do
   end subroutine handle_local_worker_results