Logo by AGUS - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. April 24, 2024, 04:07:04 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: rdrand cpu instruction  (Read 2269 times)
0 Members and 1 Guest are viewing this topic.
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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

Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #1 on: November 13, 2015, 07:16:47 PM »

  Read about it on wikipedia.. cheesy   

  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


WWW
« Reply #2 on: November 13, 2015, 07:48:17 PM »

Yes i don't care about crypto security in my code  grin

I ran some test, RDRAND is slower than a fast PRNG  angry
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #3 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/

Logged

ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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  embarrass
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #5 on: November 26, 2015, 04:31:28 PM »

UPDAAAAAATE \o/

When using multiple threads, it's faster smiley
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
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?
wink
Logged

No sweat, guardian of wisdom!
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #7 on: November 26, 2015, 07:54:18 PM »

lolz, why would this upset me? cheesy 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 tongue stuck out

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
Fractal Schemer
****
Posts: 1075



WWW
« 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


WWW
« 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

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
Roquen
Iterator
*
Posts: 180


« Reply #10 on: December 14, 2015, 03:38:19 PM »

When using multiple threads, it's faster smiley
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

All code submitted by me is in the public domain. (http://unlicense.org/)
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
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

All code submitted by me is in the public domain. (http://unlicense.org/)
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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)

Code:
; 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

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Under Divine Instruction Mandelbulb3D Gallery CO99A5 0 914 Last post April 11, 2015, 03:04:56 AM
by CO99A5
shader function or instruction cost (performance) Programming « 1 2 » TruthSerum 19 25102 Last post June 15, 2015, 05:48:17 PM
by TruthSerum

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.18 seconds with 24 queries. (Pretty URLs adds 0.01s, 2q)