Initializes a stream using the leapfrog method.
Fortran:
status = vslleapfrogstream( stream, k, nstreams )
C:
status = vslLeapfrogStream( stream, k, nstreams );
The FORTRAN 77 interfaces are specified in the mkl_vsl.f77 include file, the Fortran 90 interfaces are specified in the mkl_vsl.f90 include file, and the C interfaces are specified in the mkl_vsl_functions.h include file.
Name |
Type |
Description |
---|---|---|
stream |
FORTRAN 77: INTEGER*4 stream(2) Fortran 90: TYPE(VSL_STREAM_STATE), INTENT(IN) C: VSLStreamStatePtr |
Fortran: Descriptor of the stream to which leapfrog method is applied C: Pointer to the stream state structure to which leapfrog method is applied |
k |
FORTRAN 77: INTEGER Fortran 90: INTEGER, INTENT(IN) C: const int |
Index of the computational node, or stream number |
nstreams |
FORTRAN 77: INTEGER Fortran 90: INTEGER, INTENT(IN) C: const int |
Largest number of computational nodes, or stride |
The LeapfrogStream function generates random numbers in a random stream with non-unit stride. This feature is particularly useful in distributing random numbers from the original stream across the nstreams buffers without generating the original random sequence with subsequent manual distribution.
One of the important applications of the leapfrog method is splitting the original sequence into non-overlapping subsequences across nstreams computational nodes. The function initializes the original random stream (see Figure"Leapfrog Method") to generate random numbers for the computational node k, 0 ≤ k < nstreams, where nstreams is the largest number of computational nodes used.
The leapfrog method is supported only for those basic generators that allow splitting elements by the leapfrog method, which is more efficient than simply generating them by a generator with subsequent manual distribution across computational nodes. See VSL Notes for details.
For quasi-random basic generators, the leapfrog method allows generating individual components of quasi-random vectors instead of whole quasi-random vectors. In this case nstreams parameter should be equal to the dimension of the quasi-random vector while k parameter should be the index of a component to be generated (0 ≤ k < nstreams). Other parameters values are not allowed.
The following code examples illustrate the initialization of three independent streams using the leapfrog method:
...
TYPE(VSL_STREAM_STATE) ::stream1
TYPE(VSL_STREAM_STATE) ::stream2
TYPE(VSL_STREAM_STATE) ::stream3
! Creating 3 identical streams
status = vslnewstream(stream1, VSL_BRNG_MCG31, 174)
status = vslcopystream(stream2, stream1)
status = vslcopystream(stream3, stream1)
! Leapfrogging the streams
status = vslleapfrogstream(stream1, 0, 3)
status = vslleapfrogstream(stream2, 1, 3)
status = vslleapfrogstream(stream3, 2, 3)
! Generating random numbers
...
! Deleting the streams
status = vsldeletestream(stream1)
status = vsldeletestream(stream2)
status = vsldeletestream(stream3)
...
...
VSLStreamStatePtr stream1;
VSLStreamStatePtr stream2;
VSLStreamStatePtr stream3;
/* Creating 3 identical streams */
status = vslNewStream(&stream1, VSL_BRNG_MCG31, 174);
status = vslCopyStream(&stream2, stream1);
status = vslCopyStream(&stream3, stream1);
/* Leapfrogging the streams
*/
status = vslLeapfrogStream(stream1, 0, 3);
status = vslLeapfrogStream(stream2, 1, 3);
status = vslLeapfrogStream(stream3, 2, 3);
/* Generating random numbers
*/
...
/* Deleting the streams
*/
status = vslDeleteStream(&stream1);
status = vslDeleteStream(&stream2);
status = vslDeleteStream(&stream3);
...
Copyright © 1994 - 2011, Intel Corporation. All rights reserved.