Page 1 of 1
Creating indipendent random numbers on each core

Posted:
Mon Aug 18, 2014 2:21 pm
by isk
Re: Creating indipendendt random numbers on each core

Posted:
Tue Aug 19, 2014 10:20 am
by notzed
Check the binary and linker script to ensure that each has core it's own copy of the various state variables?
Personally I would just find something simple (and small) and good enough for the task and just include the code in your build instead. I needed one for some gpu/OpenCL code and found something suitable on the net with a quick search; can't remember which right now though.
Re: Creating indipendent random numbers on each core

Posted:
Wed Aug 20, 2014 11:21 am
by isk
Re: Creating indipendent random numbers on each core

Posted:
Wed Aug 20, 2014 12:24 pm
by notzed
You'll almost certainly save memory by not using the C library because it wasn't designed for size but for standards compliance and portability. There is no shared library mechanism so you wont save a single byte by using a C library function over a replacement either - everything needs to be linked in statically. If you're talking about putting the C library into the shared memory (quite likely the root cause of your problem, as below) then you can also do that with any code you write yourself. It's just up to the linker script and sections you use. But it comes at such a performance penalty it should only be used for code that is very rarely executed.
On your last point thats why you search for someone who has done it already (like knuth) and use theirs? Do you even know if the one in the C library is any "good" or are you just going on trust? If you needed a particularly good PRNG you would have to validate the C library anyway.
As far as I know (but i could be wrong), right now the C library is simply broken if you put any writable storage into the shared memory area because for a given program they will all use the same linked C library instance (and variables). Last time I looked (IIRC, some time ago) the C library itself just isn't built with any support for multi-threading whatsoever. It works fine if every core has it's own private copy because then it isn't physically multi-threading.
Re: Creating indipendent random numbers on each core

Posted:
Wed Aug 20, 2014 1:51 pm
by isk
Thank you. I was not aware that the standard library is placed in the external memory. Placing it in
the internal memory reduces the available memory considerably. Thus the only solution seems to use my own code.