Merge pull request #5 from XSShawnZeng/cmake_transition

Cmake transition
This commit is contained in:
XSShawnZeng 2025-01-17 10:51:43 +08:00 committed by GitHub
commit 03a7300081
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 222 additions and 28 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
build
.vs
.vs
.clangd

View File

@ -25,3 +25,17 @@ target_compile_options(simpleTexture PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extend
target_compile_features(simpleTexture PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Copy data files to output directory
add_custom_command(TARGET simpleTexture POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot512.pgm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET simpleTexture POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_rotated.pgm
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -43,6 +43,20 @@ add_custom_command(
COMMENT "Building CUDA fatbin: ${CUDA_FATBIN_FILE}"
)
# Copy data files to output directory
add_custom_command(TARGET simpleTextureDrv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot512.pgm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET simpleTextureDrv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_rotated.pgm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Create a dummy target for fatbin generation
add_custom_target(generate_fatbin_textureDrv ALL DEPENDS ${CUDA_FATBIN_FILE})

View File

@ -47,3 +47,24 @@ target_compile_features(boxFilter PRIVATE cxx_std_17 cuda_std_17)
else()
message(STATUS "OpenGL not found - will not build sample 'boxFilter'")
endif()
# Copy data files to output directory
add_custom_command(TARGET boxFilter POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot1024.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET boxFilter POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_14.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET boxFilter POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_22.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -36,3 +36,17 @@ add_custom_command(TARGET dct8x8 POST_BUILD
${REF_DATA}
${CMAKE_CURRENT_BINARY_DIR}
)
# Copy data files to output directory
add_custom_command(TARGET dct8x8 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot512.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET dct8x8 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot512.bmp
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -25,3 +25,24 @@ target_compile_options(eigenvalues PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended
target_compile_features(eigenvalues PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(eigenvalues PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Copy data files to output directory
add_custom_command(TARGET eigenvalues POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/diagonal.dat
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET eigenvalues POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/superdiagonal.dat
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET eigenvalues POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/reference.dat
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -25,3 +25,24 @@ target_compile_options(segmentationTreeThrust PRIVATE $<$<COMPILE_LANGUAGE:CUDA>
target_compile_features(segmentationTreeThrust PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(segmentationTreeThrust PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Copy data files to output directory
add_custom_command(TARGET segmentationTreeThrust POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/test.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET segmentationTreeThrust POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_00.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET segmentationTreeThrust POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_09.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -47,3 +47,10 @@ target_compile_features(freeImageInteropNPP PRIVATE cxx_std_17 cuda_std_17)
else()
message(STATUS "FreeImage not found - will not build sample 'freeImageInteropNPP'")
endif()
# Copy data files to output directory
add_custom_command(TARGET freeImageInteropNPP POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/data/teapot512.pgm
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -48,3 +48,10 @@ target_compile_features(histEqualizationNPP PRIVATE cxx_std_17 cuda_std_17)
else()
message(STATUS "FreeImage not found - will not build sample 'histEqualizationNPP'")
endif()
# Copy data files to output directory
add_custom_command(TARGET histEqualizationNPP POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/data/teapot512.pgm
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -35,3 +35,24 @@ target_link_libraries(watershedSegmentationNPP PRIVATE
CUDA::nppif
CUDA::cudart
)
# Copy data files to output directory
add_custom_command(TARGET watershedSegmentationNPP POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/data/teapot_512x512_8u_Gray.raw
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET watershedSegmentationNPP POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/data/CT_skull_512x512_8u_Gray.raw
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET watershedSegmentationNPP POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/data/Rocks_512x512_8u_Gray.raw
${CMAKE_CURRENT_BINARY_DIR}/
)

View File

@ -33,32 +33,5 @@ cudaDeviceGetAttribute, cudaNvSciBufMultiplanar, cudaDestroyExternalMemory, cuDr
Download and install the [CUDA Toolkit 12.8](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
## Build and Run
### Linux
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
```
$ cd <sample_dir>
$ make
```
The samples makefiles can take advantage of certain options:
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are aarch64.
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
`$ make TARGET_ARCH=aarch64` <br/>
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
* **dbg=1** - build with debug symbols
```
$ make dbg=1
```
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
```
$ make SMS="50 60"
```
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
```
$ make HOST_COMPILER=g++
```
## References (for more details)

View File

@ -0,0 +1,80 @@
#==============================================================================
# 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)
# Target processor architecture
set(CMAKE_SYSTEM_PROCESSOR aarch64)
#------------------------------------------------------------------------------
# QNX host and target come from environment
# 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 ..
#------------------------------------------------------------------------------
#----------------------------------------------------------------------------
# C/C++ Compilers from QNX
#----------------------------------------------------------------------------
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)
message(FATAL_ERROR "Could not find qcc or q++ in QNX_HOST=${QNX_HOST}/usr/bin")
endif()
set(CMAKE_C_COMPILER "${QNX_QCC}")
set(CMAKE_CXX_COMPILER "${QNX_QPLUS}")
#----------------------------------------------------------------------------
# Sysroot (if you want CMake to know the default sysroot)
#----------------------------------------------------------------------------
# This is optional, but convenient if the QNX headers/libraries must be found:
#----------------------------------------------------------------------------
if(DEFINED QNX_TARGET)
set(CMAKE_SYSROOT "${QNX_TARGET}")
endif()
#----------------------------------------------------------------------------
# Additional preprocessor definitions & include paths
#----------------------------------------------------------------------------
add_compile_options(
-D_QNX_SOURCE
-DWIN_INTERFACE_CUSTOM
)
# Add an include path to /usr/include/aarch64-qnx-gnu:
include_directories("/usr/include/aarch64-qnx-gnu")
#----------------------------------------------------------------------------
# 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")
# ...
#----------------------------------------------------------------------------