llvm / llvm/llvm-project

[flang][OpenMP] Multiple parallel regions inside "omp target loop" is skipped

Open
#186,125 1 comment 0 reactions 0 assignees View on GitHub
flang:openmp
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Take the following reproducer:

```fortran
PROGRAM reproducer
IMPLICIT NONE
INTEGER :: i

!$omp target teams loop
DO i = 1, 2
!$omp parallel
WRITE(*, *) "Hello from the first parallel region!"
!$omp end parallel

!$omp parallel
WRITE(*, *) "Hello from the second parallel region!"
!$omp end parallel
END DO
!$omp end target teams loop
END PROGRAM reproducer
```

When compiling with a recent build from source I get no output:

```
$ flang --version
flang version 23.0.0git (https://github.com/llvm/llvm-project.git 430e2b7b796756eac94c53e5f083826b625b5abc)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm/llvm-project/install/bin
$ flang -fopenmp --offload-arch=gfx1201 multiple-parallel.F90
$ ./a.out
$
```

Merging the two parallel regions into a single give the output as expected. I have tested this with both Nvidia and AMD GPU's with the same LLVM compiler, and the behavior/bug is the same on both platforms (i.e. no output at all).

Intel ifx and Cray ftn works as expected.

The reproducer here is just showing how inserting multiple parallel regions after each other in the same `omp target loop` causes the parallel regions to be completely skipped. I found this originally through a computation that was not giving the correct answer, and found that the computations were completely skipped over where I had several regions after each other in a pattern like the above.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the provided reproducer with flang -fopenmp --offload-arch=gfx1201, then compare its behavior with the version where the parallel regions are merged. Trace the OpenMP target-loop handling for consecutive parallel regions; done means both regions execute and produce output on the affected GPU targets.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.