Skip to content

[OpenMP 4.5] ORDERED SIMD construct in loop SIMD doesn't work as required by the specification #51043

Open
@llvmbot

Description

@llvmbot
Bugzilla Link 51701
Version 10.0
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

For the following code:

#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):

#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaopenmp

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions