Title: rdrand cpu instruction Post by: ker2x on November 13, 2015, 05:37:26 PM Friendly greetings !
Anyone studied/used the RDRAND Intel Instruction ? https://software.intel.com/sites/default/files/m/d/4/1/d/8/441_Intel_R__DRNG_Software_Implementation_Guide_final_Aug7.pdf Title: Re: rdrand cpu instruction Post by: M Benesi on November 13, 2015, 07:16:47 PM Read about it on wikipedia.. :D
There were some issues with its lack of randomness for encryption purposes, although for fractal purposes it should be fine. rdrand byte ptr ... stores a "random" 16 bit value in the memory location given rdrand word ptr.... stores a "random" 32 bit value in the memory location given Title: Re: rdrand cpu instruction Post by: ker2x on November 13, 2015, 07:48:17 PM Yes i don't care about crypto security in my code ;D
I ran some test, RDRAND is slower than a fast PRNG :angry: Title: Re: rdrand cpu instruction Post by: M Benesi on November 13, 2015, 08:02:49 PM That is weird. Or maybe not.
Search (<ctrl>-<f> find in Firefox) for "3.4.1" in: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide/ Title: Re: rdrand cpu instruction Post by: ker2x on November 13, 2015, 09:24:54 PM I'm computing a buddhabrot.
Calling RDRAND 3x make my code 2x slower. It's a major bottleneck. Avoid it :embarrass: Title: Re: rdrand cpu instruction Post by: ker2x on November 26, 2015, 04:31:28 PM UPDAAAAAATE \o/
When using multiple threads, it's faster :) Title: Re: rdrand cpu instruction Post by: DarkBeam on November 26, 2015, 06:23:02 PM Trying to upset Lyc?
;) Title: Re: rdrand cpu instruction Post by: lycium on November 26, 2015, 07:54:18 PM lolz, why would this upset me? :D has my willingness to speak out on controversial matters made me regarded as easily upset? i smoke way too much weed to be an uptight person, i assure you :P
on topic though, i have to admit i was reading this thread, scratching my head wondering why not just use a fast, high quality PRNG. but to each their own, i imagine it must "feel good" to use real random numbers, something i wouldn't mind trying myself for fun sometime (since i also have a haswell cpu). that multiple threads makes RNG faster is a bit surprising; either they have one RNG per core, or it's simply making the surrounding code faster. Title: Re: rdrand cpu instruction Post by: M Benesi on November 27, 2015, 07:52:34 PM They get into describing the timing of the on chip RNG in the article I provided a link for:
"3.4.1 RDRAND Performance† In current-generation Intel processors the DRBG runs on a self-timed circuit clocked at 800 MHz and can service a RDRAND transaction (1 Tx) every 8 clocks for a maximum of 100 MTx per second. A transaction can be for a 16-, 32-, or 64-bit RDRAND, and the greatest throughput is achieved with 64-bit RDRANDs, capping the throughput ceiling at 800 MB/sec. These limits are an upper bound on all hardware threads across all cores on the CPU. Single thread performance is limited by the instruction latencies imposed by the bus infrastructure, which is also impacted in part by clock speed. On real-world systems, a single thread executing RDRAND continuously may see throughputs ranging from 70 to 200 MB/sec, depending on the SPU architecture....." Title: Re: rdrand cpu instruction Post by: ker2x on December 05, 2015, 08:13:46 AM Exactly, latency vs bandwidth.
Anyway. Why use rdrand ? Because i play a lot with ASM, so yes : for fun. Title: Re: rdrand cpu instruction Post by: Roquen on December 14, 2015, 03:38:19 PM When using multiple threads, it's faster :) An instance of a PRNG should never be shared across threads...well extend that to any data that's written to by any thread.Title: Re: rdrand cpu instruction Post by: ker2x on January 07, 2016, 10:16:05 AM An instance of a PRNG should never be shared across threads...well extend that to any data that's written to by any thread. what's an instance of a prng in the context of rdrand ? Title: Re: rdrand cpu instruction Post by: Roquen on February 19, 2016, 02:06:06 PM That comment was for software PRNGs (sharing is the problem) . WRT the opcode, I think the latency is very long..something over 200 cycles.
Title: Re: rdrand cpu instruction Post by: ker2x on September 06, 2016, 08:28:00 AM A little update : I still use RDRAND. My little code. It's PureBasic code with inline ASM. I don't mind using C/C++ but Purebasic generate clean ASM code and it's super easy to inline ASM. So whenever i want to have fun with ASM i use PureBasic. And the language isn't bad, i would recommend it for both beginner and intermediate coder. (i don't know about advanced coder, i'm not one of them) Code: ; Generate a random number |