Bug 5133216: Add QNX tooltrain and cross build support

This commit is contained in:
shawnz 2025-05-29 16:57:28 +08:00
parent 9c0d5aaae6
commit 49307463b5
16 changed files with 113 additions and 72 deletions

View File

@ -19,6 +19,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
if(CMAKE_GENERATOR MATCHES "Visual Studio") if(CMAKE_GENERATOR MATCHES "Visual Studio")
find_package(OpenMP REQUIRED C CXX) find_package(OpenMP REQUIRED C CXX)

View File

@ -46,6 +46,14 @@ foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}") list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}")
endforeach() endforeach()
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(INCLUDES_LIST)
foreach(dir ${CUDAToolkit_INCLUDE_DIRS})
list(APPEND INCLUDES_LIST "-I${dir}")
endforeach()
string(JOIN " " INCLUDES "${INCLUDES_LIST}")
endif()
add_custom_command( add_custom_command(
OUTPUT ${CUDA_FATBIN_FILE} OUTPUT ${CUDA_FATBIN_FILE}
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE} COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

View File

@ -37,6 +37,6 @@ target_link_libraries(matrixMulDynlinkJIT PUBLIC
CUDA::cuda_driver CUDA::cuda_driver
) )
if(UNIX) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(matrixMulDynlinkJIT PUBLIC dl) target_link_libraries(matrixMulDynlinkJIT PUBLIC dl)
endif() endif()

View File

@ -48,6 +48,14 @@ foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}") list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}")
endforeach() endforeach()
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(INCLUDES_LIST)
foreach(dir ${CUDAToolkit_INCLUDE_DIRS})
list(APPEND INCLUDES_LIST "-I${dir}")
endforeach()
string(JOIN " " INCLUDES "${INCLUDES_LIST}")
endif()
add_custom_command( add_custom_command(
OUTPUT ${CUDA_FATBIN_FILE} OUTPUT ${CUDA_FATBIN_FILE}
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE} COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

View File

@ -45,6 +45,14 @@ foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}") list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}")
endforeach() endforeach()
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(INCLUDES_LIST)
foreach(dir ${CUDAToolkit_INCLUDE_DIRS})
list(APPEND INCLUDES_LIST "-I${dir}")
endforeach()
string(JOIN " " INCLUDES "${INCLUDES_LIST}")
endif()
add_custom_command( add_custom_command(
OUTPUT ${CUDA_FATBIN_FILE} OUTPUT ${CUDA_FATBIN_FILE}
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE} COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

View File

@ -45,6 +45,14 @@ foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}") list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}")
endforeach() endforeach()
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(INCLUDES_LIST)
foreach(dir ${CUDAToolkit_INCLUDE_DIRS})
list(APPEND INCLUDES_LIST "-I${dir}")
endforeach()
string(JOIN " " INCLUDES "${INCLUDES_LIST}")
endif()
add_custom_command( add_custom_command(
OUTPUT ${CUDA_FATBIN_FILE} OUTPUT ${CUDA_FATBIN_FILE}
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE} COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

View File

@ -50,6 +50,14 @@ foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}") list(APPEND GENCODE_FLAGS "-gencode=arch=compute_${arch},code=sm_${arch}")
endforeach() endforeach()
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(INCLUDES_LIST)
foreach(dir ${CUDAToolkit_INCLUDE_DIRS})
list(APPEND INCLUDES_LIST "-I${dir}")
endforeach()
string(JOIN " " INCLUDES "${INCLUDES_LIST}")
endif()
add_custom_command( add_custom_command(
OUTPUT ${CUDA_FATBIN_FILE} OUTPUT ${CUDA_FATBIN_FILE}
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE} COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

View File

@ -18,6 +18,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for bf16TensorCoreGemm # Add target for bf16TensorCoreGemm
add_executable(bf16TensorCoreGemm bf16TensorCoreGemm.cu) add_executable(bf16TensorCoreGemm bf16TensorCoreGemm.cu)

View File

@ -17,6 +17,12 @@ else()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo") # add line information to all builds for debug tools (exclusive to -G option) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo") # add line information to all builds for debug tools (exclusive to -G option)
endif() endif()
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)

View File

@ -20,6 +20,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for globalToShmemAsyncCopy # Add target for globalToShmemAsyncCopy
add_executable(globalToShmemAsyncCopy globalToShmemAsyncCopy.cu) add_executable(globalToShmemAsyncCopy globalToShmemAsyncCopy.cu)

View File

@ -20,6 +20,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for tf32TensorCoreGemm # Add target for tf32TensorCoreGemm
add_executable(tf32TensorCoreGemm tf32TensorCoreGemm.cu) add_executable(tf32TensorCoreGemm tf32TensorCoreGemm.cu)

View File

@ -21,6 +21,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for conjugateGradientMultiBlockCG # Add target for conjugateGradientMultiBlockCG
add_executable(conjugateGradientMultiBlockCG conjugateGradientMultiBlockCG.cu) add_executable(conjugateGradientMultiBlockCG conjugateGradientMultiBlockCG.cu)

View File

@ -20,6 +20,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for conjugateGradientMultiDeviceCG # Add target for conjugateGradientMultiDeviceCG
add_executable(conjugateGradientMultiDeviceCG conjugateGradientMultiDeviceCG.cu) add_executable(conjugateGradientMultiDeviceCG conjugateGradientMultiDeviceCG.cu)

View File

@ -19,6 +19,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for jitLto # Add target for jitLto
add_executable(jitLto jitLto.cpp) add_executable(jitLto jitLto.cpp)

View File

@ -19,6 +19,12 @@ endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../Common)
# This sample is not supported on QNX
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
message(STATUS "Will not build sample ${PROJECT_NAME} - not supported on QNX")
return()
endif()
# Source file # Source file
# Add target for watershedSegmentationNPP # Add target for watershedSegmentationNPP
add_executable(watershedSegmentationNPP watershedSegmentationNPP.cpp) add_executable(watershedSegmentationNPP watershedSegmentationNPP.cpp)

View File

@ -1,80 +1,27 @@
#==============================================================================
# Toolchain file for cross-compiling to aarch64 QNX
#==============================================================================
# Cross-compiling, so tell CMake that we are not building for the host system
set(CMAKE_SYSTEM_NAME QNX) set(CMAKE_SYSTEM_NAME QNX)
# Target processor architecture
set(CMAKE_SYSTEM_PROCESSOR aarch64) set(CMAKE_SYSTEM_PROCESSOR aarch64)
#------------------------------------------------------------------------------ set(QNX_HOST $ENV{QNX_HOST})
# QNX host and target come from environment set(QNX_TARGET $ENV{QNX_TARGET})
# Adjust these or hard-code paths as needed:
#
# set(QNX_HOST "/path/to/qnx/host") # e.g. /qnx/qnx710/host/linux/x86_64
# set(QNX_TARGET "/path/to/qnx/target") # e.g. /qnx/qnx710/target/qnx7
#
# You can also pass them on the cmake command line:
# cmake -D QNX_HOST=/path/to/qnx/host \
# -D QNX_TARGET=/path/to/qnx/target \
# -DCMAKE_TOOLCHAIN_FILE=toolchain-aarch64-qnx.cmake ..
#------------------------------------------------------------------------------
#---------------------------------------------------------------------------- message(STATUS "QNX_HOST = ${QNX_HOST}")
# C/C++ Compilers from QNX message(STATUS "QNX_TARGET = ${QNX_TARGET}")
#----------------------------------------------------------------------------
find_program(QNX_QCC NAMES qcc PATHS "${QNX_HOST}/usr/bin")
find_program(QNX_QPLUS NAMES q++ PATHS "${QNX_HOST}/usr/bin")
if(NOT QNX_QCC OR NOT QNX_QPLUS) set(CMAKE_C_COMPILER ${QNX_HOST}/usr/bin/qcc)
message(FATAL_ERROR "Could not find qcc or q++ in QNX_HOST=${QNX_HOST}/usr/bin") set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/q++)
endif()
set(CMAKE_C_COMPILER "${QNX_QCC}") set(CMAKE_C_COMPILER_TARGET aarch64)
set(CMAKE_CXX_COMPILER "${QNX_QPLUS}") set(CMAKE_CXX_COMPILER_TARGET aarch64)
#---------------------------------------------------------------------------- set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "" FORCE)
# Sysroot (if you want CMake to know the default sysroot) set(CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "-nodlink -L${CUDA_ROOT}/lib64 -L${CUDA_ROOT}/lib -I${CUDA_ROOT}/include")
#----------------------------------------------------------------------------
# This is optional, but convenient if the QNX headers/libraries must be found:
#----------------------------------------------------------------------------
if(DEFINED QNX_TARGET)
set(CMAKE_SYSROOT "${QNX_TARGET}")
endif()
#---------------------------------------------------------------------------- set(CMAKE_C_FLAGS " \"-V${__qnx_gcc_ver},gcc_ntoaarch64le\"")
# Additional preprocessor definitions & include paths set(CMAKE_CXX_FLAGS " \"-V${__qnx_gcc_ver},gcc_ntoaarch64le\"")
#---------------------------------------------------------------------------- set(CMAKE_CUDA_FLAGS " --qpp-config=${__qnx_gcc_ver},gcc_ntoaarch64le")
add_compile_options( set(AUTOMAGIC_NVCC_FLAGS --qpp-config=${__qnx_gcc_ver},gcc_ntoaarch64le CACHE STRING "automagic feature detection flags for cross build")
-D_QNX_SOURCE add_link_options("-V${__qnx_gcc_ver},gcc_ntoaarch64le")
-DWIN_INTERFACE_CUSTOM
)
# Add an include path to /usr/include/aarch64-qnx-gnu: set(CROSS_COMPILE_FOR_QNX ON CACHE BOOL "Cross compiling for QNX platforms")
include_directories("/usr/include/aarch64-qnx-gnu") string(APPEND CMAKE_CXX_FLAGS " -D_QNX_SOURCE")
string(APPEND CMAKE_CUDA_FLAGS " -D_QNX_SOURCE")
#----------------------------------------------------------------------------
# Linker flags
#----------------------------------------------------------------------------
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/lib/aarch64-qnx-gnu")
# Because the Makefile also adds -Wl,-rpath-link,/usr/lib/aarch64-qnx-gnu:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,/usr/lib/aarch64-qnx-gnu")
# If you have a target filesystem (TARGET_FS) to link with:
# -L$(TARGET_FS)/usr/lib
# -L$(TARGET_FS)/usr/libnvidia
# etc., you can optionally extend the link flags. For example:
#
# if(DEFINED TARGET_FS)
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
# -L${TARGET_FS}/usr/lib -Wl,-rpath-link,${TARGET_FS}/usr/lib \
# -L${TARGET_FS}/usr/libnvidia -Wl,-rpath-link,${TARGET_FS}/usr/libnvidia")
# include_directories("${TARGET_FS}/../include")
# endif()
# If you need to link additional libraries, e.g. -lslog2 under certain conditions:
# list(APPEND EXTRA_LIBS "slog2")
# ...
#----------------------------------------------------------------------------