llvm / llvm/llvm-project

[flang][OpenMP] defaultmap(firstprivate:scalar) is not implemented and aborts the compiler

Open
#211,433 0 comments 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

`defaultmap(firstprivate:scalar)` is not implemented and aborts the compiler.

```fortran
subroutine k(a, b, n)
real(8), intent(in) :: a(*)
real(8), intent(inout) :: b(*)
integer, intent(in) :: n
integer :: i
real(8) :: sc
sc = 2.0d0
!$omp target teams distribute parallel do defaultmap(firstprivate:scalar)
do i = 1, n
b(i) = a(i) * sc
end do
end subroutine
```

```
$ flang -fopenmp -c repro.f90
error: ...flang/lib/Lower/OpenMP/OpenMP.cpp:1715: not yet implemented:
Firstprivate is currently unsupported defaultmap behaviour
```

Only this implicit-behavior is affected. Same construct, same body, only the clause changed:

| clause | device (`--offload-arch=gfx90a`) | host (`-fopenmp`) |
|---|---|---|
| `defaultmap(firstprivate:scalar)` | **not yet implemented** | **not yet implemented** |
| `defaultmap(tofrom:scalar)` | ok | ok |
| `defaultmap(to:scalar)` | ok | ok |
| `defaultmap(default:scalar)` | ok | ok |
| `defaultmap(present:allocatable)` | ok | ok |
| no clause | ok | ok |

Not offload-specific — plain host compilation hits it too.

Reproduces on upstream flang at `02c51adb8ff2`, and on amdflang from AFAR 23.2.1 and ROCm 7.2.0. clang accepts the direct C analogue (`#pragma omp target teams distribute parallel for defaultmap(firstprivate:scalar)`) with no diagnostics.

Raising it because `defaultmap(firstprivate:scalar)` is a common way to keep per-iteration scalar temporaries off the map list in offloaded code — [MFC](https://github.com/MFlowCode/MFC) emits exactly this clause on its NVIDIA and Cray paths, and only avoids it on the AMD path by not using it there.

Related: #211401 is another not-yet-implemented in the same area (`lastprivate` on `distribute`).

This was found with the assistance of AI tools.

Contributor guide

Open the contributing guide

Research direction

Start at flang/lib/Lower/OpenMP/OpenMP.cpp around line 1715, where the reproducer reports the unsupported defaultmap behavior. Compile the shown repro.f90 with -fopenmp on the host and with --offload-arch=gfx90a, then compare the firstprivate:scalar case with the listed working clauses. Done means both compilations accept the construct without the current not-yet-implemented abort.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.