Skip to content

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

Open
@danhoeflinger

Description

@danhoeflinger

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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions