Logger: find the NVTX3 headers next to nvcc too, so the aarch64 cross build compiles

CUDA::nvtx3 is only an alias for CUDAToolkit_INCLUDE_DIRS. In the aarch64 SBSA cross build that is
targets/sbsa-linux/include, and the cross-sbsa packages the image installs (cudart, crt, culibos,
cufft) do not put nvtx3 there, so Logger.cpp failed with "nvtx3/nvToolsExt.h: No such file or
directory". NVTX v3 is header-only and architecture-neutral, so the headers are now looked for in the
toolkit include dirs and then in the include dir beside nvcc (the host tree, which ships them).
One CMake decision sets JFJOCH_USE_NVTX on JFJochLogger; where no headers are found the ranges
compile out, as they already do without CUDA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-15 14:09:49 +02:00
1 parent d91fc7ca3d
commit 64a0bfebfc
2 files changed
+15 -2

No files matched your search

+14 -1
View File
@@ -43,8 +43,21 @@ ADD_LIBRARY(JFJochLogger STATIC
)
TARGET_LINK_LIBRARIES(JFJochLogger PUBLIC spdlog::spdlog JFJochVersion)
# NVTX v3 is header-only and architecture-neutral. CUDA::nvtx3 is no help here: it only points at
# CUDAToolkit_INCLUDE_DIRS, which in a cross build is the target tree (targets/sbsa-linux/include),
# and NVIDIA's cross-sbsa packages do not put nvtx3 there. So look in the target tree first and then
# in the toolkit's own include dir next to nvcc; where neither has it, the ranges compile out.
IF (JFJOCH_CUDA_AVAILABLE)
TARGET_LINK_LIBRARIES(JFJochLogger PRIVATE CUDA::nvtx3) # header-only NVTX v3
FIND_PATH(JFJOCH_NVTX3_INCLUDE_DIR nvtx3/nvToolsExt.h
HINTS ${CUDAToolkit_INCLUDE_DIRS} "${CUDAToolkit_BIN_DIR}/../include"
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
IF (JFJOCH_NVTX3_INCLUDE_DIR)
TARGET_INCLUDE_DIRECTORIES(JFJochLogger SYSTEM PRIVATE "${JFJOCH_NVTX3_INCLUDE_DIR}")
TARGET_LINK_LIBRARIES(JFJochLogger PRIVATE ${CMAKE_DL_LIBS}) # NVTX loads its injection library with dlopen
TARGET_COMPILE_DEFINITIONS(JFJochLogger PRIVATE JFJOCH_USE_NVTX)
ELSE()
MESSAGE(STATUS "NVTX3 headers not found - NVTX ranges compiled out")
ENDIF()
ENDIF()
ADD_LIBRARY(JFJochZMQ STATIC ZMQWrappers.cpp ZMQWrappers.h)
+1 -1
View File
@@ -9,7 +9,7 @@
#include "Logger.h"
#include "GitInfo.h"
#ifdef JFJOCH_USE_CUDA
#ifdef JFJOCH_USE_NVTX
#include <nvtx3/nvToolsExt.h>
uint64_t NvtxRangeStart(const std::string &name) {