Add support for ARMv8-R architecture
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-gwv-1.c
blob42b612a29d8de7cb28dfbd7443cb5812453501ae
1 /* This code uses nvptx inline assembly guarded with acc_on_device, which is
2 not optimized away at -O0, and then confuses the target assembler.
3 { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
5 #include <stdio.h>
7 #define N (32*32*32+17)
8 int main ()
10 int ary[N];
11 int ix;
12 int exit = 0;
13 int ondev = 0;
15 for (ix = 0; ix < N;ix++)
16 ary[ix] = -1;
18 #pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) copy(ary) copy(ondev)
20 #pragma acc loop gang worker vector
21 for (unsigned ix = 0; ix < N; ix++)
23 if (__builtin_acc_on_device (5))
25 int g = 0, w = 0, v = 0;
27 __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
28 __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
29 __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
30 ary[ix] = (g << 16) | (w << 8) | v;
31 ondev = 1;
33 else
34 ary[ix] = ix;
38 for (ix = 0; ix < N; ix++)
40 int expected = ix;
41 if(ondev)
43 int chunk_size = (N + 32*32*32 - 1) / (32*32*32);
45 int g = ix / (chunk_size * 32 * 32);
46 int w = ix / 32 % 32;
47 int v = ix % 32;
49 expected = (g << 16) | (w << 8) | v;
52 if (ary[ix] != expected)
54 exit = 1;
55 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
59 return exit;