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

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

Detailed Description

Construct and return an object of type benchBase_type.

This is the constructor of the type benchBase_type for creating objects that facilitate the benchmarking of arbitrary procedures.

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]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, default = 0.05 seconds)
[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, default = 1)
[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
benchBase : The output scalar object of type benchBase_type.


Possible calling interfaces

use pm_kind, only: SK, IK, RKD
use pm_timer, only: timer_type
type(benchBase_type) :: benchBase
character(:, SK) :: name
integer(IK) :: miniter
real(RKD) :: minsec
benchBase = benchBase_type(name, minsec = minsec, miniter = miniter, timer = timer_type())
benchBase = benchBase_type(name, minsec = minsec, miniter = miniter, timer = timerCPU_type())
benchBase = benchBase_type(name, minsec = minsec, miniter = miniter, timer = timerDAT_type())
benchBase = benchBase_type(name, minsec = minsec, miniter = miniter, timer = timerMPI_type())
benchBase = benchBase_type(name, minsec = minsec, miniter = miniter, timer = timerOMP_type())
benchBase = benchBase_type(name, 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 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
Remarks
See also benchBase_type for possible calling interfaces.
Note that the timing of the user-specified procedure wrapper is performed until both conditions related to minsec and miniter are satisfied.
In other words, the timing is performed for at least minsec seconds and at least miniter number of iterations.
The default values for these two variables are are set so that the benchmark typically ends within 50 ms, unless the runtime of the user-specified procedure is longer than 50 ms.
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
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_bench, only: benchBase_type
6 use pm_timer, only: timerCPU_type
7 use pm_timer, only: timerDAT_type
8 use pm_timer, only: timerSYS_type
9
10 implicit none
11
12 type(benchBase_type) :: benchBase
13 real(RKD) :: unifrnd
14 real(RKD) :: sumTime = 0._RKD
15 real(RKD) :: sumUnif = 0._RKD
16 integer :: i
17
18 type(display_type) :: disp
19 disp = display_type(file = "main.out.F90")
20
21 call disp%skip()
22 call disp%show("benchBase = benchBase_type(name = SK_'random_number')")
23 benchBase = benchBase_type(name = SK_'random_number')
24 call showTimerComponents()
25 call disp%skip()
26
27 call disp%skip()
28 call disp%show("allocate(benchBase%timing%values(1000))")
29 call disp%show("do i = 1, 1000")
30 call disp%show(" benchBase%timer%start = benchBase%timer%time()")
31 call disp%show(" call random_number(unifrnd)")
32 call disp%show(" benchBase%timing%values(i) = benchBase%timer%time(since = benchBase%timer%start)")
33 call disp%show(" sumTime = sumTime + benchBase%timing%values(i)")
34 call disp%show(" if (sumTime > benchBase%minsec) exit")
35 call disp%show(" sumUnif = sumUnif + unifrnd")
36 call disp%show("end do")
37 allocate(benchBase%timing%values(1000))
38 do i = 1, 1000
39 benchBase%timer%start = benchBase%timer%time()
40 call random_number(unifrnd)
41 benchBase%timing%values(i) = benchBase%timer%time(since = benchBase%timer%start)
42 sumTime = sumTime + benchBase%timing%values(i)
43 if (sumTime > benchBase%minsec) exit
44 sumUnif = sumUnif + unifrnd
45 end do
46 call disp%show("sum(benchBase%timing%values) / size(benchBase%timing%values)")
47 call disp%show( sum(benchBase%timing%values) / size(benchBase%timing%values) )
48 call disp%skip()
49
50contains
51
52 impure subroutine showTimerComponents()
53 call disp%show("benchBase%name")
54 call disp%show( benchBase%name , deliml = SK_"""" )
55 call disp%show("benchBase%minsec")
56 call disp%show( benchBase%minsec )
57 call disp%show("benchBase%miniter")
58 call disp%show( benchBase%miniter )
59 end subroutine
60
61end program example
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
2benchBase = benchBase_type(name = SK_'random_number')
3benchBase%name
4"random_number"
5benchBase%minsec
6+0.50000000000000003E-1
7benchBase%miniter
8+1
9
10
11allocate(benchBase%timing%values(1000))
12do i = 1, 1000
13 benchBase%timer%start = benchBase%timer%time()
14 call random_number(unifrnd)
15 benchBase%timing%values(i) = benchBase%timer%time(since = benchBase%timer%start)
16 sumTime = sumTime + benchBase%timing%values(i)
17 if (sumTime > benchBase%minsec) exit
18 sumUnif = sumUnif + unifrnd
19end do
20sum(benchBase%timing%values) / size(benchBase%timing%values)
21+0.27419533580541612E-7
22
23
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 308 of file pm_bench.F90.


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