<?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: Basic Random Number generators in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906021#M11695</link>
    <description>&lt;P&gt;The way you useVSL routines (via fields of VSLBRngProperties structure) is error-prone and results in unpredicted work of the library. Direct call to *properties.InitStream has no effecton streamPtras the function does not return updated stateof the generator (you pass the streamPtr parameter by value, not by reference). To have things properly worked, please use standard VSL functions.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Oct 2007 10:42:03 GMT</pubDate>
    <dc:creator>Andrey_N_Intel</dc:creator>
    <dc:date>2007-10-02T10:42:03Z</dc:date>
    <item>
      <title>Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906018#M11692</link>
      <description>&lt;P&gt;&lt;FONT color="#ff1493" size="2"&gt;// I do the following:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;VSLStreamStatePtr streamPtr;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;unsigned intbuffer[128];&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;unsigned intseed = 5489;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;vslNewStream( streamPtr, VSL_BRNG_MT2203 + 5,seed ); &lt;FONT color="#ff1493"&gt;// create &amp;amp; init&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;VSLBRngProperties properties;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;vslGetBrngProperties( VSL_BRNG_MT2203 + 5, &amp;amp;properties );&lt;FONT color="#ff1493"&gt; // get properties&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;(*properties.iBRng)( streamPtr_, 128, buffer ); &lt;FONT color="#ff1493"&gt;// generate some 32bit random numbers&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff1493" size="2"&gt;// so far so good. Now I want to reset the generator to its initial state, so that it will refegenerate exactly the same sequence of random numbers&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;(*properties.InitStream)( 1, &amp;amp;streamPtr, 1, &amp;amp;seed );&lt;FONT color="#ff1493"&gt; // attempt to reset generator status&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff1493" size="2"&gt;// unfortunately this does not work. The generator will not reproduce exactly the same sequence. What am I doing wrong?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2007 18:56:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906018#M11692</guid>
      <dc:creator>fabiocannizzo</dc:creator>
      <dc:date>2007-10-01T18:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906019#M11693</link>
      <description>&lt;P&gt;VSLBRngProperties is VSL data type which describes structure of BRNG. You may want to use it to get properties of the given generator via call to vslGetBrngProperties routine. Another and main intention of the structure is to give opportunity to register own generator following the VSL conventions. Standard functions like vslNewStream or viRngUniformBits are recommended for work with a user-defined generator (or any other BRNG registered in the library).&lt;/P&gt;
&lt;P&gt;Attempt to reset the generator in the test case fails as the second parameter of InitStreamPtr function is passed by value: &lt;/P&gt;
&lt;P&gt;typedef int (*InitStreamPtr)( int method, &lt;STRONG&gt;VSLStreamStatePtr stream&lt;/STRONG&gt;,int n, const unsigned int params[] );&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;So,second call to iBRng should return random numbers from the original random stream. If you want a copy of the original stream you could use standard vslCopyStream function. &lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2007 08:30:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906019#M11693</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-02T08:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906020#M11694</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;Now I have fixed this problem, but it still does not work. The call &lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;(*properties.InitStream)( 1, streamPtr, 1, &amp;amp;seed );&lt;FONT color="#ff1493"&gt; // attempt to reset generator status&lt;SPAN class="949570810-02102007"&gt; to initial state&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;fails with error code return LeapFrog not supported.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2007 10:18:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906020#M11694</guid>
      <dc:creator>fabiocannizzo</dc:creator>
      <dc:date>2007-10-02T10:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906021#M11695</link>
      <description>&lt;P&gt;The way you useVSL routines (via fields of VSLBRngProperties structure) is error-prone and results in unpredicted work of the library. Direct call to *properties.InitStream has no effecton streamPtras the function does not return updated stateof the generator (you pass the streamPtr parameter by value, not by reference). To have things properly worked, please use standard VSL functions.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2007 10:42:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906021#M11695</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-02T10:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906022#M11696</link>
      <description>&lt;P&gt;Thanks a lot for your reply.&lt;/P&gt;
&lt;P&gt;In fact I am keen on doing that. Except I am having difficulties in undertsanding what is the correct way to call the routines. I could not find any VSL function which reset the state of a generator.&lt;/P&gt;
&lt;P&gt;Let me please restate the definition of my problem:&lt;/P&gt;
&lt;P&gt;I want N independent (uncorrelated) streams (to be used by separate consumer threads) of 32-bit integer random deviates with uniform discrete distribution in the interval [0, 0xFFFFFFFF], based on the Mersenne Twister. &lt;/P&gt;
&lt;P&gt;I understand that this can be achieved using MT2203.&lt;/P&gt;
&lt;P&gt;I also want each of these streams to be independently resettable to their initial state (same seed as previously used in the initialization).&lt;/P&gt;
&lt;P&gt;Howwould you reccomendto achieve that?&lt;/P&gt;
&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Fabio&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2007 12:27:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906022#M11696</guid>
      <dc:creator>fabiocannizzo</dc:creator>
      <dc:date>2007-10-02T12:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906023#M11697</link>
      <description>&lt;P&gt;Fabio,&lt;/P&gt;
&lt;P&gt;VSL MT2203 BRNG allows creating up to 1024 independent random streams.&lt;BR /&gt;Their creation/use/deletion can be organized in the following way:&lt;/P&gt;
&lt;P&gt;#define N 10  /* number of random streams */&lt;BR /&gt;#define SEED 44444 /* seed can be different for different MT2203 streams */&lt;/P&gt;
&lt;P&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; ... &lt;BR /&gt; int k;&lt;BR /&gt; VSLStreamStatePtr stream&lt;N&gt;;&lt;BR /&gt; int errcode;&lt;BR /&gt; unsigned int r[128];&lt;BR /&gt; ...&lt;/N&gt;&lt;/P&gt;
&lt;P&gt; /* Create N streams */&lt;BR /&gt; for ( k=0; k&lt;N&gt; {&lt;BR /&gt; errcode = vslNewStream( &amp;amp;stream&lt;K&gt;, VSL_BRNG_MT2203+k, SEED );&lt;BR /&gt; }&lt;BR /&gt; ... &lt;BR /&gt; errcode = viRngUniformBits( method, stream[5], 128, r ); /* use 5th MT2203 stream*/&lt;BR /&gt; ...&lt;BR /&gt; &lt;BR /&gt; /* Delete streams */&lt;BR /&gt; for ( k=0; k&lt;N&gt; {&lt;BR /&gt; errcode = vslDeleteStream( &amp;amp;stream&lt;K&gt; );&lt;BR /&gt; }&lt;BR /&gt; ...&lt;/K&gt;&lt;/N&gt;&lt;/K&gt;&lt;/N&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;Support of resetting is, for example,as follows:&lt;/P&gt;
&lt;P&gt; ... &lt;BR /&gt; VSLStreamStatePtr stream&lt;N&gt;, streamCpy&lt;N&gt;; &lt;/N&gt;&lt;/N&gt;&lt;/P&gt;
&lt;P&gt; /* Create N streams and their copies */&lt;BR /&gt; for ( k=0; k&lt;N&gt; {&lt;BR /&gt; errcode = vslNewStream( &amp;amp;stream&lt;K&gt;, VSL_BRNG_MT2203+k, SEED );&lt;BR /&gt; errcode = vslCopyStream( &amp;amp;streamCpy&lt;K&gt;, stream&lt;K&gt; );&lt;BR /&gt; }&lt;BR /&gt; ... &lt;/K&gt;&lt;/K&gt;&lt;/K&gt;&lt;/N&gt;&lt;/P&gt;
&lt;P&gt;To reset any stream you would need to call vslCopyStreamState function in proper time:&lt;/P&gt;
&lt;P&gt; vslCopyStreamState( stream&lt;K&gt;, streamCpy&lt;K&gt; );&lt;/K&gt;&lt;/K&gt;&lt;/P&gt;
&lt;P&gt;or just use streamCpy&lt;K&gt; instead of stream&lt;K&gt;. &lt;/K&gt;&lt;/K&gt;&lt;/P&gt;
&lt;P&gt;In the end of the calculations you would need to free memory allocated for&lt;BR /&gt;all streams:&lt;BR /&gt; for ( k=0; k&lt;N&gt; {&lt;BR /&gt; errcode = vslDeleteStream( &amp;amp;stream&lt;K&gt; );&lt;BR /&gt; errcode = vslDeleteStream( &amp;amp;streamCpy&lt;K&gt; );&lt;BR /&gt; }&lt;BR /&gt;&lt;/K&gt;&lt;/K&gt;&lt;/N&gt;&lt;/P&gt;
&lt;P&gt;It isalso possible todelete and createthe streamforrequired MT2203 index and seed once more. &lt;/P&gt;
&lt;P&gt;Please, let us know how this scheme works for you. Additional details re the VSL functions and their use can be found in MKL Manual and Vslnotes.pdf. &lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2007 13:40:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906023#M11697</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-02T13:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906024#M11698</link>
      <description>&lt;P&gt;Andrey,&lt;/P&gt;
&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;So summarizing, you do not have a method which just re-seed an existingstream. So I have the two choices:&lt;/P&gt;
&lt;P&gt;1) Allocate stream A. Copy it into stream B. . Whenever I want to resetstream A I copyB onto A. So my extra cost is mainly"extra-memory" for stream B.&lt;/P&gt;
&lt;P&gt;2) Allocatestream A. When I am done delete it and recreate it. Now I do not have any memory extra cost, but I have a performance cost for memory reallocationand re-initialization.&lt;/P&gt;
&lt;P&gt;They both work for me.&lt;/P&gt;
&lt;P&gt;Whichmethod do you think is faster?&lt;/P&gt;
&lt;P&gt;What is the memory consumption associated withcreating of a stream of type MT2203?&lt;/P&gt;
&lt;P&gt;Thanks a lot,&lt;/P&gt;
&lt;P&gt;Fabio&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2007 18:36:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906024#M11698</guid>
      <dc:creator>fabiocannizzo</dc:creator>
      <dc:date>2007-10-02T18:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Random Number generators</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906025#M11699</link>
      <description>&lt;P&gt;Fabio,&lt;/P&gt;
&lt;P&gt;VSL does not have a function for re-seeding as existing VSL service routines cover this specific task. Answer to the question which method is faster depends on requirements of your application:&lt;BR /&gt;- how many MT2203 streams do you need to create?&lt;BR /&gt;- how often does your app re-seeds the streams and how many of them are re-seeded?&lt;BR /&gt;- how much time does the apps spend in generation of random numbers and in other calculations?&lt;BR /&gt;- what are the memory limitations? etc&lt;/P&gt;
&lt;P&gt;Probably, generation of random numbers/other calculations take significant amount of time, and either approach for re-seeding of the streams will be negligible in terms of time. All analysis of the performance and relevant experiments can easily be done on your side. Intel provides tools for analysis of performance. VTune is the instrument which would help you to analyze bottlenecks of your app and to choose the most suitable approaches in developement of your algorithm.&lt;/P&gt;
&lt;P&gt;To determine amount of memory which is required to store state of MT2203 random stream, please, call function vslGetBrngProperties( brng, &amp;amp;properties ). Field StreamStateSize of the structure properties gives idea about memory consumption.&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Andrey&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2007 06:33:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Basic-Random-Number-generators/m-p/906025#M11699</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-03T06:33:01Z</dc:date>
    </item>
  </channel>
</rss>

