Debian Codegraph @

libgomp/testsuite/libgomp.oacc-c-c++-common/private-atomic-1.c

raw
1 // 'atomic' access of thread-private variable
2
3 /* { dg-additional-options "-fopt-info-note-omp" }
4 { dg-additional-options "--param=openacc-privatization=noisy" }
5 { dg-additional-options "-foffload=-fopt-info-note-omp" }
6 { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
7 for testing/documenting aspects of that functionality. */
8
9 #include <assert.h>
10
11 int main (void)
12 {
13 int res;
14
15 res = 0;
16 #pragma acc parallel reduction(+: res)
17 /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
18 {
19 #pragma acc loop vector reduction(+: res)
20 /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
21 /* { dg-note {variable 'v' declared in block is candidate for adjusting OpenACC privatization level} "" { target *-*-* } .-2 }
22 { dg-note {variable 'v' ought to be adjusted for OpenACC privatization level: 'vector'} "" { target *-*-* } .-3 }
23 { dg-note {variable 'v' adjusted for OpenACC privatization level: 'vector'} "" { target { ! openacc_host_selected } } .-4 } */
24 /* { dg-note {variable 'j' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 } */
25 for (int i = 0; i < 2322; i++)
26 {
27 int v = -222;
28
29 #pragma acc loop seq
30 /* { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
31 for (int j = 0; j < 121; ++j)
32 {
33 #pragma acc atomic update
34 ++v;
35 }
36
37 res += (v == -222 + 121);
38 }
39 }
40 assert (res == 2322);
41
42 return 0;
43 }