Skip to content

Feature egspp xoshiro256pp - #1433

Open
mainegra wants to merge 1 commit into
developfrom
feature-egspp-xoshiro256pp
Open

Feature egspp xoshiro256pp#1433
mainegra wants to merge 1 commit into
developfrom
feature-egspp-xoshiro256pp

Conversation

@mainegra

@mainegra mainegra commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

● Add xoshiro256++ RNG to egs++ library

Summary

  • Adds EGS_Xoshiro256pp class to egs_rndm.cpp implementing the xoshiro256++ generator (Blackman & Vigna, 2019)
  • Adds virtual EGS_I64 getUInt64() to the EGS_RandomGenerator base class (returns 0 by default, enabling safe fallback in user code)
  • Activated via type = xoshiro256++ in the rng definition input block

Generator properties

Property Value
State 256-bit (4 × uint64_t), period 2²⁵⁶ − 1
Seeding SplitMix64 expansion from two integer seeds
Parallel streams jump() skips 2¹²⁸ states per sequence step — provably non-overlapping
Standard output fillArray(): 53-bit doubles, τ_max ≈ 36.7 mfp
Extended output getUInt64(): raw 64-bit integer, τ_max ≈ 44.4 mfp
State persistence storePrivateState / setPrivateState.egsdat compatible

The getUInt64() method is intended for free-path sampling: the caller computes
dpmfp = -log((double)(uint64_t)r) + 64·ln2. User codes whose RNG does not support
this method receive the base-class return value of 0 and can fall back to the standard
-log(1 − U) path.

Motivation

The high-resolution RANMAR (48-bit, τ_max ≈ 33.3 mfp) produces an artifact in
deep-penetration calculations: photon interaction sites are capped at τ_max, potentially creating a non-physical drop in depth-dose and buildup-factor curves. xoshiro256++ extends the reliable range and provides a
higher-quality generator with better-characterised parallel-stream properties than
RANMAR's seed-increment approach.

Usage: Place the following block in the input file

 :start rng definition:
      type = xoshiro256++
      initial seeds = 1802 9373
  :stop rng definition:

Test plan

  • Confirm type = xoshiro256++ accepted in input without error
  • Confirm ranmar behaviour unchanged (default RNG and defaultRNG() untouched)
  • Run existing regression tests with xoshiro256++ and verify results agree with ranmar within statistics
  • Confirm .egsdat state round-trip (store → restore → identical subsequent output)
  • Confirm parallel jobs produce non-overlapping streams

Implements the Blackman & Vigna xoshiro256++ generator (2019) as
EGS_Xoshiro256pp, a new concrete EGS_RandomGenerator subclass.

- Period 2^256-1; parallel streams separated by 2^128 states via jump(),
  giving provably non-overlapping sequences for parallel jobs
- fillArray() produces 53-bit doubles (tau_max = 53*ln2 ~ 36.7 mfp),
  compared to 24-bit (16.6 mfp) and 48-bit (33.3 mfp) for ranmar
- getUInt64() exposes the raw 64-bit integer output; callers can compute
  free paths as -log((double)r) + 64*log(2) for tau_max ~ 44.4 mfp
- Seeds expanded from two ints to 256-bit state via SplitMix64
- Full state serialization (storePrivateState/setPrivateState) wires into
  the existing .egsdat checkpoint/resume and parallel job combining paths
- Activated via 'type = xoshiro256++' in the rng definition input block

Motivated by deep-penetration artifacts in egs_kerma buildup factor
calculations traced to the 48-bit resolution limit of high-res ranmar.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mainegra
mainegra requested a review from a team as a code owner July 10, 2026 18:19
@mainegra
mainegra requested review from ftessier and rtownson and removed request for a team July 10, 2026 18:19
@rtownson
rtownson changed the base branch from master to develop July 10, 2026 18:24
@mainegra mainegra added this to the Release 2026 milestone Jul 10, 2026
@ftessier ftessier modified the milestones: Release 2026, Release 2027 Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants