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

This is the base class for creating low-level benchmark objects. More...

Inheritance diagram for pm_bench::benchBase_type:

Public Attributes

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 base class for creating low-level benchmark objects.

See also the constructor of this type.


Possible calling interfaces

use pm_kind, only: SK, IK, RKD
type(benchBase_type) :: benchBase
character(:, SK) :: name
integer(IK) :: miniter
real(RKD) :: minsec
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
Remarks
See benchBase_typer for the non-default constructor of this type.
Note
Although it is possible, this type is not meant to be directly used for benchmarking.
Instead, use the child class bench_type which greatly simplifies benchmarking.
See also
bench_type
benchBase_typer (constructor of the 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_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 200 of file pm_bench.F90.

Member Data Documentation

◆ miniter

integer(IK) pm_bench::benchBase_type::miniter = 1_IK

The minimum number of timing of the user-specified wrapper procedure. It could run more, but not fewer than miniter.

Definition at line 202 of file pm_bench.F90.

◆ minsec

real(RKD) pm_bench::benchBase_type::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.

Definition at line 201 of file pm_bench.F90.

◆ name

character(:, SK), allocatable pm_bench::benchBase_type::name

The name of the procedure to be timed.

Definition at line 204 of file pm_bench.F90.

◆ timer

class(timer_type), allocatable pm_bench::benchBase_type::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.

Definition at line 205 of file pm_bench.F90.

◆ timing

type(timing_type) pm_bench::benchBase_type::timing

The object of type timing_type containing the timing information and statistics of the benchmark.

Definition at line 203 of file pm_bench.F90.


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