Closed yencal closed 1 month ago
How did you run CMake to configure the build for your project? Did you pass -DENABLE_CUDA=On
?
@rhornung67 thanks for the suggestion. However when I do cmake -DENABLE_CUDA=On ../
, I get this warning from cmake
CMake Warning:
Manually-specified variables were not used by the project:
ENABLE_CUDA
If I go ahead and run make anyway, I get the same error:
/home/cyenusah/Project/hpc-heterogeneous-computing/src/daxpy/raja/raja_example/main.cpp: In function ‘int main(int, char**)’:
/home/cyenusah/Project/hpc-heterogeneous-computing/src/daxpy/raja/raja_example/main.cpp:37:24: error: ‘cuda_exec’ in namespace ‘RAJA’ does not name a template type
37 | using policy = RAJA::cuda_exec<256>;
It looks like your example is using CUDA, so you will need to tell CMake to compile your main.cpp file with CUDA, e.g.:
set_source_files_properties(main.cpp PROPERTIES LANGUAGE CUDA)
You will also need to add enable_language(CUDA)
to your CMakeLists
@davidbeckingsale. Thanks for the suggestions. I had to add set(CMAKE_CUDA_HOST_COMPILER gcc)
and set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
in addition to your suggestions to get it working.
Here is the final CMakeLists.txt
that worked for me.
cmake_minimum_required(VERSION 3.17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(THIS raja-example)
project(${THIS})
enable_language(CUDA)
set(CMAKE_CUDA_HOST_COMPILER gcc)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
find_package(RAJA REQUIRED)
set(SOURCE main.cpp)
set_source_files_properties(${SOURCE} PROPERTIES LANGUAGE CUDA)
add_executable(${THIS} ${SOURCE})
target_link_libraries(${THIS} PRIVATE RAJA)
I used cmake ../
and found that -DENABLE_CUDA=ON
did nothing.
I get this error when building a project using the RAJA CUDA backend.
Here is my
CMakeLists.txt
fileI installed RAJA using the ENABLE_CUDA cmake build flag, and it appears to install correctly since the examples that come with RAJA run the cuda backend when I execute them.
Please help on how to correctly use cmake for a project that used RAJA CUDA backend. Thanks.