This is an archive of the discontinued LLVM Phabricator instance.

[Flang][OpenMP] Implementation of lowering of SIMD construct.
ClosedPublic

Authored by arnamoy10 on May 9 2022, 5:12 PM.

Details

Summary

This patch adds code so that using bbc we are able to see an end-to-end lowering of simd construct in action.

Diff Detail

Event Timeline

arnamoy10 created this revision.May 9 2022, 5:12 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 9 2022, 5:12 PM
arnamoy10 requested review of this revision.May 9 2022, 5:12 PM
arnamoy10 updated this revision to Diff 428356.May 10 2022, 6:22 AM

Fixing the test case

Looks OK. Have a few comments.

flang/lib/Lower/OpenMP.cpp
326

Nit: Can this be added to the previous if using ||?

787

Can you add Todos for the clauses or add tests for supported clauses?

flang/test/Lower/OpenMP/simd.f90
4

We are aligning with the rest of the FIR lowering tests and only testing the lowering to FIR+OpenMP dialects here. Please change this test to do just that and remove the LLVM IR check.

7

Nit: align this with rest of the code.

21

Nit: no new line.

flang/test/Lower/OpenMP/simd.f90
4
shraiysh added inline comments.May 11 2022, 4:00 AM
flang/lib/Lower/OpenMP.cpp
787

If D125302 gets merged before this, please add tests for collapse too.

flang/lib/Lower/OpenMP.cpp
714

It's time to refactor this function. It's better not to share all the code of lowering clauses for different LoopDirective since they does have different clauses.

Considering the following:

if (LoopDirective == llvm::omp::OMPD_do) {
  genWsLoop(...);
} else if (LoopDirective == llvm::omp::OMPD_simd) {
  genSIMDLoop(...);
} else {
  TODO
}

Or a switch case statement?

The clauses operands collection should be extracted into some functions so that they can be shared.

787

@shraiysh @kiranchandramohan Please notice that no clause is supported for SIMD in MLIR for now.

It's better not to refactor the code for wsloop before the upstream of it is done. So it seems to be better give TODOs when getting any clause in SIMD construct.

When the upstream for wsloop is done, it's better to refactor this code as I suggested above.

arnamoy10 updated this revision to Diff 429908.May 16 2022, 5:26 PM

Addressing reviewers comments. No test case for clauses could be added as we currently support simd without any clauses

arnamoy10 updated this revision to Diff 429909.May 16 2022, 5:28 PM

Addressing reviewers comments. No test case for clauses could be added as we currently support simd without any clauses

flang/lib/Lower/OpenMP.cpp
714

Not refactoring in this patch, waiting until wsloop comes, as suggested below

787

Did, thank you

shraiysh requested changes to this revision.May 18 2022, 8:20 PM

LGTM. Minor changes requested. Thank you!

flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
74

Split the testcase by adding

// -----
117

nit: please add a new line

flang/test/Lower/OpenMP/simd.f90
8

nit: 2-space indentation for the subroutine body.

This revision now requires changes to proceed.May 18 2022, 8:20 PM
arnamoy10 updated this revision to Diff 432914.May 30 2022, 7:05 AM

Rebasing and fixing minor stuff based on comments.

It seems you missed the portion of the original test (Fortran -> OpenMP + FIR).

arnamoy10 updated this revision to Diff 432921.May 30 2022, 7:53 AM

Adding testcase, thanks @kiranchandramohan

peixin accepted this revision.Jun 1 2022, 7:52 AM

LGTM

kiranchandramohan accepted this revision.Jun 1 2022, 8:38 AM

LG.

Not for this patch: Maybe we should also adopt the base flang style of hard TODOs for unimplemented features/clauses.

shraiysh accepted this revision.Jun 3 2022, 9:51 AM
This revision is now accepted and ready to land.Jun 3 2022, 9:51 AM
arnamoy10 updated this revision to Diff 434465.Jun 6 2022, 7:21 AM

Rebase before land

arnamoy10 updated this revision to Diff 434501.Jun 6 2022, 8:48 AM

Fixing fortran->FIR testcase after rebasing.