- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include <stdlib.h>
#include <malloc.h>
#pragma offload_attribute(push, target(mic))
#include <stdio.h>
float *h;// *t;
int bytes, x, y, z;
#pragma offload_attribute(pop)
__attribute__((target (mic))) float *t;
__declspec(target (mic)) void memTest();
__declspec(target (mic)) void memTest() {
int j;
for(j=0; j<bytes; j++)
t
}
int main()
{
int i;
x = y = z = 2;
bytes = x*y*z;
h = (float*) _mm_malloc(bytes*sizeof(float), 64);
t = (float*) _mm_malloc(bytes*sizeof(float), 64);
for(i=0; i< bytes; i++)
{
h = i*1.0;
t = 0.0;
}
#pragma offload target(mic:0) in(h : length(bytes)) out( t : length(bytes) alloc_if(1) free_if(0))
{
memTest();
}
for(i=0; i<bytes; i++)
printf("%f : %f\n",h, t);
_mm_free(h);
_mm_free(t);
return 0;
}
icc memoryTest.c -o memoryTest
./memoryTest
Output :
0.000000 : 17466475581477486592.000000
1.000000 : 17897706240914489344.000000
2.000000 : 289526669708602574255922241077248.000000
3.000000 : 283188126565264719737436795568128.000000
4.000000 : 1125978593735313417306112.000000
5.000000 : 1128588921008050770330779648.000000
6.000000 : 16383931617141325824.000000
7.000000 : 289526669708602574255922241077248.000000
Instead of :
0.000000 : 1
1.000000 : 2
2.000000 : 3
3.000000 : 4
4.000000 : 5
5.000000 : 6
6.000000 : 7
7.000000 : 8
Please, suggest me what i am doing wrong
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Arpit,
You need to add "in(bytes)" to the clauses of #pragma offload, because "bytes" is a global variable:
#pragma offload target(mic:0) in(bytes) in(h : length(bytes)) out( t : length(bytes) alloc_if(1) free_if(0))
A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page