0

I have a problem with transfer data from a Intel Xeon Phi coprocessor to host CPU. I try to implement a computation using offload model. At the beginning of my computation I transfer all data to a coprocessor (one array). After computation 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 a part of source code:

array_Dc = _mm_malloc(...);
...
#pragma offload target(mic : micZero) \
 in(array_Dc : length(size) alloc_if(0) free_if(0)) \
 out(array[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?

JudgeDeath
  • 151
  • 1
  • 2
  • 9

1 Answers1

2

It is complaining that you are trying to transfer part of an array without telling it how much of the array it should be allocating on the coprocessor. It wants to know whether you want to allocate just the part of the array you are transferring or if you want to allocate a larger piece, or even the whole array. There are a couple things you can do. One is to use the alloc option. In the documentation for the 16.0 compiler, you can find the directions at Allocating Memory for Parts of Arrays. Basically, your out option would become - assuming you want to allocate space for the complete array on the coprocessor:

#pragma offload ........... out(array[micBegin : micEnd] : alloc[0 : 564001])

Another option would be to separate the array allocation from the data transfer, for example by using offload_transfer. In the documentation for the 16.0 compiler, you can find the directions at About Asynchronous Data Transfer.

One last thing - in C/C++, the value of micEnd would be the number of elements, unlike Fortran, where it would be the index of the last element. As an old time Fortran programmer, this drives me up the wall but that's the way it is.

froth
  • 319
  • 1
  • 6