sched1: debug/model: dump predecessor list and BB num [NFC]
[gcc.git] / libgomp / testsuite / libgomp.c / scan-8.c
blobf09c85c36e7e98a96fdbe241580c23d3b933b793
1 /* { dg-require-effective-target size32plus } */
3 extern void abort (void);
4 int r, a[1024], b[1024];
5 unsigned short r2, b2[1024];
6 unsigned char r3, b3[1024];
8 __attribute__((noipa)) void
9 foo (int *a, int *b, unsigned short *b2, unsigned char *b3)
11 #pragma omp for reduction (inscan, +:r, r2, r3)
12 for (int i = 0; i < 1024; i++)
15 b[i] = r;
16 b2[i] = r2;
17 b3[i] = r3;
19 #pragma omp scan exclusive(r, r2, r3)
20 { r += a[i]; r2 += a[i]; r3 += a[i]; }
24 __attribute__((noipa)) int
25 bar (unsigned short *s2p, unsigned char *s3p)
27 int s = 0;
28 unsigned short s2 = 0;
29 unsigned char s3 = 0;
30 #pragma omp parallel
31 #pragma omp for reduction (inscan, +:s, s2, s3)
32 for (int i = 0; i < 1024; i++)
34 { b[i] = s; b2[i] = s2; b3[i] = s3; }
35 #pragma omp scan exclusive(s, s2, s3)
37 s += 2 * a[i];
38 s2 += 2 * a[i];
39 s3 += 2 * a[i];
42 *s2p = s2;
43 *s3p = s3;
44 return s;
47 __attribute__((noipa)) void
48 baz (int *a, int *b, unsigned short *b2, unsigned char *b3)
50 #pragma omp parallel for reduction (inscan, +:r, r2, r3)
51 for (int i = 0; i < 1024; i++)
54 b[i] = r;
55 b2[i] = r2;
56 b3[i] = r3;
58 #pragma omp scan exclusive(r, r2, r3)
60 r += a[i];
61 r2 += a[i];
62 r3 += a[i];
67 __attribute__((noipa)) int
68 qux (unsigned short *s2p, unsigned char *s3p)
70 int s = 0;
71 unsigned short s2 = 0;
72 unsigned char s3 = 0;
73 #pragma omp parallel for reduction (inscan, +:s, s2, s3)
74 for (int i = 0; i < 1024; i++)
76 { b[i] = s; b2[i] = s2; b3[i] = s3; }
77 #pragma omp scan exclusive(s, s2, s3)
78 { s += 2 * a[i]; s2 += 2 * a[i]; s3 += 2 * a[i]; }
80 *s2p = s2;
81 *s3p = s3;
82 return s;
85 int
86 main ()
88 int s = 0;
89 unsigned short s2;
90 unsigned char s3;
91 for (int i = 0; i < 1024; ++i)
93 a[i] = i;
94 b[i] = -1;
95 b2[i] = -1;
96 b3[i] = -1;
97 asm ("" : "+g" (i));
99 #pragma omp parallel
100 foo (a, b, b2, b3);
101 if (r != 1024 * 1023 / 2
102 || r2 != (unsigned short) r
103 || r3 != (unsigned char) r)
104 abort ();
105 for (int i = 0; i < 1024; ++i)
107 if (b[i] != s
108 || b2[i] != (unsigned short) s
109 || b3[i] != (unsigned char) s)
110 abort ();
111 else
113 b[i] = 25;
114 b2[i] = 24;
115 b3[i] = 26;
117 s += i;
119 if (bar (&s2, &s3) != 1024 * 1023)
120 abort ();
121 if (s2 != (unsigned short) (1024 * 1023)
122 || s3 != (unsigned char) (1024 * 1023))
123 abort ();
124 s = 0;
125 for (int i = 0; i < 1024; ++i)
127 if (b[i] != s
128 || b2[i] != (unsigned short) s
129 || b3[i] != (unsigned char) s)
130 abort ();
131 else
133 b[i] = -1;
134 b2[i] = -1;
135 b3[i] = -1;
137 s += 2 * i;
139 r = 0;
140 r2 = 0;
141 r3 = 0;
142 baz (a, b, b2, b3);
143 if (r != 1024 * 1023 / 2
144 || r2 != (unsigned short) r
145 || r3 != (unsigned char) r)
146 abort ();
147 s = 0;
148 for (int i = 0; i < 1024; ++i)
150 if (b[i] != s
151 || b2[i] != (unsigned short) s
152 || b3[i] != (unsigned char) s)
153 abort ();
154 else
156 b[i] = 25;
157 b2[i] = 24;
158 b3[i] = 26;
160 s += i;
162 s2 = 0;
163 s3 = 0;
164 if (qux (&s2, &s3) != 1024 * 1023)
165 abort ();
166 if (s2 != (unsigned short) (1024 * 1023)
167 || s3 != (unsigned char) (1024 * 1023))
168 abort ();
169 s = 0;
170 for (int i = 0; i < 1024; ++i)
172 if (b[i] != s
173 || b2[i] != (unsigned short) s
174 || b3[i] != (unsigned char) s)
175 abort ();
176 s += 2 * i;
178 return 0;