Software Archive
Read-only legacy content
17061 Discussions

Ofload error - data transfer

H__Kamil
Beginner
591 Views

Hello,

I am writing, because i have a problem with data transfer from a coprocessor to a host processor in offload mode. In brief: at the beginning of my computation, I transfer all data to a coprocessor (one array), After completion of calculation I want to transfer to a host processor only part of this array, but in result i get following error:

offload error: data transfer (base=0x75654640, size=7896016) not subset of existing allocation (base=0x75654640, size=4512008)

Here is example of source code:

array_Dc = _mm_malloc(..., 64);
...
#pragma offload target(mic : micZero) \
 in(array_Dc : length(size) alloc_if(0) free_if(0)) \
 out(array_Dc[micBegin : micEnd] : alloc_if(0) free_if(0) 
{
   //...
}

In this case size of this array = 564001, micBegin = 423001, micEnd = 564001. I need to transfer the data because they are used by CPU. What is a problem? How to resolve it?

0 Kudos
3 Replies
Kevin_D_Intel
Employee
591 Views

I see two different array names in your offload pragma which I expect is intentional but I cannot determine enough of your interest or what you have currently tried from the small code snippet to advise on the error or what to do. Your scenario may be one where you could use the into and alloc modifiers or there may be others alternatives but to know requires having a better understanding of your interests.

Its possible the error relates to not allocating "array".

You might look at the sampleC14.c sample from the Xeon Phi™ product samples found under /opt/intel/samples_2016/en/compiler_c/psxe/mic_samples.tgz (for PSXE 2016), or under /opt/intel/composer_xe_2015/Samples/en_US/C++ (for PSXE 2015).

There are also topics in the C++ User's Guide that might help:
Allocating Memory for Parts of Arrays
Managing Memory Allocation for Pointer Variables
Device-Only Memory Allocation
Moving Data from One Variable to Another

If you can offer more details about  the out “array”, where that’s declared/allocated, that might help. If it's possible to share your program or a smaller reproducer then we can investigate further with that also.

0 Kudos
H__Kamil
Beginner
591 Views

There was mistake in a presented piece of a source code. I use the same table "array Dc" for in and out pragma. 

Edit:

I found a solution of my problem in attached articles. I had a mistake in out pragma.

I thought that "out(x[a : b])" returns elements of x table from a to b, for example: out(x[3:5]) returns elements x[3],x[4],x[5].

In fact, it returns the "b" elements starting of x. It's my mistake. I have a poor experience of offload model.

Thanks for articles. :)

 

0 Kudos
Kevin_D_Intel
Employee
591 Views

Ok, great. Glad to hear that.

0 Kudos
Reply