* c-c++-common/Wrestrict.c (test_strcpy_range): Revert latest change.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-g-1.c
blob929e01c447aca7d998a27cd601849abd0024ac71
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 ix;
11 int ondev = 0;
12 int t = 0, h = 0;
14 #pragma acc parallel num_gangs(32) copy(ondev)
16 #pragma acc loop gang reduction (+:t)
17 for (unsigned ix = 0; ix < N; ix++)
19 int val = ix;
21 if (__builtin_acc_on_device (5))
23 int g = 0, w = 0, v = 0;
25 __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
26 __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
27 __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
28 val = (g << 16) | (w << 8) | v;
29 ondev = 1;
31 t += val;
35 for (ix = 0; ix < N; ix++)
37 int val = ix;
38 if(ondev)
40 int g = ix / ((N + 31) / 32);
41 int w = 0;
42 int v = 0;
44 val = (g << 16) | (w << 8) | v;
46 h += val;
48 if (t != h)
50 printf ("t=%x expected %x\n", t, h);
51 return 1;
54 return 0;