- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @Niko_,
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-reference/top/random-number-generators/random-number-generators-device-routines/intel-onemkl-rng-device-usage-model.html
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.
Best regards,
Alina
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please let us know if your query has been resolved or not?
Regards
Rajesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I did manage to make it work that way. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
Regards
Rajesh.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page