Debian Codegraph @

libgomp/testsuite/libgomp.c-c++-common/array-field-1.c

raw
1 /* { dg-do run } */
2
3 #include <stdlib.h>
4 #include <string.h>
5 #include <assert.h>
6
7 #define N 16
8
9 struct Z {
10 int *ptr;
11 int arr[N];
12 int c;
13 };
14
15 int main (int argc, char *argv[])
16 {
17 struct Z *myz;
18 myz = (struct Z *) calloc (1, sizeof *myz);
19
20 #pragma omp target map(tofrom:myz->arr[0:N], myz->c)
21 {
22 for (int i = 0; i < N; i++)
23 myz->arr[i]++;
24 myz->c++;
25 }
26
27 for (int i = 0; i < N; i++)
28 assert (myz->arr[i] == 1);
29 assert (myz->c == 1);
30
31 free (myz);
32
33 return 0;
34 }
35