Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / firstprivate-1.c
blob27da7654de9650a93753a3ee883decdd54ed3d63
1 /* { dg-additional-options "-fopt-info-note-omp" }
2 { dg-additional-options "--param=openacc-privatization=noisy" }
3 { dg-additional-options "-foffload=-fopt-info-note-omp" }
4 { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
5 for testing/documenting aspects of that functionality. */
7 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
8 aspects of that functionality. */
10 #include <openacc.h>
13 void t1 ()
15 int ok = 1;
16 int val = 2;
17 int ary[32];
18 int ondev = 0;
20 for (int i = 0; i < 32; i++)
21 ary[i] = ~0;
23 #pragma acc parallel num_gangs (32) copy (ok) firstprivate (val) copy(ary, ondev)
24 /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
26 ondev = acc_on_device (acc_device_not_host);
27 #pragma acc loop gang(static:1)
28 /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
29 for (unsigned i = 0; i < 32; i++)
31 if (val != 2)
32 ok = 0;
33 val += i;
34 ary[i] = val;
38 if (ondev)
40 if (!ok)
41 __builtin_abort ();
42 if (val != 2)
43 __builtin_abort ();
45 for (int i = 0; i < 32; i++)
46 if (ary[i] != 2 + i)
47 __builtin_abort ();
52 void t2 ()
54 int ok = 1;
55 int val = 2;
57 #pragma acc data copy(val)
59 #pragma acc parallel present (val)
61 val = 7;
64 #pragma acc parallel firstprivate (val) copy(ok)
66 ok = val == 7;
67 val = 9;
71 if (!ok)
72 __builtin_abort ();
73 if (val != 7)
74 __builtin_abort ();
78 #define N 100
79 void t3 ()
81 int a, b[N], c, d, i;
82 int n = acc_get_device_type () != acc_device_host ? N : 1;
84 a = 5;
85 for (i = 0; i < n; i++)
86 b[i] = -1;
88 #pragma acc parallel num_gangs (n) firstprivate (a)
89 #pragma acc loop gang
90 /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
91 for (i = 0; i < n; i++)
93 a = a + i;
94 b[i] = a;
97 for (i = 0; i < n; i++)
98 if (a + i != b[i])
99 __builtin_abort ();
101 #pragma acc data copy (a)
103 #pragma acc parallel firstprivate (a) copyout (c)
105 a = 10;
106 c = a;
109 /* This version of 'a' should still be 5. */
110 #pragma acc parallel copyout (d) present (a)
112 d = a;
116 if (c != 10)
117 __builtin_abort ();
118 if (d != 5)
119 __builtin_abort ();
121 #undef N
124 void t4 ()
126 int x = 5, i, arr[32];
128 for (i = 0; i < 32; i++)
129 arr[i] = 3;
131 #pragma acc parallel firstprivate(x) copy(arr) num_gangs(32) num_workers(8) vector_length(32)
132 /* { dg-warning "region is worker partitioned but does not contain worker partitioned code" "" { target *-*-* } .-1 } */
133 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-2 } */
135 #pragma acc loop gang
136 /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
137 for (i = 0; i < 32; i++)
138 arr[i] += x;
141 for (i = 0; i < 32; i++)
142 if (arr[i] != 8)
143 __builtin_abort ();
148 main()
150 t1 ();
151 t2 ();
152 t3 ();
153 t4 ();
155 return 0;