ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_bench.F90
Go to the documentation of this file.
1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3!!!! !!!!
4!!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5!!!! !!!!
6!!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7!!!! !!!!
8!!!! This file is part of the ParaMonte library. !!!!
9!!!! !!!!
10!!!! LICENSE !!!!
11!!!! !!!!
12!!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13!!!! !!!!
14!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
38
39!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40
42
43 use pm_kind, only: SK, IK, LK, RKD
44 use pm_timer, only: TimerCPU_type
45 use pm_timer, only: TimerDAT_type
46#if MPI_ENABLED
47 use pm_timer, only: timerMPI_type
48#endif
49#if OMP_ENABLED
50 use pm_timer, only: timerOMP_type
51#endif
52 use pm_timer, only: timerSYS_type
53 use pm_timer, only: timer_type
54
55 implicit none
56
57 character(*, SK), parameter :: MODULE_NAME = SK_"@pm_bench"
58
59!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60
69 abstract interface
70 subroutine exec_proc()
71 end subroutine exec_proc
72 end interface
73
74!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
76 !!> \brief
77 !!> This is the base class for creating objects that hold the statistics of the timing information of a benchmark.
78 !!>
79 !!> \remark
80 !!> This type should generally not be explicitly used outside the [pm_bench](@ref pm_bench).
81 !!> It merely serves to create the `stat` component of the [timing_type](@ref timing_type) class below.
82 !!>
83 !!> \see
84 !!> [timing_type](@ref timing_type)<br>
85 !!>
86 !!> \test
87 !!> [test_pm_bench](@ref test_pm_bench)
88 !!>
89 !!> \final{Stat_type}
90 !!>
91 !!> \author
92 !!> Amir Shahmoradi, Wednesday 4:13 AM, August 13, 2016, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin<br>
93 !type :: Stat_type
94 ! real(RKD) :: min = -huge(0._RKD) !< @public The minimum of the timing vector of the benchmark (in seconds).
95 ! real(RKD) :: max = -huge(0._RKD) !< @public The maximum of the timing vector of the benchmark (in seconds).
96 ! real(RKD) :: std = -huge(0._RKD) !< @public The standard deviation of the timing vector of the benchmark (in seconds).
97 ! real(RKD) :: mean = -huge(0._RKD) !< @public The mean of the timing vector of the benchmark (in seconds).
98 ! !real(RKD) :: median = -huge(0._RKD) !< @public The median of the timing vector of the benchmark (in seconds).
99 ! !real(RKD) :: skewness = -huge(0._RKD) !< @public The skewness of the timing vector of the benchmark.
100 ! !real(RKD) :: kurtosis = -huge(0._RKD) !< @public The kurtosis of the timing vector of the benchmark.
101 !end type Stat_type
102
103!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104
128 !type(Stat_type) :: stat !< @public The object of type [Stat_type](@ref Stat_type) containing the statistics of the `values` component.
129 real(RKD) :: overhead = 0._RKD
130 real(RKD) :: min = -huge(0._RKD)
131 real(RKD) :: max = -huge(0._RKD)
132 real(RKD) :: std = -huge(0._RKD)
133 real(RKD) :: mean = -huge(0._RKD)
134 !real(RKD) :: median = -huge(0._RKD) !< @public The median of the timing vector of the benchmark (in seconds).
135 !real(RKD) :: skewness = -huge(0._RKD) !< @public The skewness of the timing vector of the benchmark.
136 !real(RKD) :: kurtosis = -huge(0._RKD) !< @public The kurtosis of the timing vector of the benchmark.
137 real(RKD) , allocatable :: values(:)
138 end type
139
140!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
201 real(RKD) :: minsec = 0.05_RKD
202 integer(IK) :: miniter = 1_IK
203 type(timing_type) :: timing
204 character(:, SK) , allocatable :: name
205 class(timer_type) , allocatable :: timer
209 end type
210
212 interface benchBase_type
213 module procedure :: benchBase_typer
214 end interface
216
217!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218
309 module function benchBase_typer(name, minsec, miniter, timer) result(benchBase)
310#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
311 !DEC$ ATTRIBUTES DLLEXPORT :: benchBase_typer
312#endif
313 use pm_kind, only: SK, IK, RKD
314 use pm_timer, only: timer_type
315 character(*, SK) , intent(in) :: name
316 real(RKD) , intent(in) , optional :: minsec
317 integer(IK) , intent(in) , optional :: miniter
318 class(timer_type) , intent(in) , optional :: timer
319 type(benchBase_type) :: benchBase
320 end function
321 end interface
322
323!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
324
386 type, extends(benchBase_type) :: bench_type
387 !logical(LK) , private :: isdone = .false._LK !< \private The scalar `logical` of default kind \LK that is set to `.true.` once the benchmark is over (used internally to finalize the pointer components of the type).
388 procedure(exec_proc), pointer, nopass, private :: exec => null()
390 procedure(exec_proc), pointer, nopass, private :: overhead => null()
393 contains
394 final :: finalizeBench
395 procedure, pass :: getTiming => getTimingMethod
396 procedure, pass :: setTiming => setTimingMethod
397 end type
398
400 interface bench_type
401 module procedure :: bench_typer
402 end interface
404
405!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406
498 interface bench_typer
499 module function bench_typer(name, exec, overhead, minsec, miniter, timer) result(bench)
500#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
501 !DEC$ ATTRIBUTES DLLEXPORT :: bench_typer
502#endif
503 use pm_timer, only: timer_type
504 character(*, SK) , intent(in) :: name
505 procedure(exec_proc) :: exec
506 procedure(exec_proc) , optional :: overhead
507 real(RKD) , intent(in), optional :: minsec
508 integer(IK) , intent(in), optional :: miniter
509 class(timer_type) , intent(in), optional :: timer
510 type(bench_type) :: bench
511 end function
512 end interface
513
514!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
515
574 interface getTiming
575 module function getTimingMethod(self, minsec, miniter) result(timing)
576#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
577 !DEC$ ATTRIBUTES DLLEXPORT :: getTimingMethod
578#endif
579 use pm_kind, only: IK, RKD
580 class(bench_type) , intent(inout) :: self
581 integer(IK) , intent(in) , optional :: miniter
582 real(RKD) , intent(in) , optional :: minsec
583 type(timing_type) :: timing
584 end function
585 end interface
586
587!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588
643 interface setTiming
644 module subroutine setTimingMethod(self, minsec, miniter)
645#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
646 !DEC$ ATTRIBUTES DLLEXPORT :: setTimingMethod
647#endif
648 use pm_kind, only: IK, RKD
649 class(bench_type) , intent(inout) :: self
650 integer(IK) , intent(in) , optional :: miniter
651 real(RKD) , intent(in) , optional :: minsec
652 !RUN_TIMING(self%timing)
653 end subroutine
654 end interface
655
656!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657
658 !!> \brief
659 !!> This is the base class for creating objects that hold the timing information of multiple benchmark objects and the timing statistics.
660 !!>
661 !!> \remark
662 !!> This type should generally not be explicitly used outside the [pm_bench](@ref pm_bench).<br>
663 !!> It merely serves to create the `timing` component of the [benchMulti_type](@ref benchMulti_type) class below.<br>
664 !!>
665 !!> \see
666 !!> [benchMulti_type](@ref pm_bench::benchMulti_type)<br>
667 !!> [timerDAT_type](@ref pm_timer::timerDAT_type)<br>
668 !!> [timerMPI_type](@ref pm_timer::timerMPI_type)<br>
669 !!> [timerOMP_type](@ref pm_timer::timerOMP_type)<br>
670 !!> [timerSYS_type](@ref pm_timer::timerSYS_type)<br>
671 !!> [timer_type](@ref pm_timer::timer_type)<br>
672 !!>
673 !!> \test
674 !!> [test_pm_bench](@ref test_pm_bench)
675 !!>
676 !!> \final{timing_type}
677 !!>
678 !!> \author
679 !!> Amir Shahmoradi, Wednesday 4:13 AM, August 13, 2016, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin<br>
680 !type :: timing_type
681 ! real(RKD) :: overhead = 0._RKD !< \public The average timing overhead in units of seconds.
682 ! real(RKD) :: min = -huge(0._RKD) !< \public The minimum of the timing vector of the benchmark (in seconds).
683 ! real(RKD) :: max = -huge(0._RKD) !< \public The maximum of the timing vector of the benchmark (in seconds).
684 ! real(RKD) :: std = -huge(0._RKD) !< \public The standard deviation of the timing vector of the benchmark (in seconds).
685 ! real(RKD) :: mean = -huge(0._RKD) !< \public The mean of the timing vector of the benchmark (in seconds).
686 ! !real(RKD) :: median = -huge(0._RKD) !< \public The median of the timing vector of the benchmark (in seconds).
687 ! !real(RKD) :: skewness = -huge(0._RKD) !< \public The skewness of the timing vector of the benchmark.
688 ! !real(RKD) :: kurtosis = -huge(0._RKD) !< \public The kurtosis of the timing vector of the benchmark.
689 ! type(container) , allocatable :: case(:) !< \public The matrix of timing results in units of seconds, corrected by the average overhead time.
690 !end type
691
692!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693
736 integer(IK) :: ncase
738 character(:, SK) , allocatable :: name
740 type(bench_type) , allocatable :: case(:)
742 !type(timing_type) :: timing !< The object of type [timing_type](@ref pm_bench::timing_type) containing
743 ! !! the timing information and statistics of the benchmark.
744 contains
745 procedure, pass :: showsum => showsum_
746 end type
747
748 interface benchMulti_type
749 module procedure :: benchMulti_typer
750 end interface
751
752!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
753
816 module function benchMulti_typer(case, sorted, repeat) result(self)
817#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
818 !DEC$ ATTRIBUTES DLLEXPORT :: benchMulti_typer
819#endif
820 use pm_kind, only: IK, LK
821 type(benchMulti_type) :: self
822 type(bench_type) , intent(in), contiguous :: case(:)
823 logical(LK) , intent(in), optional :: sorted
824 integer(IK) , intent(in), optional :: repeat
825 end function
826 end interface
827
828!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829
873 interface showsum
874 module subroutine showsum_(self, unit, tabular)
875#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
876 !DEC$ ATTRIBUTES DLLEXPORT :: showsum_
877#endif
878 class(benchMulti_type) , intent(in) :: self
879 integer(IK) , intent(in), optional :: unit
880 logical(LK) , intent(in), optional :: tabular
881 end subroutine
882 end interface
883
884contains
885
886!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
887
888 subroutine finalizeBench(self)
889#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
890 !DEC$ ATTRIBUTES DLLEXPORT :: finalizeBench
891#endif
892 type(bench_type), intent(inout) :: self
893 !if (self%isdone) then
894 nullify(self%overhead)
895 nullify(self%exec)
896 !end if
897 end subroutine
898
899!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
900
922 impure subroutine doNothing()
923#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
924 !DEC$ ATTRIBUTES DLLEXPORT :: doNothing
925#endif
926 end subroutine
927
928!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
929
930end module pm_bench ! LCOV_EXCL_LINE
Construct and return an object of type benchBase_type.
Definition: pm_bench.F90:308
Construct, perform multiple benchmarking, and return the multiple benchmarking results as an object o...
Definition: pm_bench.F90:815
Construct and return an object of type bench_type.
Definition: pm_bench.F90:498
This is the abstract interface of the exec static type-bound procedure pointer component of bench_typ...
Definition: pm_bench.F90:70
Generate and return an object of type timing_type containing the benchmark timing information and sta...
Definition: pm_bench.F90:574
Time the user-specified procedure wrapper in the parent object of type bench_type and store the outpu...
Definition: pm_bench.F90:643
Time the user-specified procedure wrappers in the case vector component of the parent object of type ...
Definition: pm_bench.F90:873
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
Definition: pm_bench.F90:41
subroutine finalizeBench(self)
Definition: pm_bench.F90:889
impure subroutine doNothing()
Take nothing, do nothing, and return nothing.
Definition: pm_bench.F90:923
character(*, SK), parameter MODULE_NAME
Definition: pm_bench.F90:57
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64-bit real kind.
Definition: pm_kind.F90:568
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This module contains the timer procedures and derived types to facilitate timing applications at runt...
Definition: pm_timer.F90:99
This is the base class for creating low-level benchmark objects.
Definition: pm_bench.F90:200
This is the class for creating object to perform multiple benchmarks and performance-profiling.
Definition: pm_bench.F90:735
This is the class for creating benchmark and performance-profiling objects.
Definition: pm_bench.F90:386
This is the base class for creating objects that hold the timing information of a benchmark and the t...
Definition: pm_bench.F90:127
This is the timerMPI_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:377
This is the timerMPI_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:433
This is the timerSYS_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:502
This is the abstract base derived type that serves as a simple container template for other timer cla...
Definition: pm_timer.F90:212