This is an archive of the discontinued LLVM Phabricator instance.

[Flang][OpenMP][Lower] Refactor implementation of PFT to MLIR lowering
ClosedPublic

Authored by skatrak on Jul 21 2023, 9:25 AM.

Details

Summary

This patch makes the following non-functional changes:

  • Extract OpenMP clause processing into a new internal ClauseProcessor class. Atomic and reduction-related clauses processing is kept unchanged, since atomic clauses are stored in OmpAtomicClauseList rather than OmpClauseList and there are many TODO comments related to the current implementation of reduction lowering. This has been left unchanged to avoid merge conflicts and work duplication.
  • Reorganize functions into sections in the file to improve readability.
  • Explicitly use mlir:: namespace everywhere, rather than just most places.
  • Spell out uses of auto in which the type wasn't explicitly stated as part of the initialization expression.
  • Normalize a few function names to match the rest and renamed variables in 'snake_case' to 'camelCase'.

The main purpose is to reduce code duplication and simplify the implementation of upcoming work to support loop-attached target constructs and teams/distribute lowering to MLIR.

Diff Detail

Event Timeline

skatrak created this revision.Jul 21 2023, 9:25 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 21 2023, 9:25 AM
skatrak requested review of this revision.Jul 21 2023, 9:25 AM
kiranchandramohan added a subscriber: shraiysh.

Nice work. LGTM.
Please wait for CI to pass. Also please check that there are no changes with the gfortran testsuite.

There was some prior work by @shraiysh. Could you go through the concerns there and ensure that it is all OK?
https://reviews.llvm.org/D121583

This revision is now accepted and ready to land.Jul 21 2023, 10:50 AM

Nice work. LGTM.
Please wait for CI to pass. Also please check that there are no changes with the gfortran testsuite.

There was some prior work by @shraiysh. Could you go through the concerns there and ensure that it is all OK?
https://reviews.llvm.org/D121583

Thank you Kiran for giving this a look. I didn't realize this was something there was some work in progress for, so my approach is slightly different.

Mainly, the ClauseProcessor in this patch doesn't have a collect() method to process all clauses and store them in the same class, as the equivalent class of the other patch does. This one works more like a utility class and the logic deciding when clauses are expected is left for the caller (which has the information about which construct or combined construct is being lowered). I'll add a comment to that patch to see if they would like any changes to my approach here.

skatrak added a subscriber: peixin.

@shraiysh, @peixin, can any of you confirm if this is an acceptable initial approach to refactoring OpenMP clause processing or if it needs any changes before landing? Thank you!

Please go ahead if you are convinced. @shraiysh and @peixin are not actively working on the project at the moment.

TIFitis accepted this revision.Jul 27 2023, 3:46 AM

Please go ahead if you are convinced. @shraiysh and @peixin are not actively working on the project at the moment.

Thank you @kiranchandramohan and @TIFitis for giving this a look. I think it's a good first approach to split clause and directive lowering, and we can later improve on it, so I think we can land the patch. I'll do this first thing on Monday, in case it breaks something after it lands, since I won't be able to see it until then.