I wrote some code to test the speed of allocating memory on the MIC. I find that allocte 4GB memory on MIC card need
almost 14 seconds. Is this a normal speed?
The test program is like THIS:
1 #include<stdio.h>
2 #include<stdlib.h>
3 void main(){
4 int size=1024*1024*1024;
5 __attribute__((target(mic:0)))float *a;
6 a=(float*)malloc(size*sizeof(float));
7 #pragma offload target(mic:0)nocopy(a:length(size) alloc_if(1) free_if(0))
8 {}
9 #pragma offload target(mic:0)nocopy(a:length(size) alloc_if(0) free_if(1))
10 {}
11 free(a);
12 }
Then I got the OFFLOAD report:
[Offload] [MIC 0] [File] test.c
[Offload] [MIC 0] [Line] 7
[Offload] [MIC 0] [Tag] Tag 0
[Offload] [HOST] [Tag 0] [CPU Time] 13.984358(seconds)
[Offload] [MIC 0] [Tag 0] [CPU->MIC Data] 0 (bytes)
[Offload] [MIC 0] [Tag 0] [MIC Time] 0.000158(seconds)
[Offload] [MIC 0] [Tag 0] [MIC->CPU Data] 8 (bytes)
[Offload] [MIC 0] [File] test.c
[Offload] [MIC 0] [Line] 9
[Offload] [MIC 0] [Tag] Tag 1
[Offload] [HOST] [Tag 1] [CPU Time] 0.003295(seconds)
[Offload] [MIC 0] [Tag 1] [CPU->MIC Data] 16 (bytes)
[Offload] [MIC 0] [Tag 1] [MIC Time] 0.000047(seconds)
[Offload] [MIC 0] [Tag 1] [MIC->CPU Data] 0 (bytes)
I wonder if this test is right ? And allocating 4GB memory really need 14 seconds?