[Mlir-commits] [mlir] [mlir][OpenMP] allow cancellation to not be directly nested (PR #134084)

Tom Eccles llvmlistbot at llvm.org
Thu Apr 3 02:32:57 PDT 2025


tblah wrote:

> If it is specified to require a closely nested construct then the above code is invalid. It is also invalid to have other OpenMP constructs in between. Will the relaxation in check miss this? If it is specified to require a closely nested region then the above code is valid.

>From OpenMP 6.0:
> If cancel-directive-name is not taskgroup, the cancel construct must be a closely nested construct of a construct that matches cancel-directive-name.

But being "closely nested" only refers to OpenMP constructs:
> A construct nested inside another construct with no other construct nested between them.

I find this a bit surprising because with this requirement, I don't see why the cancel-directive-name clause exists, let alone is compulsory.

Anyway I will update this patch to remove all of the MLIR verification here, because I agree your example seems standards compliant. But for now I will keep the flang semantic checks (which correctly enforce close nesting but do not allow the cancel in a subroutine call) because no other compiler supports this either, and I think it is more useful to have a semantic check which can catch this at compile time than to allow code with an incorrect cancel-directive-name and have the cancel be completely ignored (which I believe is what the runtime would do).

https://github.com/llvm/llvm-project/pull/134084


More information about the Mlir-commits mailing list