Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel ICX Compiler , Intel® DPC++ Compatibility Tool, and GDB*

Question on calling function in Kernel

RAror6
New Contributor I
1,231 Views

Hello,

I found this forum post on calling functions in the kernel: https://software.intel.com/en-us/forums/oneapi-data-parallel-c-compiler/topic/856531

How is the memcpy(d_A0 different from accessors created in the kernel scope? I am curious about it.
 

Are they the same thing? Are they different in memory? 

 

Thank you! 

0 Kudos
1 Solution
GouthamK_Intel
Moderator
1,231 Views

Hi Rushiv,

Thanks for reaching out to us.!

There are broadly two ways of managing memories: 

  1. Explicitly by the programmer.
  2. Implicitly by the runtime.

DPC++ supports both Explicit and Implicit data management strategies. As both methods have their own advantages and drawbacks, you may choose any of the methods depending on your requirements. 

To implement the above strategies DPC++ provides abstractions: USM, Buffers, and Images.

USM supports both explicit and Implicit data movement strategies. As per the query which you have asked it is USM Explicit strategy. 

  • Explicit date movement with USM can be done using malloc_device() and memcpy() operations. The data should be copied explicitly by the programmer between host and device memory before and after kernel execution using memcpy() operations.

By using Buffers we can implement an Implicit data management strategy. 

  • Buffers are represented by data objects, the interaction of these memory objects between the host and device is accomplished via an accessor, which communicates the desired location of access, such as host or device, and the particular mode of access, such as read or write.

You may refer to the below link for more information regarding the memory model for oneAPI. 

https://software.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-programming-model/memory-model.html

Please let us know if the information provided is helpful.

 

 

Thanks & Regards

Goutham

View solution in original post

0 Kudos
5 Replies
GouthamK_Intel
Moderator
1,232 Views

Hi Rushiv,

Thanks for reaching out to us.!

There are broadly two ways of managing memories: 

  1. Explicitly by the programmer.
  2. Implicitly by the runtime.

DPC++ supports both Explicit and Implicit data management strategies. As both methods have their own advantages and drawbacks, you may choose any of the methods depending on your requirements. 

To implement the above strategies DPC++ provides abstractions: USM, Buffers, and Images.

USM supports both explicit and Implicit data movement strategies. As per the query which you have asked it is USM Explicit strategy. 

  • Explicit date movement with USM can be done using malloc_device() and memcpy() operations. The data should be copied explicitly by the programmer between host and device memory before and after kernel execution using memcpy() operations.

By using Buffers we can implement an Implicit data management strategy. 

  • Buffers are represented by data objects, the interaction of these memory objects between the host and device is accomplished via an accessor, which communicates the desired location of access, such as host or device, and the particular mode of access, such as read or write.

You may refer to the below link for more information regarding the memory model for oneAPI. 

https://software.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-programming-model/memory-model.html

Please let us know if the information provided is helpful.

 

 

Thanks & Regards

Goutham

0 Kudos
RAror6
New Contributor I
1,231 Views

That is extremely helpful!

Thank you so much!

I was wondering, could you tell me what an implicit USM would look like? Thank you!

0 Kudos
GouthamK_Intel
Moderator
1,226 Views

Hi,

Glad to know that the information provided was helpful.


As I have already commented that USM Supports both explicit and Implicit data movement strategies. Implicit data movement with USM can be achieved with host and shared allocations. With these types of allocations, the programmer does not need to explicitly insert copy operations (memcpy) to move data between host and device. Instead, the programmer can simply access the pointers inside a kernel, and any required data movement is performed automatically without programmer intervention.


Please do refer to the below links for more information.


https://techdecoded.intel.io/essentials/dpc-part-2-programming-best-practices/


https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/USM.adoc


Let us know if the information provided was helpful.



Best Regards

--Goutham


0 Kudos
GouthamK_Intel
Moderator
1,212 Views

Hi,

Could you please let us if the information provided helped you.

Let us know if we can close the thread.


Regards

Goutham


0 Kudos
GouthamK_Intel
Moderator
1,182 Views

Hi,


We have not heard back from you so we are closing this inquiry now. If you need further assistance, please post a new question.


Thanks & Regards

Goutham


0 Kudos
Reply