forked from fanspaceshow/CodeTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoffload_static_array.c
42 lines (35 loc) · 1007 Bytes
/
offload_static_array.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
/**
* 传输一维静态数组到MIC上
*/
void offload_one_dim_array(int n) {
int arr[n];
int arr2[n];
int arr3[n];
int i;
for(i = 0; i < n; i++) {
arr[i] = i;
arr2[i] = n + i;
arr3[i] = 2 * n + i;
}
//上传arr的全部元素,上传arr2的前0-4共5(长度为5)个元素,上传arr3的从索引2开始的5个元素(即索引2-6)到mic上
#pragma offload target(mic) in(arr) in(arr2:length(5)) in(arr3[1:5])
{
for(i = 0; i < n; i++) {
printf(" arr[%d] is %d\n", i, arr[i]);
}
printf("==========================\n");
for(i = 0; i < n; i++) {
printf("arr2[%d] is %d\n", i, arr2[i]);
}
printf("==========================\n");
for(i = 0; i < n; i++) {
printf("arr3[%d] is %d\n", i, arr3[i]);
}
}
}
int main() {
offload_one_dim_array(10);
return 0;
}