comparison gcc/testsuite/c-c++-common/goacc/deep-copy-arrayofstruct.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* { dg-do compile } */
2
3 #include <stdlib.h>
4 #include <stdio.h>
5
6 typedef struct {
7 int *a;
8 int *b;
9 int *c;
10 } mystruct;
11
12 int main(int argc, char* argv[])
13 {
14 const int N = 1024;
15 const int S = 32;
16 mystruct *m = (mystruct *) calloc (S, sizeof (*m));
17 int i, j;
18
19 for (i = 0; i < S; i++)
20 {
21 m[i].a = (int *) malloc (N * sizeof (int));
22 m[i].b = (int *) malloc (N * sizeof (int));
23 m[i].c = (int *) malloc (N * sizeof (int));
24 }
25
26 for (j = 0; j < S; j++)
27 for (i = 0; i < N; i++)
28 {
29 m[j].a[i] = 0;
30 m[j].b[i] = 0;
31 m[j].c[i] = 0;
32 }
33
34 #pragma acc enter data copyin(m[0:1])
35
36 for (int i = 0; i < 99; i++)
37 {
38 int j, k;
39 for (k = 0; k < S; k++)
40 #pragma acc parallel loop copy(m[k].a[0:N]) /* { dg-error "expected .\\\). before .\\\.. token" } */
41 for (j = 0; j < N; j++)
42 m[k].a[j]++;
43
44 for (k = 0; k < S; k++)
45 #pragma acc parallel loop copy(m[k].b[0:N], m[k].c[5:N-10]) /* { dg-error "expected .\\\). before .\\\.. token" } */
46 /* { dg-error ".m. appears more than once in data clauses" "" { target c++ } .-1 } */
47 for (j = 0; j < N; j++)
48 {
49 m[k].b[j]++;
50 if (j > 5 && j < N - 5)
51 m[k].c[j]++;
52 }
53 }
54
55 #pragma acc exit data copyout(m[0:1])
56
57 for (j = 0; j < S; j++)
58 {
59 for (i = 0; i < N; i++)
60 {
61 if (m[j].a[i] != 99)
62 abort ();
63 if (m[j].b[i] != 99)
64 abort ();
65 if (i > 5 && i < N-5)
66 {
67 if (m[j].c[i] != 99)
68 abort ();
69 }
70 else
71 {
72 if (m[j].c[i] != 0)
73 abort ();
74 }
75 }
76
77 free (m[j].a);
78 free (m[j].b);
79 free (m[j].c);
80 }
81 free (m);
82
83 return 0;
84 }