[all-commits] [llvm/llvm-project] 411bd2: [flang][OpenMP] Support lowering parse-tree to MLI...

PeixinQiao via All-commits all-commits at lists.llvm.org
Tue Jun 7 00:10:31 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 411bd2d40788c8cb869dc4fdc37e01a57213cda9
      https://github.com/llvm/llvm-project/commit/411bd2d40788c8cb869dc4fdc37e01a57213cda9
  Author: Peixin-Qiao <qiaopeixin at huawei.com>
  Date:   2022-06-07 (Tue, 07 Jun 2022)

  Changed paths:
    M flang/include/flang/Lower/AbstractConverter.h
    M flang/include/flang/Lower/OpenMP.h
    M flang/include/flang/Lower/PFTBuilder.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Lower/OpenMP.cpp
    M flang/lib/Lower/PFTBuilder.cpp
    R flang/test/Lower/OpenMP/Todo/omp-threadprivate.f90
    A flang/test/Lower/OpenMP/threadprivate-char-array-chararray.f90
    A flang/test/Lower/OpenMP/threadprivate-commonblock.f90
    A flang/test/Lower/OpenMP/threadprivate-integer-different-kinds.f90
    A flang/test/Lower/OpenMP/threadprivate-pointer-allocatable.f90
    A flang/test/Lower/OpenMP/threadprivate-real-logical-complex-derivedtype.f90
    A flang/test/Lower/OpenMP/threadprivate-use-association.f90

  Log Message:
  -----------
  [flang][OpenMP] Support lowering parse-tree to MLIR for threadprivate directive

This supports lowering parse-tree to MLIR for threadprivate directive
following the OpenMP 5.1 [2.21.2] standard. Take the following as an
example:

```
program m
  integer, save :: i
  !$omp threadprivate(i)
  call sub(i)
  !$omp parallel
    call sub(i)
  !$omp end parallel
end
```
```
func.func @_QQmain() {
  %0 = fir.address_of(@_QFEi) : !fir.ref<i32>
  %1 = omp.threadprivate %0 : !fir.ref<i32> -> !fir.ref<i32>
  fir.call @_QPsub(%1) : (!fir.ref<i32>) -> ()
  omp.parallel   {
    %2 = omp.threadprivate %0 : !fir.ref<i32> -> !fir.ref<i32>
    fir.call @_QPsub(%2) : (!fir.ref<i32>) -> ()
    omp.terminator
  }
  return
}
```

A threadprivate operation (omp.threadprivate) is created for all
references to a threadprivate variable. The runtime will appropriately
return a threadprivate var (%1 as above) or its copy (%2 as above)
depending on whether it is outside or inside a parallel region. For
threadprivate access outside the parallel region, the threadprivate
operation is created in instantiateVar. Inside the parallel region, it
is created in createBodyOfOp.

One new utility function collectSymbolSet is created for collecting
all the variables with a property within a evaluation, which may be one
Fortran, or OpenMP, or OpenACC construct.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D124226




More information about the All-commits mailing list