From e228ad93893cb4cdce54c2233385b3ede0cf5c1d Mon Sep 17 00:00:00 2001 From: XSShawnZeng Date: Mon, 6 Jan 2025 17:12:28 +0800 Subject: [PATCH 1/5] Update the CMakeLists.txt for Tegra sample nbody_opengles --- .../Tegra/nbody_opengles/CMakeLists.txt | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/Samples/8_Platform_Specific/Tegra/nbody_opengles/CMakeLists.txt b/Samples/8_Platform_Specific/Tegra/nbody_opengles/CMakeLists.txt index ac02a090..9c16a1ec 100644 --- a/Samples/8_Platform_Specific/Tegra/nbody_opengles/CMakeLists.txt +++ b/Samples/8_Platform_Specific/Tegra/nbody_opengles/CMakeLists.txt @@ -6,24 +6,52 @@ project(nbody_opengles LANGUAGES C CXX CUDA) find_package(CUDAToolkit REQUIRED) -set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 75 80 86 89 90) +set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90) if(CMAKE_BUILD_TYPE STREQUAL "Debug") # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive) endif() # Include directories and libraries -include_directories(../../../Common) +include_directories(../../../../Common) + +find_package(EGL) +find_package(X11) +find_package(OpenGL) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Source file - # Add target for nbody_opengles - add_executable(nbody_opengles nbody_opengles.cu) + if(${OpenGL_FOUND}) + if(${EGL_FOUND}) + if(${X11_FOUND}) + # Add target for nbody_opengles + add_executable(nbody_opengles bodysystemcuda.cu render_particles.cpp nbody_opengles.cpp) - target_compile_options(nbody_opengles PRIVATE $<$:--extended-lambda>) + target_compile_options(nbody_opengles PRIVATE $<$:--extended-lambda>) - target_compile_features(nbody_opengles PRIVATE cxx_std_17 cuda_std_17) + target_compile_features(nbody_opengles PRIVATE cxx_std_17 cuda_std_17) - set_target_properties(nbody_opengles PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + set_target_properties(nbody_opengles PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + + target_include_directories(nbody_opengles PUBLIC + ${EGL_INCLUDE_DIR} + ${OPENGL_INCLUDE_DIR} + ${CUDAToolkit_INCLUDE_DIRS} + ) + + target_link_libraries(nbody_opengles + ${EGL_LIBRARY} + ${X11_LIBRARIES} + ${OPENGL_LIBRARIES} + ) + else() + message(STATUS "X11 libraries not found - will not build sample 'nbody_opengles'") + endif() + else() + message(STATUS "EGL not found - will not build sample 'nbody_opengles'") + endif() + else() + message(STATUS "OpenGL not found - will not build sample 'nbody_opengles'") + endif() else() message(STATUS "Will not build sample nbody_opengles - requires Linux OS") endif() From bb121fe02b90f0dde75c2f5c34595ec879ee00ef Mon Sep 17 00:00:00 2001 From: XSShawnZeng Date: Mon, 6 Jan 2025 17:52:53 +0800 Subject: [PATCH 2/5] the CMakeLists.txt for Tegra sample fluidsGLES Able to build the sample as below: $ make Linking CUDA device code CMakeFiles/fluidsGLES.dir/cmake_device_link.o Linking CXX executable fluidsGLES Built target fluidsGLES --- .../Tegra/fluidsGLES/CMakeLists.txt | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/Samples/8_Platform_Specific/Tegra/fluidsGLES/CMakeLists.txt b/Samples/8_Platform_Specific/Tegra/fluidsGLES/CMakeLists.txt index 37a9836c..40f648b5 100644 --- a/Samples/8_Platform_Specific/Tegra/fluidsGLES/CMakeLists.txt +++ b/Samples/8_Platform_Specific/Tegra/fluidsGLES/CMakeLists.txt @@ -11,34 +11,48 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive) endif() +# Include directories and libraries +include_directories(../../../../Common) + +find_package(EGL) +find_package(X11) +find_package(OpenGL) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - find_package (OpenGL COMPONENTS EGL GLES2) - if(${OpenGL_EGL_FOUND}) - # Source file - # Add target for fluidsGLES - add_executable(fluidsGLES - fluidsGLES.cpp - fluidsGLES_kernels.cu - ) + # Source file + if(${OpenGL_FOUND}) + if(${EGL_FOUND}) + if(${X11_FOUND}) + # Add target for fluidsGLES + add_executable(fluidsGLES fluidsGLES.cpp fluidsGLES_kernels.cu) - target_compile_options(fluidsGLES PRIVATE $<$:--extended-lambda>) + target_compile_options(fluidsGLES PRIVATE $<$:--extended-lambda>) - target_compile_features(fluidsGLES PRIVATE cxx_std_17 cuda_std_17) + target_compile_features(fluidsGLES PRIVATE cxx_std_17 cuda_std_17) - set_target_properties(fluidsGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + set_target_properties(fluidsGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON) - target_include_directories(fluidsGLES PUBLIC - ${OPENGL_INCLUDE_DIRS} - ${CUDAToolkit_INCLUDE_DIRS} - ../../../Common - ) + target_include_directories(fluidsGLES PUBLIC + ${EGL_INCLUDE_DIR} + ${OPENGL_INCLUDE_DIR} + ${CUDAToolkit_INCLUDE_DIRS} + ) - target_link_libraries(fluidsGLES - ${OPENGL_LIBRARIES} - CUDA::cuda_driver - ) + target_link_libraries(fluidsGLES + CUDA::cuda_driver + CUDA::cufft + ${EGL_LIBRARY} + ${X11_LIBRARIES} + ${OPENGL_LIBRARIES} + ) + else() + message(STATUS "X11 libraries not found - will not build sample 'fluidsGLES'") + endif() + else() + message(STATUS "EGL not found - will not build sample 'fluidsGLES'") + endif() else() - message(STATUS "EGL not found - will not build sample 'fluidsGLES'") + message(STATUS "OpenGL not found - will not build sample 'fluidsGLES'") endif() else() message(STATUS "Will not build sample fluidsGLES - requires Linux OS") From 89a84131fbb4c50587f6d2d1d780b18986dbf7ab Mon Sep 17 00:00:00 2001 From: XSShawnZeng Date: Mon, 6 Jan 2025 18:47:18 +0800 Subject: [PATCH 3/5] Update CMakeLists.txt for Tegra sample simpleGLES --- .../Tegra/simpleGLES/CMakeLists.txt | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/Samples/8_Platform_Specific/Tegra/simpleGLES/CMakeLists.txt b/Samples/8_Platform_Specific/Tegra/simpleGLES/CMakeLists.txt index 24e0b3fa..cc1bc80d 100644 --- a/Samples/8_Platform_Specific/Tegra/simpleGLES/CMakeLists.txt +++ b/Samples/8_Platform_Specific/Tegra/simpleGLES/CMakeLists.txt @@ -6,24 +6,52 @@ project(simpleGLES LANGUAGES C CXX CUDA) find_package(CUDAToolkit REQUIRED) -set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 75 80 86 89 90) +set(CMAKE_CUDA_ARCHITECTURES 53 61 70 72 75 80 86 87 90) if(CMAKE_BUILD_TYPE STREQUAL "Debug") # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive) endif() # Include directories and libraries -include_directories(../../../Common) +include_directories(../../../../Common) + +find_package(EGL) +find_package(X11) +find_package(OpenGL) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Source file - # Add target for simpleGLES - add_executable(simpleGLES simpleGLES.cu) + if(${OpenGL_FOUND}) + if(${EGL_FOUND}) + if(${X11_FOUND}) + # Add target for simpleGLES + add_executable(simpleGLES simpleGLES.cu) - target_compile_options(simpleGLES PRIVATE $<$:--extended-lambda>) + target_compile_options(simpleGLES PRIVATE $<$:--extended-lambda>) - target_compile_features(simpleGLES PRIVATE cxx_std_17 cuda_std_17) + target_compile_features(simpleGLES PRIVATE cxx_std_17 cuda_std_17) - set_target_properties(simpleGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + set_target_properties(simpleGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + + target_include_directories(simpleGLES PUBLIC + ${EGL_INCLUDE_DIR} + ${OPENGL_INCLUDE_DIR} + ${CUDAToolkit_INCLUDE_DIRS} + ) + + target_link_libraries(simpleGLES + ${EGL_LIBRARY} + ${X11_LIBRARIES} + ${OPENGL_LIBRARIES} + ) + else() + message(STATUS "X11 libraries not found - will not build sample 'simpleGLES'") + endif() + else() + message(STATUS "EGL not found - will not build sample 'simpleGLES'") + endif() + else() + message(STATUS "OpenGL not found - will not build sample 'simpleGLES'") + endif() else() message(STATUS "Will not build sample simpleGLES - requires Linux OS") -endif() \ No newline at end of file +endif() From 41a65b94c8b30b76c96661bb44a02ce5a5a30d9c Mon Sep 17 00:00:00 2001 From: XSShawnZeng Date: Mon, 6 Jan 2025 18:48:12 +0800 Subject: [PATCH 4/5] Update CMakeLists.txt to include the Tegra samples --- Samples/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Samples/CMakeLists.txt b/Samples/CMakeLists.txt index c8b2f5f3..42424942 100644 --- a/Samples/CMakeLists.txt +++ b/Samples/CMakeLists.txt @@ -6,3 +6,6 @@ add_subdirectory(4_CUDA_Libraries) add_subdirectory(5_Domain_Specific) add_subdirectory(6_Performance) add_subdirectory(7_libNVVM) +if(BUILD_TEGRA) + add_subdirectory(8_Platform_Specific/Tegra) +endif() From e36545ac1c644031a75397760a77abc4656da411 Mon Sep 17 00:00:00 2001 From: XSShawnZeng Date: Mon, 6 Jan 2025 18:49:01 +0800 Subject: [PATCH 5/5] Create CMakeLists.txt --- Samples/8_Platform_Specific/Tegra/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Samples/8_Platform_Specific/Tegra/CMakeLists.txt diff --git a/Samples/8_Platform_Specific/Tegra/CMakeLists.txt b/Samples/8_Platform_Specific/Tegra/CMakeLists.txt new file mode 100644 index 00000000..77f4bee7 --- /dev/null +++ b/Samples/8_Platform_Specific/Tegra/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(fluidsGLES) +add_subdirectory(nbody_opengles) +add_subdirectory(simpleGLES)