Update OpenACC testcases
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / kernels-private-vars-local-worker-4.c
blob7189d2a99cd0303336d773f21e41370290c0f89e
1 #include <assert.h>
3 /* Test of worker-private variables declared in a local scope, broadcasting
4 to vector-partitioned mode. Addressable worker variable. */
6 typedef struct
8 int x, y;
9 } vec2;
11 int
12 main (int argc, char* argv[])
14 int i, arr[32 * 32 * 32];
16 for (i = 0; i < 32 * 32 * 32; i++)
17 arr[i] = i;
19 #pragma acc kernels copy(arr)
21 int j;
23 #pragma acc loop gang(num:32)
24 for (i = 0; i < 32; i++)
26 #pragma acc loop worker(num:32)
27 for (j = 0; j < 32; j++)
29 int k;
30 vec2 pt, *ptp;
32 ptp = &pt;
34 pt.x = i ^ j * 3;
36 #pragma acc loop vector(length:32)
37 for (k = 0; k < 32; k++)
38 arr[i * 1024 + j * 32 + k] += ptp->x * k;
40 ptp->y = i | j * 5;
42 #pragma acc loop vector(length:32)
43 for (k = 0; k < 32; k++)
44 arr[i * 1024 + j * 32 + k] += pt.y * k;
49 for (i = 0; i < 32; i++)
50 for (int j = 0; j < 32; j++)
51 for (int k = 0; k < 32; k++)
53 int idx = i * 1024 + j * 32 + k;
54 assert (arr[idx] == idx + (i ^ j * 3) * k + (i | j * 5) * k);
57 return 0;