- Notifications
You must be signed in to change notification settings - Fork 15.3k
[OpenMP] Allow dynamic condition selector in Metadirective #86457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| @llvm/pr-subscribers-clang Author: Robin Caloudis (robincaloudis) ChangesAs reported in #82754, Metadirectives uses default for non-const user condition. This is unexpected as the OpenMP specification 5.1 allows dynamic Example:int non_const_val = 1; // A non const value makes the `condition` selector dynamic; a const value makes it static #pragma omp metadirective \ when( user= {condition(non_const_val > 0)} : parallel num_threads( num_threads ) ) \ default() { #pragma omp single assert( num_threads == omp_get_num_threads() ); } where as Background informationsAs of OpenMP 5.1, dynamic |
condition selector in Metadirective | ✅ With the latest revision this PR passed the Python code formatter. |
| ✅ With the latest revision this PR passed the C/C++ code formatter. |
| From what I understood, I'd say that there is a chance that wrong semantics are attached against the Code where Code where |
condition selector in Metadirectivecondition selector in Metadirective | // CHECK: for (int i = 0; i < 16; i++) | ||
| // CHECK: for (int i = 0; i < 16; i++) | ||
| // CHECK: int non_const_val = 1; | ||
| // CHECK-NEXT: #pragma omp parallel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual behavior: #pragma omp parallel is not in the AST as the default for non-const user condition is used
Expected: #pragma omp parallel should be in the AST as dynamic user conditions that are resolved during runtime are fully specified by OpenMP 5.1
| I'm not familiar with that section of code. Maybe @jdoerfert could give you more insights. |
As reported in #82754, Metadirectives uses default for non-const user condition. This is unexpected as the OpenMP specification 5.1 allows dynamic
conditionselector within Metadirectives. In contrast staticconditionselectors work as expected.Example (from #82754):
where as
userinuser= {...}is called selector set andconditionincondition(non_const_val > 0)is called selector (must evaluate to true for the selector to be true).Some context
As of OpenMP 5.1, dynamic
conditionselectors seem to be allowed"[...] Any non-constant expression that is evaluated to determine the suitability of a variant is evaluated according to the data state trait in the dynamic trait set of the OpenMP context. The user selector set is dynamic if the condition selector is present and the expression in the condition selector is not a constant expression; otherwise, it is static. [...]"
Assembled grammar (copied from OpenMP 5.1. specification on Metadirectives and Context Selectors):
This helps a lot when browsing through the code and its vocabulary.
Specification of Metadirectives in OpenMP 5.1
Closes: #82754