run Subroutine

subroutine run(spec, rc)

Arguments

Type IntentOptional Attributes Name
type(BW_BenchmarkSpec), intent(in) :: spec
integer, intent(out), optional :: rc

Calls

proc~~run~4~~CallsGraph proc~run~4 run mpi_comm_rank mpi_comm_rank proc~run~4->mpi_comm_rank mpi_comm_size mpi_comm_size proc~run~4->mpi_comm_size mpi_comm_split mpi_comm_split proc~run~4->mpi_comm_split proc~make_bw_benchmark make_BW_Benchmark proc~run~4->proc~make_bw_benchmark proc~mapl_return MAPL_Return proc~run~4->proc~mapl_return proc~mapl_verify MAPL_Verify proc~run~4->proc~mapl_verify proc~report report proc~run~4->proc~report proc~write_header write_header proc~run~4->proc~write_header proc~make_bw_benchmark->mpi_comm_rank proc~make_bw_benchmark->proc~mapl_return proc~make_bw_benchmark->proc~mapl_verify 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 proc~report->mpi_comm_rank proc~report->mpi_comm_size proc~report->proc~mapl_return proc~report->proc~mapl_verify proc~write_header->mpi_comm_rank proc~write_header->proc~mapl_return proc~write_header->proc~mapl_verify

Called by

proc~~run~4~~CalledByGraph proc~run~4 run program~main~4 main program~main~4->proc~run~4

Source Code

   subroutine run(spec, rc)
      type(BW_BenchmarkSpec), intent(in) :: spec
      integer, optional, intent(out) :: rc

      integer :: status

      real :: tot_time
      real :: tot_time_sq
      real :: avg_time
      real :: std_time
      type(BW_Benchmark) :: benchmark
      integer :: writer_comm
      integer :: gather_comm
      integer :: i
      real :: t

      integer :: color, rank, npes
      call MPI_Comm_rank(MPI_COMM_WORLD, rank, _IERROR)
      call MPI_Comm_size(MPI_COMM_WORLD, npes, _IERROR)

      color = (rank*spec%n_writers) / npes
      call MPI_Comm_split(MPI_COMM_WORLD, color, 0, gather_comm, _IERROR)
      
      call MPI_Comm_rank(gather_comm, rank, _IERROR)
      call MPI_Comm_split(MPI_COMM_WORLD, rank, 0, writer_comm, _IERROR)
      if (rank /= 0) writer_comm = MPI_COMM_NULL
      _RETURN_IF(writer_comm == MPI_COMM_NULL)

      benchmark = make_BW_Benchmark(spec, writer_comm, _RC)

      call write_header(writer_comm, _RC)

      tot_time = 0
      tot_time_sq = 0
      associate (n => spec%n_tries)
        do i = 1, n
           t = time(benchmark, writer_comm, _RC)
           tot_time = tot_time + t
           tot_time_sq = tot_time_sq + t**2
        end do
        avg_time = tot_time / n

        std_time = -1 ! unless
        if (n > 1) then
           std_time = sqrt((tot_time_sq - spec%n_tries*avg_time**2)/(n-1))
        end if
      end associate

      call report(spec, avg_time, std_time, writer_comm, _RC)

      _RETURN(_SUCCESS)
   end subroutine run