skip_ahead#

Proceed state of engine by the skip-ahead method.

Description and Assumptions

oneapi::mkl::rng::skip_ahead function changes the current state of the engine so that with the further call of the generator the output subsequence begins with the specified offset see Figure “Block-Splitting Method”.

Block-Splitting Method

image0

skip_ahead#

Syntax

namespace oneapi::mkl::rng {
template<typename EngineType>
void oneapi::mkl::rng::skip_ahead(EngineType& engine, std::uint64_t num_to_skip);
}

Template Parameters

EngineType

Type of engine. Note: may not be supported by all available engine classes.

Input Parameters

engine

Engine which state would be skipped.

num_to_skip

Number of elements to skip in the engine’s sequence.

Example

// Creating 3 identical engines
oneapi::mkl::rng::mcg31m1 engine_1(queue, seed);
oneapi::mkl::rng::mcg31m1 engine_2(engine_1);
oneapi::mkl::rng::mcg31m1 engine_3(engine_2);

// Skipping ahead by 7 elements the 2nd engine
oneapi::mkl::rng::skip_ahead(engine_2, 7);

// Skipping ahead by 14 elements the 3rd engine
oneapi::mkl::rng::skip_ahead(engine_3, 14);

skip_ahead (Interface with a partitioned number of skipped elements)#

Syntax

namespace oneapi::mkl::rng {
template<typename EngineType>
void oneapi::mkl::rng::skip_ahead(EngineType& engine, std::initializer_list<std::uint64_t> num_to_skip);
}

Template Parameters

EngineType

Type of engine. Note: may not be supported by all available engine classes.

Input Parameters

engine

Engine which state would be skipped.

num_to_skip

Partitioned number of elements to skip in the engine’s sequence. The total number of skipped elements would be: \(num\_to\_skip[0] + num\_to\_skip[1] \cdot 2^{64} + ... + num\_to\_skip[1] \cdot 2^{64 (n - 1)}\), where n is a number of elements in num_to_skip list.

Example with Partitioned Numer of Elements

// Creating the first engine
oneapi::mkl::rng::mrg32k3a engine_1(queue, seed);

// To skip 2^64 elements in the random stream number of skipped elements should be
/represented as num_to_skip = 2^64 = 0 + 1 * 2^64
std::initializer_list<std::uint64_t> num_to_skip = {0, 1};

// Creating the 2nd engine based on 1st. Skipping by 2^64
oneapi::mkl::rng::mrg32k3a engine_2(engine_1);
oneapi::mkl::rng::skip_ahead(engine_2, num_to_skip);

Parent topic: Service Routines