Skip to content

cmake: fix and extend openmp support #105

Open
aoymt wants to merge 3 commits intosissaschool:develfrom
aoymt:update.cmake
Open

cmake: fix and extend openmp support #105
aoymt wants to merge 3 commits intosissaschool:develfrom
aoymt:update.cmake

Conversation

@aoymt
Copy link

@aoymt aoymt commented Mar 5, 2026

This PR fixes and extends OpenMP configuration for the GNU, Intel (Legacy), and Intel oneAPI compilers. It enables OpenMP when GPU is disabled and avoids OpenMP detection issues with Intel compilers.

  • GNU compiler (cmake/compilers/GNU/CMakeLists.txt)

    • Enable OpenMP when EXT_GPU=OFF: When GPU was disabled, OpenMP was not enabled. This change adds -fopenmp for Fortran and C (compile and link) in the non-GPU path.
    • OpenMP is now available in builds without GPU support.
  • Intel Legacy compiler (cmake/compilers/intel/CMakeLists.txt)

    • OpenMP flag application: Instead of relying on add_fortran_flag_if_avail("-qopenmp") / add_c_flag_if_avail, -qopenmp is now set per target via target_compile_options and target_link_options.
    • This avoids failures of check_fortran_compiler_flag / check_c_compiler_flag for OpenMP, which can require -qopenmp at link time.
    • Both Fortran and C targets (executables and libraries) receive the appropriate -qopenmp options.
  • Intel oneAPI compiler (cmake/compilers/oneapi/CMakeLists.txt)

    • Explicit OpenMP enablement: -qopenmp is added for both Fortran and C so that oneAPI builds enable OpenMP correctly.

cf. #104

@tgorni
Copy link
Contributor

tgorni commented Mar 7, 2026

Hi, is it also possible to compile CPU code without openMP? That would be useful for workloads where multi-threading is not benficial.

@aoymt
Copy link
Author

aoymt commented Mar 7, 2026

How about introducing a cmake option EXT_OPENMP? To build the code without OpenMP, the option "-DEXT_OPENMP=OFF" would be passed to cmake (assuming that openmp is enabled by default).

@tgorni
Copy link
Contributor

tgorni commented Mar 13, 2026

That would be ok for me!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants