Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/pragma-2.c

raw
1 /* { dg-additional-options "-fdump-tree-original -save-temps" } */
2 /* PR c++/51484 */
3
4 #define TEST(T) { \
5 int fail = 0, trial; \
6 for (int trial = 0; trial < TRIALS && fail == 0; trial++) { \
7 _Pragma("omp target teams num_teams(1) thread_limit(1024)") \
8 {T} \
9 } \
10 }
11
12 #define TRIALS (1)
13 #define N (1024*3)
14
15 int main(void) {
16
17 double C[N], D[N];
18 double S[N];
19 double p[2];
20 int i;
21 for (i = 0; i < N; i++)
22 {C[i] = 1; D[i] = i;}
23
24 int max_threads = 224;
25
26 #define PARALLEL(X) TEST({ \
27 _Pragma("omp parallel if(threads[0] > 1) num_threads(threads[0])") \
28 { \
29 _Pragma("omp for ordered") \
30 X \
31 _Pragma("omp for schedule(auto) ordered") \
32 X \
33 } \
34 })
35
36 for (int t = 0; t <= max_threads; t += max_threads) {
37 int threads[1]; threads[0] = t;
38 S[0] = 0;
39 PARALLEL(
40 for (int i = 0; i < N; i++) { \
41 _Pragma("omp ordered") \
42 S[0] += C[i] + D[i]; \
43 })
44 }
45 return 0;
46 }
47
48 /* On expansion, the _Pragma were wrongly placed, ensure the order is now correct: */
49 /* { dg-final { scan-tree-dump "#pragma omp target.*#pragma omp teams num_teams\\(1\\) thread_limit\\(1024\\).*#pragma omp parallel num_threads\\(threads\\\[0\\\]\\) if\\(threads\\\[0\\\] > 1\\).*#pragma omp for ordered.*#pragma omp ordered.*#pragma omp for ordered schedule\\(auto\\).*#pragma omp ordered" "original" } } */
50