Repository navigation
Conversation
Mirror McCode's rng-gpu-mt-design header: _RNG_ALG_TINYMT 3 with a two-word uint64_t state. The generators live in McCode's runtime (mccode-r.c/.h), so this needs a runtime that provides them. KISS stays the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Similar to what I have on https://github.com/mccode-dev/McCode/tree/rng-gpu-mt-design. @g5t keeping this in draft, no reason to add until we've agreed IRL that this makes sense. (See slack chat on same topic.) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: depends on McCode's TinyMT64 runtime, which is not merged in McCode yet. It lives on branch
rng-gpu-mt-design(commit 69b18b803, "Add TinyMT64 as GPU-capable RNG_ALG=3"); the design and results are in RNG_GPU_DESIGN.md.What
This adds TinyMT64 (Saito & Matsumoto, BSD-3) as an opt-in random number generator,
RNG_ALG=3. It mirrors the header block in McCode'scogen.c.inon that branch: four lines inc_header.py, namely#define _RNG_ALG_TINYMT 3plus an#elifbranch withrandstate_t uint64_tandRANDSTATE_LEN 2.The generator functions (
tinymt64_srandom,tinymt64_random, ...) live in McCode's shared runtimemccode-r.c/mccode-r.h.in. mccode-antlr embeds that runtime from the libc registry, so it needs no copy of its own. Building with-DRNG_ALG=3needs a McCode runtime that includes TinyMT64.The default stays KISS. Results don't change unless
RNG_ALG=3is chosen.Relation to #392
#392 (porting McCode #2808's per-ray seeding) adds
RANDSTATE_LENfor MT/KISS and changes the particle struct torandstate[RANDSTATE_LEN]. This PR works without #392, because the current hard-codedrandstate[7]has room for TinyMT's 2 words. The two PRs touch neighbouring lines of the same#ifblock, so whichever lands second will hit a trivial merge conflict.Checks
pytestpasses.Test_RNG_rand01with this branch, using the runtime fromrng-gpu-mt-design(swapped in for the registry's runtime by a scratch script), then built it with-DRNG_ALG=3and ran-s 1000 Ncount=1000:_hash((pidx+1)*(seed+1)), the output differs from classic McCode, as it should: that branch uses #2808's seed._hash(_hash(seed) + cloop*gpu_innerloop + pidx)(what Port per-ray RNG seeding and _uid fix from McCode cogen (mccode-dev/McCode#2807) #392 ports), the md5 of the non-#lines ofrngout.datis753159792665dde568a61d3afd8e42ae. That is identical to classic McCode onrng-gpu-mt-design.main's only in the four header lines above, and the KISSrngout.datmd5 is identical for both.🤖 Generated with Claude Code