Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / map-arrayofstruct-3.c
blob770ac2ae1aa64855601170a9c3a7a9f32207d37c
1 #include <stdlib.h>
2 #include <assert.h>
4 struct st {
5 int *p;
6 };
8 struct tt {
9 struct st a[10];
12 struct ut {
13 struct tt *t;
16 int main (void)
18 struct tt *t = (struct tt *) malloc (sizeof *t);
19 struct ut *u = (struct ut *) malloc (sizeof *u);
21 for (int i = 0; i < 10; i++)
22 t->a[i].p = (int *) calloc (5, sizeof (int));
24 u->t = t;
26 for (int i = 0; i < 10; i++)
27 for (int j = 0; j < 10; j++)
28 for (int k = 0; k < 10; k++)
30 if (i == j || j == k || i == k)
31 continue;
33 /* This one can use "firstprivate" for T... */
34 #pragma omp target map(t->a[i].p, t->a[j].p, t->a[k].p, \
35 t->a[i].p[0:2], t->a[j].p[1:3], t->a[k].p[2])
37 t->a[i].p[0]++;
38 t->a[j].p[1]++;
39 t->a[k].p[2]++;
42 /* ...but this one must use attach/detach for T. */
43 #pragma omp target map(u->t, u->t->a[i].p, u->t->a[j].p, u->t->a[k].p, \
44 u->t->a[i].p[0:2], u->t->a[j].p[1:3], u->t->a[k].p[2])
46 u->t->a[i].p[0]++;
47 u->t->a[j].p[1]++;
48 u->t->a[k].p[2]++;
52 for (int i = 0; i < 10; i++)
54 assert (t->a[i].p[0] == 144);
55 assert (t->a[i].p[1] == 144);
56 assert (t->a[i].p[2] == 144);
57 free (t->a[i].p);
60 free (u);
61 free (t);
63 return 0;
66 /* { dg-output "(\n|\r|\r\n)" { target offload_device_nonshared_as } } */
67 /* { dg-output "libgomp: Mapped array elements must be the same .*(\n|\r|\r\n)+" { target offload_device_nonshared_as } } */
68 /* { dg-shouldfail "" { offload_device_nonshared_as } } */