[Flang][OpenMP] Initial support for integer reduction in worksharing-loopLower the Flang parse-tree containing OpenMP reductions to the OpenMPdialect. The OpenMP dialect models reductions with,1)
[Flang][OpenMP] Initial support for integer reduction in worksharing-loopLower the Flang parse-tree containing OpenMP reductions to the OpenMPdialect. 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 ofreduction accumulator variables (operands) and an array attribute of the samesize that points to the reduction declaration to be used for the reductionaccumulation.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, andcalled 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 includea) having the reduction operation as a construct containing an assignmentand then handling it appropriately in the Bridge.b) we can modify `genAssignment` or `genFIR(AssignmentStmt)` in the Bridge tohandle OpenMP reduction but so far we have tried not to mix OpenMPand 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/3367for more details.Reviewed By: awarzynskiDifferential Revision: https://reviews.llvm.org/D130077Co-authored-by: Peixin-Qiao <[email protected]>
show more ...
[flang][OpenMP] Support lowering parse-tree to MLIR for threadprivate directiveThis supports lowering parse-tree to MLIR for threadprivate directivefollowing the OpenMP 5.1 [2.21.2] standard. Take
[flang][OpenMP] Support lowering parse-tree to MLIR for threadprivate directiveThis supports lowering parse-tree to MLIR for threadprivate directivefollowing the OpenMP 5.1 [2.21.2] standard. Take the following as anexample:```program m integer, save :: i !$omp threadprivate(i) call sub(i) !$omp parallel call sub(i) !$omp end parallelend``````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 allreferences to a threadprivate variable. The runtime will appropriatelyreturn a threadprivate var (%1 as above) or its copy (%2 as above)depending on whether it is outside or inside a parallel region. Forthreadprivate access outside the parallel region, the threadprivateoperation is created in instantiateVar. Inside the parallel region, itis created in createBodyOfOp.One new utility function collectSymbolSet is created for collectingall the variables with a property within a evaluation, which may be oneFortran, or OpenMP, or OpenACC construct.Reviewed By: kiranchandramohanDifferential Revision: https://reviews.llvm.org/D124226
[flang] Add lowering stubs for OpenMP/OpenACC declarative constructsThis patch provides the basic infrastructure for lowering declarativeconstructs for OpenMP and OpenACC.This is part of the ups
[flang] Add lowering stubs for OpenMP/OpenACC declarative constructsThis patch provides the basic infrastructure for lowering declarativeconstructs for OpenMP and OpenACC.This is part of the upstreaming effort from the fir-dev branch in [1].[1] https://github.com/flang-compiler/f18-llvm-projectReviewed By: kiranchandramohan, shraiysh, clementvalDifferential Revision: https://reviews.llvm.org/D124225