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

OpenMP target flags depend on CMake version #606

Open
rhornung67 opened this issue Nov 17, 2022 · 2 comments
Open

OpenMP target flags depend on CMake version #606

rhornung67 opened this issue Nov 17, 2022 · 2 comments
Labels
flags Issues related to setting compiler flags maintenance openmp Related to OpenMP support

Comments

@rhornung67
Copy link
Member

rhornung67 commented Nov 17, 2022

In RAJA, we required CMake 3.14.5 as the min cmake version (default on LC systems). Then, we specified OpenMP compiler flags for OpenMP target offload builds using, for example for clang:

-DOpenMP_CXX_FLAGS="-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda"

In the last release, we bumped the min cmake version requirement to 3.20. Now, to build and link with OpenMP target offload, we need to use:

-DBLT_OPENMP_COMPILE_FLAGS="-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda" -DBLT_OPENMP_LINK_FLAGS="-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda"

That is, we need to over-ride BLT logic for setting OpenMP complier and linker flags and force the flag settings to get the code to build and link. Fortunately, BLT gave us a way to do that.

Anyway, is this expected? Is there anything that can be done in BLT to simplify this cmake version dependency? Or, is there a better way we can handle this in our code?

@rhornung67 rhornung67 added flags Issues related to setting compiler flags openmp Related to OpenMP support maintenance labels Nov 17, 2022
@white238
Copy link
Member

We are going to revamp the OpenMP targets very soon to use the true CMake targets. Sadly yes this is expected. The CMake openmp targets didn't exist originally (or didn't work properly I can't remember). The current generator expressions are less than ideal but that is how you override it.

@skyreflectedinmirrors
Copy link

skyreflectedinmirrors commented Jun 12, 2023

I will add: right now, if you pass in e.g.:

-DOpenMP_CXX_FLAGS:STRING="-fopenmp=libomp --offload-arch=gfx90a"

to your configure line to cmake (at least, on v3.24.2), a target depending on openmp will end up using this raw string, which fails with:

[ 25%] Building CXX object blt/tests/smoke/CMakeFiles/blt_openmp_smoke.dir/blt_openmp_smoke.cpp.o
cd ~arghdos/build/blt/tests/smoke && /opt/rocm-5.4.3//llvm/bin/clang++   -Wall -Wextra      -O3 -DNDEBUG -fPIE "-fopenmp=libomp --offload-arch=gfx90a" -std=c++11 -MD -MT blt/tests/smoke/CMakeFiles/blt_openmp_smoke.dir/blt_openmp_smoke.cpp.o -MF CMakeFiles/blt_openmp_smoke.dir/blt_openmp_smoke.cpp.o.d -o CMakeFiles/blt_openmp_smoke.dir/blt_openmp_smoke.cpp.o -c ~arghdos/blt/tests/smoke/blt_openmp_smoke.cpp
clang-15: error: unsupported argument 'libomp --offload-arch=gfx90a' to option '-fopenmp='
clang-15: error: unsupported argument 'libomp --offload-arch=gfx90a' to option '-fopenmp='
clang-15: error: unsupported argument 'libomp --offload-arch=gfx90a' to option '-fopenmp='

but is parsed correctly, at least for the target defined by cmake in this version:

image

I learned through this issue that the way to get around this is to semi-colon seperate the flags :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flags Issues related to setting compiler flags maintenance openmp Related to OpenMP support
Projects
None yet
Development

No branches or pull requests

3 participants