Random Number Testing and RDM Random numbers are particularly important for the Radioactive Decay Module Sampling decay times is important for a number of use cases: nuclear physics: e.g. looking for rare processes, summing effects Medical physics: very large data sets (current application has 500MBq and simulated for 10's of seconds) → critical is the background (scattering, energy pile-up) and random contribution (events overlapping) Repetition and more significantly granularity are crucial Computation time also has an impact – the RDM can be quite heavy (e.g. beta decay) so the efficiency of the random number generation is correlated RDM mini-workshop 22nd March 2016
Random Number Testing Create random numbers in a flat distribution: Unit test: RNG.flat() Unit test: G4UniformRand() G4UniformRand() inside an application Time distribution of decay window biased particles from RDM Outputs: Measure time for 1000000000 trials Determine time interval between events (granularity) Record created times (1s interval) Sort in increasing times Plot the distribution of time intervals between events (necessary requirement for random event pile-up studies) PRNGs tested: Ranecu Ranlux Ranshi Ranlux64 Mersenne Twist MixMax Geant4-10.2-ref02 RDM mini-workshop 22nd March 2016
Times from Trial Test (laptop/ubuntu) Generator Sequential flat() /s G4UniformRand() Multithreaded Ranecu 11.68 15.19 9.68 15.04 Ranlux 130.62 142.55 95.18 115.59 Ranshi 8.71 7.13 7.4 12.71 Ranlux64 114.58 116.81 128.29 147.53 MTwist 6.91 32.23 21.27 10.79 MixMax 10.26 11.3 7.56 15.09 RDM mini-workshop 22nd March 2016
Times from Trial Test (cluster/RHEL) Generator Sequential flat() /s G4UniformRand() Multithreaded Ranecu 10.51 13.56 10.82 18.08 Ranlux 70.79 76.27 73.82 88.58 Ranshi 5.39 7.98 5.64 11.36 Ranlux64 83.2 88.1 91.01 96.14 MTwist 6.94 10.24 8.0 11.3 MixMax 8.66 12.6 10.56 13.88 RDM mini-workshop 22nd March 2016
Application Test Create positrons with a uniform (flat) timing distribution – across 1s Sequential RDM mini-workshop 22nd March 2016
ST: 100k G4UniformRand() - Ranecu RDM mini-workshop 22nd March 2016
ST: 100k G4UniformRand() - Ranlux RDM mini-workshop 22nd March 2016
ST: 100k G4UniformRand() - Ranshi RDM mini-workshop 22nd March 2016
ST: 100k G4UniformRand() - Ranlux64 RDM mini-workshop 22nd March 2016
ST: 100k G4UniformRand() - MTwist RDM mini-workshop 22nd March 2016
ST: 100k G4UniformRand() - MixMax RDM mini-workshop 22nd March 2016
Application Test Create positrons with a uniform (flat) timing distribution – across 1s Multi threaded (4 threads) RDM mini-workshop 22nd March 2016
MT: 100k G4UniformRand() - Ranecu RDM mini-workshop 22nd March 2016
MT: 100k G4UniformRand() - Ranlux RDM mini-workshop 22nd March 2016
MT: 100k G4UniformRand() - Ranshi RDM mini-workshop 22nd March 2016
MT: What's happened to Ranshi The time is somehow limited to ~2200000000 (signed 32-bit) – bit loss? RDM mini-workshop 22nd March 2016
MT: 100k G4UniformRand() - Ranlux64 RDM mini-workshop 22nd March 2016
MT: 100k G4UniformRand() - MTwist RDM mini-workshop 22nd March 2016
MT: 100k G4UniformRand() - MixMax Super slow – race condition? RDM mini-workshop 22nd March 2016
Profiling? Gprof and kcachegrind both seem to indicate minimal impact/differences between mixmax and ranecu Threadlock hazard blocking mixmax? RDM mini-workshop 22nd March 2016
Application Test Create positrons with a uniform (flat) timing distribution – across 1s Multi threaded, but with only ONE thread RDM mini-workshop 22nd March 2016
MT1: 100k G4UniformRand() - Ranecu RDM mini-workshop 22nd March 2016
MT1: 100k G4UniformRand() - Ranlux RDM mini-workshop 22nd March 2016
MT1: 100k G4UniformRand() - Ranshi RDM mini-workshop 22nd March 2016
MT1: What's happened to Ranshi? The time is somehow limited to ~2200000000 (signed 32-bit) – bit loss? RDM mini-workshop 22nd March 2016
MT1: 100k G4UniformRand() - Ranlux64 RDM mini-workshop 22nd March 2016
MT1: 100k G4UniformRand() - MTwist RDM mini-workshop 22nd March 2016
MT1: 100k G4UniformRand() - MixMax Super slow – race condition? RDM mini-workshop 22nd March 2016
Radioactive Decay Time Window Set decay time window to 1s Record the decay time of 22Na RDM should use G4UniformRand() across the time window and weighted by the half-life Essentially flat for 22Na (>2 year half-life) RDM mini-workshop 22nd March 2016
RDM Test Sequential RDM mini-workshop 22nd March 2016
ST: 100k RDM (22Na decay) - Ranecu RDM mini-workshop 22nd March 2016
ST: 100k RDM (22Na decay) - Ranlux RDM mini-workshop 22nd March 2016
ST: 100k RDM (22Na decay) - Ranshi RDM mini-workshop 22nd March 2016
ST: 100k RDM (22Na decay) - Ranlux64 RDM mini-workshop 22nd March 2016
ST: 100k RDM (22Na decay) - MTwist RDM mini-workshop 22nd March 2016
ST: 100k RDM (22Na decay) - MixMax RDM mini-workshop 22nd March 2016
RDM Test Multi Threaded RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - Ranecu RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - Ranlux RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - Ranshi RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - Ranlux64 RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - MTwist RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - MixMax RDM mini-workshop 22nd March 2016
RDM Test Multi Threaded, but with only ONE thread RDM mini-workshop 22nd March 2016
MT: 100k RDM (22Na decay) - Ranlux64 RDM mini-workshop 22nd March 2016
MT1: 100k RDM (22Na decay) - Ranlux64 RDM mini-workshop 22nd March 2016
Times from RDM (laptop/ubuntu) Generator Sequential positron /s 22Na Multithreaded 1 Multithreaded Ranecu 27.8 34.5 48.4 (69.7s) [gprof: 5m17] 32.9 Ranlux 31.1 58.0 37.5 (93.3s) [gprof: 7m10) 38.6 Ranshi 30.7 51.1 18.9 (29.65s) [gprof: 42.7s] 11.8 Ranlux64 31.6 60.1 44.4 (114.6s) [gprof: 7m2s] 55.5 MTwist 26.4 56.5 37.3 (75.7s) [gprof: 7m22s] 30.6 MixMax 28.6 46.2 17m12.3 (62m28.5s) [gprof: 945m28s] 31m57 MT: 22Na similar behaviour, except MixMax – real 43m, user: 54m RDM mini-workshop 22nd March 2016
Times from RDM (cluster/RHEL) Generator Sequential positron /s Single Threaded 22Na Multithreaded 1 Multithreaded Ranecu 46.1 2m34.3 (4m38s) 44.6 Ranlux 40.4 2m26.6 (4m43s) 49.0 Ranshi 40.2 2m21.7 (3m44s) 16.7 Ranlux64 43.2 2m28.5 (4m39s) 49.2 MTwist 38.7 2m27.2 (4m35s) 42.3 MixMax 40.0 3m25.1 (45m11s)!!! 27m30.4 RDM mini-workshop 22nd March 2016
RDM Biasing Options For PET: A common use case is to have an activity (Bq) and not be interested in decay time GATE “recommends” modifying the PDG lifetime This (previous external) hack now requires modifying Geant4 source The RDM biasing fixes this, however, needs work – default is flat-branching ratios (feature) and daughters are not decayed (bug) RDM mini-workshop 22nd March 2016
GATE “fix” RDM mini-workshop 22nd March 2016
RDM mini-workshop 22nd March 2016
Summary The issues with random numbers and MT and RDM are still present – no surprise we didn't change anything.... With new PRNGs (mixmax) there seem to be other problems with race conditions More investigation needed Biasing options could be more user friendly (as previously self-proposed) RDM mini-workshop 22nd March 2016