|
M Benesi
|
|
« Reply #1 on: November 13, 2015, 07:16:47 PM » |
|
Read about it on wikipedia.. 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
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #2 on: November 13, 2015, 07:48:17 PM » |
|
Yes i don't care about crypto security in my code I ran some test, RDRAND is slower than a fast PRNG
|
|
|
Logged
|
|
|
|
M Benesi
|
|
« Reply #3 on: November 13, 2015, 08:02:49 PM » |
|
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #4 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
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #5 on: November 26, 2015, 04:31:28 PM » |
|
UPDAAAAAATE \o/ When using multiple threads, it's faster
|
|
|
Logged
|
|
|
|
DarkBeam
Global Moderator
Fractal Senior
Posts: 2512
Fragments of the fractal -like the tip of it
|
|
« Reply #6 on: November 26, 2015, 06:23:02 PM » |
|
Trying to upset Lyc?
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
lycium
|
|
« Reply #7 on: November 26, 2015, 07:54:18 PM » |
|
lolz, why would this upset me? 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 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.
|
|
|
Logged
|
|
|
|
M Benesi
|
|
« Reply #8 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....."
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #9 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.
|
|
|
Logged
|
|
|
|
Roquen
Iterator
Posts: 180
|
|
« Reply #10 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.
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #11 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 ?
|
|
|
Logged
|
|
|
|
Roquen
Iterator
Posts: 180
|
|
« Reply #12 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.
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #13 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) ; Generate a random number Procedure.f mrdrand() Define r.f Define d.f = 536870911 Define two.f = 2 ; r = ((Random(2147483647)/(536870911)) - 2.0) ; ProcedureReturn r EnableASM ! RDRAND eax ! MOV dword [p.v_r], eax ! FILD dword [p.v_r] ! FDIV dword [p.v_d] ! FSUB dword [p.v_two] ! FST dword [p.v_d] ! MOV EAX, [p.v_d] DisableASM ProcedureReturn ;ProcedureReturn ((Random(2147483647)/(536870911)) - 2.0) EndProcedure
|
|
|
Logged
|
|
|
|
|