mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yann Droneaud" <ydroneaud@opteya.com>
To: "Eric Biggers" <ebiggers@kernel.org>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	sneves@dei.uc.pt
Subject: Re: [PATCH] random: use rejection sampling for uniform bounded random integers
Date: Mon, 17 Oct 2022 20:39:41 +0000	[thread overview]
Message-ID: <e50884573b0f88ebd1f5b495476c13f28a5f0aa2@opteya.com> (raw)
In-Reply-To: <Y02ehdiCtHyLErB8@sol.localdomain>

Hi, 

17 octobre 2022 à 20:27 "Eric Biggers" a écrit:
> On Sun, Oct 16, 2022 at 08:37:53PM -0600, Jason A. Donenfeld wrote:
> 
> > 
> > In order to be efficient, we implement a kernel-specific variant of
> >  Daniel Lemire's algorithm from "Fast Random Integer Generation in an
> >  Interval", linked below. The kernel's variant takes advantage of
> >  constant folding to avoid divisions entirely in the vast majority of
> >  cases, works on both 32-bit and 64-bit architectures, and requests a
> >  minimal amount of bytes from the RNG.
> >  
> >  Link: https://arxiv.org/pdf/1805.10941.pdf
> > 
> 

> Thanks for doing this! Your code looks correct, but it was hard for me to
> understand until I read the paper that is linked to. 

Other algorithms exists that might be easier to understand before the Lemire’s one.
M.E. O’Neil has written a long blog post on many possible alternatives.

https://www.pcg-random.org/posts/bounded-rands.html

Regards.

—- 
Yann Droneaud
OPTEYA

      parent reply	other threads:[~2022-10-17 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17  2:37 Jason A. Donenfeld
2022-10-17 18:27 ` Eric Biggers
2022-10-18  5:31   ` Jason A. Donenfeld
2022-10-18  7:04     ` Eric Biggers
2022-10-18 17:34       ` [PATCH v2] " Jason A. Donenfeld
2022-10-17 20:39 ` Yann Droneaud [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e50884573b0f88ebd1f5b495476c13f28a5f0aa2@opteya.com \
    --to=ydroneaud@opteya.com \
    --cc=Jason@zx2c4.com \
    --cc=ebiggers@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sneves@dei.uc.pt \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®