[llvm-bugs] [Bug 51701] New: [OpenMP 4.5] ORDERED SIMD construct in loop SIMD doesn't work as required by the specification

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 1 00:18:19 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51701

            Bug ID: 51701
           Summary: [OpenMP 4.5] ORDERED SIMD construct in loop SIMD
                    doesn't work as required by the specification
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenMP
          Assignee: unassignedclangbugs at nondot.org
          Reporter: shiwei.lu at compiler-dev.com
                CC: llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210901/0b1fb7f2/attachment.html>


More information about the llvm-bugs mailing list