<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Random Number Generator State Info in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975934#M17090</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Well, you are very advanced and powerful user! Thanks for asking interesting questions. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;VSL do not provide direct access to the stream state data. This is because VSL has a number of basic generators, and each basic generator's state has different size, fields, etc. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Bad news is that MKLVSL currently do not provide routines to save/restore stream to a file. However, such a feature might be useful for Monte Carlo people since Monte Carlo simulation is basically takes a lot of time. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Good news is that you are able to get the size of the stream state, and try to store/restore data yourself. The &lt;FONT face="Courier New"&gt;vslGetBrngProperties&lt;/FONT&gt; routine is what you really need:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT face="Courier New"&gt;vslGetBrngProperties(brng,properties)&lt;/FONT&gt; - fills the fields of the structure &lt;FONT face="Courier New"&gt;properties&lt;/FONT&gt; with the data describing properties of the basic generator &lt;FONT face="Courier New"&gt;brng&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Among other fields the properties structure has the &lt;FONT face="Courier New"&gt;streamstatesize&lt;/FONT&gt; field (the first field in the structure, its size is 4 bytes). For further information I would recommend the Advanced Service Subroutines chapter of the MKL Reference Manual.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;To implement the save/restore to a file I would suggest the following scheme:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Perform the first run of a simulation.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Determine the size in bytes of the stream state structure.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Get access to the memory, where the stream state data is stored, and save this data to a file (you know number of bytes to store from Step 2).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Delete all streams and finish application.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;For the second run.&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Create new stream &lt;FONT face="Courier New"&gt;restored_stream&lt;/FONT&gt; by &lt;FONT face="Courier New"&gt;vslNewStream &lt;/FONT&gt;routine. The basic generator should be the same as in the first run. No matter which seed you will pass.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Before the second run you should determine the size of the stream state structure again, and load the stream state data from the file to the memory &lt;FONT face="Courier New"&gt;restored_stream&lt;/FONT&gt; points to.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;I would not recommend using restored stream state directly because there are some fields in the structure you saved to a f
ile, which are pointers to allocated memory (used internally by VSL in some cases). To avoid non-allocated memory access you should do following:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Create one more stream stream by &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt; function. No matter which seed you will pass, the only important is &lt;FONT face="Courier New"&gt;brng&lt;/FONT&gt; - should be the same as you saved/restored.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Use &lt;FONT face="Courier New"&gt;vslCopyStreamState&lt;/FONT&gt; to copy the state of &lt;FONT face="Courier New"&gt;restored_stream&lt;/FONT&gt; to the stream. This routine will copy only the stream state related information and will not copy pointers.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Perform second run.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Delete all streams.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;The main difficulty is in getting access to the stream state data you want to save/restore in FORTRAN. (It could be done very naturally in C). I have no nice idea how to do this. Let me explain in more details why.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Each instance of &lt;FONT face="Courier New"&gt;VSL_STREAM_STATE &lt;/FONT&gt;(i.e. the stream we want to save) has two 32-bit fields used internally to store address of the memory block allocated in &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt;, which is used to store stream state data. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT face="Courier New"&gt;TYPE VSL_STREAM_STATE&lt;BR /&gt; INTEGER*4 descriptor1&lt;/FONT&gt; - stores 32-bit address of the memory block used to store stream state information&lt;BR /&gt;&lt;FONT face="Courier New"&gt; INTEGER*4 descriptor2&lt;/FONT&gt; - stores higher 32-bits of the address (for 64-bit systems)&lt;BR /&gt;&lt;FONT face="Courier New"&gt;END TYPE VSL_STREAM_STATE&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;I don't know how to use these fields in the FORTRAN. Perhaps, you have ideas. I would really appreciate you if you could share with me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;- Sergey&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jan 2004 15:44:22 GMT</pubDate>
    <dc:creator>Sergey_M_Intel2</dc:creator>
    <dc:date>2004-01-20T15:44:22Z</dc:date>
    <item>
      <title>Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975929#M17085</link>
      <description>I'm porting some Fortran applications from CVF to Fortran 8.0&lt;BR /&gt;and also moving to MKL 6.1.  I'm using Visual Studio 2003 .NET&lt;BR /&gt;for the IDE.&lt;BR /&gt;&lt;BR /&gt;Some of my old software uses the ability to get / set the current&lt;BR /&gt;state of the current random number generator, and I'm looking&lt;BR /&gt;for a similar facility in MKL 6.1 from Fortran.  I see the&lt;BR /&gt;following in C headers accessed by mkl_vsl.h:&lt;BR /&gt;&lt;BR /&gt;vslGetBrngProperties(int  , VSLBRngProperties* properties);&lt;BR /&gt;&lt;BR /&gt;vslGetStreamStateBrng(VSLStreamStatePtr);&lt;BR /&gt;&lt;BR /&gt;vslRegisterBrng(const VSLBRngProperties* properties);&lt;BR /&gt;&lt;BR /&gt;But at the moment, all I can see is the SIZE of the stream state,&lt;BR /&gt;not it's location or structure.  &lt;BR /&gt;&lt;BR /&gt;Is there a capability for reading / writing the RNG state under&lt;BR /&gt;the current or a future version of MKL?  This capability is&lt;BR /&gt;important IF I have to "back up" a simulation, say to re-run&lt;BR /&gt;the last 10,000 iterations while recording a new parameter....&lt;BR /&gt;&lt;BR /&gt;This note may duplicate a previous attempt of 1/4/2004.&lt;BR /&gt;&lt;BR /&gt;Well Howell</description>
      <pubDate>Fri, 09 Jan 2004 19:57:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975929#M17085</guid>
      <dc:creator>welling-howell</dc:creator>
      <dc:date>2004-01-09T19:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975930#M17086</link>
      <description>&lt;DIV&gt;The developer has a rather complete response to this question but is having some difficulty in getting access to the forum. While I could submit his response, I would prefer to wait until he is able to provide the response himself. This should be resolved soon. I will give away the plot, but not the details - what you want to do can be done.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Bruce&lt;/DIV&gt;</description>
      <pubDate>Wed, 14 Jan 2004 01:33:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975930#M17086</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2004-01-14T01:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975931#M17087</link>
      <description>That Intel "can do" is not giving much away - I knew that ~;)&lt;BR /&gt;Thanks for the good news - I can concentrate on other areas&lt;BR /&gt;(like the really neat MV addition to gaussian RNG in 7.0 beta!!!).</description>
      <pubDate>Wed, 14 Jan 2004 06:50:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975931#M17087</guid>
      <dc:creator>welling-howell</dc:creator>
      <dc:date>2004-01-14T06:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975932#M17088</link>
      <description>&lt;DIV&gt;Yes,MKLVSL provides means tocontrola state of the generator.A number of VSL service routines control RNG (to save, copy its state as well as routines useful to use RNGs in parallel).&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;vslNewStream(stream,brng,seed)&lt;/FONT&gt; - creates and initializes new random stream &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt;. Routine allocates the memory to store the state of brng, initial value &lt;FONT face="Courier New"&gt;seed&lt;/FONT&gt; is used to set initial state (pick up a random sequence).Descriptor&lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt; is used later for reference to this particular sequence. (You may create unlimited number of streams in your simulation).&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;vslCopyStream(newstream,srcstream)&lt;/FONT&gt; - createsa copy ofthe &lt;FONT face="Courier New"&gt;srcstream&lt;/FONT&gt;. Descriptor&lt;FONT face="Courier New"&gt;newstrem&lt;/FONT&gt; is used later for reference to the stream copy.This routine is similar to &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt;. The only difference is that &lt;FONT face="Courier New"&gt;brng&lt;/FONT&gt; and its state are copied from the &lt;FONT face="Courier New"&gt;srcstream&lt;/FONT&gt;.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;vslCopyStreamState(deststream,srcstream)&lt;/FONT&gt; - copiesthe state of the&lt;FONT face="Courier New"&gt;srcstream&lt;/FONT&gt;&lt;FONT face="Arial"&gt; to the&lt;FONT face="Courier New"&gt;deststream&lt;/FONT&gt;.&lt;/FONT&gt;The &lt;FONT face="Courier New"&gt;deststream &lt;/FONT&gt;&lt;FONT face="Arial"&gt;should be created earlier, i.e. by&lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt; or by &lt;FONT face="Courier New"&gt;vslCopyStream&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;vslDeleteStream(stream)&lt;/FONT&gt; -deallocates the memory used for the stream &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt;.You should delete all the streams you created at the end of simulation.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Regarding to your particular question, I would recommend the following general scheme:&lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;Create an original stream &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt; by &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt; routine.&lt;/LI&gt;
&lt;LI&gt;Perform initial propagation (RNG generation) using the &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt;. After initial propagation you will start main simulation (10,000 iterations) with different parameters.&lt;/LI&gt;
&lt;LI&gt;Create a copy of the stream &lt;FONT face="Courier New"&gt;streamcopy&lt;/FONT&gt;, which will hold the state of the generator after initial propagation.&lt;/LI&gt;
&lt;LI&gt;Perform last 10,000 iterations with the &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt;.&lt;/LI&gt;
&lt;LI&gt;Restore the state of the &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt; from the streamcopy using &lt;FONT face="Courier New"&gt;vslCopyStreamState&lt;/FONT&gt; routine: &lt;FONT face="Courier New"&gt;vslCopyStreamState(stream,streamcopy)&lt;/FONT&gt;&lt;FONT face="Arial"&gt;.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;Perform last 10,000 iterations with the &lt;FONT face="Courier New"&gt;stream &lt;/FONT&gt;&lt;FONT face="Arial"&gt;and different simulation parameter.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;Delete the &lt;FONT face="Courier New"&gt;stream&lt;/FONT&gt; and the &lt;FONT face="Courier New"&gt;streamcopy&lt;/FONT&gt;.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Steps 5 and 6 are used every time you change the simulation parameter.&lt;/P&gt;
&lt;P&gt;For further information I would recommend you MKL Reference Manual (API and list of routines). Also I would recommend you VSL Notes document, which provides VSL-related general discussions, RNG testing results and performance figures.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jan 2004 15:38:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975932#M17088</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2004-01-19T15:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975933#M17089</link>
      <description>smaidano,&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply and help.  &lt;BR /&gt;&lt;BR /&gt;Your 7 steps are useful in changing the state of a generator&lt;BR /&gt;within a single computer run.  However, I also need what might&lt;BR /&gt;be called a "persistant state save", which is what I intended&lt;BR /&gt;to ask for with the ability to read / write the state information.&lt;BR /&gt;&lt;BR /&gt;This would seem to conflict with an other design objective of&lt;BR /&gt;"data hiding" where I should not want to know just how the state&lt;BR /&gt;is stored inside the RNG.  However, if my uninterruptable power&lt;BR /&gt;supply sends a signal which requires that I shut down a long-running&lt;BR /&gt;task, I'd like to be able to query the RNG state, possibly with&lt;BR /&gt;streamcopy(), and then write the results of that query to my&lt;BR /&gt;hard-drive prior to shutdown.  Then I could restore the RNG&lt;BR /&gt;when I restart.&lt;BR /&gt;&lt;BR /&gt;Can I bypass "data hiding" and determine the size of the data&lt;BR /&gt;structure to be stored and the contents of that structure?&lt;BR /&gt;&lt;BR /&gt;Sorry to be such an ah, er, NAG.&lt;BR /&gt;&lt;BR /&gt;Well</description>
      <pubDate>Tue, 20 Jan 2004 07:11:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975933#M17089</guid>
      <dc:creator>welling-howell</dc:creator>
      <dc:date>2004-01-20T07:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975934#M17090</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Well, you are very advanced and powerful user! Thanks for asking interesting questions. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;VSL do not provide direct access to the stream state data. This is because VSL has a number of basic generators, and each basic generator's state has different size, fields, etc. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Bad news is that MKLVSL currently do not provide routines to save/restore stream to a file. However, such a feature might be useful for Monte Carlo people since Monte Carlo simulation is basically takes a lot of time. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Good news is that you are able to get the size of the stream state, and try to store/restore data yourself. The &lt;FONT face="Courier New"&gt;vslGetBrngProperties&lt;/FONT&gt; routine is what you really need:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT face="Courier New"&gt;vslGetBrngProperties(brng,properties)&lt;/FONT&gt; - fills the fields of the structure &lt;FONT face="Courier New"&gt;properties&lt;/FONT&gt; with the data describing properties of the basic generator &lt;FONT face="Courier New"&gt;brng&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Among other fields the properties structure has the &lt;FONT face="Courier New"&gt;streamstatesize&lt;/FONT&gt; field (the first field in the structure, its size is 4 bytes). For further information I would recommend the Advanced Service Subroutines chapter of the MKL Reference Manual.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;To implement the save/restore to a file I would suggest the following scheme:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Perform the first run of a simulation.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Determine the size in bytes of the stream state structure.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Get access to the memory, where the stream state data is stored, and save this data to a file (you know number of bytes to store from Step 2).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Delete all streams and finish application.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;For the second run.&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Create new stream &lt;FONT face="Courier New"&gt;restored_stream&lt;/FONT&gt; by &lt;FONT face="Courier New"&gt;vslNewStream &lt;/FONT&gt;routine. The basic generator should be the same as in the first run. No matter which seed you will pass.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Before the second run you should determine the size of the stream state structure again, and load the stream state data from the file to the memory &lt;FONT face="Courier New"&gt;restored_stream&lt;/FONT&gt; points to.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;I would not recommend using restored stream state directly because there are some fields in the structure you saved to a f
ile, which are pointers to allocated memory (used internally by VSL in some cases). To avoid non-allocated memory access you should do following:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Create one more stream stream by &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt; function. No matter which seed you will pass, the only important is &lt;FONT face="Courier New"&gt;brng&lt;/FONT&gt; - should be the same as you saved/restored.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Use &lt;FONT face="Courier New"&gt;vslCopyStreamState&lt;/FONT&gt; to copy the state of &lt;FONT face="Courier New"&gt;restored_stream&lt;/FONT&gt; to the stream. This routine will copy only the stream state related information and will not copy pointers.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Perform second run.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Delete all streams.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;The main difficulty is in getting access to the stream state data you want to save/restore in FORTRAN. (It could be done very naturally in C). I have no nice idea how to do this. Let me explain in more details why.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;Each instance of &lt;FONT face="Courier New"&gt;VSL_STREAM_STATE &lt;/FONT&gt;(i.e. the stream we want to save) has two 32-bit fields used internally to store address of the memory block allocated in &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt;, which is used to store stream state data. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT face="Courier New"&gt;TYPE VSL_STREAM_STATE&lt;BR /&gt; INTEGER*4 descriptor1&lt;/FONT&gt; - stores 32-bit address of the memory block used to store stream state information&lt;BR /&gt;&lt;FONT face="Courier New"&gt; INTEGER*4 descriptor2&lt;/FONT&gt; - stores higher 32-bits of the address (for 64-bit systems)&lt;BR /&gt;&lt;FONT face="Courier New"&gt;END TYPE VSL_STREAM_STATE&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;I don't know how to use these fields in the FORTRAN. Perhaps, you have ideas. I would really appreciate you if you could share with me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;- Sergey&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2004 15:44:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975934#M17090</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2004-01-20T15:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975935#M17091</link>
      <description>Sergey,&lt;BR /&gt;&lt;BR /&gt;Thanks for your detailed and helpful suggestions.  You may have&lt;BR /&gt;just sold be an Intel C compiler to go with my Fortran ~;)&lt;BR /&gt;&lt;BR /&gt;For now, I may just hope that any random starting point is as good&lt;BR /&gt;as any other, and not worry about restarting at the very point&lt;BR /&gt;where I left off - after all, the numbers are random!  That feature&lt;BR /&gt;is needed, however, if I need to re-start at an earlier, rather&lt;BR /&gt;than a random point.&lt;BR /&gt;&lt;BR /&gt;While I'm bi-lingual, I couldn't think of a way of doing&lt;BR /&gt;    typedef void* VSLStreamStatePtr; &lt;BR /&gt;in Fortran 8 either.&lt;BR /&gt;&lt;BR /&gt;Your trick of vslCopyStreamState to move the state info without&lt;BR /&gt;changing the stream pointers is very interesting.  I may have&lt;BR /&gt;to wait until the weekend to try it (darn "day jobs" anyway ~;).</description>
      <pubDate>Tue, 20 Jan 2004 20:06:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975935#M17091</guid>
      <dc:creator>welling-howell</dc:creator>
      <dc:date>2004-01-20T20:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975936#M17092</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Hello Well,&lt;/P&gt;
&lt;P&gt;Please let me know any issues you encounter while testing save/restore to a file.&lt;/P&gt;
&lt;P&gt;I have one more idea how to resolve the issue with stream state storing/restoring.&lt;/P&gt;
&lt;P&gt;There is &lt;FONT face="Courier New"&gt;vslSkipAheadStream&lt;/FONT&gt; routine, which might be useful to restart simulation. Parameters are the stream and number of random numbers to skip. Thus, the solution might be following:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create the stream with &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt; function (you will pass basic generator and the &lt;STRONG&gt;seed&lt;/STRONG&gt;). Perform the first run. At the end of the run you know how many numbers N were generated.&lt;/LI&gt;
&lt;LI&gt;Save this N to a file, delete the stream and finish the application.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;In the second run you should do following:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create the stream with &lt;FONT face="Courier New"&gt;vslNewStream&lt;/FONT&gt; function (you will pass &lt;STRONG&gt;the same basic generator&lt;/STRONG&gt; and &lt;STRONG&gt;the same seed &lt;/STRONG&gt;as in the first run).&lt;/LI&gt;
&lt;LI&gt;Call &lt;FONT face="Courier New"&gt;vslSkipAheadStream&lt;/FONT&gt; subroutine to skip N numbers generated in the first run. This subroutine works much faster than if you would simply generate these N numbers. One restriction is that not all VSL basic generators support the skip-ahead method. Please see VSL Notes document for details.&lt;/LI&gt;
&lt;LI&gt;Perform the second run.&lt;/LI&gt;
&lt;LI&gt;Delete the stream and finish the application.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Regarding to choosing initial state at random fashion, yes, this isanotherpossible solution. Isee several things I need to keep in mind in this situation.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Is it acceptable tostudy the system under different parameters and different random sequences? &lt;/STRONG&gt;Sometimes it might be important to use the same random numbers with different parameters (i.e. to study correlation properties).&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Does basic generator have sufficient period to choose sequences at random?&lt;/STRONG&gt;It is quite general recommendation not use random numbers more than square root of generator's period. In addition, choosing subsequences at random there is a chance that two subsequences will significantly overlap. (This chance is higher when total length of subsequences goes toward generator's period). Sometimes overlapping is not critical.On the other hand,situations are possible when overlapping in two sequences with result in inconsistent (biased) result.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Thanks for interesting discussion.&lt;/P&gt;
&lt;P&gt;- Sergey&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2004 21:07:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975936#M17092</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2004-01-20T21:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number Generator State Info</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975937#M17093</link>
      <description>Sergey,&lt;BR /&gt;&lt;BR /&gt;And thank you for all your suggestions.  As for "interesting",&lt;BR /&gt;I'd reserve that term for your wonderful article on&lt;BR /&gt;"Monte Carlo European Options Pricing....." in the Intel&lt;BR /&gt;download library.  Random numbers are fun, and maybe the&lt;BR /&gt;ancient statisticians who helped their kings wager were&lt;BR /&gt;really on to something!&lt;BR /&gt;&lt;BR /&gt;Well</description>
      <pubDate>Wed, 21 Jan 2004 11:25:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Random-Number-Generator-State-Info/m-p/975937#M17093</guid>
      <dc:creator>welling-howell</dc:creator>
      <dc:date>2004-01-21T11:25:09Z</dc:date>
    </item>
  </channel>
</rss>

