Developer Reference for Intel® oneAPI Math Kernel Library for Fortran

ID 766686
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

vslSkipAheadStream

Initializes a stream using the block-splitting method.

Syntax

status = vslskipaheadstream( stream, nskip )

Include Files

  • mkl.fi, mkl_vsl.f90

Input Parameters

Name

Type

Description

stream

TYPE(VSL_STREAM_STATE), INTENT(IN)

Descriptor of the stream to which block-splitting method is applied

nskip

INTEGER(KIND=8), INTENT(IN)

Number of skipped elements

Description

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").

Block-Splitting Method


Block-Splitting Method


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 VS 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 illustrates how to initialize three independent streams using the vslSkipAheadStream function:

Code for Block-Splitting Method

...
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)
...

Return Values

VSL_ERROR_OK, VSL_STATUS_OK

Indicates no error, execution is successful.

VSL_ERROR_NULL_PTR

stream is a NULL pointer.

VSL_RNG_ERROR_BAD_STREAM

stream is not a valid random stream.

VSL_RNG_ERROR_SKIPAHEAD_UNSUPPORTED

BRNG does not support the Skip-Ahead method.

VSL_RNG_ERROR_QRNG_PERIOD_ELAPSED

Period of the quasi-random number generator is exceeded.