Is there any way to initialize data to random values inside a kernel? I need all the values to be different, and since this is for porting a C++ application to DPC++ I am using USM on my data.
As a side note since I am new to DPC++. When I call a function from within a kernel it's executed on the device that kernel belongs to right?
For a generation of random numbers inside of a kernel, there is a special device APIs: https://software.intel.com/content/www/us/en/develop/documentation/oneapi-mkl-dpcpp-developer-refere...
These APIs produce scalar (similar to C++) or vector (by sycl::vec) output and you may store it in both USM or buffer-based memory or post-process it without saving it to global memory. You will need to add #include "oneapi/mkl/rng/device.hpp" only to use it, as it's header-based. Also, please, note, that you will need to add -fno-sycl-early-optimizations flag to your link line (it's a temporary known limitation, will be removed in future library releases).
Yes, you are right, that all functions, which are called within a kernel are executed on the device that kernels belong to, that's why the definition of these functions should be available in the same translation unit or it should be marked as SYCL_EXTERNAL.
Please, fill free to ask any other RNG-related questions.
Glad to know that your issue is resolved. If you need any additional information, please submit a new question as this thread will no longer be monitored.