[flang][OpenMP] Extend do concurrent mapping to multi-range loops by ergawy · Pull Request #127634 · llvm/llvm-project (original) (raw)
@llvm/pr-subscribers-flang-fir-hlfir
Author: Kareem Ergawy (ergawy)
Changes
Adds support for converting mulit-range loops to OpenMP (on the host only for now). The changes here "prepare" a loop nest for collapsing by sinking iteration variables to the innermost fir.do_loop op in the nest.
Full diff: https://github.com/llvm/llvm-project/pull/127634.diff
3 Files Affected:
- (modified) flang/docs/DoConcurrentConversionToOpenMP.md (+29)
- (modified) flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp (+91)
- (added) flang/test/Transforms/DoConcurrent/multiple_iteration_ranges.f90 (+72)
diff --git a/flang/docs/DoConcurrentConversionToOpenMP.md b/flang/docs/DoConcurrentConversionToOpenMP.md index 914ace0813f0e..e7665a7751035 100644 --- a/flang/docs/DoConcurrentConversionToOpenMP.md +++ b/flang/docs/DoConcurrentConversionToOpenMP.md @@ -173,6 +173,35 @@ omp.parallel {
+### Multi-range loops + +The pass currently supports multi-range loops as well. Given the following +example: + +```fortran
- do concurrent(i=1:n, j=1:m)
a(i,j) = i * j- end do +```
- +The generated
omp.loop_nestoperation look like: - +```
+omp.loop_nest (%arg0, %arg1)
- : index = (%17, %19) to (%18, %20)
- inclusive step (%c1_2, %c1_4) {
- fir.store %arg0 to %private_i#1 : !fir.ref
- fir.store %arg1 to %private_j#1 : !fir.ref
- ...
- omp.yield +} +```
- +It is worth noting that we have privatized versions for both iteration
+variables:
iandj. These are locally allocated inside the parallel/target +OpenMP region similar to what the single-range example in previous section +shows.