Hello!
I'm optimizing an application with Xeon Phi 5110P. And its initialization part looks as below:
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { float *W[7]; float *B[7]; //float *dW[7]; //float *dB[7]; } net; int main(int argc, char *argv[]) { int a[8]; a[:] = 1024; //a[:] = 64; int arr1[7], arr2[7]; arr1[0:7] = a[0:7]*a[1:7]; arr2[0:7] = a[1:7]; net n1; for(int i=0; i<7; i++) { n1.W[i] = new float[arr1[i]]; memset(n1.W[i], 0, arr1[i]*sizeof(float)); #pragma offload_transfer target(mic:0) in(n1.W[i:1]:extent(0:arr1[i]) alloc_if(1) free_if(0)) n1.B[i] = new float[arr2[i]]; memset(n1.B[i], 0, arr2[i]*sizeof(float)); #pragma offload_transfer target(mic:0) in(n1.B[i:1]:extent(0:arr2[i]) alloc_if(1) free_if(0)) } //calculation on phi #pragma offload_transfer target(mic:0) out(n1.W[0:7]:extent(0:arr1[0:7]) alloc_if(0) free_if(1)) #pragma offload_transfer target(mic:0) out(n1.B[0:7]:extent(0:arr2[0:7]) alloc_if(0) free_if(1)) return 0; }
In the initialization step, I tried to allocate memory for the arrays of pointers on the host and transfer data to Phi. If I set the elements of array a with 64, the program runs correctly. But when I tried to set array a as 1024 as above, the program gives "offload error: allocation (base=0x10d6010, size=8388608) overlaps with existing allocation (base=0xcd6000, size=8388608)".
I'm wondering whether this problem comes from memory size limits or other reasons.
I'd appreciate if someone could help to explain this problem. thx