Skip to content
Snippets Groups Projects
Commit 9d9633d2 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

Add cmake option to set cuda architectures.

parent 5fd0c71d
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,10 @@ if (NOT DEFINED XPU_ENABLE_CUDA) ...@@ -14,6 +14,10 @@ if (NOT DEFINED XPU_ENABLE_CUDA)
set(XPU_ENABLE_CUDA OFF) set(XPU_ENABLE_CUDA OFF)
endif() endif()
if (NOT DEFINED XPU_CUDA_ARCHITECTURES)
set(XPU_CUDA_ARCHITECTURES 75)
endif()
if (NOT DEFINED XPU_ENABLE_HIP) if (NOT DEFINED XPU_ENABLE_HIP)
set(XPU_ENABLE_HIP OFF) set(XPU_ENABLE_HIP OFF)
endif() endif()
...@@ -38,7 +42,7 @@ message(STATUS " XPU_BUILD_EXAMPLES: ${XPU_BUILD_EXAMPLES}") ...@@ -38,7 +42,7 @@ message(STATUS " XPU_BUILD_EXAMPLES: ${XPU_BUILD_EXAMPLES}")
if (XPU_ENABLE_CUDA) if (XPU_ENABLE_CUDA)
include(CheckLanguage) include(CheckLanguage)
check_language(CUDA) check_language(CUDA)
message(STATUS " XPU_ENABLE_CUDA: ON (cc: ${CMAKE_CUDA_COMPILER})") message(STATUS " XPU_ENABLE_CUDA: ON (cc: ${CMAKE_CUDA_COMPILER}, arch: ${XPU_CUDA_ARCHITECTURES})")
else() else()
message(STATUS " XPU_ENABLE_CUDA: OFF") message(STATUS " XPU_ENABLE_CUDA: OFF")
endif() endif()
...@@ -69,6 +73,7 @@ endif() ...@@ -69,6 +73,7 @@ endif()
set_property(GLOBAL PROPERTY XpuRootDir "${CMAKE_CURRENT_SOURCE_DIR}") set_property(GLOBAL PROPERTY XpuRootDir "${CMAKE_CURRENT_SOURCE_DIR}")
set_property(GLOBAL PROPERTY XpuEnableCuda "${XPU_ENABLE_CUDA}") set_property(GLOBAL PROPERTY XpuEnableCuda "${XPU_ENABLE_CUDA}")
set_property(GLOBAL PROPERTY XpuCudaArchitectures "${XPU_CUDA_ARCHITECTURES}")
set_property(GLOBAL PROPERTY XpuEnableHip "${XPU_ENABLE_HIP}") set_property(GLOBAL PROPERTY XpuEnableHip "${XPU_ENABLE_HIP}")
if (DEFINED XPU_HIP_COMPILER) if (DEFINED XPU_HIP_COMPILER)
set_property(GLOBAL PROPERTY XpuHipCompiler "${XPU_HIP_COMPILER}") set_property(GLOBAL PROPERTY XpuHipCompiler "${XPU_HIP_COMPILER}")
...@@ -78,6 +83,7 @@ function(xpu_create_subproject Library DriverType UnitySrcAbsolute) ...@@ -78,6 +83,7 @@ function(xpu_create_subproject Library DriverType UnitySrcAbsolute)
include(ExternalProject) include(ExternalProject)
set(SrcDir "${CMAKE_CURRENT_BINARY_DIR}/${Library}_${DriverType}") set(SrcDir "${CMAKE_CURRENT_BINARY_DIR}/${Library}_${DriverType}")
get_property(RootDir GLOBAL PROPERTY XpuRootDir) get_property(RootDir GLOBAL PROPERTY XpuRootDir)
get_property(CudaArchitectures GLOBAL PROPERTY XpuCudaArchitectures)
get_target_property(IncludeDirectories ${Library} INCLUDE_DIRECTORIES) get_target_property(IncludeDirectories ${Library} INCLUDE_DIRECTORIES)
get_property(HipCxx GLOBAL PROPERTY XpuHipCompiler) get_property(HipCxx GLOBAL PROPERTY XpuHipCompiler)
......
...@@ -26,6 +26,7 @@ The public headers in `src/xpu` expose the entire API (With the exception of def ...@@ -26,6 +26,7 @@ The public headers in `src/xpu` expose the entire API (With the exception of def
CMake Options: CMake Options:
- `XPU_ENABLE_CUDA`: Enable / Disable compilation for cuda. (default=`OFF`) - `XPU_ENABLE_CUDA`: Enable / Disable compilation for cuda. (default=`OFF`)
- `XPU_CUDA_ARCHITECTURES`: List of target cuda architectures. (default=`75`)
- `XPU_ENABLE_HIP`: Enable / Disable compilation for hip. (default=`OFF`) - `XPU_ENABLE_HIP`: Enable / Disable compilation for hip. (default=`OFF`)
- `XPU_HIP_COMPILER`: Path to hip-clang. (default=`/opt/rocm/llvm/bin/clang`) - `XPU_HIP_COMPILER`: Path to hip-clang. (default=`/opt/rocm/llvm/bin/clang`)
- `XPU_DEBUG`: Build gpu code with debug symbols and disable optimizations. (default=`OFF`) - `XPU_DEBUG`: Build gpu code with debug symbols and disable optimizations. (default=`OFF`)
......
...@@ -9,6 +9,7 @@ if (@DriverType@ STREQUAL "Cuda") ...@@ -9,6 +9,7 @@ if (@DriverType@ STREQUAL "Cuda")
else() else()
add_definitions(-DNDEBUG) add_definitions(-DNDEBUG)
endif() endif()
set(CMAKE_CUDA_ARCHITECTURES @CudaArchitectures@)
set_source_files_properties(@UnitySrcAbsolute@ PROPERTIES LANGUAGE CUDA) set_source_files_properties(@UnitySrcAbsolute@ PROPERTIES LANGUAGE CUDA)
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment