This is a simple memory benchmarking tool that makes an array of pseudorandom numbers and sorts them using an execution policy. The length and policy are specified by the user.
ParallelMemoryBenchmark is an outgrowth of a program meant to reproduce a vexing system stability problem. It is not really well-suited to use as a general-purpose benchmark.
However, it remains interesting as a demonstration of C++ parallel execution policies and as a limited benchmark of them in sorting.
This software is licensed under 0BSD.
See LICENSE
.
64-bit builds are recommended.
Release builds (that is, building with optimizations turned on and debug symbols not emitted) are highly recommended. This is because the timings are of only slight interest otherwise, and completely irrelevant for comparison purposes.
Library dependencies are resolved with
vcpkg
, which is set up as a
submodule.
See building.md
for build instructions.
The most basic usage is to run pmb
specifying only the length of the
array—that is, the number of integers to sort. For example, to sort a billion
integers:
./pmb 1000000000
Output looks like this:
length: 1000000000 elements (~3814 MiB)
seed: 1824255722 (generated by the system)
sort mode: std::execution::par (parallelize)
Allocating/zeroing... Done. (1296 ms)
Generating... Done. (3491 ms)
Hashing... 7c99ae86. (220 ms)
Sorting... Done. (15077 ms)
Rehashing... 7c99ae86, same. (253 ms)
Checking... sorted. (608 ms)
Test completed in about 21.3 seconds (21320 ms).
Passing --help
prints a message that includes a description of all options.
The other currently available options are:
-l [ --length ] arg specify how many elements to generate and sort
-s [ --seed ] arg custom seed for PRNG (omit to use system entropy)
-2 [ --twice ] after sorting, sort again (may test adaptivity)
-t [ --time ] display human-readable start time
-S [ --seq ] don't try to parallelize
-P [ --par ] try to parallelize (default)
-U [ --par-unseq ] try to parallelize, may migrate thread and vectorize
Of special importance are the options --seq
, --par
, and --par-unseq
, which
specify the policy execution. By default, as shown above, it is as if --par
were passed. These options correspond to
execution_policy_tag_t
policies.
ParallelMemoryBenchmark is written by Eliah Kagan and David Vassallo.
The -2
/--twice
feature is due to a suggestion by Godfrey Vassallo, who
pointed out that it would be interesting to compare the performance of the
original sorting operation with a second sorting operation, carried out
immediately thereafter on the just-sorted elements.