[mlir][OpenMP] `linear` clause on `omp.wsloop` asserts on `lastiter` when translating for a target device
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Please see the following mlir and fortran testcases. They both fail the following assertion:
`OpenMPToLLVMIRTranslation.cpp:4802: llvm::LogicalResult convertOmpWsloop(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&): Assertion `loopInfo->getLastIter() && "`lastiter` in CanonicalLoopInfo is nullptr"' failed.`
```mlir
module attributes {llvm.target_triple = "amdgcn-amd-amdhsa",
omp.is_gpu = true, omp.is_target_device = true} {
llvm.func @wsloop_linear_target(%x : !llvm.ptr) attributes {
omp.declare_target = #omp.declaretarget
} {
%lb = llvm.mlir.constant(0 : i32) : i32
%ub = llvm.mlir.constant(9 : i32) : i32
%step = llvm.mlir.constant(1 : i32) : i32
omp.wsloop linear(%x : !llvm.ptr = %step : i32) {
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) inclusive step (%step) {
omp.yield
}
} {linear_var_types = [i32]}
llvm.return
}
}
```
```
mlir-translate -mlir-to-llvmir test.mlir
```
```fortran
subroutine s(a)
integer :: a(10)
integer :: i, k
k = 1
!$omp target map(tofrom: a) map(tofrom: k)
!$omp parallel do linear(k:1)
do i = 1, 10
a(i) = k
end do
!$omp end parallel do
!$omp end target
end subroutine s
```
```
flang -O0 -fopenmp --offload-arch=gfx1100 -c t.f90
```
Contributor guide
Research direction
Start in OpenMPToLLVMIRTranslation.cpp at convertOmpWsloop and inspect how CanonicalLoopInfo handles lastiter for a linear clause on a target device. Reproduce with the supplied MLIR using mlir-translate and the Fortran case using flang; done means both translations complete without the assertion.
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
- Mostly clear
- Newbie friendliness
- 48/100