Skip to content

Remove the per-element staging buffer in the BRNG fallback - #178

Open
vlad-perevezentsev wants to merge 3 commits into
update_randint_untypedfrom
refactor-uniform-bits-vec
Open

vlad-perevezentsev wants to merge 3 commits into
update_randint_untypedfrom
refactor-uniform-bits-vec

Conversation

@vlad-perevezentsev

Copy link
Copy Markdown
Collaborator

This PR proposes two changes to irk_uniform_bits_vec, neither of which alters generated values.

  • The viRngUniform fallback taken by WH, MCG31, R250 and MRG32K3A assembles 16-bit halves in a 4096-entry stack tile instead of an mkl_malloc buffer of 8 or 16 bytes per element. That allocation was also unchecked in release builds, where assert compiles out, so a large request could crash instead of raising.
  • The two overloads become one template on the word type, so the MKL_INT / 2 count cap of viRngUniformBits64 no longer lives in a copy of its own, far from the 32-bit limit it is contrasted with

For randint(0, 2**64, size=2**30 + 4096) on WH, peak memory drops from 24.05 to 8.05 GiB and time from 12.6 to 5.6 s, matching the native path in memory. Generation is also 1.6–3x faster for 4M–16M elements on all four BRNGs, and unchanged below that.

@ndgrigorian ndgrigorian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this does what I mentioned in the recent review comment on that PR, no?

@antonwolfy antonwolfy added this to the 1.6.0 release milestone Sep 25, 2026

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

3 participants