Skip to content
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

Issue with OpenMP Macros disabling required ordered construct within SIMD loop #1975

Open
danhoeflinger opened this issue Dec 18, 2024 · 0 comments
Assignees
Labels

Comments

@danhoeflinger
Copy link
Contributor

danhoeflinger commented Dec 18, 2024

In a OpenMP SIMD loop, an ordered construct signals that the contents of the construct should be run in order, and not vectorized.
Therefore, if a SIMD loop is written with an ordered construct to preserve correctness, we should only indicate that OpenMP SIMD pragma be used if the ordered construct is also available.
Right now that is not the case. We currently use in a few places like this _ONEDPL_PRAGMA_SIMD_ORDERED_MONOTONIC. However, the monotonic clause is an ICC specific optimization which is not part of the OpenMP spec, and is ignored currently by IntelLLVM and other compilers.

IntelLLVM fully supports OpenMP 4.5 as of 2021.1 (including the SIMD loop ordered construct). However, we currently enable or disable _ONEDPL_PRAGMA_SIMD_ORDERED_MONOTONIC... based upon the availability of monotonic, not based on the availability of ordered. This results in a SIMD loop without the ordered construct should be needed for correctness.

I believe we do not see correctness issues because the compiler detects loop dependencies and refuses to vectorize the loops, but we should still fix the problem to not request a SIMD loop when an ordered construct is unavailable.

My proposed fix is to separate support for the ordered construct from ordered monotonic, and make the later depend on the former. Additionally, because we have some support for #pragma simd without OpenMP, we should connect SIMD pragmas which require an ordered construct to the availability of ordered.

Adding and utilizing the following macros should resolve the issue:
_ONEDPL_PRAGMA_SIMD_ORDERED(...) which provides _ONEDPL_PRAGMA(omp ordered simd ##__VA_ARGS__) when available
_ONEDPL_PRAGMA_SIMD_WITH_ORDERED which provides _ONEDPL_PRAGMA(omp simd), but only when ordered is also supported.

(variable number of args are to allow clauses like monotonic to be added to ordered constructs where applicable)

@danhoeflinger danhoeflinger self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant