Skip to content

Guard #pragma omp simd with OpenMP version check #2585

Description

@ggorman

Description:

When targeting OpenMP with Devito, we're seeing compilation-time warnings on some older systems:
ignoring #pragma omp simd

This is expected behavior when compiling with an OpenMP version < 4.0, as #pragma omp simd was only introduced in OpenMP 4.0 (released July 2013). In particular, the macro _OPENMP is not sufficient for this use case unless its value is ≥ 201307.

Option 1:
We should add a check in the Devito compiler pipeline to conditionally emit #pragma omp simd only if _OPENMP >= 201307.

Option 2:
We update the writing out pragma omp simd to include preprocessor guards in the generated code, e.g.:

#if defined(_OPENMP) && _OPENMP >= 201307
#pragma omp simd
#endif

The disadvantage is that this will reduce the readability of the generated code.

Option 3:
Alternative considered: Adding -Wno-unknown-pragmas to the compiler flags to silence the warning. However, this is fragile and may suppress legitimate warnings from other unintended or misspelled pragmas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions