Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build generate_ctest_json in try_compile() #537

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dd465ca
Build generate_ctest_json in a try_compile()
KyleFromNVIDIA Feb 7, 2024
69ddc60
Use execute_process() instead
KyleFromNVIDIA Feb 7, 2024
37430db
Revert "Use execute_process() instead"
KyleFromNVIDIA Feb 7, 2024
1916d7b
Change compilation language depending on compiler
KyleFromNVIDIA Feb 7, 2024
758e757
Pass CUDAToolkit_LIBRARY_ROOT
KyleFromNVIDIA Feb 7, 2024
f9065e6
Find CUDAToolkit REQUIRED if found in parent
KyleFromNVIDIA Feb 7, 2024
b007c4f
Don't propagate compiler variable
KyleFromNVIDIA Feb 7, 2024
166faac
Use old try_compile() signature
KyleFromNVIDIA Feb 7, 2024
bf4e197
Use CUDAToolkit_ROOT
KyleFromNVIDIA Feb 7, 2024
135ff76
Debugging: print build.ninja for generator
KyleFromNVIDIA Feb 8, 2024
8f4e5d0
Revert "Debugging: print build.ninja for generator"
KyleFromNVIDIA Feb 8, 2024
9978afc
Debugging: nvidia-smi
KyleFromNVIDIA Feb 8, 2024
34c7212
Debugging: $RAPIDS_CMAKE_TESTING_GPU_COUNT
KyleFromNVIDIA Feb 8, 2024
2c96dec
More debugging
KyleFromNVIDIA Feb 8, 2024
13f49db
Static CUDA, no dependencies
KyleFromNVIDIA Feb 8, 2024
5da0122
Remove no longer needed variables
KyleFromNVIDIA Feb 8, 2024
26f00e6
Debugging
KyleFromNVIDIA Feb 8, 2024
ad0f28a
More debugging
KyleFromNVIDIA Feb 8, 2024
b3a124f
Debugging: rules.ninja
KyleFromNVIDIA Feb 8, 2024
08362ef
Debugging: compare generator executables
KyleFromNVIDIA Feb 8, 2024
1f3defc
Try not using sccache
KyleFromNVIDIA Feb 8, 2024
84476c3
Debugging: unset the variables in the right place
KyleFromNVIDIA Feb 8, 2024
f077f18
Unset properties
KyleFromNVIDIA Feb 8, 2024
677d338
Remove debugging and extraneous variables
KyleFromNVIDIA Feb 8, 2024
ebbea1e
Revert copyright
KyleFromNVIDIA Feb 8, 2024
a0fde33
Revert "Revert copyright"
KyleFromNVIDIA Feb 8, 2024
5796af6
Use sccache again - this will work once we upgrade to 0.7.6
KyleFromNVIDIA Feb 8, 2024
e7a8e38
Merge branch 'branch-24.04' into generate-ctest-json-try-compile
robertmaynard Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions rapids-cmake/test/detail/generate_resource_spec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#=============================================================================
# Copyright (c) 2024, 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(generate_resource_spec ${lang})

set(CMAKE_CUDA_ARCHITECTURES all)

add_executable(generate_ctest_json generate_resource_spec.cpp)
target_link_libraries(generate_ctest_json PRIVATE rt ${CMAKE_DL_LIBS})
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
if(cuda_toolkit)
find_package(CUDAToolkit REQUIRED QUIET)
target_link_libraries(generate_ctest_json PRIVATE CUDA::cudart)
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
target_compile_definitions(generate_ctest_json PRIVATE HAVE_CUDA)
endif()
set_property(SOURCE generate_resource_spec.cpp PROPERTY LANGUAGE ${lang})

add_custom_command(TARGET generate_ctest_json POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:generate_ctest_json>
"${output_file}" COMMENT "Copying executable to destination")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
22 changes: 10 additions & 12 deletions rapids-cmake/test/generate_resource_spec.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,30 @@ function(rapids_test_generate_resource_spec DESTINATION filepath)
]=])

include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/default_names.cmake)
set(eval_file ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/generate_resource_spec.cpp)
set(eval_exe ${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name})
set(error_file ${PROJECT_BINARY_DIR}/rapids-cmake/detect_gpus.stderr.log)
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved

if(NOT EXISTS "${eval_exe}")
find_package(CUDAToolkit QUIET)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/rapids-cmake/")

if(CUDAToolkit_FOUND)
set(cuda_include_options ${CUDAToolkit_INCLUDE_DIRS})
list(TRANSFORM cuda_include_options PREPEND "-I")
set(compile_options ${cuda_include_options} "-DHAVE_CUDA")
endif()
set(link_options ${CUDA_cudart_LIBRARY} -lpthread -lrt -ldl)
set(compiler "${CMAKE_CXX_COMPILER}")
set(lang CXX)
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(compiler "${CMAKE_CUDA_COMPILER}")
set(lang CUDA)
endif()

execute_process(COMMAND "${compiler}" "${eval_file}" ${compile_options} ${link_options} -o
"${eval_exe}" OUTPUT_VARIABLE compile_output
ERROR_VARIABLE compile_output RESULT_VARIABLE result)
try_compile(result "${PROJECT_BINARY_DIR}/rapids-cmake/generate_ctest_json-build"
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/generate_resource_spec"
generate_resource_spec
CMAKE_FLAGS "-DCUDAToolkit_ROOT=${CUDAToolkit_ROOT}" "-Doutput_file=${eval_exe}"
"-Dlang=${lang}" "-Dcuda_toolkit=${CUDAToolkit_FOUND}"
OUTPUT_VARIABLE compile_output)

if(NOT result EQUAL 0)
if(NOT result)
string(REPLACE "\n" "\n " compile_output "${compile_output}")
message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}"
message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nfailure details are:\n ${compile_output}"
)
endif()
endif()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,3 +30,5 @@ 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)

add_test(NAME nvidia-smi COMMAND /bin/bash -c "nvidia-smi && echo $RAPIDS_CMAKE_TESTING_GPU_COUNT && false")
Loading