[flang][OpenMP] Support reduction and in_reduction on taskloop
Flang currently parses, semantically checks, and lowers OpenMP taskloop reduction / in_reduction clauses to OpenMP MLIR, but LLVM IR translation is still missing for the full taskloop reduction path.
A minimal taskloop reduction case currently fails during OpenMP MLIR -> LLVM IR translation with:
not yet implemented: Unhandled clause reduction in omp.taskloop.context operation
The implementation is being split into smaller reviewable patches:
-
#199565 translates
task_reductiononomp.taskgroup. This is the prerequisite task-reduction setup needed by the later taskloopin_reductionpath. -
#199670 translates
reductionandin_reductiononomp.taskloop.context. It is currently stacked on #199565.
The taskloop follow-up covers the scalar/non-byref path. For taskloop reduction, the lowering emits the implicit taskgroup reduction setup and maps each generated task to runtime-provided private reduction storage through __kmpc_task_reduction_get_th_data.
For taskloop in_reduction, the lowering uses the same runtime lookup path with a null descriptor so the runtime can find the enclosing task-reduction context.
Byref reductions, reductions with cleanup regions, and two-argument initializer forms remain unsupported and are kept as diagnosed follow-up cases.
check issue #199418 more than like related i submitted a pr on that ticket yesterday
check issue #199418
Thanks for the pointer. I checked #199418, but that looks like a LoopFusion/LCSSA issue in LLVM transforms, while this issue is for Flang/OpenMP taskloop reduction/in_reduction translation.
The related upstream work I found is #110008, which tracks this as an unsupported OpenMP/Flang item, and #139704, which added TODO tests for taskloop reduction and in_reduction. This issue is intended to track the implementation work, split into smaller patches.
If you meant another taskloop/taskgroup reduction PR or issue, please point me to it and I can link it here.
The main taskloop reduction / in_reduction support tracked here has landed through the task-reduction translation stack:
- #199565 added
task_reductiontranslation foromp.taskgroup. - #199670 added
reduction/in_reductiontranslation foromp.taskloop.context. - #202611 added the related explicit
omp.task in_reductiontranslation.
The remaining unsupported richer cases such as byref reductions, cleanup regions, and two-argument initializer forms are still diagnosed and can be tracked separately if needed.
Closing this as implemented.
@llvm/issue-subscribers-mlir
Author: Sairudra More (Saieiei)
A minimal taskloop reduction case currently fails during OpenMP MLIR -> LLVM IR translation with:
not yet implemented: Unhandled clause reduction in omp.taskloop.context operation
The implementation is being split into smaller reviewable patches:
-
#199565 translates
task_reductiononomp.taskgroup. This is the prerequisite task-reduction setup needed by the later taskloopin_reductionpath. -
#199670 translates
reductionandin_reductiononomp.taskloop.context. It is currently stacked on #199565.
The taskloop follow-up covers the scalar/non-byref path. For taskloop reduction, the lowering emits the implicit taskgroup reduction setup and maps each generated task to runtime-provided private reduction storage through __kmpc_task_reduction_get_th_data.
For taskloop in_reduction, the lowering uses the same runtime lookup path with a null descriptor so the runtime can find the enclosing task-reduction context.
Byref reductions, reductions with cleanup regions, and two-argument initializer forms remain unsupported and are kept as diagnosed follow-up cases.