Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
2,480 ms | x64 debian > AddressSanitizer-x86_64-linux.TestCases::printf-5.c |
Event Timeline
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
1808 | On a first look, it looks like we have a construct here instead of a clause. Would CancelConstructType be a better name? | |
mlir/test/Dialect/OpenMP/ops.mlir | ||
1014–1037 | There are a few restrictions regarding closely nested constructs. Some of the above might not be valid usage. Could you try implementing them? |
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
1808 | If I change CancelConstruct to CancelConstructType, I am getting llvm-project/flang/lib/Semantics/check-omp-structure.cpp:1808:21: error: ‘CancelConstructType’ in ‘struct Fortran::parser::OmpClause’ does not name a type Also, it looks like code in flang has been using CancelConstruct in multiple places. | |
mlir/test/Dialect/OpenMP/ops.mlir | ||
1014–1037 | Something like this? func @omp_cancel(%if_cond : i1) -> () { // Test with optional operand; if_expr. omp.parallel { // CHECK: omp.cancel cancel_construct(parallel) if(%{{.*}}) omp.cancel cancel_construct(parallel) if(%if_cond) // CHECK: omp.terminator omp.terminator } return } |
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
1808 | You have the error because you have to update the name in OMP.td first. |
@raghavendhra Apologies for not being clear. The change request was to add a verifier to the operation to issue errors where the closely nested construct restrictions do not hold.
As per the standard, for example, the following usages are not allowed.
!$omp master !$omp cancel parallel !$omp end master
!$omp cancel parallel
Could you go through the restrictions of cancel and cancellation point (the restriction on nesting of constructs) and implement these in the verifier? You could use the Reduction Op's verifier for reference. We probably have to check the parent Op and ensure it meets the restrictions specified in the standard.
https://github.com/llvm/llvm-project/blob/76410040b9f391185c7df48c14519860e1cf75e5/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td#L1074
https://github.com/llvm/llvm-project/blob/76410040b9f391185c7df48c14519860e1cf75e5/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp#L713
Thank you so much for more insight. I added verifier and tests to invalid.mlir. Please review my latest changes.
Generally LGTM. A couple nits and minor comments.
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
---|---|---|
961 | Same as below: please expand auto and can we change the name to parentOp because op is too generic. | |
969 | Same as below: string based matching should be avoided. It would be better to use isa<ParallelOp>(parentOp) instead. | |
977 | do/for is omp.wsloop. We can add check for that too. | |
985 | nit: please expand auto for small type names and when the type is not obvious from the right hand side. | |
986 | nit: op is too generic. Can we please change the name to parentOp? | |
994 | string based matching should be avoided. It would be better to use isa<ParallelOp>(parentOp) instead. | |
mlir/test/Dialect/OpenMP/ops.mlir | ||
1016 | Nit: please add tests for cancel construct under omp.sections, omp.section and omp.wsloop also. |
Thanks for making the changes. This looks mostly good. A few more comments.
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | ||
---|---|---|
963 | Nit: Might be better to use braces here since the return message is in two lines. Same for cancellation point as well. | |
964 | Nit: an region -> a region | |
968 | Nit: Might be better to use braces in this entire if-else construct since some of them are in two lines. Same for cancellation point as well. | |
972 | Can you add the following two as well? |
Addressed comments
Updating D123828: [mlir][OpenMP] Add omp.cancel and omp.cancellationpoint.
llvm/include/llvm/Frontend/OpenMP/OMP.td | ||
---|---|---|
174 | Can you update them all if you use CancellationConstructType for the keyword? |
Fixed git-clang-format
Updating D123828: [mlir][OpenMP] Add omp.cancel and omp.cancellationpoint.
Rebasing with main
Updating D123828: [mlir][OpenMP] Add omp.cancel and omp.cancellationpoint.
ninja clang had a -Wswitch warning when the host compiler is clang. It was something like:
clang/lib/CodeGen/CGStmtOpenMP.cpp:6166:11: error: enumeration value 'OMPC_cancellation_construct_type' not handled in switch [-Werror,-Wswitch]
I have fixed it in 4d34c4e0e67d321ac6b52f787648a68ea6d267c0 but please pay attention to warnings in the future :)
On a first look, it looks like we have a construct here instead of a clause. Would CancelConstructType be a better name?