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

Construct and return an object of type bench_type. More...

Detailed Description

Construct and return an object of type bench_type.

This is the constructor of the type bench_type for creating objects to perform benchmarking of the user-specified procedures within the user-provided wrapper function.

Parameters
[in]name: The input scalar character of arbitrary length of default kind SK, containing the benchmark name (typically the name of the procedure to be timed).
[in]exec: The input procedure pointer with the abstract interface exec_proc pointing to the user-defined wrapper procedure that calls the arbitrary procedure to be timed.
[in]overhead: The input procedure pointer with the abstract interface exec_proc pointing to a user-defined wrapper procedure that calls everything executed within wrapper procedure exec(), except the call to the procedure that is being timed.
This procedure pointer will be used to measure the overhead due to calling or executing any non-relevant statements within the wrapper procedure exec().
(optional. If missing, then a default empty wrapper procedure will be used to compute the overhead.
Note the default overhead is likely optimized away in production builds of the library, effectively yielding zero overhead.)
[in]minsec: The input scalar of type real of kind double precision RKD representing the minimum time in units of seconds that the overall benchmark should last.
(optional. The default is set by the constructor of the superclass benchBase_type.)
[in]miniter: The input scalar of type integer of default kind IK representing the minimum number of timing the user-specified wrapper procedure repeatedly.
(optional. The default is set by the constructor of the superclass benchBase_type.)
[in]timer: The input object of abstract class timer_type representing the benchmark timer.
This object can be one of the available timers in pm_timer:
  1. timerCPU_type,
  2. timerDAT_type,
  3. timerMPI_type,
  4. timerOMP_type,
  5. timerSYS_type,
or any other user-defined subclass of the abstract timer_type class.
(optional, default = timer_type)
Returns
bench : The output scalar object of type bench_type.


Possible calling interfaces

use pm_kind, only: SK, IK, RKD
use pm_timer, only: timer_type
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 = timer_type())
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
This is the abstract base derived type that serves as a simple container template for other timer cla...
Definition: pm_timer.F90:212
Note
If the specified benchmark routine is to be called certain number of times, set minsec = 0. and miniter to desired number of times the routine must be timed.
See also
benchBase_type
benchMulti_type
timerDAT_type
timerMPI_type
timerOMP_type
timerSYS_type
timer_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

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.22604502138542149E-6
12bench%timing%std
13+0.68037835551224595E-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.20747135432595663E-6
17bench%timing%std
18+0.43650225530541366E-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.92292511819425713E-7
32bench%timing%std
33+0.40737882127251760E-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 Austin

Definition at line 498 of file pm_bench.F90.


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