Skip to content

Commit b5ced6c

Browse files
[oneDPL][RNG] Add Philox engine to the oneAPI spec (#653)
Co-authored-by: Alexey Kukanov <[email protected]>
1 parent 969aba6 commit b5ced6c

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

source/elements/oneDPL/source/sycl_kernels_api.rst

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Supported Functionality
2727
- Engine class templates:
2828
- ``linear_congruential_engine``
2929
- ``subtract_with_carry_engine``
30+
- ``philox_engine``
3031
- Engine adaptor class templates:
3132
- ``discard_block_engine``
3233
- Engines and engine adaptors with predefined parameters:
@@ -36,6 +37,8 @@ Supported Functionality
3637
- ``ranlux48_base``
3738
- ``ranlux24``
3839
- ``ranlux48``
40+
- ``philox4x32``
41+
- ``philox4x64``
3942
- Distribution class templates:
4043
- ``uniform_int_distribution``
4144
- ``uniform_real_distribution``
@@ -48,7 +51,11 @@ Supported Functionality
4851
- ``cauchy_distribution``
4952
- ``extreme_value_distribution``
5053

51-
``linear_congruential_engine`` and ``subtract_with_carry_engine`` satisfy the uniform random bit generator requirements.
54+
.. note::
55+
The ``philox_engine`` class template and the corresponding predefined engines match the respective API
56+
in the working draft of the next C++ standard edition (C++26).
57+
58+
``linear_congruential_engine``, ``subtract_with_carry_engine``, and ``philox_engine`` satisfy the uniform random bit generator requirements.
5259

5360
Limitations
5461
-----------
@@ -82,7 +89,7 @@ The ``scalar_type`` is used instead of ``result_type`` in all contexts where a s
8289
Since ``scalar_type`` is the same as ``result_type`` except for template instantiations with ``sycl::vec``,
8390
class templates still meet the applicable requirements of the `C++ Standard`_.
8491

85-
When instantiated with ``sycl::vec<Type,N>``, ``linear_congruential_engine`` and ``subtract_with_carry_engine`` may not
92+
When instantiated with ``sycl::vec<Type,N>``, ``linear_congruential_engine``, ``subtract_with_carry_engine``, and ``philox_engine`` may not
8693
formally satisfy the uniform random bit generator requirements defined by the `C++ Standard`_. Instead, the following
8794
alternative requirements apply: for an engine object ``g`` of type ``G``,
8895

@@ -105,10 +112,12 @@ The following engines and engine adaptors with predefined parameters are defined
105112
.. code:: cpp
106113
107114
template <int N>
108-
using minstd_rand0_vec = linear_congruential_engine<sycl::vec<::std::uint_fast32_t, N>, 16807, 0, 2147483647>;
115+
using minstd_rand0_vec =
116+
linear_congruential_engine<sycl::vec<uint_fast32_t, N>, 16807, 0, 2147483647>;
109117
110118
template <int N>
111-
using minstd_rand_vec = linear_congruential_engine<sycl::vec<uint_fast32_t, N>, 48271, 0, 2147483647>;
119+
using minstd_rand_vec =
120+
linear_congruential_engine<sycl::vec<uint_fast32_t, N>, 48271, 0, 2147483647>;
112121
113122
template <int N>
114123
using ranlux24_base_vec = subtract_with_carry_engine<sycl::vec<uint_fast32_t, N>, 24, 10, 24>;
@@ -122,6 +131,14 @@ The following engines and engine adaptors with predefined parameters are defined
122131
template <int N>
123132
using ranlux48_vec = discard_block_engine<ranlux48_base_vec<N>, 389, 11>;
124133
134+
template <int N>
135+
using philox4x32_vec = philox_engine<sycl::vec<uint_fast32_t, N>, 32, 4, 10, 0xCD9E8D57,
136+
0x9E3779B9, 0xD2511F53, 0xBB67AE85>;
137+
138+
template <int N>
139+
using philox4x64_vec = philox_engine<sycl::vec<uint_fast64_t, N>, 64, 4, 10, 0xCA5A826395121157,
140+
0x9E3779B97F4A7C15, 0xD2E7470EE14C6C93, 0xBB67AE8584CAA73B>;
141+
125142
Except for producing a ``sycl::vec`` of random values per invocation, the behavior of these engines is equivalent to
126143
the corresponding scalar engines, as described in the following table:
127144

@@ -151,7 +168,12 @@ the corresponding scalar engines, as described in the following table:
151168
* - ``ranlux48_vec``
152169
- ``ranlux48``
153170
- 1112339016
154-
171+
* - ``philox4x32_vec``
172+
- ``philox4x32``
173+
- 1955073260
174+
* - ``philox4x64_vec``
175+
- ``philox4x64``
176+
- 3409172418970261260
155177

156178
Function Objects
157179
++++++++++++++++

0 commit comments

Comments
 (0)