spcl / open-earth-compiler

development repository for the open earth compiler
https://arxiv.org/abs/2005.13014
Other
72 stars 14 forks source link

CMake needs to include CUDA directories #32

Closed Mogball closed 3 years ago

Mogball commented 3 years ago

The include

https://github.com/spcl/open-earth-compiler/blob/0303e0ec4c8476b667da84186aee1f4ac1fa7e6f/lib/Conversion/LoopsToGPU/ConvertKernelFuncToCubin.cpp#L15

Complains that cuda.h cannot be found. I had to add

include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

To the top-level CMakeLists.txt. I'm not sure this is the proper fix but I was able to compile with it.

gysit commented 3 years ago

Did you set CUDA_BACKEND_ENABLED to true in ccmake?

If yes cmake should run enable_language(CUDA) which should be sufficient to get the right include paths.

Mogball commented 3 years ago

CUDA_BACKEND_ENABLED is enabled by default, but enabling it explicitly didn't append the include path. Maybe the cmake version affects its behaviour. I'm on 3.18.1.

gysit commented 3 years ago

Interesting! Maybe CUDA is in the default include path on ubuntu (all our machines use ubuntu)

out of curiosity does it work for you to add the path /lib/Conversion/LoopsToGPU/CMakeLists.txt:

add_mlir_dialect_library(GPUToKernelAndRuntimeCalls
  ConvertKernelFuncToCubin.cpp
  ConvertKernelFuncToHsaco.cpp

  ADDITIONAL_HEADER_DIRS
  ${PROJECT_SOURCE_DIR}/include/Conversion/LoopsToGPU
  ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}

I have a slight preference for this solution. If it doesn't work I will add the path to the global cmakelists as you suggested.

Mogball commented 3 years ago

Yeah this works. Thanks!

gysit commented 3 years ago

Thanks for reporting this! Should be fixed in the master.