|
1 | 1 | cmake_minimum_required(VERSION 3.18) |
2 | 2 | project(InfiniOps LANGUAGES CXX) |
3 | 3 |
|
| 4 | +if(POLICY CMP0116) |
| 5 | + cmake_policy(SET CMP0116 NEW) |
| 6 | +endif() |
| 7 | + |
4 | 8 | set(CMAKE_CXX_STANDARD 17) |
5 | 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
6 | 10 |
|
@@ -237,34 +241,24 @@ if(WITH_NVIDIA) |
237 | 241 | find_package(CUDAToolkit REQUIRED) |
238 | 242 | endif() |
239 | 243 |
|
240 | | -# Iluvatar: CUDA-compatible device, uses `clang++` with `-x ivcore` (not `nvcc`). |
| 244 | +# Iluvatar: CUDA-compatible device. CoreX clang++ works for `-x ivcore` |
| 245 | +# compilation, but CMake's CUDA language path appends `-x cuda` and can crash |
| 246 | +# the compiler. Keep CMake's CUDA language disabled for this backend and |
| 247 | +# compile the few generated dispatch sources that need CUDA syntax via custom |
| 248 | +# clang++ commands. |
241 | 249 | # Reference: `InfiniCore` `xmake/iluvatar.lua`. |
242 | 250 | if(WITH_ILUVATAR) |
243 | 251 | add_compile_definitions(WITH_ILUVATAR=1) |
244 | 252 | set(ILUVATAR_ARCH "ivcore20" CACHE STRING "Iluvatar GPU architecture") |
245 | | - find_program(CLANGXX NAMES clang++) |
246 | | - if(CLANGXX) |
247 | | - set(CMAKE_CUDA_COMPILER "${CLANGXX}" CACHE STRING "Iluvatar CUDA compiler (clang++)") |
248 | | - else() |
249 | | - set(CMAKE_CUDA_COMPILER "clang++" CACHE STRING "Iluvatar CUDA compiler (clang++)") |
| 253 | + find_program(ILUVATAR_CUDA_COMPILER NAMES clang++ HINTS /usr/local/corex/bin) |
| 254 | + if(NOT ILUVATAR_CUDA_COMPILER) |
| 255 | + message(FATAL_ERROR "`WITH_ILUVATAR` is `ON` but CoreX `clang++` was not found.") |
250 | 256 | endif() |
251 | | - # `-x ivcore` must not be in `CMAKE_CUDA_FLAGS` — CMake passes those flags |
252 | | - # to both compile and link steps. During linking, `-x ivcore` causes |
253 | | - # `clang++` to re-parse `.o` files as source code. |
254 | | - set(CMAKE_CUDA_FLAGS "--cuda-gpu-arch=${ILUVATAR_ARCH} -fPIC -Wno-error=unused-variable -Wno-error=unused-private-field -Wno-unused-variable -std=c++17" CACHE STRING "Iluvatar CUDA flags") |
255 | | - set(CMAKE_CUDA_SEPARABLE_COMPILATION OFF CACHE BOOL "Disable RDC for Iluvatar") |
256 | | - set(CMAKE_CUDA_ARCHITECTURES OFF CACHE STRING "Iluvatar CUDA architectures (passed via CMAKE_CUDA_FLAGS)") |
257 | | - # Iluvatar does not ship `libcudadevrt`, which CMake's compiler test |
258 | | - # tries to link. Disable automatic CUDA runtime linking and link |
259 | | - # manually via `find_package(CUDAToolkit)` instead. |
260 | | - set(CMAKE_CUDA_RUNTIME_LIBRARY NONE) |
261 | | - message(STATUS "Iluvatar: CUDA compiler ${CMAKE_CUDA_COMPILER}, arch ${ILUVATAR_ARCH}") |
262 | | - enable_language(CUDA) |
| 257 | + set(ILUVATAR_CUDA_FLAGS |
| 258 | + "--cuda-gpu-arch=${ILUVATAR_ARCH};-fPIC;-Wno-error=unused-variable;-Wno-error=unused-private-field;-Wno-unused-variable;-std=c++17;--cuda-path=/usr/local/corex;-x;ivcore" |
| 259 | + CACHE STRING "Iluvatar CUDA compiler flags") |
| 260 | + message(STATUS "Iluvatar: CUDA compiler ${ILUVATAR_CUDA_COMPILER}, arch ${ILUVATAR_ARCH}") |
263 | 261 | find_package(CUDAToolkit REQUIRED) |
264 | | - # Add `-x ivcore` as a compile-only flag so it is not passed during |
265 | | - # linking, where it would cause `clang++` to re-parse `.o` files as |
266 | | - # source. |
267 | | - add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-x$<SEMICOLON>ivcore>) |
268 | 262 | endif() |
269 | 263 |
|
270 | 264 | if(WITH_METAX) |
|
0 commit comments