This is an archive of the discontinued LLVM Phabricator instance.

[Flang][OpenMP] Upstream the lowering of the parallel do combined construct
ClosedPublic

Authored by kiranchandramohan on May 12 2022, 6:10 AM.

Details

Summary

When parallel is used in a combined construct, then use a separate
function to create the parallel operation. It handles the parallel
specific clauses and leaves the rest for handling at the inner
operations.

Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Nimish Mishra <neelam.nimish@gmail.com>

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 12 2022, 6:10 AM
kiranchandramohan requested review of this revision.May 12 2022, 6:10 AM

LGTM except fow a few nits.

flang/lib/Lower/OpenMP.cpp
302
484–490

Nit: SIMD/Taskloop/Loop and combined constructs will be also implemented here.

flang/test/Lower/OpenMP/omp-parallel-wsloop.f90
4

One more regression test case for private and firstprivate with one simple data type support?

How would this affect parallel sections? Should that be changed to use the new function createCombinedParallelOp too? If not, can we change the comment to state that this is for "loop constructs" only?

Changes to address review comments.
-> Call the createCombinedParallelOp for Parallel sections too.
-> Add tests for privatisation clauses.
-> Modified the TODO

kiranchandramohan marked an inline comment as done.May 18 2022, 4:12 AM

How would this affect parallel sections? Should that be changed to use the new function createCombinedParallelOp too? If not, can we change the comment to state that this is for "loop constructs" only?

Modified the parallel sections code to use createCombinedParallelOp.

flang/lib/Lower/OpenMP.cpp
302

These two clauses are also present in inner constructs like worksharing loop, sections. Hence I left them out.

peixin accepted this revision.May 18 2022, 6:18 AM

LGTM

flang/lib/Lower/OpenMP.cpp
302

Got it. Thanks.

flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
82
flang/test/Lower/OpenMP/omp-parallel-wsloop.f90
13

Usually, I think it's better to put these filecheck before the subroutine (line 6). These filecheck and omp directives are both grey color. It's kind of hard to read. But it's also OK to me to not change this.

This revision is now accepted and ready to land.May 18 2022, 6:18 AM
shraiysh accepted this revision.May 18 2022, 9:12 PM

LGTM thank you. There is a bit of code duplication with procbind clause, can we maybe extract that in a genProcBindAttr(Fortran::parser::OmpClause::ProcBind &, mlir::omp::ClauseProcBindKindAttr&) function?

Refactor genProcBindKindAttr.

shraiysh accepted this revision.May 19 2022, 8:20 AM
shraiysh added inline comments.
flang/lib/Lower/OpenMP.cpp
347

allocateOperands and allocatorOperands are not set. They should probably use genAllocateClause. Or is it not required for parallel constructs?

flang/lib/Lower/OpenMP.cpp
347

They are left for handling at the inner construct level.

kiranchandramohan marked an inline comment as done.May 19 2022, 2:28 PM
kiranchandramohan added inline comments.
flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
82

This is the input, so no patterns here. Hence I chose not to address this comment.

flang/test/Lower/OpenMP/omp-parallel-wsloop.f90
13

At some point we can standardise the way we write. Chose to skip this for now.

peixin added inline comments.May 19 2022, 6:07 PM
flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
82

Sorry. I misread this.

flang/test/Lower/OpenMP/omp-parallel-wsloop.f90
13

Sure. I like to push forward the upstream work. Thanks for landing this.