Loading...
Searching...
No Matches
runner Module Reference

Inherits runner_options.

Definition

Provides properties and instance methods for the execution a benchmarking run. The runner class extends the base class runner_options .

Examples

The following examples demonstrate some of the main members of the runner.
The first example shows a simple benchmark of the methods foo and bar passing two Dummy arguments. This example make use of the preprocessing macros found in the include file benchmark.inc.

#include <benchmark.inc>
use rhofunc
use benchmark_library
implicit none
type(runner) :: br
!calling using preprocessor macro
benchmark(br, run(1.0d-6, 30, foo))
benchmark(br, run(1.0d-6, 30, bar))
read(*,*)


The second example demonstrates how the benchmarking options can be serialized to disk and loaded for later use. The options are saved as namelist on disk.

use benchmark_kinds
use benchmark_library
type(runner) :: br
type(runner) :: br2
logical :: exists
integer :: lu
br%maxcalls = 10
br%csv_unit = -10
br%mintime = 50_r8
br%maxtime = 100_r8
br%offset = 20.0_r8
br%sampling_window = 10
br%ssd_threshold = 0.025_r8
call br%write('benchmark.nml')
inquire(file='benchmark.nml', exist=exists)
if (exists) then
call br2%read('benchmark.nml')
end if


The third example demonstarte how functions can be passed using the iso_c_binbing module. The address of the procedure is first obtained using c_funloc and then casted into an implicit procedure using c_f_procpointer.

type(runner) :: br
type(c_funptr) :: cfunptr
procedure(), pointer :: f
cfunptr = c_funloc(compute_pi)
call c_f_procpointer(cfunptr, f)
benchmark(br, run(10000000, f))
benchmark(br, run(100000000, f))
benchmark(br, run(200000000, f))
f => null()

Remarks

Note
This class is best used together with the include file benchmark.inc.
Warning
Due to a bug (?) in gfortran, functions cannot be passed as argument using implicit procedure(). This means that benchmarking only works for subroutines with gfortran. PROCEDURE() with no type or interface name is supposed to work as a dummy procedure or procedure pointer that can handle either a function or a subroutine, so long as it isn't referenced. Many compilers assume that it means a subroutine, or just can't deal with it. (more info)

Definition at line 55 of file Benchmark.f90.


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

Variables

type(output), public unit
 Output unit. By default the standard output is used.
 
integer, public maxcalls = 100000000
 Maximum number of function calls.
 
integer, public csv_unit = 0
 Integer designating the logical output unit for csv results. Null value corresponds to unset value.
 
real(r8), public mintime = 100.0_r8
 Minimum sampling time in ms to collect data.
 
real(r8), public maxtime = 100000.0_r8
 Maximum sampling time in ms to collect data.
 
real(r8), public overhead = 0.0_r8
 Time overhead corresponding to the surounding methods calls.
 
integer, public sampling_window = 20
 Integer option to adjust the size of the sampling window.
 
real(r8), public ssd_threshold = 0.05_r8
 Acceptance threshold for the steady-state detection.
 
logical, public skip_prelude = .false.
 Logical flag. If set to .true., only the benchmarking step will be performed.
 
character(200), public name = ''
 String name.
 

Static Public Attributes

procedure(), pointer, nopass caller => null()
 Caller wrapper procedure.
 

Methods

◆ dispose()

procedure, pass, public dispose ( class(runner), intent(inout) this)

Dispose resources associated with The type bound to the method.

Parameters
[in,out]thisThe type bound to the method

Remarks

Definition at line 99 of file Benchmark.f90.

◆ read()

procedure, pass, public read ( class(runner), intent(inout) this,
character(*), intent(in) path )

Read runner options from namelist.

Example

use benchmark_kinds
use benchmark_library
type(runner) :: br
call br2%read('benchmark.nml')

Remarks

Definition at line 98 of file Benchmark.f90.

◆ run() [1/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
class(*), intent(in) a6,
class(*), intent(in) a7,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
[in]a2Dummy argument
[in]a3Dummy argument
[in]a4Dummy argument
[in]a5Dummy argument
[in]a6Dummy argument
[in]a7Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [2/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
class(*), intent(in) a6,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
[in]a2Dummy argument
[in]a3Dummy argument
[in]a4Dummy argument
[in]a5Dummy argument
[in]a6Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1', 'a2', 'a3', 'a4', 'a5', 'a6')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [3/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
[in]a2Dummy argument
[in]a3Dummy argument
[in]a4Dummy argument
[in]a5Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1', 'a2', 'a3', 'a4', 'a5')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [4/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
[in]a2Dummy argument
[in]a3Dummy argument
[in]a4Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1', 'a2', 'a3', 'a4')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [5/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
[in]a2Dummy argument
[in]a3Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1', 'a2', 'a3')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [6/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
[in]a2Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1', 'a2')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [7/8]

generic, public run ( class(runner), intent(inout) this,
class(*), intent(in) a1,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
[in]a1Dummy argument
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run('a1')

Remarks

Definition at line 89 of file Benchmark.f90.

◆ run() [8/8]

generic, public run ( class(runner), intent(inout) this,
procedure() f )

Bound procedure to run the benchmark.

Parameters
[in]thisThe type bound to the method
fThe procedure to benchmark

Examples

type(runner) :: br
call br%run()

Remarks

Definition at line 89 of file Benchmark.f90.

◆ set_caller()

procedure, pass, public set_caller ( class(runner), intent(inout) this,
procedure() caller )

Set the function caller to wrap function call.

Parameters
[in]thisThe type bound to the method
callerFunction wrapper

Examples The following example demonstrate how to use the caller wrapper. By doing so, one can enforce a specific interface to the procedure argument. This is especially handy when benchmarking functions or requiring inout and out intents

type(runner) :: br
call br%set_caller(foo)

Where foo is defined as follows.

subroutine foo(f, a)
procedure(foo_x) :: f
type(string), intent(in) :: a
block
character(len(a)) :: res
res = f(a%chars)
end block
end subroutine

With the following interface

interface
pure function foo_x(str) result(res)
character(*), intent(in) :: str
character(len(str)) :: res
end function
end interface

Remarks

Definition at line 80 of file Benchmark.f90.

◆ write()

procedure, pass, public write ( class(runner), intent(inout) this,
character(*), intent(in) path )

Write runner options to namelist.

Example

use benchmark_kinds
use benchmark_library
type(runner) :: br
integer :: lu
br%maxcalls = 10
br%csv_unit = -10
br%mintime = 50_r8
br%maxtime = 100_r8
br%sampling_window = 10
br%ssd_threshold = 0.025_r8
call br%write('benchmark.nml')

The output file is a namelist. It looks as follows

&config
bench%MAXCALLS=10 ,
bench%CSV_UNIT=-10 ,
bench%MINTIME= 50.000000000000000 ,
bench%MAXTIME= 100.00000000000000 ,
bench%SAMPLING_WINDOW=10 ,
bench%SSD_THRESHOLD= 2.5000000000000001e-002,
bench%SKIP_PRELUDE=f,
bench%COUNT=0 ,
bench%NAME=',

Remarks

Definition at line 97 of file Benchmark.f90.

Finalizer

◆ finalize()

final finalize ( type(runner), intent(inout) this)
final

Definition at line 100 of file Benchmark.f90.