[all-commits] [llvm/llvm-project] ce8032: [Flang][OpenMP] Use simdloop operation only for om...

Dominik Adamski via All-commits all-commits at lists.llvm.org
Mon Jan 29 01:33:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ce8032394fa4ff55c36d857e85241c1bd0cacc60
      https://github.com/llvm/llvm-project/commit/ce8032394fa4ff55c36d857e85241c1bd0cacc60
  Author: Dominik Adamski <dominik.adamski at amd.com>
  Date:   2024-01-29 (Mon, 29 Jan 2024)

  Changed paths:
    M flang/lib/Lower/OpenMP.cpp
    M flang/test/Lower/OpenMP/FIR/if-clause.f90
    M flang/test/Lower/OpenMP/FIR/loop-combined.f90
    A flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90
    A flang/test/Lower/OpenMP/Todo/omp-do-simd-linear.f90
    A flang/test/Lower/OpenMP/Todo/omp-do-simd-safelen.f90
    A flang/test/Lower/OpenMP/Todo/omp-do-simd-simdlen.f90
    M flang/test/Lower/OpenMP/if-clause.f90
    M flang/test/Lower/OpenMP/loop-combined.f90

  Log Message:
  -----------
  [Flang][OpenMP] Use simdloop operation only for omp simd pragma (#79559)

OpenMP standard differentiates between omp simd (2.9.3.1) and omp do/for
simd (2.9.3.2 for OpenMP 5.0 standard) pragmas. The first one describes
the loop which needs to be vectorized. The second pragma describes the
loop which needs to be workshared between existing threads. Each thread
can use SIMD instructions to execute its chunk of the loop.

That's why we need to model
```
!$omp simd
  do-loop
```
as `omp.simdloop` operation and add compiler hints for vectorization.

The worksharing loop:
!$omp do simd
  do-loop
should be represented as worksharing loop (`omp.wsloop`).

Currently Flang denotes both types of OpenMP pragmas by `omp.simdloop`
operation. In consequence we cannot differentiate between:
```
!$omp parallel simd
   do-loop
```
and
```
!$omp parallel do simd
   do-loop
 ```
The second loop should be workshared between multiple threads. The first one describes the loop which needs to be redundantly executed by multiple threads. Current Flang implementation does not perform worksharing for `!$omp do simd` pragma and generates valid code only for the first case.




More information about the All-commits mailing list