.. _intel-onemkl-rng-usage-model: oneMKL RNG Usage Model ====================== .. contents:: :local: :depth: 1 A typical algorithm for random number generators is as follows: #. Create and initialize the object for basic random number generator. - Use the ``skip_ahead`` or ``leapfrog`` function if it is required (used in parallel with random number generation for Host and CPU devices). #. Create and initialize the object for distribution generator. #. Call the generate routine to get random numbers with appropriate statistical distribution. The following example demonstrates generation of random numbers that is output from basic generator (engine) PHILOX4X32X10. The seed is equal to 777. The generator is used to generate 10,000 normally distributed random numbers with parameters ``a`` = 5 and ``sigma``\ = 2. The purpose of the example is to calculate the sample mean for normal distribution with the given parameters. Example of RNG Usage ******************** **Buffer API** .. literalinclude:: /_examples/rng_usage_buffer_api.cpp :language: none :linenos: **USM API** .. literalinclude:: /_examples/rng_usage_usm_api.cpp :language: none :linenos: You can also use USM with raw pointers by using the ``sycl::malloc_shared`` / ``sycl::malloc_device`` function. Additionally, examples that demonstrate usage of random number generators functionality are available in: .. code-block:: ${MKL}/examples/dpcpp/rng/source