Commit d4e801a9 authored by Christoph Conrads's avatar Christoph Conrads

Update AWC vs SWB benchmark

parent 1e885c18
......@@ -17,22 +17,36 @@
namespace rlxt = ranlux_tools;
using awc16 =
rlxt::add_with_carry_engine<std::uint16_t, 16, 2, 9>;
using swc16 =
using awc16_base = rlxt::add_with_carry_engine<std::uint16_t, 16, 2, 9>;
using awc16 = std::discard_block_engine<awc16_base, 97, 9>;
using fast_awc16 = std::discard_block_engine<awc16_base, 23, 9>;
using swb16_base =
rlxt::subtract_with_borrow_engine<std::uint16_t, 16, 3, 11>;
using swb16 = std::discard_block_engine<swb16_base, 127, 11>;
using fast_swb16 = std::discard_block_engine<swb16_base, 37, 11>;
using awc32 =
rlxt::add_with_carry_engine<std::uint32_t, 32, 3, 16>;
using swc32 =
using awc32_base = rlxt::add_with_carry_engine<std::uint32_t, 32, 3, 16>;
using awc32 = std::discard_block_engine<awc32_base, 277, 16>;
using fast_awc32 = std::discard_block_engine<awc32_base, 71, 16>;
using swb32_base =
rlxt::subtract_with_borrow_engine<std::uint32_t, 32, 3, 17>;
using swb32 = std::discard_block_engine<swb32_base, 293, 17>;
using fast_swb32 = std::discard_block_engine<swb32_base, 73, 17>;
using swb64_base = rlxt::subtract_with_borrow_engine<std::uint64_t, 64, 62, 3>;
using swb64 = std::discard_block_engine<swb64_base, 1303, 62>;
using fast_swb64 = std::discard_block_engine<swb64_base, 331, 62>;
#if RANLUX_TOOLS_HAS_INT128
using swb64 =
// performance depends unfortunately on long lag and short lag
using swx64_base =
rlxt::subtract_with_borrow_engine<std::uint64_t, 64, 15, 2>;
using swc64 =
rlxt::subtract_with_borrow_engine<std::uint64_t, 64, 4, 26>;
#endif
int main()
......@@ -40,17 +54,34 @@ int main()
constexpr auto num_draws = std::uintmax_t{1000} * 1000u * 1000u;
std::printf(
"%-25s | %10s | %20s | %s\n",
"%-26s | %10s | %20s | %s\n",
"generator", "time(sec)", "throughput(byte/sec)", "dummy"
);
rlxt::run<rlxt::dummy_engine>(num_draws);
std::printf("\n");
rlxt::run<awc16_base>(num_draws);
rlxt::run<swb16_base>(num_draws);
rlxt::run<awc32_base>(num_draws);
rlxt::run<swb32_base>(num_draws);
rlxt::run<swb64_base>(num_draws);
rlxt::run<swx64_base>(num_draws);
std::printf("\n");
rlxt::run<fast_awc16>(num_draws);
rlxt::run<fast_swb16>(num_draws);
rlxt::run<fast_awc32>(num_draws);
rlxt::run<fast_swb32>(num_draws);
rlxt::run<fast_swb64>(num_draws);
std::printf("\n");
rlxt::run<awc16>(num_draws);
rlxt::run<swc16>(num_draws);
rlxt::run<swb16>(num_draws);
rlxt::run<awc32>(num_draws);
rlxt::run<swc32>(num_draws);
#if RANLUX_TOOLS_HAS_INT128
rlxt::run<swb32>(num_draws);
rlxt::run<swb64>(num_draws);
rlxt::run<swc64>(num_draws);
#endif
}
......@@ -66,7 +66,7 @@ std::string get_name(const xoshiro128plus&) { return "xoshiro128+"; }
template<typename T, std::size_t W, std::size_t S, std::size_t R>
std::string get_name(const add_with_carry_engine<T, W, S, R>&)
{
constexpr auto FORMAT = "AWC(2^%-2zu, %2zu, %1zu)";
constexpr auto FORMAT = "AWC(2^%-2zu, %2zu, %2zu)";
char buffer[80] = { 0 };
snprintf(buffer, sizeof(buffer), FORMAT, W, R, S);
......@@ -78,7 +78,7 @@ std::string get_name(const add_with_carry_engine<T, W, S, R>&)
template<typename T, std::size_t W, std::size_t P, std::size_t Q>
std::string get_name(const subtract_with_borrow_engine<T, W, P, Q>&)
{
constexpr auto FORMAT = "SWB(2^%-2zu, %2zu, %1zu)";
constexpr auto FORMAT = "SWB(2^%-2zu, %2zu, %2zu)";
char buffer[80] = { 0 };
snprintf(buffer, sizeof(buffer), FORMAT, W, P, Q);
......@@ -90,7 +90,7 @@ std::string get_name(const subtract_with_borrow_engine<T, W, P, Q>&)
template<typename T, std::size_t W, std::size_t S, std::size_t R>
std::string get_name(const std::subtract_with_carry_engine<T, W, S, R>&)
{
constexpr auto FORMAT = "SWC(2^%-2zu, %2zu, %1zu)";
constexpr auto FORMAT = "SWC(2^%-2zu, %2zu, %2zu)";
char buffer[80] = { 0 };
snprintf(buffer, sizeof(buffer), FORMAT, W, S, R);
......@@ -151,7 +151,7 @@ void run(std::uintmax_t num_draws)
auto dummy = std::uint16_t(gen());
std::printf(
"%-25s | %10ju | %20.2e | %hu\n",
"%-26s | %10ju | %20.2e | %hu\n",
name.c_str(), t_msec, bytes_per_msec, dummy
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment