From 04959e0285a1473a40b5053b453988aff9bb7534 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 14 Dec 2023 14:05:28 -0500 Subject: Tests: Verify CUDA::cupti existence on a subset of machines When we know that the cupti library exists explicitly request the CUDA Toolkit test to verify the existence --- .gitlab/ci/configure_cuda10.2_clang.cmake | 1 + .gitlab/ci/configure_cuda10.2_nvidia.cmake | 1 + .gitlab/ci/configure_cuda11.6_nvidia.cmake | 1 + .gitlab/ci/configure_nvhpc_ninja.cmake | 1 + Tests/Cuda/CMakeLists.txt | 1 + Tests/Cuda/Toolkit/CMakeLists.txt | 17 +++++++++++++++++ Tests/CudaOnly/CMakeLists.txt | 1 + Tests/CudaOnly/Toolkit/CMakeLists.txt | 20 +++++++++++++++++++- 8 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/configure_cuda10.2_clang.cmake b/.gitlab/ci/configure_cuda10.2_clang.cmake index e13ca88..e2d5a9c 100644 --- a/.gitlab/ci/configure_cuda10.2_clang.cmake +++ b/.gitlab/ci/configure_cuda10.2_clang.cmake @@ -1,3 +1,4 @@ set(CMake_TEST_CUDA "Clang" CACHE STRING "") +set(CMake_TEST_CUDA_CUPTI "ON" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_cuda10.2_nvidia.cmake b/.gitlab/ci/configure_cuda10.2_nvidia.cmake index 519699b..2cb2950 100644 --- a/.gitlab/ci/configure_cuda10.2_nvidia.cmake +++ b/.gitlab/ci/configure_cuda10.2_nvidia.cmake @@ -1,3 +1,4 @@ set(CMake_TEST_CUDA "NVIDIA" CACHE STRING "") +set(CMake_TEST_CUDA_CUPTI "ON" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_cuda11.6_nvidia.cmake b/.gitlab/ci/configure_cuda11.6_nvidia.cmake index 519699b..2cb2950 100644 --- a/.gitlab/ci/configure_cuda11.6_nvidia.cmake +++ b/.gitlab/ci/configure_cuda11.6_nvidia.cmake @@ -1,3 +1,4 @@ set(CMake_TEST_CUDA "NVIDIA" CACHE STRING "") +set(CMake_TEST_CUDA_CUPTI "ON" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_nvhpc_ninja.cmake b/.gitlab/ci/configure_nvhpc_ninja.cmake index ca8ba93..07e47c4 100644 --- a/.gitlab/ci/configure_nvhpc_ninja.cmake +++ b/.gitlab/ci/configure_nvhpc_ninja.cmake @@ -1,4 +1,5 @@ set(CMake_TEST_CUDA "NVIDIA" CACHE STRING "") +set(CMake_TEST_CUDA_CUPTI "ON" CACHE STRING "") set(configure_no_sccache 1) diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index c737bcc..efe0358 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -14,6 +14,7 @@ add_cuda_test_macro(Cuda.MixedStandardLevels5 MixedStandardLevels5) add_cuda_test_macro(Cuda.NotEnabled CudaNotEnabled) add_cuda_test_macro(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly) add_cuda_test_macro(Cuda.StubRPATH StubRPATH) +set(Cuda.Toolkit_BUILD_OPTIONS -DHAS_CUPTI:BOOL=${CMake_TEST_CUDA_CUPTI}) add_cuda_test_macro(Cuda.Toolkit Toolkit) add_cuda_test_macro(Cuda.IncludePathNoToolkit IncludePathNoToolkit) add_cuda_test_macro(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) diff --git a/Tests/Cuda/Toolkit/CMakeLists.txt b/Tests/Cuda/Toolkit/CMakeLists.txt index c2989f0..4255b82 100644 --- a/Tests/Cuda/Toolkit/CMakeLists.txt +++ b/Tests/Cuda/Toolkit/CMakeLists.txt @@ -79,6 +79,23 @@ endforeach() add_executable(Toolkit main.cpp) target_link_libraries(Toolkit PRIVATE CUDA::toolkit) +if(HAS_CUPTI) + set(cupti_libs ) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.2) + list(APPEND cupti_libs cupti nvperf_target) + endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.3) + list(APPEND cupti_libs pcsamplingutil) + endif() + foreach (cuda_lib IN LISTS cupti_libs) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() + endforeach() +endif() # cupti is an optional component of the CUDA toolkit if(TARGET CUDA::cupti) add_executable(cupti cupti.cpp) diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index b7ce5a1..82366df 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -12,6 +12,7 @@ add_cuda_test_macro(CudaOnly.ExportPTX CudaOnlyExportPTX) add_cuda_test_macro(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusToolkit) add_cuda_test_macro(CudaOnly.StaticRuntimePlusToolkit CudaOnlyStaticRuntimePlusToolkit) add_cuda_test_macro(CudaOnly.Standard98 CudaOnlyStandard98) +set(CudaOnly.Toolkit_BUILD_OPTIONS -DHAS_CUPTI:BOOL=${CMake_TEST_CUDA_CUPTI}) add_cuda_test_macro(CudaOnly.Toolkit CudaOnlyToolkit) add_cuda_test_macro(CudaOnly.ToolkitBeforeLang CudaOnlyToolkitBeforeLang) add_cuda_test_macro(CudaOnly.ToolkitMultipleDirs CudaOnlyToolkitMultipleDirs) diff --git a/Tests/CudaOnly/Toolkit/CMakeLists.txt b/Tests/CudaOnly/Toolkit/CMakeLists.txt index 506fc9f..b2694bf 100644 --- a/Tests/CudaOnly/Toolkit/CMakeLists.txt +++ b/Tests/CudaOnly/Toolkit/CMakeLists.txt @@ -41,7 +41,6 @@ if(CUDAToolkit_VERSION_MAJOR VERSION_LESS 11) list(APPEND cuda_libs nvgraph) endif() - # Verify that all the CUDA:: targets and variables exist foreach (cuda_lib IN LISTS cuda_libs) if(NOT CUDA_${cuda_lib}_LIBRARY) @@ -81,5 +80,24 @@ foreach (cuda_lib nvrtc nvToolsExt OpenCL) endif() endforeach() +if(HAS_CUPTI) + set(cupti_libs ) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.2) + list(APPEND cupti_libs cupti nvperf_target) + endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.3) + list(APPEND cupti_libs pcsamplingutil) + endif() + + foreach (cuda_lib IN LISTS cupti_libs) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() + endforeach() +endif() + add_executable(CudaOnlyToolkit main.cu) target_link_libraries(CudaOnlyToolkit PRIVATE CUDA::toolkit) -- cgit v0.12