Skip to content

Commit

Permalink
Applying the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldyakov committed Sep 1, 2023
1 parent e4f0c5b commit 12a2ba2
Showing 1 changed file with 45 additions and 66 deletions.
111 changes: 45 additions & 66 deletions source/elements/oneDPL/source/sycl_kernels_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,91 +46,70 @@ Supported functionality:
- ``cauchy_distribution``
- ``extreme_value_distribution``

Additionally, ``sycl::vec<>`` can be used as the result type for engines, engine adaptors, and distributions.

Limitations:
------------
The following deviations from the `C++ Standard`_ may apply:

- ``random_device`` and ``seed_seq`` classes and related APIs in other classes are not required;
- ``operator>>()``, ``operator<<()``, ``operator==()`` are not required;
- specifying the size of a random number engine's state is not required;
- distributions are only required to operate with floating point types applicable to supported SYCL devices.

Extensions:
------------
The following extensions from the `C++ Standard`_ may apply:

- ``linear_congruential_engine`` and ``subtract_with_carry_engine`` satisfy the requirements of UniformRandomBitGenerator
for all cases except when ``UIntType`` template parameter equals ``sycl::vec<>``.
When ``UIntType`` equals ``sycl::vec<>``
- As the ``result_type`` for engines, engine adaptors, and distributions ``sycl::vec<>`` can be used.

- ``linear_congruential_engine`` and ``subtract_with_carry_engine`` satisfy the description and main requirements of UniformRandomBitGenerator.
Next extensions are applied: when ``UIntType`` equals ``sycl::vec<>``

- ``G::result_type`` is ``sycl::vec<UIntElemType, N>`` , where ``UIntElemType`` is one of unsigned integers type supported by SYCL devices, ``N`` is a number of elements
- ``G::min()`` returns the smallest scalar value of ``UIntElemType`` type that G's operator() may return.
- ``G::min()`` returns the largest scalar value of ``UIntElemType`` type that G's operator() may return.
- ``g()`` returns a ``sycl::vec<UIntElemType, N>`` filled with ``N`` values in the closed interval ``[G::min(), G::max()]``

- Next engines and engine adaptors with predefined parameters may be implemented:

.. code:: cpp
template <int _N>
using minstd_rand0_vec = linear_congruential_engine<sycl::vec<::std::uint_fast32_t, _N>, 16807, 0, 2147483647>;``
Required behavior: The 10000th consecutively produced random number value of a default-constructed object
of type ``minstd_rand0_vec<>`` is the same as for ``minstd_rand0`` and equals 1043618065.

.. code:: cpp
template <int _N>
using minstd_rand_vec = linear_congruential_engine<sycl::vec<uint_fast32_t, _N>, 48271, 0, 2147483647>;
Required behavior: The 10000th consecutively produced random number value of a default-constructed object
of type ``minstd_rand_vec<>`` is the same as for ``minstd_rand`` and equals 399268537.

.. code:: cpp
template <int _N>
using ranlux24_base_vec = subtract_with_carry_engine<sycl::vec<uint_fast32_t, _N>, 24, 10, 24>
Required behavior: The 10000th consecutively produced random number value of a default-constructed object
of type ``ranlux24_base_vec<>`` is the same as for ``ranlux24_base`` and equals 7937952.

.. code:: cpp
template <int _N>
using ranlux48_base_vec = subtract_with_carry_engine<sycl::vec<uint_fast64_t, _N>, 48, 5, 12>;
Required behavior: The 10000th consecutively produced random number value of a default-constructed object
of type ``ranlux48_base_vec<>`` is the same as for ``ranlux48_base`` and equals 61839128582725.

.. code:: cpp
template <int _N>
using ranlux24_vec = discard_block_engine<ranlux24_base_vec<_N>, 223, 23>;
Required behavior: The 10000th consecutively produced random number value of a default-constructed object
of type ``ranlux24_vec<>`` is the same as for ``ranlux24`` and equals 9901578.

.. code:: cpp
template <int _N>
using ranlux48_vec = discard_block_engine<ranlux48_base_vec<_N>, 389, 11>;
Required behavior: The 10000th consecutively produced random number value of a default-constructed object
of type ``ranlux48_vec<>`` is the same as for ``ranlux48`` and equals 1112339016.

- ``linear_congruential_engine<>`` class template has the UIntScalarType type for template parameters ``a``, ``c``, ``m``
- ``linear_congruential_engine<>`` class template has the ``UIntScalarType`` type for template parameters ``a``, ``c``, ``m``.
Template type parameter ``UIntScalarType``

- equals appropriate ``UIntType`` if the last one is scalar
- equals ``T`` if the ``UIntType`` is of ``sycl::vec<T, N>`` type

- distribution class templates uses a scalar_type as a type for input arguments in costructors that is
- distribution class templates uses a ``scalar_type`` as a type for input arguments in costructors that

- equals appropriate ``IntType`` or ``RealType`` distribution template parameter if the last one is scalar
- equals ``T`` if the ``UIntType`` or ``RealType`` distribution template parameter is of ``sycl::vec<T, N>`` type

- Next engines and engine adaptors with predefined parameters may be implemented:

.. container:: tablenoborder


.. list-table::
:header-rows: 1

* - Engines and engine adaptors based on ``sycl::vec<>``
- C++ standard analogue
- The 10000th consecutively produced random number value of a default-constructed object
* - ``template <int N> using minstd_rand0_vec = linear_congruential_engine<sycl::vec<::std::uint_fast32_t, N>, 16807, 0, 2147483647>;``
- ``minstd_rand0``
- 1043618065
* - ``template <int N> using minstd_rand_vec = linear_congruential_engine<sycl::vec<uint_fast32_t, N>, 48271, 0, 2147483647>;``
- ``minstd_rand``
- 399268537
* - ``template <int N> using ranlux24_base_vec = subtract_with_carry_engine<sycl::vec<uint_fast32_t, N>, 24, 10, 24>;``
- ``ranlux24_base``
- 7937952
* - ``template <int N> using ranlux48_base_vec = subtract_with_carry_engine<sycl::vec<uint_fast64_t, N>, 48, 5, 12>;``
- ``ranlux48_base``
- 61839128582725
* - ``template <int N> using ranlux24_vec = discard_block_engine<ranlux24_base_vec<N>, 223, 23>;``
- ``ranlux24``
- 9901578
* - ``template <int N> using ranlux48_vec = discard_block_engine<ranlux48_base_vec<N>, 389, 11>;``
- ``ranlux48``
- 1112339016

Limitations:
------------
The following deviations from the `C++ Standard`_ may apply:

- ``random_device`` and ``seed_seq`` classes and related APIs in other classes are not required;
- ``operator>>()``, ``operator<<()``, ``operator==()`` are not required;
- specifying the size of a random number engine's state is not required;
- distributions are only required to operate with floating point types applicable to supported SYCL devices.

Function Objects
++++++++++++++++

Expand Down

0 comments on commit 12a2ba2

Please sign in to comment.