Add support for SIMD modifier in OpenMP worksharing loops.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
231–232 | I'm not sure I understand the modeling here. The same enum attribute is listed twice with different names, and there is no verification of what can go where. It looks like one can have OMP_SCHEUDLE_MOD_SIMD as schedule_modifiers and OMP__SCHEDULE_MOD_None as simd_modifier. Or even monotonic in one and non-monotonic in the other. Should SIMD be just a unit attribute? Also consider renaming schedule_modifiers to schedule_modifier (singular) because it can only contain a single instance anyway. | |
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
272–275 | Nit: you may need to update this comment | |
860 | This needs to error out with a message if there is more than two modifiers. We also need a verifier that checks that modifiers are what we expect them to be, e.g., there's no conflict between monotonic and non-monotonic, no repetition, etc. See the remark above. | |
990 | It looks preferable to have the default case here (modifier is none and missing modifier are the same, aren't they?) and just avoid extra printing in that case altogether. |
There is an RFC for better support for unordered lists in MLIR assembly, maybe that could be used. However, as @Leporacanthicus mentioned in the OpenMP/flang conference call, D111051 and this are part of upstreaming the fir-dev branch. In the interest of not making the upstreaming process for fir-dev more difficult, we should consider to keep the delta low and defer larger changes after complete upstreaming of fir-dev.
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
231–232 | Since simd is also a schedule modifier, maybe rename schedule_modifiers to monotonicity_modifier? I.e. we'd have monotonicity_[schedule_]modifier and simd_[schedule_]modifier. | |
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
990 | [serious] I think there might be a real bug here. If no monotonicity modifier is used, but the simd modifier, then according this code will print schedule(static,simd). However, the parsing code will interpret the first modifier as monotonicity modifier, and try to interpret simd as one. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
231–232 | I haven't completely fixed this, but i have added error checking code in a separate commit [to keep changes here to a minimum -> helping the rebase on fir-dev to avoid too much problems]. https://reviews.llvm.org/D112526 | |
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
272–275 | Done as a separate commit. https://reviews.llvm.org/D112526 | |
860 | Done in a separate commit: | |
990 | Done in a separate commit, see https://reviews.llvm.org/D112526 |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
231–232 | Why can't that commit be folded into this change? It has not landed yet, and it would be significantly easier to review to bisect if necessary. This may require rebasing some downstream patchset, but that is the usual price to pay for developing downstream. |
Could you address @ftynse's question on why you create new reviews instead of updating this one?
Thanks for this patch. I have a few comments @Leporacanthicus.
Could you please clarify the purpose of mlir/test/Target/LLVMIR/openmp-llvm-bad-schedule-modifier.mlir? As far as I can tell, these tests can be a part of llvm-project/mlir/test/Dialect/OpenMP/invalid.mlir.
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
231–232 | +1 to SIMD being a unit attribute. Would it be better to have an ArrayAttr of ScheculeModifier (similar to the spec)? | |
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
245 | suggestion: renaming it to verifyScheduleClause and calling it from verifyWsLoopOp? | |
mlir/test/Target/LLVMIR/openmp-llvm.mlir | ||
525–526 | nit: indentation | |
537–538 | nit: indentation |
LGTM when all comments are addresesd.
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
---|---|---|
258 | Nit: please use braces symmterically | |
269 | Having two terms on the LHS isn't valid BNF AFAIK. | |
274 | Ditto, I don't understand what this wants to say. | |
307 | I believe there is a function symbolizeScheduleModifier or something similar that is generated from ODS, which returns Optional<ScheduleModifier> equal to None if the wrong keyword is used. This avoids magic strings and is also future-proof. | |
307–310 | Nit: I would have put this into the validation function. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
231–232 | I've made the simd_modifier into a unit attribute. This will need to be updated in fir-dev to match, I will make a patch for that when I get this one into llvm/main. | |
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
245 | Rename: I've changed the name to verifyScheduelModifiers to represent what it does. | |
258 | Rewritten it in a simpler way to reduce the need for parenthesis. | |
269 | Darned clang-format has messed with my comments! I'll fix, but may need to use shorter names. | |
274 | Ditto clang-format reflowing comments. | |
307 | Indeed there is. I'm changing this here, and then doing a similar change for the ScheduleKind which is being tested in form of strings above. | |
mlir/test/Target/LLVMIR/openmp-llvm.mlir | ||
525–526 | Fixing all of the incorrectly formatted tests (all my fault!) |
LGTM.
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp | ||
---|---|---|
695 | The simd modifier info is not passed to applyStaticWorkshareLoop. That is, the schedule type of StaticBalancedChunked is not handled and checked. Considering this function is refactored in https://reviews.llvm.org/D114413. Maybe you can merge this patch, and let it to be handled in D114413. |
I'm not sure I understand the modeling here. The same enum attribute is listed twice with different names, and there is no verification of what can go where. It looks like one can have OMP_SCHEUDLE_MOD_SIMD as schedule_modifiers and OMP__SCHEDULE_MOD_None as simd_modifier. Or even monotonic in one and non-monotonic in the other.
Should SIMD be just a unit attribute?
Also consider renaming schedule_modifiers to schedule_modifier (singular) because it can only contain a single instance anyway.