Question about machine dependency of ULong_t

Hi,

In ATLAS, we need to generate a unique set of bootstrap weights (random weights with Poisson mean of 1) in a way that will generate the same set of weights for the same events (same run number, same event number and the same MC identifier in case of MC simulated events). One of the requirements is that the procedure has to be machine independent. We plan to use TRandom3 for the random number generation by setting proper seed per event, as the documentation says the random numbers are machine independent. However, what is not clear to us is if the SetSeed function is machine independent? The question is related to the definition of unsigned long types, see: Fundamental types - cppreference.com - it seems the size of this type depends on the data model and is NOT machine independent, is this correct?

To give bit more details, we plan to use the FNV hash (see: Fowler–Noll–Vo hash function - Wikipedia) to merge the three numbers: run number, event number and MC ID number into a single unsigned long hash that can be passed as a seed. However, we are not sure if this will make the procedure machine independent. Can you, please, let us know if this procedure is correct to keep the results machine independent or we need to update it?

The actual ATLAS implementation can be found in this merge request: CPAlgorithms: common bootstrapping algorithm (!66346) · Merge requests · atlas / athena · GitLab

Cheers,
Tomas

All I can tell is that on Windows for example, the size of Long_t is always 32 bit, no matter on which architecture (32 or 64 bit). Maybe @Axel can give his thoughts for other platforms

Thank you for the reply. On my linux machine the size of unsigned long is 64 bits, same as unsigned long long. That is why it is not clear to us how to set the seed in this case to make it machine independent.

Hello,

If you want to generate unique sequences of random numbers based on unique seeds of 64 bits, you should use a 64 bit generator. TRandom3 is a 32 bits generator, and only 32 bits are used buy the value passed in SetSeed. It is tru ULong_t is not portable, but only 32 bits are used, therefore even on machine where ULong_t is 64 bits only 32 are used. Therefore the TRandom3::SetSeed function is machine independent. However I would not recommend it to use for your use-case.
We have much better generators for this use case, such as Ranlux++. I would suggest you to use directly the class ROOT::Math::RanluxppEngine2048, which has a SetSeed function taking a uint64_t as input. This generator also guarantees that given unique seeds you will get unique sequences of random numbers

Best regards

Lorenzo

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.