Initializes a stream using the block-splitting method.
FORTRAN:
status = vslskipaheadstream( stream, nskip )
C:
status = vslSkipAheadStream( stream, nskip);
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 block-splitting method is applied C: Pointer to the stream state structure to which block-splitting method is applied |
nskip |
FORTRAN 77: INTEGER*4 nskip(2) Fortran 90: INTEGER(KIND=8), INTENT(IN) C: const long long int |
Number of skipped elements |
The vslSkipAheadStream function skips a given number of elements in a random stream. This feature is particularly useful in distributing random numbers from original random stream across different computational nodes. If the largest number of random numbers used by a computational node is nskip, then the original random sequence may be split by vslSkipAheadStream into non-overlapping blocks of nskip size so that each block corresponds to the respective computational node. The number of computational nodes is unlimited. This method is known as the block-splitting method or as the skip-ahead method. (see Figure "Block-Splitting Method").
The skip-ahead method is supported only for those basic generators that allow skipping elements by the skip-ahead method, which is more efficient than simply generating them by generator with subsequent manual skipping. See VSL Notes for details.
Please note that for quasi-random basic generators the skip-ahead method works with components of quasi-random vectors rather than with whole quasi-random vectors. Therefore, to skip NS quasi-random vectors, set the nskip parameter equal to the NS*DIMEN, where DIMEN is the dimension of the quasi-random vector. If this operation results in exceeding the period of the quasi-random number generator, which is 232-1, the library returns the VSL_RNG_ERROR_QRNG_PERIOD_ELAPSED error code.
The following code examples illustrate how to initialize three independent streams using the vslSkipAheadStream function:
...
type(VSL_STREAM_STATE) ::stream1
type(VSL_STREAM_STATE) ::stream2
type(VSL_STREAM_STATE) ::stream3
! Creating the 1st stream
status = vslnewstream(stream1, VSL_BRNG_MCG31, 174)
! Skipping ahead by 7 elements the 2nd stream
status = vslcopystream(stream2, stream1);
status = vslskipaheadstream(stream2, 7);
! Skipping ahead by 7 elements the 3rd stream
status = vslcopystream(stream3, stream2);
status = vslskipaheadstream(stream3, 7);
! Generating random numbers
...
! Deleting the streams
status = vsldeletestream(stream1)
status = vsldeletestream(stream2)
status = vsldeletestream(stream3)
...
VSLStreamStatePtr stream1;
VSLStreamStatePtr stream2;
VSLStreamStatePtr stream3;
/* Creating the 1st stream
*/
status = vslNewStream(&stream1, VSL_BRNG_MCG31, 174);
/* Skipping ahead by 7 elements the 2nd stream */
status = vslCopyStream(&stream2, stream1);
status = vslSkipAheadStream(stream2, 7);
/* Skipping ahead by 7 elements the 3rd stream */
status = vslCopyStream(&stream3, stream2);
status = vslSkipAheadStream(stream3, 7);
/* Generating random numbers
*/
...
/* Deleting the streams
*/
status = vslDeleteStream(&stream1);
status = vslDeleteStream(&stream2);
status = vslDeleteStream(&stream3);
...