Skip to content

OpenMP SIMD meta-option #1112

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

Open
ivan-pi opened this issue Mar 19, 2025 · 3 comments
Open

OpenMP SIMD meta-option #1112

ivan-pi opened this issue Mar 19, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@ivan-pi
Copy link
Member

ivan-pi commented Mar 19, 2025

Description

Some fpm packages may like to use OpenMP SIMD directives for vectorization.

Most compilers have specific flags to enable these separately from the multi-threading and target offloading.

OpenMP SIMD Flags

Compiler SIMD Flag
GNU (gfortran) -fopenmp-simd
Intel (ifx) -qopenmp-simd
Flang -fopenmp-simd (not sure if implemented yet)
Cray (crayftn) -h omp_simd or -fopenmp-simd
NVIDIA (nvfortran) No specific flag available
LFortran ?

Possible Solution

Could this be added to the meta-package dependencies?

name = "my_openmp_package"
[dependencies]
openmp = "*"
openmp-simd = "*"

Additional Information

@ivan-pi ivan-pi added the enhancement New feature or request label Mar 19, 2025
@perazz
Copy link
Member

perazz commented Mar 19, 2025

Are simd directives part of the standard?
In other words, should we add them when versioning is available:

[dependencies]
openmp = ">=5.1" # if package uses SIMD

another option would be to use the recently introduced compiler introspection #1051 to just check if the current compiler supports them, and add them by default if so.

imho they should not be seen as a separate package (which they are not).

@ivan-pi
Copy link
Member Author

ivan-pi commented Mar 19, 2025

SIMD directives are part of the standard since OpenMP 4.0. By default options like -fopenmp/-qopenmp will also turn on the SIMD directives.

The reason there are separate flags is if only the SIMD directives are needed, it isn't necessary to link against an OpenMP runtime library (i.e. libgomp, libomp, or libiomp). Typically when -fopenmp is used there may be some hidden initialization calls needed to initialize the ICVs (internal control variables) of the runtime library. At least that is how I understood it.

@ivan-pi
Copy link
Member Author

ivan-pi commented Mar 23, 2025

I found the place where it is stated for GNU compilers,

The -fopenmp-simd flag can be used to enable a subset of OpenMP directives that do not require the linking of either the OpenMP runtime library or the POSIX threads library.

And for Intel Fortran Compiler,

You can use this option if you want to enable or disable the SIMD support with no impact on other OpenMP features. In this case, no OpenMP runtime library is needed to link and the compiler does not need to generate OpenMP runtime initialization code.

I guess the better idea would be to promote the key-value pair into an inline table (borrowing from the answer here):

openmp = "*"

to

openmp = { version=">=5.0", simd-only=true}

One could extend this to include offloading to accelerator devices:

openmp = { version=">=5.0", offload = true}

I would need to survey what other OpenMP features can be controlled individually using compiler flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants