Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 12/16/2022
Public

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

Document Table of Contents

vslSkipAheadStreamEx

Initializes a stream using the block-splitting method with partitioned number of skipped elements.

Syntax

status = vslSkipAheadStreamEx( stream, n, nskip);

Include Files
  • mkl.h
Input Parameters

Name

Type

Description

stream

VSLStreamStatePtr

Pointer to the stream state structure to which block-splitting method is applied

n

const MKL_INT

Number of summands in nskip

nskip

const MKL_UINT64[]

Partitioned number of skipped elements

Description

The vslSkipAheadStreamEx 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 vslSkipAheadStreamEx 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 Notes for Intel® MKL Vector Statisticsfor more details.

Use this function when the number of elements to skip in a random stream is greater than 263. Prior calls to the function represent the number of skipped elements with array of size n as shown below:

nskip[0]+ nskip[1]*264+nskip[2]* 2128+ … +nskip[n-1]*2(64*(n-1) );

When the number of skipped elements is less than 263 you can use either vslSkipAheadtreamEx or vslSkipAheadStream. The following code illustrates how to initialize three independent streams using the vslSkipAheadStreamEx function:

VSLStreamStatePtr stream1; VSLStreamStatePtr stream2; VSLStreamStatePtr stream3;

/* Creating the 1st stream
*/
status = vslNewStream(&stream1, VSL_BRNG_MCG31, 174);

/* To skip 2^64 elements in the random stream SkipAheadStreamEx(nskip) function should be called with nskip represented as nskip = 2^64 = 0 + 1 * 2^64
*/
MKL_UINT64 nskip[2];
nskip[0]=0;
nskip[1]=1;

/* Skipping ahead by 2^64 elements the 2nd stream
/*
status = vslCopyStream(&stream2, stream1); 
status = vslSkipAheadStreamEx (stream2, 2, nskip);

/* Skipping ahead by 2^64 elements the 3rd stream
/*
status = vslCopyStream(&stream3, stream2); 
status = vslSkipAheadStreamEx (stream3, 2, nskip);

/* 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_SKIPAHEADEX_UNSUPPORTED

BRNG does not support the advanced Skip-Ahead method.