From 14662b51ce218c6b60c0b2f3e69e2bf3eb4dc758 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 26 Feb 2021 14:18:14 -0800 Subject: [PATCH] ircd::rand: Add random distribution vector generation. --- include/ircd/rand.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/ircd/rand.h b/include/ircd/rand.h index 8259a32f9..f2eb89c5a 100644 --- a/include/ircd/rand.h +++ b/include/ircd/rand.h @@ -41,6 +41,11 @@ namespace ircd::rand template<> u256x1 vector() noexcept; template<> u512x1 vector() noexcept; + // Random vector over distribution + template + T vector(distribution &); + // Random fill of buffer const_buffer fill(const mutable_buffer &out) noexcept; @@ -98,6 +103,23 @@ noexcept return dict[pos]; } +template +inline T +ircd::rand::vector(distribution &dist) +{ + constexpr auto lanes + { + simd::lanes() + }; + + T ret; + for(unsigned i(0); i < lanes; ++i) + ret[i] = dist(mt); + + return ret; +} + inline ircd::rand::xoshiro256p::xoshiro256p() noexcept