This is the abstract
base derived type for defining variants of Xoshiro256** Uniform Random Number Generator derived types.
- See also
- rngu_type
splitmix64_type
xoshiro256ssg_type
xoshiro256ssw_type
getUnifRandStateSize
- Benchmarks:
Benchmark :: The runtime performance of intrinsic random_number()
vs. xoshiro256ssg_type vs. xoshiro256ssw_type. ⛓
11 integer(IK) :: i, j, fileUnit
12 integer(IK) ,
parameter :: NSIM
= 100000_IK
13 logical(LKG) :: dumm_LK
= .false._LKG
14 logical(LKG) :: rand_LK(NSIM)
15 integer(IKG) :: rand_IK(NSIM)
16 real(RKG) :: rand_RK(NSIM)
17 type(bench_type) ,
allocatable :: bench(:)
18 type(xoshiro256ssg_type) :: xoshiro256ssg
19 type(xoshiro256ssw_type) :: xoshiro256ssw
23 bench
= [
bench_type(name
= SK_
"random_number_LK", exec
= random_number_LK, overhead
= setOverhead_LK)
&
24 ,
bench_type(name
= SK_
"xoshiro256ssg_type_LK", exec
= xoshiro256ssg_type_LK, overhead
= setOverhead_LK)
&
25 ,
bench_type(name
= SK_
"xoshiro256ssw_type_LK", exec
= xoshiro256ssw_type_LK, overhead
= setOverhead_LK)
&
26 ,
bench_type(name
= SK_
"random_number_IK", exec
= random_number_IK, overhead
= setOverhead_LK)
&
27 ,
bench_type(name
= SK_
"xoshiro256ssg_type_IK", exec
= xoshiro256ssg_type_IK, overhead
= setOverhead_IK)
&
28 ,
bench_type(name
= SK_
"xoshiro256ssw_type_IK", exec
= xoshiro256ssw_type_IK, overhead
= setOverhead_IK)
&
29 ,
bench_type(name
= SK_
"random_number_RK", exec
= random_number_RK, overhead
= setOverhead_RK)
&
30 ,
bench_type(name
= SK_
"xoshiro256ssg_type_RK", exec
= xoshiro256ssg_type_RK, overhead
= setOverhead_RK)
&
31 ,
bench_type(name
= SK_
"xoshiro256ssw_type_RK", exec
= xoshiro256ssw_type_RK, overhead
= setOverhead_RK)
&
34 write(
*,
"(*(g0,:,' '))")
35 write(
*,
"(*(g0,:,' '))")
"xoshiro256ssg_type() vs. xoshiro256ssw_type()."
36 write(
*,
"(*(g0,:,' '))")
38 open(newunit
= fileUnit, file
= "main.out", status
= "replace")
40 write(fileUnit,
"(*(g0,:,','))") (bench(i)
%name, i
= 1,
size(bench))
44 do j
= 1,
minval([(
size(bench(i)
%timing
%values), i
= 1,
size(bench))])
45 write(fileUnit,
"(*(g0,:,','))") (bench(i)
%timing
%values(j)
/ NSIM, i
= 1,
size(bench))
47 write(
*,
"(*(g0,:,' '))")
57 subroutine setOverhead_LK()
61 subroutine setOverhead_IK()
65 subroutine setOverhead_RK()
69 subroutine getDummy_LK()
70 dumm_LK
= dumm_LK
.or. count(rand_LK)
== 0
73 subroutine getDummy_IK()
74 dumm_LK
= dumm_LK
.or. any(rand_IK
== 0_IKG)
77 subroutine getDummy_RK()
78 dumm_LK
= dumm_LK
.or. any(rand_RK
== 0._RKG)
81 subroutine random_number_LK()
91 subroutine xoshiro256ssg_type_LK()
96 subroutine xoshiro256ssw_type_LK()
102 subroutine random_number_IK()
107 subroutine xoshiro256ssg_type_IK()
112 subroutine xoshiro256ssw_type_IK()
118 subroutine random_number_RK()
123 subroutine xoshiro256ssg_type_RK()
128 subroutine xoshiro256ssw_type_RK()
Generate and return an object of type timing_type containing the benchmark timing information and sta...
Return a uniform random scalar or contiguous array of arbitrary rank of randomly uniformly distribute...
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
This module contains classes and procedures for computing various statistical quantities related to t...
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
This is the class for creating benchmark and performance-profiling objects.
This is the derived type for declaring and generating objects of type xoshiro256ssg_type containing a...
This is the derived type for declaring and generating objects of type xoshiro256ssw_type containing a...
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Postprocessing of the benchmark output ⛓
3import matplotlib.pyplot
as plt
8dirname = os.path.basename(os.getcwd())
12df = pd.read_csv(
"main.out", delimiter =
",")
13colnames = list(df.columns.values)
15df = pd.read_csv(
"main.out")
21ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
24for colname
in colnames:
25 plt.hist( np.log10(df[colname].values)
26 , histtype =
"stepfilled"
32plt.xticks(fontsize = fontsize)
33plt.yticks(fontsize = fontsize)
34ax.set_xlabel(
"$\log_{10}$ ( Runtime [ seconds ] )", fontsize = fontsize)
35ax.set_ylabel(
"Count", fontsize = fontsize)
40plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
41ax.tick_params(axis =
"y", which =
"minor")
42ax.tick_params(axis =
"x", which =
"minor")
50plt.savefig(
"benchmark." + dirname +
".runtime.png")
56ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
59for colname
in colnames[0:]:
60 plt.hist( np.log10(df[colname].values / df[colnames[0]].values)
61 , histtype =
"stepfilled"
66ax.legend ( colnames[1:]
72plt.xticks(fontsize = fontsize)
73plt.yticks(fontsize = fontsize)
74ax.set_title(
"Runtime Ratio Comparison. Lower means faster.\nLower than 1 means faster than {}().".format(colnames[0]), fontsize = fontsize)
75ax.set_xlabel(
r"$\log_{{10}}$ ( Runtime Ratio ) w.r.t. {}".format(colnames[0]), fontsize = fontsize)
76ax.set_ylabel(
"Count", fontsize = fontsize)
78plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
79ax.tick_params(axis =
"y", which =
"minor")
80ax.tick_params(axis =
"x", which =
"minor")
83plt.savefig(
"benchmark." + dirname +
".runtime.ratio.png")
Visualization of the benchmark output ⛓
Benchmark moral ⛓
- The xoshiro256ssg_type RNG greedily attempts to use as many randomly generated bits as possible in the output random values.
- The xoshiro256ssw_type RNG takes a wasteful approach of using at least one or more chunks of 64 randomly generated bits in the output random values.
- This fundamental difference between the two RNG types generally leads to faster random logical value generations with the greedy approach, because 64bits chunks translate to 64 logical values without updating the RNG state.
- However, the greedy approach leads to generally slower runtimes for real random value generation.
- Both greedy and wasteful RNGs appear to be much faster than the ParaMonte library wrappers for the implementations offered by GNU Fortran Compiler
gfortran
and Intel Classic Fortran Compiler ifort
.
- Moral: If your application requires many
logical
random number generations, use the greedy xoshiro256ssg_type RNG. Conversely, if your application requires a mixture of random number generations of various types and kinds, use the wasteful xoshiro256ssw_type RNG.
- Test:
- test_pm_distUnif
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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Fatemeh Bagheri, Wednesday 12:20 AM, October 13, 2021, Dallas, TX
Definition at line 2984 of file pm_distUnif.F90.