Visible to Intel only — GUID: GUID-AC7BEB38-730C-43AF-8F67-DD7A35C0BD11
Visible to Intel only — GUID: GUID-AC7BEB38-730C-43AF-8F67-DD7A35C0BD11
Device Distributions
oneMKL RNG routines are used to generate random numbers with different types of distribution. Each function group is introduced below by the type of underlying distribution and contains a short description of its functionality, as well as specifications of the call sequence and the explanation of input and output parameters. The Device Continuous Distribution Generators table and Device Discrete Distribution Generators table list the random number generator routines with data types and output distributions, and sets correspondence between data types of the generator routines and the basic random number generators.
Device Continuous Distribution Generators
Type of Distribution |
Data Types |
BRNG Data Type |
Description |
---|---|---|---|
float, double |
float, double |
Uniform continuous distribution on the interval [a,b) |
|
float, double |
float, double |
Normal (Gaussian) distribution |
|
float, double |
float, double |
Exponential distribution |
|
float, double |
float, double |
Lognormal distribution |
|
float, double |
float, double |
Beta distribution |
|
float, double |
float, double |
Gamma distribution |
Device Discrete Distribution Generators
Type of Distribution |
Data Types |
BRNG Data Type |
Description |
---|---|---|---|
integer |
float for uniform_method::standard, double for uniform_method::accurate, and raw output for 64 bit integers |
Uniform discrete distribution on the interval [a,b) |
|
integer |
integer |
Bits of underlying BRNG integer sequence |
|
integer |
integer |
Uniformly distributed bits in 32/64-bit chunks |
|
integer |
float |
Bernoulli distribution |
|
integer |
double |
Poisson distribution |
- In case of integer, check the desired distribution for supported data types.
To get continuously distributed numbers of sycl::half, convert the generated numbers to sycl::half as shown below:
queue.submit([&](sycl::handler& cgh) {
cgh.parallel_for(sycl::range<1>(n / VecSize), [=](sycl::item<1> item) {
size_t item_id = item.get_id(0);
oneapi::mkl::rng::device::mcg59<VecSize> engine(seed, item_id * VecSize);
oneapi::mkl::rng::device::uniform<float> distr;
auto res = oneapi::mkl::rng::device::generate(distr, engine);
if constexpr(VecSize == 1) {
r_acc[item_id] = static_cast<sycl::half>(res);
}
else {
sycl::vec<sycl::half, VecSize> res_;
res_ = res.template convert<sycl::half>();
res_.store(item_id, r_acc);
}
});
});