.. _intel-onemkl-rng-device-usage-model: oneMKL RNG Device Usage Model ============================= .. contents:: :local: :depth: 1 A typical usage model for device routines is the same as described in :ref:`intel-onemkl-rng-usage-model`: #. Create and initialize the object for basic random number generator. #. Create and initialize the object for distribution generator. #. Call the generate routine to get random numbers with appropriate statistical distribution. Example of Scalar Random Numbers Generation ------------------------------------------- .. literalinclude:: /_examples/scalar_rng.cpp :language: cpp :linenos: Example of Vector Random Numbers Generation ------------------------------------------- .. literalinclude:: /_examples/vector_rng.cpp :language: cpp :linenos: There is an opportunity to store engines between kernels manually via ``sycl::buffer`` / USM pointers or by using a specific host-side helper class called, engine descriptor. Example of Random Numbers Generation by Engines Stored in ``sycl::buffer`` -------------------------------------------------------------------------- Engines are initialized in the first kernel. Random number generation is performed in the second kernel. .. literalinclude:: /_examples/rng_engines_sycl_buffer.cpp :language: cpp :linenos: Example of Random Numbers Generation with Host-side Helpers Usage ----------------------------------------------------------------- .. literalinclude:: /_examples/rng_host_helper.cpp :language: cpp :linenos: Additionally, examples that demonstrate usage of random number generators device routines are available in: .. code-block:: ${MKL}/examples/dpcpp_device/rng/source