Stops the currently active benchmark, calculates performance metrics, and writes the results to the file and terminal.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(benchmark), | intent(inout) | :: | this |
Benchmark object |
||
procedure(Fun), | optional | :: | flops |
Function to calculate Floating Point Operations Per Second (optional) |
impure subroutine stop_benchmark(this, flops) !! author: Seyed Ali Ghasemi !! Stops the currently active benchmark, calculates performance metrics, and writes the results to the file and terminal. !! interface impure function Fun(argi, argr) import rk, ik integer(ik), dimension(:), intent(in), optional :: argi real(rk), dimension(:), intent(in), optional :: argr real(rk) :: Fun end function Fun end interface procedure(Fun), optional :: flops !! Function to calculate Floating Point Operations Per Second (optional) class(benchmark), intent(inout) :: this !! Benchmark object select case (trim(this%timer)) case ('wall') call this%marks(this%imark)%time%timer_stop(message=' Elapsed time :',nloops=this%nloops) this%marks(this%imark)%elapsed_time = this%marks(this%imark)%time%elapsed_time case ('date_and_time') call this%marks(this%imark)%time%dtimer_stop(message=' Elapsed time :',nloops=this%nloops) this%marks(this%imark)%elapsed_time = this%marks(this%imark)%time%elapsed_dtime case ('cpu') call this%marks(this%imark)%time%ctimer_stop(message=' Elapsed time :',nloops=this%nloops) this%marks(this%imark)%elapsed_time = this%marks(this%imark)%time%cpu_time case ('omp') #if defined(USE_OMP) call this%marks(this%imark)%time%otimer_stop(message=' Elapsed time :',nloops=this%nloops) this%marks(this%imark)%elapsed_time = this%marks(this%imark)%time%omp_time #else error stop 'Use -DUSE_OMP to enable OpenMP.' #endif case ('mpi') #if defined(USE_MPI) call this%marks(this%imark)%time%mtimer_stop(message=' Elapsed time :',nloops=this%nloops) this%marks(this%imark)%elapsed_time = this%marks(this%imark)%time%mpi_time #else error stop 'Use -DUSE_MPI to enable MPI.' #endif end select if (this%marks(this%imark)%elapsed_time <= epsilon(0.0_rk)) error stop 'Elapsed time is too small' this%marks(this%imark)%speedup = this%marks(1)%elapsed_time/this%marks(this%imark)%elapsed_time if (present(flops)) then print'(a,f7.3,a)', ' Speedup :', this%marks(this%imark)%speedup,' [-]' this%marks(this%imark)%flops = flops(this%argi,this%argr)/this%marks(this%imark)%elapsed_time print'(a,f7.3,a)', ' Performance :', this%marks(this%imark)%flops,' [GFLOPS]' else this%marks(this%imark)%flops = 0.0_rk endif print'(a)', '' call this%write_benchmark() end subroutine stop_benchmark