Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ endif()

if(KYNEMA_DRIVER_ENABLE_CUDA)
include(kynema-driver-utils)
# Host-only sources that must not be compiled as CUDA (i.e. must bypass
# nvcc/cudafe++) — see set_cuda_build_properties() for details.
set(_kynema_host_only_srcs
"${CMAKE_SOURCE_DIR}/src/MemoryUsage.cpp"
)
set(kyntargets "${KYNEMA_DRIVER_LIB_NAME};${KYNEMA_DRIVER_EXE_NAME}")
foreach(tgt IN LISTS kyntargets)
set_cuda_build_properties(${tgt})
set_cuda_build_properties(${tgt} ${_kynema_host_only_srcs})
endforeach()
endif()

Expand Down
14 changes: 14 additions & 0 deletions cmake/kynema-driver-utils.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
function(set_cuda_build_properties target)
# Optional additional arguments: a list of host-only source file paths that
# must not be compiled as CUDA. These files are explicitly kept as LANGUAGE CXX
# so they bypass nvcc/cudafe++, which crashes on GCC 13 (libstdc++ 13) headers
# such as stl_construct.h when using nvcc 12.8.1 (cudafe++ internal assertion
# failure at lexical.c in find_allocated_name_reference).
set(_host_only_srcs ${ARGN})

get_target_property(_tgt_src ${target} SOURCES)
list(FILTER _tgt_src INCLUDE REGEX "\\.cpp")

# Remove host-only sources from the CUDA list and mark them as plain CXX.
if(_host_only_srcs)
list(REMOVE_ITEM _tgt_src ${_host_only_srcs})
set_source_files_properties(${_host_only_srcs} PROPERTIES LANGUAGE CXX)
endif()

set_source_files_properties(${_tgt_src} PROPERTIES LANGUAGE CUDA)
set_target_properties(${target} PROPERTIES CUDA_ARCHITECTURES "${KYNEMA_DRIVER_CUDA_ARCH}")
set_target_properties(${target} PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
Expand Down
Loading