ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_bench::bench_type Type Reference

This is the class for creating benchmark and performance-profiling objects. More...

Inheritance diagram for pm_bench::bench_type:
Collaboration diagram for pm_bench::bench_type:

Public Member Functions

procedure, pass getTiming => getTimingMethod
 The generic method name pointing to function getTimingMethod be called by the user to initiate the timing of the wrapper for procedure of interest. More...
 
procedure, pass setTiming => setTimingMethod
 The generic method name pointing to subroutine setTimingMethod be called by the user to initiate the timing of the wrapper for procedure of interest. More...
 

Public Attributes

procedure(exec_proc), pointer, nopass overhead => null()
 Procedure Pointer to the (user-provided) overhead wrapper with explicit interface exec_proc. The overhead wrapper is used to measure the overhead of the exec wrapper component besides the cost of calling the wrapped procedure with the exec wrapper component. More...
 
- Public Attributes inherited from pm_bench::benchBase_type
real(RKD) minsec = 0.05_RKD
 The minimum time in units of seconds that the benchmark should last. It could take longer, but not less than minsec. More...
 
integer(IK) miniter = 1_IK
 The minimum number of timing of the user-specified wrapper procedure. It could run more, but not fewer than miniter. More...
 
type(timing_typetiming
 The object of type timing_type containing the timing information and statistics of the benchmark. More...
 
character(:, SK), allocatable name
 The name of the procedure to be timed. More...
 
class(timer_type), allocatable timer
 The allocatable component of abstract class timer_type used for internal timing.
Public access to this component provided is provided solely for the convenience of the user when access to a timer is needed.
Otherwise, it not meant to be directly accessed or manipulated.
The concrete type of this class component is set by the user at runtime depending on their choice of timer.
More...
 

Detailed Description

This is the class for creating benchmark and performance-profiling objects.

This type has two public methods both of which accomplish the same task of timing the user-specified procedure wrapper.
However, one (getTiming) has a function interface where the output of the method can be clearly specified, while the other (setTiming) has a subroutine interface where the output of the timing is implicitly assigned to the timing component of the parent object of type bench_type.
The former has an explicit clear calling syntax.
The latter has a more concise syntax with potentially faster runtime performance (which is likely irrelevant in almost all practical scenarios).

See also the constructor of this type.


Possible calling interfaces

use pm_kind, only: SK, IK, RKD
type(bench_type) :: bench
character(:, SK) :: name
integer(IK) :: miniter
real(RKD) :: minsec
benchBase = bench_type(name, exec, overhead = overhead, minsec = minsec, miniter = miniter, timer = timerCPU_type())
benchBase = bench_type(name, exec, overhead = overhead, minsec = minsec, miniter = miniter, timer = timerDAT_type())
benchBase = bench_type(name, exec, overhead = overhead, minsec = minsec, miniter = miniter, timer = timerMPI_type())
benchBase = bench_type(name, exec, overhead = overhead, minsec = minsec, miniter = miniter, timer = timerOMP_type())
benchBase = bench_type(name, exec, overhead = overhead, minsec = minsec, miniter = miniter, timer = timerSYS_type())
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
Definition: pm_bench.F90:41
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
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 benchmark and performance-profiling objects.
Definition: pm_bench.F90:386
This is the timerCPU_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:271
This is the timerDAT_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:322
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
See also
benchMulti_type
benchBase_type
timing_type
bench_type
timer_type
timerDAT_type
timerMPI_type
timerOMP_type
timerSYS_type


Example usage

1program example
2
3 use pm_kind, only: IK, LK, SK, RKD
4 use pm_io, only: display_type
5 use pm_timer, only: timerCPU_type
6 use pm_timer, only: timerDAT_type
7 use pm_timer, only: timerSYS_type
8 use pm_bench, only: bench_type
9
10 implicit none
11
12 type(bench_type) :: bench
13 real(RKD) :: unifrnd
14 real(RKD) :: unifsum = 0._RKD ! dummy calculation to prevent aggressive compiler optimizations.
15
16 type(display_type) :: disp
17 disp = display_type(file = "main.out.F90")
18
19 call disp%skip()
20 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
21 call disp%show("!Benchmark the uniform random number generation.")
22 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
23 call disp%skip()
24
25 call disp%skip()
26 call disp%show("subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end")
27 call disp%show("bench = bench_type(name = SK_'random_number', exec = wrapper)")
28 bench = bench_type(name = SK_'random_number', exec = wrapper)
29 call disp%show("bench%timing = bench%getTiming() ! same as below")
30 bench%timing = bench%getTiming()
31 call disp%show("bench%timing%mean")
32 call disp%show( bench%timing%mean )
33 call disp%show("bench%timing%std")
34 call disp%show( bench%timing%std )
35 call disp%show("call bench%setTiming(minsec = 0.1_RKD) ! same as above but with a non-default minimum overall repetitive timing for 0.1 seconds.")
36 call bench%setTiming(minsec = 0.1_RKD)
37 call disp%show("bench%timing%mean")
38 call disp%show( bench%timing%mean )
39 call disp%show("bench%timing%std")
40 call disp%show( bench%timing%std )
41 call disp%skip()
42
43 call disp%skip()
44 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
45 call disp%show("!Benchmark the uniform random number generation while excluding the overhead of redundant operations.")
46 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
47 call disp%skip()
48
49 call disp%skip()
50 call disp%show("subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end")
51 call disp%show("subroutine overhead(); unifsum = unifsum + unifrnd; end")
52 call disp%show("bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead)")
53 bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead)
54 call disp%show("bench%timing = bench%getTiming() ! same as below")
55 bench%timing = bench%getTiming()
56 call disp%show("bench%timing%mean")
57 call disp%show( bench%timing%mean )
58 call disp%show("bench%timing%std")
59 call disp%show( bench%timing%std )
60 call disp%show("bench%timer%resol")
61 call disp%show( bench%timer%resol )
62 call disp%skip()
63
64 call disp%skip()
65 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
66 call disp%show("!Benchmark the uniform random number generation while excluding the overhead of redundant operations using a non-default CPU timer.")
67 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
68 call disp%skip()
69
70 call disp%skip()
71 call disp%show("subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end")
72 call disp%show("subroutine overhead(); unifsum = unifsum + unifrnd; end")
73 call disp%show("bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead, timer = timerCPU_type())")
74 bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead, timer = timerCPU_type())
75 call disp%show("bench%timing = bench%getTiming() ! same as below")
76 bench%timing = bench%getTiming()
77 call disp%show("bench%timing%mean")
78 call disp%show( bench%timing%mean )
79 call disp%show("bench%timing%std")
80 call disp%show( bench%timing%std )
81 call disp%show("bench%timer%resol")
82 call disp%show( bench%timer%resol )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
87 call disp%show("!Benchmark the uniform random number generation while excluding the overhead of redundant operations using a non-default date_and_time() timer.")
88 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
89 call disp%skip()
90
91 call disp%skip()
92 call disp%show("subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end")
93 call disp%show("subroutine overhead(); unifsum = unifsum + unifrnd; end")
94 call disp%show("bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead, timer = timerDAT_type())")
95 bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead, timer = timerDAT_type())
96 call disp%show("bench%timing = bench%getTiming() ! same as below")
97 bench%timing = bench%getTiming()
98 call disp%show("bench%timing%mean")
99 call disp%show( bench%timing%mean )
100 call disp%show("bench%timing%std")
101 call disp%show( bench%timing%std )
102 call disp%show("bench%timer%resol")
103 call disp%show( bench%timer%resol )
104 call disp%skip()
105
106contains
107
108 impure subroutine showTimerComponents()
109 call disp%show("bench%name")
110 call disp%show( bench%name , deliml = SK_"""" )
111 call disp%show("bench%minsec")
112 call disp%show( bench%minsec )
113 call disp%show("bench%miniter")
114 call disp%show( bench%miniter )
115 end
116
117 subroutine wrapper()
118 call random_number(unifrnd)
119 unifsum = unifsum + unifrnd
120 end
121
122 subroutine overhead()
123 unifsum = unifsum + unifrnd
124 end
125
126end program example
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
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
Generate and return an object of type display_type.
Definition: pm_io.F90:10282
subroutine bench(sort, arraySize)

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!Benchmark the uniform random number generation.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end
8bench = bench_type(name = SK_'random_number', exec = wrapper)
9bench%timing = bench%getTiming() ! same as below
10bench%timing%mean
11+0.66193291502516973E-7
12bench%timing%std
13+0.40616561412735004E-6
14call bench%setTiming(minsec = 0.1_RKD) ! same as above but with a non-default minimum overall repetitive timing for 0.1 seconds.
15bench%timing%mean
16+0.67673793269174873E-7
17bench%timing%std
18+0.24452389383915063E-6
19
20
21!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22!Benchmark the uniform random number generation while excluding the overhead of redundant operations.
23!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24
25
26subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end
27subroutine overhead(); unifsum = unifsum + unifrnd; end
28bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead)
29bench%timing = bench%getTiming() ! same as below
30bench%timing%mean
31+0.53278598053064465E-7
32bench%timing%std
33+0.34007175818398098E-6
34bench%timer%resol
35+0.10000000000000001E-8
36
37
38!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39!Benchmark the uniform random number generation while excluding the overhead of redundant operations using a non-default CPU timer.
40!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41
42
43subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end
44subroutine overhead(); unifsum = unifsum + unifrnd; end
45bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead, timer = timerCPU_type())
46bench%timing = bench%getTiming() ! same as below
47bench%timing%mean
48+0.10000000000287557E-5
49bench%timing%std
50+0.10000000000287557E-5
51bench%timer%resol
52+0.10000000000287557E-5
53
54
55!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56!Benchmark the uniform random number generation while excluding the overhead of redundant operations using a non-default date_and_time() timer.
57!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58
59
60subroutine wrapper(); call random_number(unifrnd); unifsum = unifsum + unifrnd; end
61subroutine overhead(); unifsum = unifsum + unifrnd; end
62bench = bench_type(name = SK_'random_number', exec = wrapper, overhead = overhead, timer = timerDAT_type())
63bench%timing = bench%getTiming() ! same as below
64bench%timing%mean
65+0.10000000000000007E-2
66bench%timing%std
67+0.10000000000000000E-2
68bench%timer%resol
69+0.10000000000000000E-2
70
71
Test:
test_pm_bench


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Wednesday 4:13 AM, August 13, 2016, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 386 of file pm_bench.F90.

Member Function/Subroutine Documentation

◆ getTiming()

procedure, pass pm_bench::bench_type::getTiming

The generic method name pointing to function getTimingMethod be called by the user to initiate the timing of the wrapper for procedure of interest.

Definition at line 395 of file pm_bench.F90.

◆ setTiming()

procedure, pass pm_bench::bench_type::setTiming

The generic method name pointing to subroutine setTimingMethod be called by the user to initiate the timing of the wrapper for procedure of interest.

Definition at line 396 of file pm_bench.F90.

Member Data Documentation

◆ overhead

procedure(exec_proc), pointer, nopass pm_bench::bench_type::overhead => null()

Procedure Pointer to the (user-provided) overhead wrapper with explicit interface exec_proc. The overhead wrapper is used to measure the overhead of the exec wrapper component besides the cost of calling the wrapped procedure with the exec wrapper component.

Definition at line 390 of file pm_bench.F90.


The documentation for this type was generated from the following file: