Max <
maxt...@gmx.net> wrote:
> On 28.09.22 22:49, Chris M. Thomasson wrote:
>> Experimentally creating some "random" numbers from a multi-threaded race
>> condition. Is this post on topic?
It is closer to on topic than scam posts about blank cards for get rich
quick schemes. :)
> If it runs on your system why wouldn't it run on mine?
Indeed, it should, provided the same C++ compiler (and a compatible
version) was used. Using a different one from the one Chris used (or a
different version) may or may not make one's mileage vary.
> Haven't tried it, yet. A short explanation what exactly you're
> measuring would be nice (i.e. how many threads, what task).
Yes. (This next sentence is for Chris): Instead of a blob of C++, with
only one comment, how about an explanation of the algorithm you are
implementing, how you think it works, and why you think it works?
> As the race conditions may come out biased, keep in mind to use the
> von Neumann method to convert the output to unbiased randomness
>
https://mcnp.lanl.gov/pdf_files/nbs_vonneumann.pdf (tl;dr check
> double-bits, discard 00 and 11 and use 01 for 0 and 10 for 1).
Also, given that it is 'race condition' based, and 'threads' based
(which is about all the detail Chris has provided) it also probably has
a very big failure mode: single CPU systems.
Now, granted, in 2022, single CPU systems are way less common than they
used to be, but in a single CPU system, the 'race' will be synchronized
to the task switch frequency used by the host OS. Which likely will
introduce either non-randomness, or quite significant bias.
And, in a multi-cpu system, if the host OS happens, for some reason, to
schedule the threads of this task all on the same CPU, the end result
would be identical to running it on a single CPU system.