repo_id
stringlengths
21
96
file_path
stringlengths
31
155
content
stringlengths
1
92.9M
__index_level_0__
int64
0
0
rapidsai_public_repos/rapids-cmake/testing/export
rapidsai_public_repos/rapids-cmake/testing/export/export-verify-no-namespace/CMakeLists.txt
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/export/export.cmake) cmake_minimum_required(VERSION 3.23.1) project(FakEProJecT LANGUAGES CXX VERSION 3.1.4) add_library(fakeLib1 INTERFACE) add_library(fakeLib2 INTERFACE) set_target_properties(fakeLib2 PROPERTIES EXPORT_NAME namespacefor2only) install(TARGETS fakeLib1 fakeLib2 EXPORT fake_set) rapids_export(BUILD FakEProJecT EXPORT_SET fake_set LANGUAGES CXX ) # Add a custom command that generates a second project # that verifies our target was exported with the correct # namespace file(WRITE "${CMAKE_BINARY_DIR}/verify/CMakeLists.txt" [=[ cmake_minimum_required(VERSION 3.23.1) project(verify_build_targets LANGUAGES CXX) message(STATUS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake") if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake") message(FATAL_ERROR "rapids_export failed to generate correct config file name") endif() include("${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake") if(NOT TARGET fakeLib1) message(FATAL_ERROR "rapids_export failed to generate correct namespace targets") endif() if(NOT TARGET namespacefor2only) message(FATAL_ERROR "rapids_export failed to generate correct namespace targets") endif() ]=]) add_custom_target(verify_target_file ALL COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify/build" COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify" -B="${CMAKE_BINARY_DIR}/verify/build" )
0
rapidsai_public_repos/rapids-cmake/testing/export
rapidsai_public_repos/rapids-cmake/testing/export/export-verify-code-block/CMakeLists.txt
#============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/export/export.cmake) cmake_minimum_required(VERSION 3.23.1) project(FakEProJecT LANGUAGES CXX VERSION 3.1.4) add_library(fakeLib INTERFACE) install(TARGETS fakeLib EXPORT fake_set) set(code_block [=[ set(code_block_variable "Unique String To Verify") ]=]) rapids_export(BUILD FakEProJecT EXPORT_SET fake_set NAMESPACE test:: FINAL_CODE_BLOCK code_block ) # Add a custom command that generates a second project # that verifies our target was exported with the correct # namespace file(WRITE "${CMAKE_BINARY_DIR}/verify/CMakeLists.txt" [=[ cmake_minimum_required(VERSION 3.23.1) project(verify_build_targets LANGUAGES CXX) message(STATUS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake") if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake") message(FATAL_ERROR "rapids_export failed to generate correct config file name") endif() set(CMAKE_FIND_PACKAGE_NAME FakEProJecT) # Emulate `find_package` include("${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake") if(NOT code_block_variable STREQUAL "Unique String To Verify") message(FATAL_ERROR "rapids_export failed to generate correct final code block") endif() ]=]) add_custom_target(verify_target_file ALL COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify/build" COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify" -B="${CMAKE_BINARY_DIR}/verify/build" )
0
rapidsai_public_repos/rapids-cmake/testing/export
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/export/write_language.cmake) cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) project(write_language-nested-dirs LANGUAGES NONE) # verify that enabling langues CUDA in A/B allows us to build targets # that use CUDA add_subdirectory(A) add_executable(write_language-nested-dirs main.cu) target_link_libraries(write_language-nested-dirs PRIVATE A B)
0
rapidsai_public_repos/rapids-cmake/testing/export
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/main.cu
/* * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> int static_launch_kernelA(int x, int y); int static_launch_kernelB(int x, int y); int main(int argc, char**) { auto resultA = static_launch_kernelA(3, argc); auto resultB = static_launch_kernelB(3, argc); if (resultA != 6 && resultB != 6) { return 1; } return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/A/static.cu
/* * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ static __global__ void example_cuda_kernel(int& r, int x, int y) { r = x * y + (x * 4 - (y / 2)); } int static_launch_kernelA(int x, int y) { int r; example_cuda_kernel<<<1, 1>>>(r, x, y); return r; }
0
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/A/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) add_subdirectory(B) add_library(A STATIC static.cu)
0
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/A
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/A/B/static.cu
/* * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ static __global__ void example_cuda_kernel(int& r, int x, int y) { r = x * y + (x * 4 - (y / 2)); } int static_launch_kernelB(int x, int y) { int r; example_cuda_kernel<<<1, 1>>>(r, x, y); return r; }
0
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/A
rapidsai_public_repos/rapids-cmake/testing/export/write_language-nested-dirs/A/B/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/export/write_language.cmake) function(enable_nested_language file_path) #replicates CPM including the file include("${file_path}") endfunction() set(path "${CMAKE_CURRENT_BINARY_DIR}/enable_cuda_language.cmake") rapids_export_write_language(INSTALL CUDA "${path}") enable_nested_language("${path}") add_library(B STATIC static.cu)
0
rapidsai_public_repos/rapids-cmake/testing/export
rapidsai_public_repos/rapids-cmake/testing/export/export-verify-build-components-targets/CMakeLists.txt
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/export/export.cmake) cmake_minimum_required(VERSION 3.20) project(fake LANGUAGES CXX VERSION 3.1.4) add_library(fakeLib INTERFACE) install(TARGETS fakeLib EXPORT fake_set) add_library(fakeLib_c1 INTERFACE) install(TARGETS fakeLib_c1 EXPORT fake_set_c1) add_library(fakeLib_c2 INTERFACE) install(TARGETS fakeLib_c2 EXPORT fake_set_c2-exports) rapids_export(BUILD fake EXPORT_SET fake_set COMPONENTS c1 c2 COMPONENTS_EXPORT_SET fake_set_c1 fake_set_c2-exports NAMESPACE test:: ) # Add a custom command that generates a second project # that verifies our component targets are exported correctly file(WRITE "${CMAKE_BINARY_DIR}/verify-1/CMakeLists.txt" [=[ cmake_minimum_required(VERSION 3.20) project(verify_build_targets LANGUAGES CXX) set(components c1 c2) set(nice_names c1-set c2-set) foreach(comp nice_name IN ZIP_LISTS components nice_names) include("${CMAKE_CURRENT_LIST_DIR}/../fake-${nice_name}-targets.cmake") if(NOT TARGET test::fakeLib_${comp}) message(FATAL_ERROR "rapids_export failed to generate correct component target of test::fakeLib_${comp}") endif() endforeach() ]=]) add_custom_target(verify_target_component_files ALL COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify-1/build" COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify-1" -B="${CMAKE_BINARY_DIR}/verify-1/build" ) # Add a custom command that generates a second project # that verifies our component aren't brought in with `find_package()` file(WRITE "${CMAKE_BINARY_DIR}/verify-2/CMakeLists.txt" [=[ cmake_minimum_required(VERSION 3.20) project(verify_build_targets LANGUAGES CXX) set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../) find_package(fake REQUIRED) if(TARGET test::fakeLib_c1 OR TARGET test::fakeLib_c2) message(FATAL_ERROR "incorrectly included generated components without COMPONENTS keyword to `find_package`") endif() ]=]) add_custom_target(verify_target_find_package ALL COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify-2/build" COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify-2" -B="${CMAKE_BINARY_DIR}/verify-2/build" ) # Add a custom command that generates a second project # that verifies our component are brought in with `find_package( COMPONENTS)` file(WRITE "${CMAKE_BINARY_DIR}/verify-3/CMakeLists.txt" [=[ cmake_minimum_required(VERSION 3.20) project(verify_build_targets LANGUAGES CXX) set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../) find_package(fake COMPONENTS c1 c2 REQUIRED) if(NOT (TARGET test::fakeLib_c1 AND TARGET test::fakeLib_c2)) message(FATAL_ERROR "find_package(COMPONENTS) failed to bring in components") endif() ]=]) add_custom_target(verify_target_find_components ALL COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify-3/build" COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify-3" -B="${CMAKE_BINARY_DIR}/verify-3/build" )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-install.cmake
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(ZLIB INSTALL_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB) rapids_find_package(PNG INSTALL_EXPORT_SET test_export_set ) if(ZLIB_FOUND) get_target_property(is_imported ZLIB::ZLIB IMPORTED) get_target_property(is_global ZLIB::ZLIB IMPORTED_GLOBAL) if(NOT is_imported OR NOT is_global) message(FATAL_ERROR "rapids_find_package failed to make ZLIB::ZLIB GLOBAL") endif() endif() # Check the export information was invoked if(NOT TARGET rapids_export_install_test_export_set) message(FATAL_ERROR "rapids_find_package failed to generate target for build") endif() # Verify that we encoded both packages for exporting get_target_property(packages rapids_export_install_test_export_set PACKAGE_NAMES) if(ZLIB_FOUND AND NOT ZLIB IN_LIST packages) message(FATAL_ERROR "rapids_find_package failed to record ZLIB needs to be exported") endif() if(PNG_FOUND AND NOT PNG IN_LIST packages) message(FATAL_ERROR "rapids_find_package failed to record PNG needs to be exported") endif() # Verify that we encoded what `targets` are marked as global export get_target_property( global_targets rapids_export_install_test_export_set GLOBAL_TARGETS) if(ZLIB_FOUND AND NOT "ZLIB::ZLIB" IN_LIST global_targets) message(FATAL_ERROR "rapids_find_package failed to record ZLIB::ZLIB needs to be global") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/rapids-find.cmake
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/rapids-find.cmake)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/CMakeLists.txt
#============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= add_cmake_config_test( rapids-find.cmake ) add_cmake_config_test( find_package-no-variable-leak.cmake ) add_cmake_config_test( find_package-components ) add_cmake_config_test( find_package-components-failed.cmake ) add_cmake_config_test( find_package-build.cmake ) add_cmake_config_test( find_package-install.cmake ) add_cmake_config_test( find_package-cudatoolkit-patching.cmake ) # The inverse of `find_package-optional-failed` is the # above two tests. # The inverse of `find_package-required-found` is always # a hard error and therefore has no test add_cmake_config_test( find_package-optional-failed.cmake ) add_cmake_config_test( find_package-required-found.cmake ) add_cmake_config_test( find_package-version-explicit-failed.cmake ) add_cmake_config_test( find_package-version-explicit.cmake ) add_cmake_config_test( find_package-version-none.cmake ) add_cmake_config_test( find_package-version-required-explicit-failed.cmake SHOULD_FAIL "but required is exact version \"99999999999\"") add_cmake_config_test( find_generate_module-build ) add_cmake_config_test( find_generate_module-install ) add_cmake_config_test( find_generate_module-header-only ) add_cmake_config_test( find_generate_module-code-blocks ) add_cmake_config_test( find_generate_module-back-initial-code-block-var.cmake SHOULD_FAIL "INITIAL_CODE_BLOCK variable `var_doesn't_exist` doesn't exist") add_cmake_config_test( find_generate_module-back-final-code-block-var.cmake SHOULD_FAIL "FINAL_CODE_BLOCK variable `var_doesn't_exist` doesn't exist")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-version-explicit.cmake
#============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) #============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(CUDAToolkit 11 REQUIRED INSTALL_EXPORT_SET test_export_set BUILD_EXPORT_SET test_export_set) set(to_match_string "find_package(CUDAToolkit 11 QUIET)") set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_CUDAToolkit.cmake") file(READ "${path}" contents) string(FIND "${contents}" "${to_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "rapids_find_package(BUILD) failed to preserve version information in exported file") endif() set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/install/package_CUDAToolkit.cmake") file(READ "${path}" contents) string(FIND "${contents}" "${to_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "rapids_find_package(INSTALL) failed to preserve version information in exported file") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-build.cmake
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(ZLIB BUILD_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB) rapids_find_package(PNG BUILD_EXPORT_SET test_export_set ) if(ZLIB_FOUND) get_target_property(is_imported ZLIB::ZLIB IMPORTED) get_target_property(is_global ZLIB::ZLIB IMPORTED_GLOBAL) if(NOT is_imported OR NOT is_global) message(FATAL_ERROR "rapids_find_package failed to make ZLIB::ZLIB GLOBAL") endif() endif() # Check the export information was invoked if(NOT TARGET rapids_export_build_test_export_set) message(FATAL_ERROR "rapids_find_package failed to generate target for build") endif() # Verify that we encoded both packages for exporting get_target_property(packages rapids_export_build_test_export_set PACKAGE_NAMES) if(ZLIB_FOUND AND NOT ZLIB IN_LIST packages) message(FATAL_ERROR "rapids_find_package failed to record ZLIB needs to be exported") endif() if(PNG_FOUND AND NOT PNG IN_LIST packages) message(FATAL_ERROR "rapids_find_package failed to record PNG needs to be exported") endif() # Verify that we encoded what `targets` are marked as global export get_target_property( global_targets rapids_export_build_test_export_set GLOBAL_TARGETS) if(ZLIB_FOUND AND NOT "ZLIB::ZLIB" IN_LIST global_targets) message(FATAL_ERROR "rapids_find_package failed to record ZLIB::ZLIB needs to be global") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-no-variable-leak.cmake
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) function(track_normal_find_package count_var) # We need to establish CMAKE_MESSAGE_CONTEXT before we count # as it is expected to leak set(CMAKE_MESSAGE_CONTEXT "test") find_package(${ARGN}) get_cmake_property(_all_local_variables VARIABLES) list(LENGTH _all_local_variables count_var) set(count_var ${count_var} PARENT_SCOPE) endfunction() function(track_rapids_find_package count_var) # We need to establish CMAKE_MESSAGE_CONTEXT before we count # as it is expected to leak set(CMAKE_MESSAGE_CONTEXT "test") rapids_find_package(${ARGN}) get_cmake_property(_all_local_variables VARIABLES) list(LENGTH _all_local_variables count_var) set(count_var ${count_var} PARENT_SCOPE) # verify CMAKE_MESSAGE_CONTEXT has been properly popped list(LENGTH CMAKE_MESSAGE_CONTEXT context_len) if(context_len GREATER 1) message(FATAL_ERROR "CMAKE_MESSAGE_CONTEXT hasn't been properly reset") endif() endfunction() # Need to create both of the length variables ahead of time so # that they are included in the counts and track_rapids_find_package set(normal_len 0) set(rapids_len 0) track_normal_find_package(normal_len PNG) track_rapids_find_package(rapids_len PNG) if(NOT normal_len EQUAL rapids_len) message(FATAL_ERROR "A simple rapids_find_package leaked variables!") endif() track_normal_find_package(normal_len ZLIB) track_rapids_find_package(rapids_len ZLIB INSTALL_EXPORT_SET test_export_set BUILD_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB ) if(NOT normal_len EQUAL rapids_len) message(FATAL_ERROR "A complex rapids_find_package leaked variables!") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-version-explicit-failed.cmake
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(ZLIB 99999999999 EXACT CONFIG INSTALL_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB) if(ZLIB_FOUND) message(FATAL_ERROR "rapids_find_package should have reported a failed find") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-cudatoolkit-patching.cmake
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) function(verify_links_to target library) get_target_property(link_libs ${target} INTERFACE_LINK_LIBRARIES) if(NOT ${library} IN_LIST link_libs) message(FATAL_ERROR "${target} doesn't link to ${library}") endif() endfunction() rapids_find_package(CUDAToolkit) if(TARGET CUDA::cublas_static) verify_links_to(CUDA::cublas CUDA::cublasLt) verify_links_to(CUDA::cublas_static CUDA::cublasLt_static) verify_links_to(CUDA::cusolver_static CUDA::cusolver_lapack_static) endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_generate_module-back-final-code-block-var.cmake
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/generate_module.cmake) rapids_find_generate_module( RapidsTest HEADER_NAMES rapids-cmake-test-header_only.hpp FINAL_CODE_BLOCK var_doesn't_exist INSTALL_EXPORT_SET test_set )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_generate_module-back-initial-code-block-var.cmake
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/generate_module.cmake) rapids_find_generate_module( RapidsTest HEADER_NAMES rapids-cmake-test-header_only.hpp INITIAL_CODE_BLOCK var_doesn't_exist INSTALL_EXPORT_SET test_set )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-optional-failed.cmake
#============================================================================= # Copyright (c) 2021-2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(BUILD_FIND_OPT BUILD_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB) rapids_find_package(INSTALL_FIND_OPT INSTALL_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB) if(BUILD_FIND_OPT_FOUND OR INSTALL_FIND_OPT_FOUND) message(FATAL_ERROR "rapids_find_package should have reported a failed find ") endif() if(TARGET ZLIB::ZLIB) message(FATAL_ERROR "rapids_find_package shouldn't create targets when the find failed") endif() # Check the export information was invoked if(TARGET rapids_export_build_test_export_set) message(FATAL_ERROR "rapids_find_package shouldn't have constructed a export set") endif() if(TARGET rapids_export_install_test_export_set) message(FATAL_ERROR "rapids_find_package shouldn't have constructed a export set") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-version-required-explicit-failed.cmake
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(ZLIB 99999999999 EXACT REQUIRED INSTALL_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-version-none.cmake
#============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) #============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(CUDAToolkit REQUIRED INSTALL_EXPORT_SET test_export_set BUILD_EXPORT_SET test_export_set) # no version specified at find time, verify none recorded # If we record the found version we break things like CUDA backwards runtime compat set(to_match_string "find_dependency(CUDAToolkit)") set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_CUDAToolkit.cmake") file(READ "${path}" contents) string(FIND "${contents}" "${to_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "rapids_find_package(BUILD) failed to preserve version information in exported file") endif() set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/install/package_CUDAToolkit.cmake") file(READ "${path}" contents) string(FIND "${contents}" "${to_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "rapids_find_package(INSTALL) failed to preserve version information in exported file") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-required-found.cmake
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) rapids_find_package(ZLIB REQUIRED INSTALL_EXPORT_SET test_export_set GLOBAL_TARGETS ZLIB::ZLIB) rapids_find_package(PNG REQUIRED INSTALL_EXPORT_SET test_export_set ) get_target_property(is_imported ZLIB::ZLIB IMPORTED) get_target_property(is_global ZLIB::ZLIB IMPORTED_GLOBAL) if(NOT (is_imported AND is_global)) message(FATAL_ERROR "rapids_find_package failed to make ZLIB::ZLIB GLOBAL") endif() # Check the export information was invoked if(NOT TARGET rapids_export_install_test_export_set) message(FATAL_ERROR "rapids_find_package failed to generate target for build") endif() # Verify that we encoded both packages for exporting get_target_property(packages rapids_export_install_test_export_set PACKAGE_NAMES) if(NOT ZLIB IN_LIST packages) message(FATAL_ERROR "rapids_find_package failed to record ZLIB needs to be exported") endif() if(NOT PNG IN_LIST packages) message(FATAL_ERROR "rapids_find_package failed to record PNG needs to be exported") endif() # Verify that we encoded what `targets` are marked as global export get_target_property( global_targets rapids_export_install_test_export_set GLOBAL_TARGETS) if(NOT "ZLIB::ZLIB" IN_LIST global_targets) message(FATAL_ERROR "rapids_find_package failed to record ZLIB::ZLIB needs to be global") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/find/find_package-components-failed.cmake
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) set(CMAKE_PREFIX_PATH "${rapids-cmake-testing-dir}/find/find_package-components/") rapids_find_package(FakeDependency 11 COMPONENTS AAAAA BUILD_EXPORT_SET test_export_set ) if(FakeDependency_FOUND) message(FATAL_ERROR "rapids_find_package recorded incorrect FOUND state for a failed find_package request") endif() set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_FakeDependency.cmake") if(EXISTS "${path}") message(FATAL_ERROR "rapids_find_package(BUILD) recorded a failed find_package request") endif()
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_generate_module-build/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/generate_module.cmake) cmake_minimum_required(VERSION 3.23.1) project(rapids-test-project LANGUAGES CXX) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") # Generate the find module rapids_find_generate_module( RapidsTest HEADER_NAMES rapids-cmake-test-header.h LIBRARY_NAMES rapids-cmake-test VERSION 42 INCLUDE_SUFFIXES rapids-cmake BUILD_EXPORT_SET test_set ) find_package(RapidsTest REQUIRED) if(NOT RapidsTest_FOUND) message(FATAL_ERROR "RapidsTest_FOUND should be set to TRUE") endif() if(NOT RAPIDSTEST_FOUND) message(FATAL_ERROR "RAPIDSTEST_FOUND should be set to TRUE") endif() if(NOT TARGET RapidsTest::RapidsTest) message(FATAL_ERROR "RapidsTest target should be generated") endif() get_target_property(include_dir RapidsTest::RapidsTest INTERFACE_INCLUDE_DIRECTORIES) get_target_property(release_lib RapidsTest::RapidsTest IMPORTED_LOCATION_RELEASE) get_target_property(debug_lib RapidsTest::RapidsTest IMPORTED_LOCATION_DEBUG) if(NOT IS_DIRECTORY "${include_dir}") message(FATAL_ERROR "rapids_find_generate_module failed to generate correct include dir search logic") endif() if(NOT EXISTS "${release_lib}") message(FATAL_ERROR "rapids_find_generate_module failed to generate correct library search logic") endif() if(NOT EXISTS "${debug_lib}") message(FATAL_ERROR "rapids_find_generate_module failed to generate correct debug/versioned library search logic") endif()
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_generate_module-code-blocks/CMakeLists.txt
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/generate_module.cmake) cmake_minimum_required(VERSION 3.23.1) project(rapids-test-project LANGUAGES CXX) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") # Generate the find module set(initial_code_block [[set(RapidsTest_INITIAL_CODE_BLOCK TRUE)]]) set(final_code_block [[set(RapidsTest_FINAL_CODE_BLOCK TRUE)]]) rapids_find_generate_module( RapidsTest HEADER_NAMES rapids-cmake-test-header_only.hpp INITIAL_CODE_BLOCK initial_code_block FINAL_CODE_BLOCK final_code_block INSTALL_EXPORT_SET test_set ) find_package(RapidsTest REQUIRED) if(NOT RapidsTest_INITIAL_CODE_BLOCK) message(FATAL_ERROR "RapidsTest_FOUND should be set to TRUE") endif() if(NOT RapidsTest_FINAL_CODE_BLOCK) message(FATAL_ERROR "RAPIDSTEST_FOUND should be set to TRUE") endif()
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_generate_module-header-only/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/generate_module.cmake) cmake_minimum_required(VERSION 3.23.1) project(rapids-test-project LANGUAGES CXX) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") # Generate the find module rapids_find_generate_module( RapidsTest HEADER_NAMES rapids-cmake-test-header_only.hpp INSTALL_EXPORT_SET test_set ) find_package(RapidsTest REQUIRED) if(NOT RapidsTest_FOUND) message(FATAL_ERROR "RapidsTest_FOUND should be set to TRUE") endif() if(NOT RAPIDSTEST_FOUND) message(FATAL_ERROR "RAPIDSTEST_FOUND should be set to TRUE") endif() if(NOT TARGET RapidsTest::RapidsTest) message(FATAL_ERROR "RapidsTest target should be generated") endif() get_target_property(include_dir RapidsTest::RapidsTest INTERFACE_INCLUDE_DIRECTORIES) get_target_property(release_lib RapidsTest::RapidsTest IMPORTED_LOCATION_RELEASE) get_target_property(debug_lib RapidsTest::RapidsTest IMPORTED_LOCATION_DEBUG) if(NOT IS_DIRECTORY "${include_dir}") message(FATAL_ERROR "rapids_find_generate_module failed to generate correct include dir search logic") endif() if(release_lib OR debug_lib) message(FATAL_ERROR "rapids_find_generate_module incorrectly found libraries for a header only package") endif()
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_package-components/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/package.cmake) cmake_minimum_required(VERSION 3.23.1) project(rapids-test-project LANGUAGES CXX) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") rapids_find_package(FakeDependency 11 REQUIRED COMPONENTS A B C INSTALL_EXPORT_SET test_export_set BUILD_EXPORT_SET test_export_set ) if(NOT (DEFINED FakeDependency_A_FOUND AND DEFINED FakeDependency_B_FOUND AND DEFINED FakeDependency_C_FOUND) ) message(FATAL_ERROR "rapids_find_package() failed to propagate COMPONENT A B C") endif() set(to_match_string "find_package(FakeDependency 11 QUIET COMPONENTS A;B;C)") set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_FakeDependency.cmake") file(READ "${path}" contents) string(FIND "${contents}" "${to_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "rapids_find_package(BUILD) failed to preserve version information in exported file") endif() set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/install/package_FakeDependency.cmake") file(READ "${path}" contents) string(FIND "${contents}" "${to_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "rapids_find_package(INSTALL) failed to preserve version information in exported file") endif()
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_package-components/fakedependency-config.cmake
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.21) set(allowed_components A B C) foreach(comp IN LISTS FakeDependency_FIND_COMPONENTS) if(${comp} IN_LIST allowed_components) set(FakeDependency_${comp}_FOUND ON) else() string(APPEND _FAIL_REASON "component '${comp}' was requested, but not found. ") endif() endforeach() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FakeDependency REASON_FAILURE_MESSAGE "${_FAIL_REASON}" HANDLE_COMPONENTS)
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_package-components/fakedependency-config-version.cmake
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= set(PACKAGE_VERSION "11") if(PACKAGE_FIND_VERSION_MAJOR STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_COMPATIBLE TRUE) else() set(PACKAGE_VERSION_COMPATIBLE FALSE) endif() if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) endif()
0
rapidsai_public_repos/rapids-cmake/testing/find
rapidsai_public_repos/rapids-cmake/testing/find/find_generate_module-install/CMakeLists.txt
#============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/find/generate_module.cmake) cmake_minimum_required(VERSION 3.23.1) project(rapids-test-project LANGUAGES CXX) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") # Generate the find module rapids_find_generate_module( RapidsTest HEADER_NAMES rapids-cmake-test-header.h LIBRARY_NAMES rapids-cmake-test INCLUDE_SUFFIXES rapids-cmake INSTALL_EXPORT_SET test_set ) find_package(RapidsTest REQUIRED) if(NOT RapidsTest_FOUND) message(FATAL_ERROR "RapidsTest_FOUND should be set to TRUE") endif() if(NOT RAPIDSTEST_FOUND) message(FATAL_ERROR "RAPIDSTEST_FOUND should be set to TRUE") endif() if(NOT TARGET RapidsTest::RapidsTest) message(FATAL_ERROR "RapidsTest target should be generated") endif() get_target_property(include_dir RapidsTest::RapidsTest INTERFACE_INCLUDE_DIRECTORIES) get_target_property(release_lib RapidsTest::RapidsTest IMPORTED_LOCATION_RELEASE) get_target_property(debug_lib RapidsTest::RapidsTest IMPORTED_LOCATION_DEBUG) get_target_property(is_global RapidsTest::RapidsTest IMPORTED_GLOBAL) if(NOT IS_DIRECTORY "${include_dir}") message(FATAL_ERROR "rapids_find_generate_module failed to generate correct include dir search logic") endif() if(NOT EXISTS "${release_lib}") message(FATAL_ERROR "rapids_find_generate_module failed to generate correct library search logic") endif() if(debug_lib) message(FATAL_ERROR "rapids_find_generate_module incorrectly found a debug library") endif() if(NOT is_global) message(FATAL_ERROR "rapids_find_generate_module created a target that is not global") endif() # verify header only lib rapids_find_generate_module( RapidsTestHeaderOnly HEADER_NAMES rapids-cmake-test-header_only.hpp INSTALL_EXPORT_SET test_set ) find_package(RapidsTest REQUIRED)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-zero-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 1 PERCENT 0)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/add-with-no-gpus.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) include(${rapids-cmake-dir}/test/add.cmake) enable_language(CUDA) rapids_test_init() file(WRITE "${CMAKE_BINARY_DIR}/main.cu" "int main(){return 0;}") add_executable(verify_alloc "${CMAKE_BINARY_DIR}/main.cu") enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc INSTALL_COMPONENT_SET testing) get_test_property(simple_test RESOURCE_GROUPS value) if(value) message(FATAL_ERROR "Unexpected RESOURCE_GROUPS test property value(${value}) found, should not be set") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-over-max-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 1 PERCENT 101)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/add-with-install-component.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) include(${rapids-cmake-dir}/test/add.cmake) enable_language(CUDA) rapids_test_init() file(WRITE "${CMAKE_BINARY_DIR}/main.cu" "int main(){return 0;}") add_executable(verify_alloc "${CMAKE_BINARY_DIR}/main.cu") enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc GPUS 1 INSTALL_COMPONENT_SET testing) # Verify that we have recorded `simple_test` as part of the `testing` component get_target_property(names rapids_test_install_testing TESTS_TO_RUN) if(NOT "simple_test" IN_LIST names) message(FATAL_ERROR "Failed to record `simple_test` as part of the testing component") endif() # Verify that `verify_alloc` is marked as to be installed get_target_property(names rapids_test_install_testing TARGETS_TO_INSTALL) if(NOT "verify_alloc" IN_LIST names) message(FATAL_ERROR "Failed to record `verify_alloc` as a target to be installed in the testing component") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-include-in-all.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) enable_testing() rapids_test_init() rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing INCLUDE_IN_ALL) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install_rules.cmake" "set(install_rules_file \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install_rules.cmake" [=[ file(READ "${install_rules_file}" contents) set(exclude_from_all_string [===[if(CMAKE_INSTALL_COMPONENT STREQUAL "testing" OR NOT CMAKE_INSTALL_COMPONENT)]===]) string(FIND "${contents}" ${exclude_from_all_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "`rapids_test_install_relocatable` failed to mark items as EXCLUDE_FROM_ALL") endif() ]=]) add_custom_target(verify_install_rule ALL COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install_rules.cmake") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" [=[ file(READ "${installed_test_file}" contents) set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===]) string(FIND "${contents}" ${execute_process_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") endif() ]=]) add_custom_target(install_testing_component ALL COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-single.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 1 PERCENT 4) get_test_property(fake_test RESOURCE_GROUPS value) if(NOT value STREQUAL "1,gpus:4") message(FATAL_ERROR "Unexpected RESOURCE_GROUPS test property value after rapids_test_gpu_requirements") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-zero-gpu.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 0 PERCENT 100)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-char-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 1 PERCENT abc)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= add_cmake_config_test( rapids-test.cmake ) add_cmake_config_test(generate_resource_spec-no-gpus.cmake) add_cmake_config_test(generate_resource_spec-simple.cmake) set(percent_error_message "rapids_test_gpu_requirements requires a numeric PERCENT value [1-100].") set(gpu_error_message "rapids_test_gpu_requirements GPUS requires a numeric value") set(gpu_missing_message "rapids_test_gpu_requirements requires the GPUS option to be provided") add_cmake_config_test(gpu_requirements-char-percent.cmake SHOULD_FAIL "${percent_error_message}") add_cmake_config_test(gpu_requirements-char-gpu.cmake SHOULD_FAIL "${gpu_error_message}") add_cmake_config_test(gpu_requirements-zero-gpu.cmake) add_cmake_config_test(gpu_requirements-max-percent.cmake) add_cmake_config_test(gpu_requirements-min-percent.cmake) add_cmake_config_test(gpu_requirements-multi.cmake) add_cmake_config_test(gpu_requirements-negative-percent.cmake SHOULD_FAIL "${percent_error_message}") add_cmake_config_test(gpu_requirements-negative-gpu.cmake SHOULD_FAIL "${gpu_error_message}") add_cmake_config_test(gpu_requirements-no-gpus.cmake SHOULD_FAIL "${gpu_missing_message}") add_cmake_config_test(gpu_requirements-no-percent.cmake) add_cmake_config_test(gpu_requirements-over-max-percent.cmake SHOULD_FAIL "${percent_error_message}") add_cmake_config_test(gpu_requirements-single.cmake) add_cmake_config_test(gpu_requirements-zero-percent.cmake SHOULD_FAIL "${percent_error_message}") add_cmake_config_test(init-existing-specfile.cmake) add_cmake_config_test(init-simple.cmake) set(wrong_component_message "No install component set [wrong_component] can be found") add_cmake_build_test(install_relocatable-include-in-all.cmake) add_cmake_build_test(install_relocatable-labels.cmake) add_cmake_build_test(install_relocatable-no-tests.cmake) add_cmake_build_test(install_relocatable-simple.cmake) add_cmake_build_test(install_relocatable-complex) add_cmake_config_test(install_relocatable-wrong-component.cmake SHOULD_FAIL "${wrong_component_message}") add_cmake_ctest_test(add-impossible-allocation SHOULD_FAIL "Insufficient resources for test") add_cmake_config_test(add-with-install-component.cmake) add_cmake_config_test(add-with-no-gpus.cmake) add_cmake_ctest_test(add-no-cuda-toolkit) if(RAPIDS_CMAKE_TESTING_GPU_COUNT GREATER 0) add_cmake_ctest_test(add-allocation-simple) add_cmake_ctest_test(add-allocation-throws-runtime-error) add_cmake_ctest_test(add-multi-allocations-same-gpu) add_cmake_ctest_test(add-multi-jobs-single-gpu SERIAL) add_cmake_ctest_test(no_add-with-cpp-handler-from-docs) add_cmake_ctest_test(no_add-with-no-resource-spec) endif() if(RAPIDS_CMAKE_TESTING_GPU_COUNT GREATER 1) add_cmake_ctest_test(add-single-job-multi-gpu) endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-no-tests.cmake
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) enable_testing() rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" "set(install_rules_file \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" [=[ file(READ "${install_rules_file}" contents) set(bad_install_rule_match_string [===[rapids-cmake/generate_ctest_json")]===]) string(FIND "${contents}" ${bad_install_rule_match_string} is_found) if(NOT is_found EQUAL -1) message(FATAL_ERROR "`rapids_test_install_relocatable` trying to install files that don't exist") endif() ]=]) add_custom_target(verify_install_files_valid ALL COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-wrong-component.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) rapids_test_init() rapids_test_install_relocatable(INSTALL_COMPONENT_SET wrong_component DESTINATION bin/testing) rapids_test_install_relocatable(INSTALL_COMPONENT_SET another_wrong_component DESTINATION bin/testing)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/generate_resource_spec-simple.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/generate_resource_spec.cmake) enable_language(CUDA) set(CTEST_RESOURCE_SPEC_FILE "sentinel file") rapids_test_generate_resource_spec(DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/spec.json ) if(NOT CTEST_RESOURCE_SPEC_FILE STREQUAL "sentinel file") message(FATAL_ERROR "CTEST_RESOURCE_SPEC_FILE shouldn't be modified by calling rapids_test_generate_resource_spec") endif() if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/spec.json") message(FATAL_ERROR "rapids_test_generate_resource_spec failed to write out the requested spec file") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/rapids-test.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/rapids-test.cmake)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-negative-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 2 PERCENT -1)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-multi.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 12 PERCENT 25) get_test_property(fake_test RESOURCE_GROUPS value) if(NOT value STREQUAL "12,gpus:25") message(FATAL_ERROR "Unexpected RESOURCE_GROUPS test property value after rapids_test_gpu_requirements") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-simple.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) enable_testing() rapids_test_init() rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" "set(install_rules_file \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" [=[ file(READ "${install_rules_file}" contents) set(exclude_from_all_string [===[if(CMAKE_INSTALL_COMPONENT STREQUAL "testing")]===]) string(FIND "${contents}" ${exclude_from_all_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "`rapids_test_install_relocatable` failed to mark items as EXCLUDE_FROM_ALL") endif() ]=]) add_custom_target(verify_install_rule ALL COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" [==[ file(READ "${installed_test_file}" contents) set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===]) string(FIND "${contents}" ${execute_process_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") endif() set(add_test_match_string [===[add_test([=[verify_]=] "cmake" -Dcommand_to_run=ls -Dcommand_args= -P=./run_gpu_test.cmake)]===]) string(FIND "${contents}" ${add_test_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate an installed `add_test` for verify_") endif() set(properties_match_string [===[PROPERTIES RESOURCE_GROUPS 1,gpus:100]===]) string(FIND "${contents}" ${properties_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "${contents}\nFailed to generate an installed `GPU` requirements for verify_") endif() ]==]) add_custom_target(install_testing_component ALL COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-negative-gpu.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS -2 PERCENT 1)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/init-simple.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) enable_language(CUDA) rapids_test_init() if(NOT DEFINED CTEST_RESOURCE_SPEC_FILE) message(FATAL_ERROR "CTEST_RESOURCE_SPEC_FILE should be set after calling rapids_test_init") endif() if(NOT EXISTS "${CTEST_RESOURCE_SPEC_FILE}") message(FATAL_ERROR "CTEST_RESOURCE_SPEC_FILE should exist on disk after calling rapids_test_init") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-min-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 1 PERCENT 1)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-max-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 1 PERCENT 100)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/generate_resource_spec-no-gpus.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/generate_resource_spec.cmake) enable_language(CUDA) # Set the visible device list to invalid device ids so we have zero visible set(ENV{CUDA_VISIBLE_DEVICES} -1) set(CTEST_RESOURCE_SPEC_FILE "sentinel file") rapids_test_generate_resource_spec(DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/spec.json ) if(NOT CTEST_RESOURCE_SPEC_FILE STREQUAL "sentinel file") message(FATAL_ERROR "CTEST_RESOURCE_SPEC_FILE shouldn't be modified by calling rapids_test_generate_resource_spec") endif() if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/spec.json") message(FATAL_ERROR "rapids_test_ll generate_resource_spec failed to write out the requested spec file") endif() file(READ "${CMAKE_CURRENT_BINARY_DIR}/spec.json" content) if(NOT content MATCHES [=[.*{"id": "0", "slots": 0}.*]=]) message(FATAL_ERROR "rapids_test_generate_resource_spec incorrectly detected a GPU") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-char-gpu.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS -1 PERCENT 100)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-no-gpus.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test PERCENT 50)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/gpu_requirements-no-percent.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/gpu_requirements.cmake) add_test(fake_test COMMAND "${CMAKE_COMMAND} -E echo") rapids_test_gpu_requirements(fake_test GPUS 9) get_test_property(fake_test RESOURCE_GROUPS value) if(NOT value STREQUAL "9,gpus:100") message(FATAL_ERROR "Unexpected RESOURCE_GROUPS test property value(${value}) after rapids_test_gpu_requirements") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-labels.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) enable_testing() rapids_test_init() rapids_test_add(NAME verify_labels COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) set_tests_properties(verify_labels PROPERTIES LABELS "has_label") rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" [==[ file(READ "${installed_test_file}" contents) set(labels_match_string [===[PROPERTIES LABELS has_label]===]) string(FIND "${contents}" "${labels_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to record the LABELS property") endif() ]==]) add_custom_target(install_testing_component ALL COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/test/init-existing-specfile.cmake
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/test/init.cmake) enable_language(CUDA) set(CTEST_RESOURCE_SPEC_FILE "sentinel file") rapids_test_init() if(NOT CTEST_RESOURCE_SPEC_FILE STREQUAL "sentinel file") message(FATAL_ERROR "CTEST_RESOURCE_SPEC_FILE shouldn't be modified if already set before calling rapids_test_init") endif()
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-no-cuda-toolkit/CMakeLists.txt
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CXX) include(${rapids-cmake-dir}/rapids-test.cmake) #Disable searching for the CUDA Toolkit so we emulate #support for CPU only rapids-cmake-testing support set(CMAKE_DISABLE_FIND_PACKAGE_CUDAToolkit True) rapids_test_init() add_executable(verify_alloc main.cpp) enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc)
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-no-cuda-toolkit/main.cpp
/* * Copyright (c) 2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> int main() { return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-single-job-multi-gpu/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() add_executable(verify_alloc main.cu) enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc GPUS 2 PERCENT 75)
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-single-job-multi-gpu/main.cu
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> int main() { int nDevices = 0; cudaGetDeviceCount(&nDevices); // We should have anywhere from 1 to 2 devices allocated std::cout << "Seeing " << nDevices << " GPU devices" << std::endl; if (nDevices == 0 || nDevices > 2) { return 1; } return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/no_add-with-cpp-handler-from-docs/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CXX CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() find_package(CUDAToolkit REQUIRED) add_executable(verify_docs main.cpp) target_compile_features(verify_docs PRIVATE cxx_std_17) target_include_directories(verify_docs PRIVATE "${rapids-cmake-dir}/../docs/cpp_code_snippets/") target_link_libraries(verify_docs PRIVATE CUDA::cudart) enable_testing() add_test(NAME simple_test COMMAND verify_docs) rapids_test_gpu_requirements(simple_test GPUS 1 PERCENT 25)
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/no_add-with-cpp-handler-from-docs/main.cpp
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> #include "rapids_cmake_ctest_allocation.cpp" #include "rapids_cmake_ctest_allocation.hpp" int main() { // Verify we only have a single GPU visible to us auto allocs = rapids_cmake::full_allocation(); if (allocs.size() != 1) { return 1; } auto alloc = allocs[0]; if (alloc.slots != 25) { return 1; } return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/detail/file_locker.hpp
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <chrono> #include <iostream> #include <thread> #include <vector> #include <fcntl.h> #include <unistd.h> #include <cuda_runtime_api.h> #define DefineToString(a) define_to_str(a) #define define_to_str(a) #a std::string lock_file_name(int tid) { const static std::string dir = DefineToString(BINARY_DIR); return std::string(dir + "/lock." + std::to_string(tid)); } struct ctest_lock { std::string file_name; int fd; ctest_lock(int test_id) { this->file_name = lock_file_name(test_id); this->fd = open(file_name.c_str(), O_RDWR | O_CREAT, S_IRGRP | S_IRWXU); int activeDevice = 0; cudaGetDevice(&activeDevice); cudaDeviceProp prop; cudaGetDeviceProperties(&prop, activeDevice); auto deviceIdAsStr = std::to_string(prop.pciBusID); write(fd, deviceIdAsStr.c_str(), deviceIdAsStr.size()); lockf(fd, F_TLOCK, 0); } }; template <typename LockValidator> bool validate_locks(LockValidator lock_checker, int min_lock_id, int max_lock_id) { using namespace std::chrono_literals; // barrier // wait for all other tests to lock the respective sentinel file std::this_thread::sleep_for(5000ms); int valid_count = 0; for (int i = min_lock_id; i <= max_lock_id; ++i) { auto path = lock_file_name(i); auto fd = open(path.c_str(), O_RDONLY); auto lock_state = lockf(fd, F_TEST, 0); bool valid_lock_state = lock_checker(lock_state, i); if (valid_lock_state) { ++valid_count; } } // barrier again so nothing unlocks while other are checking // for a lock std::this_thread::sleep_for(2000ms); return (valid_count == ((max_lock_id + 1) - min_lock_id)); } void unlock(ctest_lock& lock) { close(lock.fd); }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-impossible-allocation/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() add_executable(verify_alloc main.cu) enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc simple_test GPUS 25)
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-impossible-allocation/main.cu
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> int main() { return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-allocation-throws-runtime-error/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() add_executable(verify_alloc main.cu) enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc GPUS 1) # Validate that the test fails set_tests_properties(simple_test PROPERTIES WILL_FAIL ON)
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-allocation-throws-runtime-error/main.cu
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> #include <new> int main() { throw std::bad_alloc(); return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/no_add-with-no-resource-spec/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA CXX) include(${rapids-cmake-dir}/rapids-test.cmake) set(CTEST_RESOURCE_SPEC_FILE "fake-value-to-stop-generation") rapids_test_init() unset(CTEST_RESOURCE_SPEC_FILE) find_package(CUDAToolkit REQUIRED) add_executable(verify_no_alloc main.cpp) target_compile_features(verify_no_alloc PRIVATE cxx_std_17) target_include_directories(verify_no_alloc PRIVATE "${rapids-cmake-dir}/../docs/cpp_code_snippets/") target_link_libraries(verify_no_alloc PRIVATE CUDA::cudart) enable_testing() add_test(NAME simple_test COMMAND verify_no_alloc) rapids_test_gpu_requirements(simple_test GPUS 1) # Validate that the test runs correctly set_tests_properties(simple_test PROPERTIES PASS_REGULAR_EXPRESSION "failed to have a resource file" )
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/no_add-with-no-resource-spec/main.cpp
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> #include "rapids_cmake_ctest_allocation.cpp" #include "rapids_cmake_ctest_allocation.hpp" int main() { if (!rapids_cmake::using_resources()) { std::cout << "failed to have a resource file" << std::endl; return 0; } return 1; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-multi-jobs-single-gpu/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() find_package(CUDAToolkit REQUIRED) add_executable(verify_multi_concurrent main.cu) target_link_libraries(verify_multi_concurrent PRIVATE CUDA::cudart) target_include_directories(verify_multi_concurrent PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_compile_definitions(verify_multi_concurrent PRIVATE "BINARY_DIR=${CMAKE_BINARY_DIR}") enable_testing() foreach(v RANGE 5) # this way all our tests can reside on the same gpu rapids_test_add(NAME concurrent_test_${v} COMMAND verify_multi_concurrent ${v} GPUS 1 PERCENT 1${v}) endforeach()
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-multi-jobs-single-gpu/main.cu
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <chrono> #include <iostream> #include <thread> #include <vector> #include <fcntl.h> #include <unistd.h> #include "../detail/file_locker.hpp" int main(int argc, char** argv) { const constexpr int min_lock_id = 0; const constexpr int max_lock_id = 5; // Lock our sentinel file auto my_id = std::stoi(argv[1]); auto lock = ctest_lock(my_id); // verify all sentinel files are locked auto checker = [my_id](int lock_state, int i) { bool valid_lock_state = false; if (i == my_id) { // we have this file locked valid_lock_state = (lock_state == 0); } else { // some other process has this file locked valid_lock_state = (lock_state == -1); } std::cout << i << " lock_state: " << lock_state << " valid " << valid_lock_state << std::endl; return valid_lock_state; }; bool all_locked = validate_locks(checker, min_lock_id, max_lock_id); // unlock and return unlock(lock); return (all_locked) ? 0 : 1; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-complex/CMakeLists.txt
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) set(CMAKE_CONFIGURATION_TYPES Debug) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) add_library(preload SHARED usage.cu) add_subdirectory(tests) install(TARGETS preload DESTINATION lib)
0
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-complex
rapidsai_public_repos/rapids-cmake/testing/test/install_relocatable-complex/tests/CMakeLists.txt
#============================================================================= # Copyright (c) 2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= include(${rapids-cmake-dir}/rapids-test.cmake) enable_testing() rapids_test_init() rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) set_tests_properties( verify_ PROPERTIES ENVIRONMENT "STREAM_MODE=new_mode;LD_PRELOAD=$<TARGET_FILE:preload>" ) rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing INCLUDE_IN_ALL) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" [==[ file(READ "${installed_test_file}" contents) set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===]) string(FIND "${contents}" ${execute_process_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") endif() set(properties_match_strings [===[PROPERTIES ENVIRONMENT "STREAM_MODE]===] [===[LD_PRELOAD=${CMAKE_INSTALL_PREFIX}/lib/libpreload]===]) foreach(to_match IN LISTS properties_match_strings) string(FIND "${contents}" ${to_match} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "${contents}\nFailed to generate a proper set of test properties") endif() endforeach() ]==]) add_custom_target(install_testing_component ALL COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --prefix install/ --config Debug COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" ) add_dependencies(install_testing_component preload)
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-multi-allocations-same-gpu/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() add_executable(verify_alloc main.cu) enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc GPUS 10 PERCENT 1) # Validate that the test runs correctly set_tests_properties(simple_test PROPERTIES PASS_REGULAR_EXPRESSION "Seeing at least a single GPU" )
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-multi-allocations-same-gpu/main.cu
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> int main() { // Very we only have a single GPU visible to us int nDevices = 0; cudaGetDeviceCount(&nDevices); if (nDevices == 0) { return 1; } std::cout << "Seeing at least a single GPU" << std::endl; return 0; }
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-allocation-simple/CMakeLists.txt
#============================================================================= # Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.20) project(rapids-test-project LANGUAGES CUDA) include(${rapids-cmake-dir}/rapids-test.cmake) rapids_test_init() add_executable(verify_alloc main.cu) enable_testing() rapids_test_add(NAME simple_test COMMAND verify_alloc GPUS 1) # Validate that the test runs correctly set_tests_properties(simple_test PROPERTIES PASS_REGULAR_EXPRESSION "Seeing 1 GPU devices" )
0
rapidsai_public_repos/rapids-cmake/testing/test
rapidsai_public_repos/rapids-cmake/testing/test/add-allocation-simple/main.cu
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <iostream> #include <vector> int main() { // Verify we only have a single GPU visible to us int nDevices = 0; cudaGetDeviceCount(&nDevices); std::cout << "Seeing " << nDevices << " GPU devices" << std::endl; if (nDevices == 0 || nDevices > 3) { return 1; } return 0; }
0
rapidsai_public_repos/rapids-cmake/conda/recipes
rapidsai_public_repos/rapids-cmake/conda/recipes/rapids_core_dependencies/CMakeLists.txt
#============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.23.1) project(rapids-dependencies LANGUAGES CXX) set(rapids-cmake-dir "${PROJECT_SOURCE_DIR}/../../../rapids-cmake/") include(${rapids-cmake-dir}/cpm/init.cmake) rapids_cpm_init() # Download all source packages include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) include(${rapids-cmake-dir}/cpm/thrust.cmake) set(CPM_DOWNLOAD_ALL "ON") rapids_cpm_libcudacxx(INSTALL_EXPORT_SET rapids-dependencies) rapids_cpm_thrust(NAMESPACE temp INSTALL_EXPORT_SET rapids-dependencies)
0
rapidsai_public_repos/rapids-cmake/conda/recipes
rapidsai_public_repos/rapids-cmake/conda/recipes/rapids_core_dependencies/conda_build_config.yaml
cxx_compiler_version: - 11 cuda_compiler: - cuda-nvcc cuda11_compiler: - nvcc cmake_version: - ">=3.26.4" sysroot_version: - "2.17"
0
rapidsai_public_repos/rapids-cmake/conda/recipes
rapidsai_public_repos/rapids-cmake/conda/recipes/rapids_core_dependencies/build.sh
# Copyright (c) 2022, NVIDIA CORPORATION. # Script assumes the script is executed from the root of the repo directory REPO_DIR=$(cd $(dirname $0); pwd) SOURCE_DIR=${REPO_DIR}/conda/recipes/rapids_core_dependencies BUILD_DIR=${BUILD_DIR:=${REPO_DIR}/build} INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX:=$BUILD_DIR/install}}} export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} # If the dir to clean is a mounted dir in a container, the # contents should be removed but the mounted dirs will remain. # The find removes all contents but leaves the dirs, the rmdir # attempts to remove the dirs but can fail safely. if [ -d "${BUILD_DIR}" ]; then find "${BUILD_DIR}" -mindepth 1 -delete rmdir "${BUILD_DIR}" || true fi cmake -S "${SOURCE_DIR}" -B "${BUILD_DIR}" \ -DCMAKE_INSTALL_LIBDIR="lib" \ -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} cmake --build "${BUILD_DIR}" --target install -j${PARALLEL_LEVEL}
0
rapidsai_public_repos/rapids-cmake/conda/recipes
rapidsai_public_repos/rapids-cmake/conda/recipes/rapids_core_dependencies/meta.yaml
# Copyright (c) 2022-2023, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} {% set date_string = environ['RAPIDS_DATE_STRING'] %} package: name: rapids_core_dependencies version: {{ version }} source: git_url: ../../.. build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} ignore_run_exports_from: {% if cuda_major == "11" %} - {{ compiler('cuda11') }} {% endif %} requirements: build: - cmake {{ cmake_version }} - {{ compiler('cxx') }} {% if cuda_major == "11" %} - {{ compiler('cuda11') }} ={{ cuda_version }} {% else %} - {{ compiler('cuda') }} {% endif %} - cuda-version ={{ cuda_version }} - make - ninja - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cuda-version ={{ cuda_version }} run: - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} about: home: https://rapids.ai/ license: Apache-2.0 license_family: Apache license_file: LICENSE summary: RAPIDS patched CUDA dependencies description: | A subset of RAPIDS CUDA/C++ dependencies that need to be packaged with custom C++ header locations to avoid compiler issues.
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/example/CMakeLists.txt
#============================================================================= # Copyright (c) 2021-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/EXAMPLE_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/EXAMPLE_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/EXAMPLE_RAPIDS.cmake) include(rapids-cmake) include(rapids-cpm) include(rapids-cuda) include(rapids-export) include(rapids-find) rapids_cuda_init_architectures(integration) project(integration VERSION 21.12 LANGUAGES C CXX CUDA) message(STATUS "Example: CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES}") option(CUDA_STATIC_RUNTIME "Use CUDA static runtime" OFF) # Set a default build type if none was specified rapids_cmake_build_type(Release) # Set the CUDA runtime CUDA targets will use rapids_cuda_init_runtime(USE_STATIC ${CUDA_STATIC_RUNTIME}) # conda environment rapids_cmake_support_conda_env( conda_env MODIFY_PREFIX_PATH ) # Find the CUDAToolkit rapids_find_package(CUDAToolkit REQUIRED BUILD_EXPORT_SET example-targets INSTALL_EXPORT_SET example-targets ) # Generate a `FindZLIBS` module that will searches for the zlib.h # header and `libz` or `libzlib` library. # In practise this function should be used to search for packages # that don't provide a -config.cmake file or CMake doesn't # already package a find module for ( includes ZLIB ). rapids_find_generate_module(ZLIBS HEADER_NAMES zlib.h LIBRARY_NAMES z zlib BUILD_EXPORT_SET example-targets INSTALL_EXPORT_SET example-targets ) # Since `rapids_find_generate_module` doesn't interact with the export-set # like `rapids_find` does, we manually establish this connection. # The vast majority of calls should use `rapids_find_package`, and # rapids_export_package should only be used in edge cases. The most common # edge case being when a package doesn't provide a built directory -config.cmake # module find_package(ZLIBS REQUIRED) rapids_export_package(INSTALL ZLIBS example-targets GLOBAL_TARGETS ZLIBS::ZLIBS) rapids_export_package(BUILD ZLIBS example-targets) # find Threads (needed by cudftestutil) rapids_find_package(Threads REQUIRED BUILD_EXPORT_SET example-targets INSTALL_EXPORT_SET example-targets ) rapids_cpm_init() # Use one of rapids-cmake pre-configured packages # And mark rmm as part of our export interface include(${rapids-cmake-dir}/cpm/rmm.cmake) rapids_cpm_rmm(BUILD_EXPORT_SET example-targets INSTALL_EXPORT_SET example-targets) # Bring in any arbitrary package rapids_cpm_find(fmt 7.1.3 GLOBAL_TARGETS fmt::fmt CPM_ARGS GITHUB_REPOSITORY fmtlib/fmt GIT_TAG 7.1.3 GIT_SHALLOW TRUE ) add_library(example SHARED source.cu) set_target_properties(example PROPERTIES BUILD_RPATH "$ORIGIN" INSTALL_RPATH "$ORIGIN" # set target compile options CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON ) target_link_libraries(example PUBLIC rmm::rmm PRIVATE fmt::fmt) # Add Conda env exist s, use it for link and include dirs if(TARGET conda_env) target_link_libraries(example PUBLIC $<BUILD_INTERFACE:conda_env> ) endif() # - install targets ------------------------------------------------------------------------------- rapids_cmake_install_lib_dir( lib_dir ) install(TARGETS example DESTINATION ${lib_dir} EXPORT example-targets ) ################################################################################################ # - install export ------------------------------------------------------------------------------- set(doc_string [=[ Provide targets for the example library. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ]=]) rapids_export(INSTALL example EXPORT_SET example-targets GLOBAL_TARGETS example # since we can't hook into EXPORT SETS NAMESPACE example:: DOCUMENTATION doc_string ) ################################################################################################ # - build export ------------------------------------------------------------------------------- set(code_string [=[ message(STATUS "hi from example-config") ]=]) rapids_export(BUILD example EXPORT_SET example-targets GLOBAL_TARGETS example # since we can't hook into EXPORT SETS LANGUAGES CUDA DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string )
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/dependency_tracking.rst
Dependency Tracking ################### One of the biggest features of rapids-cmake is that it can track dependencies ( `find_package`, `cpm` ), allowing projects to easily generate `<project>-config.cmake` files with correct dependency requirements. In a normal CMake project, public dependencies need to be recorded in two locations: the original ``CMakeLists.txt`` file and the generated `<project>-config.cmake`. This dual source of truth increases developer burden, and adds a common source of error. ``rapids-cmake`` is designed to remove this dual source of truth by expanding the concept of Modern CMake `Usage Requirements <https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-specification-and-usage-requirements>`_ to include external packages. This is done via the ``BUILD_EXPORT_SET`` ( maps to `<BUILD_INTERFACE>` ) and ``INSTALL_EXPORT_SET`` ( maps to `<INSTALL_INTERFACE>` ) keywords on commands such as :cmake:command:`rapids_find_package` and :cmake:command:`rapids_cpm_find`. Let's go over an example of how these come together to make dependency tracking for projects easy. .. code-block:: cmake rapids_find_package(Threads REQUIRED BUILD_EXPORT_SET example-targets INSTALL_EXPORT_SET example-targets ) rapids_cpm_find(nlohmann_json 3.9.1 BUILD_EXPORT_SET example-targets ) add_library(example src.cpp) target_link_libraries(example PUBLIC Threads::Threads $<BUILD_INTERFACE:nlohmann_json::nlohmann_json> ) install(TARGETS example DESTINATION lib EXPORT example-targets ) set(doc_string [=[Provide targets for the example library.]=]) rapids_export(INSTALL example EXPORT_SET example-targets NAMESPACE example:: DOCUMENTATION doc_string ) rapids_export(BUILD example EXPORT_SET example-targets NAMESPACE example:: DOCUMENTATION doc_string ) Tracking find_package ********************* .. code-block:: cmake rapids_find_package(Threads REQUIRED BUILD_EXPORT_SET example-targets INSTALL_EXPORT_SET example-targets ) The :cmake:command:`rapids_find_package(<PackageName>)` combines the :cmake:command:`find_package <cmake:command:find_package>` command and dependency tracking. This example records that the `Threads` package is required by both the export set `example-targets` for both the install and build configuration. This means that when :cmake:command:`rapids_export` is called the generated `example-config.cmake` file will include the call `find_dependency(Threads)`, removing the need for developers to maintain that dual source of truth. The :cmake:command:`rapids_find_package(<PackageName>)` command also supports non-required finds correctly. In those cases `rapids-cmake` only records the dependency when the underlying :cmake:command:`find_package <cmake:command:find_package>` command is successful. It is common for projects to have dependencies for which CMake doesn't have a `Find<Package>`. In those cases projects will have a custom `Find<Package>` that they need to use, and install for consumers. Rapids-cmake tries to help projects simplify this process with the commands :cmake:command:`rapids_find_generate_module` and :cmake:command:`rapids_export_package`. The :cmake:command:`rapids_find_generate_module` allows projects to automatically generate a `Find<Package>` and encode via the `BUILD_EXPORT_SET` and `INSTALL_EXPORT_SET` parameters when the generated module should also be installed and added to `CMAKE_MODULE_PATH` so that consumers can use it. If you already have an existing `Find<Package>` written, :cmake:command:`rapids_export_package` simplifies the process of installing the module and making sure it is part of `CMAKE_MODULE_PATH` for consumers. Tracking CPM ************ .. code-block:: cmake rapids_cpm_find(nlohmann_json 3.9.1 BUILD_EXPORT_SET example-targets ) The :cmake:command:`rapids_cpm_find` combines the :cmake:command:`CPMFindPackage` command and dependency tracking, in a very similar way to :cmake:command:`rapids_find_package`. In this example what we are saying is that nlohmann_json is only needed by the build directory `example-config` and not needed by the installed `example-config`. While this pattern is rare, it occurs when projects have some dependencies that aren't needed by consumers but are propagated through the usage requirements inside a project via $<BUILD_INTERFACE>. Why use a build directory `config` file at all? The most common reason is that developers need to work on multiple dependent projects in a fast feedback loop. In that case this workflow avoids having to re-install a project each time a change needs to be tested in a dependent project. When used with `BUILD_EXPORT_SET`, :cmake:command:`rapids_cpm_find` will generate a :cmake:command:`CPMFindPackage(<PackageName> ...)` call, and when used with `INSTALL_EXPORT_SET` it will generate a :cmake:command:`find_dependency(<PackageName> ...) <cmake:command:find_dependency>` call. The theory behind this is that most packages currently don't have great build `config.cmake` support so it is best to have a fallback to cpm, while it is expected that all CMake packages have install rules. If this isn't the case for a CPM package you can instead use :cmake:command:`rapids_export_cpm`, and :cmake:command:`rapids_export_package` to specify the correct generated commands and forgo using `[BUILD|INSTALL]_EXPORT_SET`. Generating example-config.cmake ******************************* .. code-block:: cmake set(doc_string [=[Provide targets for the example library.]=]) rapids_export(INSTALL example EXPORT_SET example-targets NAMESPACE example:: DOCUMENTATION doc_string ) rapids_export(BUILD example EXPORT_SET example-targets NAMESPACE example:: DOCUMENTATION doc_string ) Before `rapids-cmake`, if a project wanted to generate a config module they would follow the example in the :ref:`cmake-packages docs <cmake:Creating Packages>` and use :cmake:command:`install(EXPORT) <cmake:command:install>`, :cmake:command:`export(EXPORT) <cmake:command:export>`, :cmake:command:`write_basic_package_version_file <cmake:command:write_basic_package_version_file>`, and a custom `config.cmake.in` file. The goal of :cmake:command:`rapids_export` is to replace all the boilerplate with an easy to use function that also embeds the necessary dependency calls collected by `BUILD_EXPORT_SET` and `INSTALL_EXPORT_SET`. :cmake:command:`rapids_export` uses CMake best practises to generate all the necessary components of a project config file. It handles generating a correct version file, finding dependencies and all the other boilerplate necessary to make well-behaved CMake config files. Moreover, the files generated by :cmake:command:`rapids_export` are completely standalone with no dependency on `rapids-cmake`.
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/Makefile
# Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/conf.py
# Copyright (c) 2023, NVIDIA CORPORATION. # # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import sphinx_rtd_theme # -- Project information ----------------------------------------------------- project = "rapids-cmake" copyright = "2021-2023, NVIDIA" author = "NVIDIA" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = "24.02" # The full version, including alpha/beta/rc tags. release = "24.02.00" # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "sphinx.ext.intersphinx", "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx_copybutton", "sphinxcontrib.moderncmakedomain" ] copybutton_prompt_text = ">>> " ipython_mplbackend = "str" # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst'] source_suffix = {".rst": "restructuredtext"} # The master toctree document. master_doc = "index" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ["_static"] # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = "rapidscmakedoc" # Intersphinx mappings for referencing external documentation intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "cmake": ("https://cmake.org/cmake/help/latest/", None), } # Config numpydoc numpydoc_show_inherited_class_members = True numpydoc_class_members_toctree = False autoclass_content = "init" def setup(app): app.add_js_file("copybutton_pydocs.js") app.add_css_file("https://docs.rapids.ai/assets/css/custom.css") app.add_js_file("https://docs.rapids.ai/assets/js/custom.js", loading_method="defer")
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/hardware_resources_and_testing.rst
.. _rapids_resource_allocation: Hardware Resources and Testing ############################## Resource Allocation ******************* CTest resource allocation frameworks allow tests to specify which hardware resources that they need, and for projects to specify the specific local/machine resources available. Combined together this ensures that tests are told which specific resources they should use, and ensures over-subscription won't occur no matter the requested testing parallel level. To get CTest resource allocation used by tests the following components are needed. - A JSON per-machine resource specification file - The :cmake:variable:`CTEST_RESOURCE_SPEC_FILE` points to the JSON file - Each :cmake:command:`add_test` records what resources it requires via test properties - Each test reads the relevant environment variables to determine what specific resources it should use These are steep requirements that require large amounts of infrastructure setup for each project. In addition the CTest resource allocation specification is very relaxed, allowing it to represent arbitrary requirements such as CPUs, GPUs, and ASICs. rapids_test *********** To help RAPIDS projects utilize all GPUs on a machine when running tests, the ``rapids-cmake`` project offers a suite of commands to simplify the process. These commands simplify GPU detection, setting up resource specification files, specifying test requirements, and setting the active CUDA GPU. Machine GPU Detection ********************* The key component of CTest resource allocation is having an accurate representation of the hardware that exists on the developer's machine. The :cmake:command:`rapids_test_init` function will do system introspection to determine the number of GPUs on the current machine and generate a resource allocation JSON file representing these GPUs. .. code-block:: cmake include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(rapids-test) enable_testing() rapids_test_init() The CTest resource allocation specification isn't limited to representing GPUs as a single unit. Instead it allows the JSON file to specify the capacity (slots) that each GPU has. In the case of rapids-cmake we always represent each GPU as having 100 slots allowing projects to think in total percentages when calculating requirements. Specifying Tests GPU Requirements ********************************* As discussed above, each CMake test needs to specify the GPU resources they require to allow CTest to properly partition GPUs given the CTest parallel level. The easiest path for for developers is to use the :cmake:command:`rapids_test_add` which wraps each execution in a wrapper script that sets the CUDA visible devices, making tests only see the allocated device(s). For example below we have three tests, two which can run concurrently on the same GPU and one that requires a full GPU. This specification will allow all three tests to run concurrently when a machine has 2+ GPUs with no modification of the tests! .. code-block:: cmake include(rapids-test) enable_testing() rapids_test_init() add_executable( cuda_test test.cu ) rapids_test_add(NAME test_small_alloc COMMAND cuda_test 50 GPUS 1 PERCENT 10) rapids_test_add(NAME test_medium_alloc COMMAND cuda_test 100 GPUS 1 PERCENT 20) rapids_test_add(NAME test_very_large_alloc COMMAND cuda_test 10000 GPUS 1) Multi GPU Tests *************** The :cmake:command:`rapids_test_add` command also supports tests that require multiple GPU bindings. In that case you will need to request two (or more) GPUs with a full allocation like this: .. code-block:: cmake include(rapids-test) enable_testing() rapids_test_init() add_executable( cuda_test test.cu ) rapids_test_add(NAME multi_gpu COMMAND cuda_test GPUS 3) Due to how CTest does allocations if you need distinct GPUs you need to request a percentage of 51% or higher. Otherwise you have a chance for multiple allocations to be placed on the same GPU. When rapids-cmake test wrapper is insufficient ********************************************** At times the approach of using wrapper scripts is insufficient, usually due to using existing test wrappers. As discussed above, each CMake test still needs to specify the GPU resources they require to allow CTest to properly partition GPUs given the CTest parallel level. But in those cases the tests themselves will need to parse the CTest environment variables to extract what GPUs they should run on. For the CMake side you can use :cmake:command:`rapids_test_gpu_requirements` to specify the requirements: .. code-block:: cmake include(rapids-test) enable_testing() rapids_test_init() add_executable( cuda_test test.cu ) target_link_libraries( cuda_test PRIVATE RAPIDS::test ) add_test(NAME test_small_alloc COMMAND cuda_test 50) rapids_test_gpu_requirements(test_small_alloc GPUS 1 PERCENT 10) Now in the C++ you need to parse the relevant `CTEST_RESOURCE_GROUP` environment variables. To simplify the process, here is some helper C++ code that will do the heavy lifting for you: .. literalinclude:: cpp_code_snippets/rapids_cmake_ctest_allocation.hpp :language: cpp .. literalinclude:: cpp_code_snippets/rapids_cmake_ctest_allocation.cpp :language: cpp
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/basics.rst
RAPIDS-CMake Basics ################### Installation ************ The ``rapids-cmake`` module is designed to be acquired via CMake's `Fetch Content <https://cmake.org/cmake/help/latest/module/FetchContent.html>`_ into your project. .. code-block:: cmake cmake_minimum_required(...) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/<PROJ>_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/<PROJ>_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/<PROJ>_RAPIDS.cmake) include(rapids-cmake) include(rapids-cpm) include(rapids-cuda) include(rapids-export) include(rapids-find) project(...) Usage ***** ``rapids-cmake`` is designed for projects to use only the subset of features that they need. To enable this `rapids-cmake` comprises the following primary components: - `cmake <api.html#common>`__ - `cpm <api.html#cpm>`__ - `cython <api.html#cython>`__ - `cuda <api.html#cuda>`__ - `export <api.html#export>`__ - `find <api.html#find>`__ - `testing <api.html#testing>`__ There are two ways projects can use ``rapids-cmake`` functions. 1. Call ``include(rapids-<component>)``, which imports commonly used functions for the component. 2. Load each function independently via ``include(${rapids-cmake-dir}/<component>/<function_name>.cmake)``. Overriding RAPIDS.cmake *********************** At times projects or developers will need to verify ``rapids-cmake`` branches. To do this you need to override the default git repository and branch that ``RAPIDS.cmake`` downloads, which should be done like this: .. code-block:: cmake include(FetchContent) FetchContent_Declare( rapids-cmake GIT_REPOSITORY https://github.com/<my_fork>/rapids-cmake.git GIT_TAG <my_feature_branch> ) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) This tells ``FetchContent`` to ignore the explicit url and branch in ``RAPIDS.cmake`` and use the ones provided. An incorrect approach that people try is to modify the ``file(DOWNLOAD)`` line to point to the custom ``rapids-cmake`` branch. That doesn't work as the downloaded ``RAPIDS.cmake`` contains which version of the rapids-cmake repository to clone.
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/api.rst
API Reference ############# .. _`common`: Common ****** The `rapids_cmake` functions provide common CMake logic that numerous projects require. .. toctree:: :titlesonly: /command/rapids_cmake_build_type /command/rapids_cmake_install_lib_dir /command/rapids_cmake_make_global /command/rapids_cmake_parse_version /command/rapids_cmake_support_conda_env /command/rapids_cmake_write_git_revision_file /command/rapids_cmake_write_version_file .. _`cpm`: CPM *** The `rapids_cpm` functions allow projects to find or build dependencies with built-in tracking of these dependencies for correct export support. .. toctree:: :titlesonly: /command/rapids_cpm_init /command/rapids_cpm_find /command/rapids_cpm_package_override CPM Pre-Configured Packages *************************** These `rapids_cpm` functions allow projects to easily find or build common RAPIDS dependencies. These allow projects to make sure they use the same version and flags for dependencies as the rest of RAPIDS. The exact versions that each pre-configured package uses :ref:`can be found here. <cpm_versions>` .. toctree:: :titlesonly: /packages/rapids_cpm_cuco /packages/rapids_cpm_fmt /packages/rapids_cpm_gbench /packages/rapids_cpm_gtest /packages/rapids_cpm_libcudacxx /packages/rapids_cpm_nvbench /packages/rapids_cpm_nvcomp /packages/rapids_cpm_rmm /packages/rapids_cpm_spdlog /packages/rapids_cpm_thrust .. _`cython`: Cython ****** The `rapids_cython` functions allow projects to easily build cython modules using `scikit-build <https://scikit-build.readthedocs.io/en/latest/>`_. .. note:: Use of the rapids-cython component of rapids-cmake requires scikit-build. The behavior of the functions provided by this component is undefined if they are invoked outside of a build managed by scikit-build. .. toctree:: :titlesonly: /command/rapids_cython_init /command/rapids_cython_create_modules /command/rapids_cython_add_rpath_entries .. _`find`: Find **** The `rapids_find` functions allow projects to find system dependencies with built-in tracking of these dependencies for correct export support. .. toctree:: :titlesonly: /command/rapids_find_generate_module /command/rapids_find_package .. _`cuda`: CUDA **** The `rapids_cuda` functions provide common CMake CUDA logic that numerous projects require. .. toctree:: :titlesonly: rapids_cuda_init_architectures </command/rapids_cuda_init_architectures> rapids_cuda_init_runtime </command/rapids_cuda_init_runtime> rapids_cuda_patch_toolkit </command/rapids_cuda_patch_toolkit> rapids_cuda_set_runtime </command/rapids_cuda_set_runtime> rapids_cuda_set_architectures [Advanced] </command/rapids_cuda_set_architectures> .. _`export`: Export Set Generation ********************* These `rapids_export` functions allow projects to generate correct build and install tree `Project-Config.cmake` modules including required dependencies. For the vast majority of projects :cmake:command:`rapids_export` should be sufficient. But when not projects may use commands such as :cmake:command:`rapids_write_dependencies` and cmake:command:`rapids_write_language` to create a custom `Project-Config.cmake`. .. toctree:: :maxdepth: 1 rapids_export </command/rapids_export> rapids_export_write_dependencies [Advanced] </command/rapids_export_write_dependencies> rapids_export_write_language [Advanced] </command/rapids_export_write_language> Export Set Tracking ******************* These `rapids_export` functions allow projects to track track dependencies for correct export generation. These should only be used when :cmake:command:`rapids_find_package`, :cmake:command:`rapids_cpm_find`, or :cmake:command:`rapids_find_generate_module` are insufficient. .. toctree:: :titlesonly: rapids_export_cpm [Advanced] </command/rapids_export_cpm> rapids_export_find_package_file [Advanced] </command/rapids_export_find_package_file> rapids_export_find_package_root [Advanced] </command/rapids_export_find_package_root> rapids_export_package [Advanced] </command/rapids_export_package> .. _`testing`: Testing ******* The `rapids_test` functions simplify CTest resource allocation, allowing for tests to run in parallel without over-allocating GPU resources. More information on resource allocation can be found in the rapids-cmake :ref:`Hardware Resources and Testing documentation <rapids_resource_allocation>`. .. toctree:: :titlesonly: /command/rapids_test_init /command/rapids_test_add /command/rapids_test_generate_resource_spec /command/rapids_test_gpu_requirements /command/rapids_test_install_relocatable
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/docs/index.rst
.. rapids-cmake documentation file Welcome to rapids-cmake's documentation! ======================================== This is a collection of CMake modules that are useful for all RAPIDS projects. By sharing the code in a single place it makes rolling out CMake fixes easier. .. toctree:: :maxdepth: 1 :caption: Contents: api.rst basics.rst dependency_tracking.rst hardware_resources_and_testing.rst Indices and tables ================== * :ref:`genindex` * :ref:`search`
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/cpp_code_snippets/rapids_cmake_ctest_allocation.hpp
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <cuda_runtime_api.h> #include <vector> namespace rapids_cmake { /* * Represents a GPU Allocation provided by a CTest resource specification. * * The `device_id` maps to the CUDA gpu id required by `cudaSetDevice`. * The slots represent the percentage of the GPU that this test will use. * Primarily used by CTest to ensure proper load balancing of tests. */ struct GPUAllocation { int device_id; int slots; }; /* * Returns true when a CTest resource specification has been specified. * * Since the vast majority of tests should execute without a CTest resource * spec (e.g. when executed manually by a developer), callers of `rapids_cmake` * should first ensure that a CTestresource spec file has been provided before * trying to query/bind to the allocation. * * ```cxx * if (rapids_cmake::using_resouces()) { * rapids_cmake::bind_to_first_gpu(); * } * ``` */ bool using_resources(); /* * Returns all GPUAllocations allocated for a test * * To support multi-GPU tests the CTest resource specification allows a * test to request multiple GPUs. As CUDA only allows binding to a * single GPU at any time, this API allows tests to know what CUDA * devices they should bind to. * * Note: The `device_id` of each allocation might not be unique. * If a test says it needs 50% of two GPUs, it could be allocated * the same physical GPU. If a test needs distinct / unique devices * it must request 51%+ of a device. * * Note: rapids_cmake does no caching, so this query should be cached * instead of called multiple times. */ std::vector<GPUAllocation> full_allocation(); /* * Have CUDA bind to a given GPUAllocation * * Have CUDA bind to the `device_id` specified in the CTest * GPU allocation * * Note: Return value is the cudaError_t of `cudaSetDevice` */ cudaError_t bind_to_gpu(GPUAllocation const& alloc); /* * Convenience method to bind to the first GPU that CTest has allocated * Provided as most RAPIDS tests only require a single GPU * * Will return `false` if no GPUs have been allocated, or if setting * the CUDA device failed for any reason. */ bool bind_to_first_gpu(); } // namespace rapids_cmake
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/cpp_code_snippets/rapids_cmake_ctest_allocation.cpp
/* * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <rapids_cmake_ctest_allocation.hpp> #include <cuda_runtime_api.h> #include <algorithm> #include <cstdlib> #include <numeric> #include <string> #include <string_view> namespace rapids_cmake { namespace { GPUAllocation noGPUAllocation() { return GPUAllocation{-1, -1}; } GPUAllocation parseCTestAllocation(std::string_view env_variable) { std::string gpu_resources{std::getenv(env_variable.begin())}; // need to handle parseCTestAllocation variable being empty // need to handle parseCTestAllocation variable not having some // of the requested components // The string looks like "id:<number>,slots:<number>" auto id_start = gpu_resources.find("id:") + 3; auto id_end = gpu_resources.find(","); auto slot_start = gpu_resources.find("slots:") + 6; auto id = gpu_resources.substr(id_start, id_end - id_start); auto slots = gpu_resources.substr(slot_start); return GPUAllocation{std::stoi(id), std::stoi(slots)}; } std::vector<GPUAllocation> determineGPUAllocations() { std::vector<GPUAllocation> allocations; const auto* resource_count = std::getenv("CTEST_RESOURCE_GROUP_COUNT"); if (!resource_count) { allocations.emplace_back(); return allocations; } const auto resource_max = std::stoi(resource_count); for (int index = 0; index < resource_max; ++index) { std::string group_env = "CTEST_RESOURCE_GROUP_" + std::to_string(index); std::string resource_group{std::getenv(group_env.c_str())}; std::transform(resource_group.begin(), resource_group.end(), resource_group.begin(), ::toupper); if (resource_group == "GPUS") { auto resource_env = group_env + "_" + resource_group; auto&& allocation = parseCTestAllocation(resource_env); allocations.emplace_back(allocation); } } return allocations; } } // namespace bool using_resources() { const auto* resource_count = std::getenv("CTEST_RESOURCE_GROUP_COUNT"); return resource_count != nullptr; } std::vector<GPUAllocation> full_allocation() { return determineGPUAllocations(); } cudaError_t bind_to_gpu(GPUAllocation const& alloc) { return cudaSetDevice(alloc.device_id); } bool bind_to_first_gpu() { if (using_resources()) { std::vector<GPUAllocation> allocs = determineGPUAllocations(); return (bind_to_gpu(allocs[0]) == cudaSuccess); } return false; } } // namespace rapids_cmake
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/rapids_cpm_nvbench.rst
.. cmake-module:: ../../rapids-cmake/cpm/nvbench.cmake
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/rapids_cpm_cuco.rst
.. cmake-module:: ../../rapids-cmake/cpm/cuco.cmake
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/example.json
{ "packages" : { "Thrust" : { "version" : "1.12.0", "git_url" : "https://github.com/NVIDIA/thrust.git", "git_tag" : "${version}", "git_shallow" : true, "always_download" : true, "exclude_from_all" : false } } }
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/common_package_args.txt
``BUILD_EXPORT_SET`` Record that a :cmake:command:`CPMFindPackage()` for |PKG_NAME| is required in our build directory export set. ``INSTALL_EXPORT_SET`` Record that a :cmake:command:`find_dependency() <cmake:module:CMakeFindDependencyMacro>` for |PKG_NAME| is required in our install directory export set. .. note:: Installation of |PKG_NAME| will occur if an INSTALL_EXPORT_SET is provided, and |PKG_NAME| is added to the project via :cmake:command:`add_subdirectory <cmake:command:add_subdirectory>` by CPM. ``CPM_ARGS`` Any arguments after `CPM_ARGS` will be forwarded to the underlying |PKG_NAME| :cmake:command:`CPMFindPackage`()` call
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/rapids_cpm_versions.rst
:orphan: .. _cpm_version_format: rapids-cmake package version format ################################### rapids-cmake uses a JSON file to encode the version of a project and how to download the project. The JSON format is a root object that contains the ``packages`` object. The ``packages`` object contains a key/value map of all supported packages where the key is the case sensitive name of the project and the value is a ``project`` object, as seen in this example: .. literalinclude:: /packages/example.json :language: json Project Object Fields ********************* Each ``project`` object must contain the following fields so that rapids-cmake can properly use CPM to find or download the project as needed. ``version`` A required string representing the version of the project to be used by :cmake:command:`rapids_cpm_find` when looking for a local installed copy of the project. Supports the following placeholders: - ``${rapids-cmake-version}`` will be evulated to 'major.minor' of the current rapids-cmake cal-ver value. ``git_url`` A required string representing the git url to be used when cloning the project locally by the :cmake:command:`rapids_cpm_find` when a locally installed copy of the project can't be found. ``git_tag`` A required string representing the git tag to be used when cloning the project locally by the :cmake:command:`rapids_cpm_find` when a locally installed copy of the project can't be found. Supports the following placeholders: - ``${rapids-cmake-version}`` will be evulated to 'major.minor' of the current rapids-cmake cal-ver value. - ``${version}`` will be evaluated to the contents of the ``version`` field. ``git_shallow`` An optional boolean value that represents if we should do a shallow git clone or not. If no such field exists the default is `true`. ``exclude_from_all`` An optional boolean value that represents the CMake `EXCLUDE_FROM_ALL` property. If this is set to `true`, and the project is built from source all targets of that project will be excluded from the `ALL` build rule. This means that any target that isn't used by the consuming project will not be compiled. This is useful when a project generates multiple targets that aren't required and the cost of building them isn't desired. If no such field exists the default is `false`. ``always_download`` An optional boolean value that represents if CPM should just download the package ( `CPM_DOWNLOAD_ALL` ) instead of first searching for it on the machine. The default value for this field is `false` unless all of the following criteria is met. - The projects exists in both the default and override files - The `git_url`, `git_tag`, `patches` keys exist in the override ``patches`` An optional list of dictionary sets of git patches to apply to the project when it is built from source. .. literalinclude:: /packages/patches.json :language: json Each dictionary in the array of patches contains the following fields: ``file`` A required string representing the git diff ( .diff ) or patch ( .patch ) to apply. Absolute and relative paths are supported. Relative paths are evaluated in relation to the `rapids-cmake/cpm/patches` directory. Supports the following placeholders: - ``${current_json_dir}`` will be evaluated to the absolute path to the directory holding the current json file ``issue`` A required string that explains the need for the patch. Preference is for the string to also contain the URL to the upstream issue or PR that this patch addresses. ``fixed_in`` A required entry that represents which version this patch is no longer needed in. If this patch is required for all versions an empty string should be supplied. ``proprietary_binary`` An optional dictionary of cpu architecture and operating system keys to url values that represents a download for a pre-built proprietary version of the library. This creates a new entry in the search logic for a project: - Search for a local version matching the `version` key - disabled by `always_download` - Download proprietary version if a valid OS + CPU Arch exists - disabled by `USE_PROPRIETARY_BLOB` being off - Fallback to using git url and tag To determine the correct key, CMake will query for a key that matches the lower case value of `<arch>-<os>` where `arch` maps to :cmake:variable:`CMAKE_SYSTEM_PROCESSOR <cmake:variable:CMAKE_SYSTEM_PROCESSOR>` and `os` maps to :cmake:variable:`CMAKE_SYSTEM_NAME <cmake:variable:CMAKE_SYSTEM_NAME>`. If no such key exists the request to use a `proprietary_binary` will be ignored. .. literalinclude:: /packages/proprietary_binary.json :language: json As this represents a proprietary binary only the following packages support this command: - nvcomp Due to requirements of proprietary binaries, explicit opt-in by the user on usage is required. Therefore for this binary to be used the caller must call the associated `rapids_cpm` command with the `USE_PROPRIETARY_BLOB` set to `ON`. Supports the following placeholders: - ``${rapids-cmake-version}`` will be evaluated to 'major.minor' of the current rapids-cmake cal-ver value. - ``${version}`` will be evaluated to the contents of the ``version`` field. - ``${cuda-toolkit-version}`` will be evaluated to 'major.minor' of the current CUDA Toolkit version. - ``${cuda-toolkit-version-major}`` will be evaluated to 'major' of the current CUDA Toolkit version. If this field exists in the default package, the value will be ignored when an override file entry exists for the package. This ensures that the git url or `proprietary_binary` entry in the override will be used. rapids-cmake package versions ############################# .. _cpm_versions: .. literalinclude:: /../rapids-cmake/cpm/versions.json :language: json
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/rapids_cpm_nvcomp.rst
.. cmake-module:: ../../rapids-cmake/cpm/nvcomp.cmake
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/proprietary_binary.json
{ "proprietary_binary" : { "aarch64-linux" : "<url>", "x86_64-linux" : "<url>" } }
0
rapidsai_public_repos/rapids-cmake/docs
rapidsai_public_repos/rapids-cmake/docs/packages/rapids_cpm_libcudacxx.rst
.. cmake-module:: ../../rapids-cmake/cpm/libcudacxx.cmake
0