[PATCH] D123403: [OpenMP] Refactor OMPScheduleType enum.

Michael Kruse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 8 09:33:28 PDT 2022

Meinersbur created this revision.
Meinersbur added reviewers: peixin, tianshilei1992, jdoerfert, sriharikrishna, Leporacanthicus, kiranchandramohan, clementval.
Meinersbur added a project: OpenMP.
Herald added subscribers: awarzynski, sdasgup3, wenzhicui, wrengr, Chia-hungDuan, ormris, dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, guansong, hiraditya, yaxunl.
Herald added a reviewer: ftynse.
Herald added a project: All.
Meinersbur requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

The OMPScheduleType enum stores the constants from libomp's internal sched_type in kmp.h and are used by several kmp API functions. The enum values have an internal structure, namely each scheduling algorithm (e.g.) exists in four variants: unordered, orderend, normerge unordered, and nomerge ordered.

This patch (basically a followup to D114940 <https://reviews.llvm.org/D114940>) splits the "ordered" and "nomerge" bits into separate flags, as was already done for the "monotonic" and "nonmonotonic", so we can apply bit flags operations on them. It also now contains all possible combinations according to kmp's sched_type. Deriving of the OMPScheduleType enum from clause parameters has been moved form MLIR's OpenMPToLLVMIRTranslation.cpp to OpenMPIRBuilder to make available for clang as well. Since the primary purpose of the flag is the binary interface to libomp, it has been made more private to LLVMFrontend. The primary interface for generating worksharing-loop using OpenMPIRBuilder code becomes `applyWorkshareLoop` which derives the OMPScheduleType automatically and calls the appropriate emitter function.

While this is mostly a NFC refactor, it still applies the following functional changes:

- The logic from OpenMPToLLVMIRTranslation to derive the OMPScheduleType also applies to clang. Most notably, it now applies the nonmonotonic flag for non-static schedules by default.
- In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was previously not applied if the simd modifier was used. I assume this was a bug, since the effect was due to `loop.schedule_modifier()` returning `mlir::omp::ScheduleModifier::none` instead of `llvm::Optional::None`.
- In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was set even if ordered was specified, in breach to what the comment before citing the OpenMP specification says. I assume this was an oversight.

The ordered flag with parameter was not considered in this patch. Changes will need to be made (e.g. adding/modifying function parameters) when support for it is added. The lengthy names of the enum values can be discussed, for the moment this is avoiding reusing previously existing enum value names such as `StaticChunked` to avoid confusion.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123403.421525.patch
Type: text/x-patch
Size: 46245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220408/9a4a50fe/attachment-0001.bin>

More information about the cfe-commits mailing list