test_handoff_to_waiting_ranks Subroutine

public subroutine test_handoff_to_waiting_ranks(this)

Arguments

Type IntentOptional Attributes Name
class(MpiTestMethod), intent(inout) :: this

Calls

proc~~test_handoff_to_waiting_ranks~~CallsGraph proc~test_handoff_to_waiting_ranks test_handoff_to_waiting_ranks assertequal assertequal proc~test_handoff_to_waiting_ranks->assertequal getmpicommunicator getmpicommunicator proc~test_handoff_to_waiting_ranks->getmpicommunicator getnumprocesses getnumprocesses proc~test_handoff_to_waiting_ranks->getnumprocesses getprocessrank getprocessrank proc~test_handoff_to_waiting_ranks->getprocessrank mpi_barrier mpi_barrier proc~test_handoff_to_waiting_ranks->mpi_barrier mpi_win_free mpi_win_free proc~test_handoff_to_waiting_ranks->mpi_win_free mpi_wtime mpi_wtime proc~test_handoff_to_waiting_ranks->mpi_wtime none~acquire MpiMutex%acquire proc~test_handoff_to_waiting_ranks->none~acquire none~free_mpi_resources MpiMutex%free_mpi_resources proc~test_handoff_to_waiting_ranks->none~free_mpi_resources none~release MpiMutex%release proc~test_handoff_to_waiting_ranks->none~release proc~create_counter create_counter proc~test_handoff_to_waiting_ranks->proc~create_counter proc~increment_counter increment_counter proc~test_handoff_to_waiting_ranks->proc~increment_counter proc~read_counter read_counter proc~test_handoff_to_waiting_ranks->proc~read_counter mpi_get mpi_get none~acquire->mpi_get mpi_put mpi_put none~acquire->mpi_put mpi_recv mpi_recv none~acquire->mpi_recv mpi_win_lock mpi_win_lock none~acquire->mpi_win_lock mpi_win_unlock mpi_win_unlock none~acquire->mpi_win_unlock proc~mapl_return MAPL_Return none~acquire->proc~mapl_return proc~mapl_verify MAPL_Verify none~acquire->proc~mapl_verify none~free_mpi_resources->mpi_win_free mpi_comm_free mpi_comm_free none~free_mpi_resources->mpi_comm_free mpi_free_mem mpi_free_mem none~free_mpi_resources->mpi_free_mem mpi_type_free mpi_type_free none~free_mpi_resources->mpi_type_free none~free_mpi_resources->proc~mapl_return none~free_mpi_resources->proc~mapl_verify none~release->mpi_get none~release->mpi_put mpi_send mpi_send none~release->mpi_send none~release->mpi_win_lock none~release->mpi_win_unlock none~release->proc~mapl_return none~release->proc~mapl_verify mpi_type_get_extent mpi_type_get_extent proc~create_counter->mpi_type_get_extent mpi_win_create mpi_win_create proc~create_counter->mpi_win_create proc~increment_counter->proc~read_counter proc~increment_counter->mpi_put proc~increment_counter->mpi_win_lock proc~increment_counter->mpi_win_unlock proc~read_counter->mpi_get proc~read_counter->mpi_win_lock proc~read_counter->mpi_win_unlock at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Source Code

   subroutine test_handoff_to_waiting_ranks(this)
      class (MpiTestMethod), intent(inout) :: this

      type (MpiMutex) :: mutex
      integer :: comm, npes, rank, status
      integer :: win
      integer, target :: counter
      real(kind=kind(0.d0)) :: t0

      comm = this%getMpiCommunicator()
      npes = this%getNumProcesses()
      rank = this%getProcessRank()

      call create_counter(comm, counter, win)

      mutex = MpiMutex(comm, rc=status)
      @assertEqual(0, status)

      if (rank == 0) then
         call mutex%acquire(rc=status)
         @assertEqual(0, status)
      end if

      call MPI_Barrier(comm, status)
      @assertEqual(0, status)

      if (rank == 0) then
         ! Give the other ranks time to register as waiters.
         t0 = MPI_Wtime()
         do while (MPI_Wtime() - t0 < 0.2d0)
         end do
      else
         call mutex%acquire(rc=status)
         @assertEqual(0, status)
      end if

      call increment_counter(win)
      call mutex%release(rc=status)
      @assertEqual(0, status)

      call MPI_Barrier(comm, status)
      @assertEqual(0, status)

      if (rank == 0) then
         @assertEqual(npes, read_counter(win))
      end if

      call mutex%free_mpi_resources(rc=status)
      @assertEqual(0, status)
      call MPI_Win_free(win, status)

   end subroutine test_handoff_to_waiting_ranks