- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am used to old fashioned Fortran code where I saved the state of my random number generators by putting the current seed/state into a common block. Rather than run a bunch of tests, I would like to ask here how do I maintain persistance of the random number generators? I need to generate a large number of random numbers for Monte Carlo ray tracing, but the number of random numbers required for each ray is unknown ahead of time. In my legacy code, I just save the seed/state in a common block and call a random number generator from within the subroutine that makes the Monte Carlo decision and using the seed to get a new random number. Do the "streams" need to be maintained in a common block or passed through my chains of subroutine arguments in order to maintain persistance and independence of the random numbers?
Thanks very much!
Thanks very much!
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
VSLhas functions vslsavestreamf/vslloadstreamf for storing/restoring descriptive data of random stream to and from binary files. They may be very useful in time consuming Monte Carlo simulations.
You also might want to use vslcopystream (or vslcopystreamstate) functions to store copy of the random stream (or its state) in memory.
More details about storing/restoring random streams are available in MKL Manual and VSL Notes. I do not have all details regarding to your application; however, it appears that it is not required to hold random stream in a common block to maintain persistence as library service functionality mentioned above helps to do this.
Does it answer your question?
Thanks,
Andrey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page