Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer overflow in lattice RNG #167

Closed
jc-harrison opened this issue May 31, 2018 · 1 comment
Closed

Integer overflow in lattice RNG #167

jc-harrison opened this issue May 31, 2018 · 1 comment

Comments

@jc-harrison
Copy link
Contributor

I have found a bug which appears for large lattices when using a fast-discard RNG.

In lib/lattice/Lattice_rng.h (lines 149-167) we have:

static void Skip(RngEngine &eng,uint64_t site)
    {
      uint64_t skip = site;
      skip = skip<<40;
      eng.discard(skip);
    }

If site >= 2^24 then skip<<40 gives an overflow, so the (2^24+n)th site gets an identical random sequence to the nth site.

@paboyle
Copy link
Owner

paboyle commented Jun 4, 2018

Patch committed to develop; underlying problem is the ".discard(uint64_t) " interface does not have
enough bits for all possible lattice calculations.

Compromised; the earlier 40 bit shift was (erroneously) conservative about the number of randoms in a quenched evolution and compromised the volume too much.

Note that 5D fields are even worse.

After our call today, we concluded 30 bits (1 billion draws per site) is enough for all except some rare quenched evolutions.

Hence I moved the develop branch to shift=30,
inserted an assert to check for overflow in the 64 bit

((site << shift)>>shift) == site

@paboyle paboyle closed this as completed Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants