Software Archive
Read-only legacy content
17061 Discussions

Copy A to MIC and write result to B

Dhairya_M_
Beginner
306 Views

I have arrays A and B (lets say they are big, 6GB each). I want to copy A to MIC, process it inplace and write the result to B. How do I do this?

0 Kudos
2 Replies
Sumedh_N_Intel
Employee
306 Views

To do this you would need to use the 'into' clause in your offload pragma. However, there are certain restrictions on the usage of this clause. You can find more at this compiler reference. 

I am copying a part of the compiler FAQs which could possibly help here: 

Q) The into modifier does not work correctly with offload or results in an error?

The into modifier enables you to transfer data from a variable on the host to another variable located on the coprocessor, and vice versa. When you use into with the in clause, data is copied from the CPU object to the coprocessor object. The alloc_iffree_if, and alloc modifiers apply to the into expression.

Similarly, when you use into with the out clause, data is copied from the coprocessor object to the CPU object. The alloc_iffree_if, and alloc modifiers apply to the out expression. However, there are certain conditions you need to fulfill for the into directive to work correctly with an offload.

  • The into modifier is not allowed with inout and nocopy clauses.
  • An overlap between the source and destination memory ranges leads to undefined behavior.
  •  Shape change is not allowed, e.g. transferring from a 1D array to a 2D array.

More information can be found in the compiler reference at:
Key Features > Intel® Many Integrated Core Architecture (Intel® MIC Architecture) > Programming for Intel® MIC Architecture > Offload using a pragma > Moving Data from One Variable to Another.

0 Kudos
Dhairya_M_
Beginner
306 Views

Thanks Sumedh.

0 Kudos
Reply