Skip to content

Speed up randint array-bounds via chunking Lemire - #173

Open
vlad-perevezentsev wants to merge 2 commits into
masterfrom
chunk-randint-broadcast-words
Open

Speed up randint array-bounds via chunking Lemire#173
vlad-perevezentsev wants to merge 2 commits into
masterfrom
chunk-randint-broadcast-words

Conversation

@vlad-perevezentsev

Copy link
Copy Markdown
Collaborator

This PR implements the word-generation speedup suggested for randint array-like bounds in the #168 (comment)

It changes irk_rand_bounded_broadcast to:

  • consume MKL words in cache-sized chunks instead of one full-length pass, avoiding a memory round-trip over the whole array;
  • drop the unpredictable lo < s branch in the Lemire loop (t < s always so lo < t already implies lo < s) and memoize the reject threshold per range.

Performance (Intel(R) Xeon(R) Platinum 8480+)

(low=0, high=1e9):

Size (N) dtype Before After Speedup
5,000,000 int32 52.00 ms 31.44 ms 1.65x
5,000,000 int64 48.82 ms 35.53 ms 1.37x
50,000,000 int32 642.91 ms 428.80 ms 1.50x
50,000,000 int64 602.30 ms 466.51 ms 1.29x

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.

1 participant