7bb1151ba2
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@huawei.com> |
||
---|---|---|
.. | ||
flang | ||
CMakeLists.txt |