[all-commits] [llvm/llvm-project] 7bb115: [Flang][OpenMP] Initial support for integer reduct...

kiranchandramohan via All-commits all-commits at lists.llvm.org
Mon Jul 25 11:47:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7bb1151ba21e26d91ddaa83177bb58b4d1c36710
      https://github.com/llvm/llvm-project/commit/7bb1151ba21e26d91ddaa83177bb58b4d1c36710
  Author: Kiran Chandramohan <kiran.chandramohan at arm.com>
  Date:   2022-07-25 (Mon, 25 Jul 2022)

  Changed paths:
    M flang/include/flang/Lower/OpenMP.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Lower/OpenMP.cpp
    A flang/test/Lower/OpenMP/Todo/parallel-reduction.f90
    A flang/test/Lower/OpenMP/Todo/reduction-allocatable.f90
    A flang/test/Lower/OpenMP/Todo/reduction-and.f90
    A flang/test/Lower/OpenMP/Todo/reduction-arrays.f90
    A flang/test/Lower/OpenMP/Todo/reduction-derived-type-field.f90
    A flang/test/Lower/OpenMP/Todo/reduction-eqv.f90
    A flang/test/Lower/OpenMP/Todo/reduction-iand.f90
    A flang/test/Lower/OpenMP/Todo/reduction-ieor.f90
    A flang/test/Lower/OpenMP/Todo/reduction-ior.f90
    A flang/test/Lower/OpenMP/Todo/reduction-max.f90
    A flang/test/Lower/OpenMP/Todo/reduction-min.f90
    A flang/test/Lower/OpenMP/Todo/reduction-multiply.f90
    A flang/test/Lower/OpenMP/Todo/reduction-neqv.f90
    A flang/test/Lower/OpenMP/Todo/reduction-or.f90
    A flang/test/Lower/OpenMP/Todo/reduction-real.f90
    A flang/test/Lower/OpenMP/Todo/reduction-subtract.f90
    A flang/test/Lower/OpenMP/wsloop-reduction-int.f90
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp

  Log Message:
  -----------
  [Flang][OpenMP] Initial support for integer reduction in worksharing-loop

Lower the Flang parse-tree containing OpenMP reductions to the OpenMP
dialect. The OpenMP dialect models reductions with,
1) A reduction declaration operation that specifies how to initialize, combine,
and atomically combine private reduction variables.
2) The OpenMP operation (like wsloop) that supports reductions has an array of
reduction accumulator variables (operands) and an array attribute of the same
size that points to the reduction declaration to be used for the reduction
accumulation.
3) The OpenMP reduction operation that takes a value and an accumulator.
This operation replaces the original reduction operation in the source.

(1) is implemented by the `createReductionDecl` in OpenMP.cpp,
(2) is implemented while creating the OpenMP operation,
(3) is implemented by the `genOpenMPReduction` function in OpenMP.cpp, and
called from Bridge.cpp. The implementation of (3) is not very robust.

NOTE 1: The patch currently supports only reductions for integer type addition.
NOTE 2: Only supports reduction in the worksharing loop.
NOTE 3: Does not generate atomic combination region.
NOTE 4: Other options for creating the reduction operation include
a) having the reduction operation as a construct containing an assignment
and then handling it appropriately in the Bridge.
b) we can modify `genAssignment` or `genFIR(AssignmentStmt)` in the Bridge to
handle OpenMP reduction but so far we have tried not to mix OpenMP
and non-OpenMP code and this will break that.
I will try (b) in a separate patch.
NOTE 5: OpenMP dialect gained support for reduction with the patches:
D105358, D107343. See https://discourse.llvm.org/t/rfc-openmp-reduction-support/3367
for more details.

Reviewed By: awarzynski

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

Co-authored-by: Peixin-Qiao <qiaopeixin at huawei.com>




More information about the All-commits mailing list