<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [OpenMP 4.5] ORDERED SIMD construct in loop SIMD doesn't work as required by the specification"
href="https://bugs.llvm.org/show_bug.cgi?id=51701">51701</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[OpenMP 4.5] ORDERED SIMD construct in loop SIMD doesn't work as required by the specification
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>OpenMP
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>shiwei.lu@compiler-dev.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>For the following code:
```c
#include <stdio.h>
void work(int j) {
int i;
#pragma omp parallel
#pragma omp for simd ordered
for (i = 1; i <= 10; i++) {
printf("%d\n", i);
#pragma omp ordered simd threads
{
printf("%d\n", i * j + 100000);
}
}
}
int main() {
int k = 13;
work(k);
}
```
GCC (Ubuntu 9.3.0-11ubuntu0~18.04.1) will generate an executable which prints
something like:
```
9
7
4
5
2
3
1
100013
100026
100039
10
6
8
100052
100065
100078
100091
100104
100117
100130
```
And this output is in line with what is required by the specification (OpenMP
API v4.5): the block demarcated by an ORDERED SIMD construct in a "simd, or
loop SIMD region [..] will be exectued in the order of the loop iterations".
But the executable generated by clang will print something like:
```
1
100013
4
100052
5
100065
7
100091
6
100078
2
100026
3
100039
8
100104
10
100130
9
100117
```
For another piece of code (using ORDERED SIMD in a SIMD region, not in a loop
SIMD region):
```c
#include <stdio.h>
void work(int j) {
int i;
#pragma omp simd
for (i = 1; i <= 10; i++) {
printf("%d\n", i);
#pragma omp ordered simd
{
printf("%d\n", i * j + 100000);
}
}
}
int main() {
int k = 13;
work(k);
}
```
Both sides will output:
```
1
100013
2
100026
3
100039
4
100052
5
100065
6
100078
7
100091
8
100104
9
100117
10
```
which is correct according to the specification.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>