OpenACC + CUDA + CMake

New users can not upload attachements, so I linked them here:
https://forums.developer.nvidia.com/t/openacc-cuda-interop-with-cmake/270794/4?u=janos.mihaly.sisak

We would like to use C with OpenACC pragmas and CUDA kernels in some hotspots.
With make everything is fine. However we would like to build with CMake.
We started with this repo:
https://github.com/jefflarkin/openacc-interoperability
We needed to remove <LINK_LIBRARIES> from CMAKE_CUDA_LINK_EXECUTABLE because it tries to link cuda libraries in the nvc++ link step, causing errors at runtime. This way however we can not link external libraries, which we want to do.

The CMake line with added LINK_LIBRARIES:

set(CMAKE_CUDA_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

It would be preferable to have an elegant solution work, without the cmake list mangling for example. Is it possible?

1 Like

Cc: @robert.maynard