Skip to content

Commit c478a7d

Browse files
authored
Merge branch 'main' into main
2 parents afb1e05 + 9b133a9 commit c478a7d

File tree

6 files changed

+57
-20
lines changed

6 files changed

+57
-20
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ else()
1111
set(NVBench_TOPLEVEL_PROJECT OFF)
1212
endif()
1313

14+
# Default to native if no cuda arches are specified:
15+
if (NOT (DEFINED CMAKE_CUDA_ARCHITECTURES OR DEFINED ENV{CUDAARCHS}))
16+
set(CMAKE_CUDA_ARCHITECTURES "native")
17+
endif()
18+
1419
include(cmake/NVBenchRapidsCMake.cmake)
15-
nvbench_load_rapids_cmake()
20+
nvbench_load_rapids_cmake(25.12)
1621

1722
project(NVBench
1823
LANGUAGES CUDA CXX

cmake/NVBenchConfigTarget.cmake

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,46 @@ function(nvbench_add_cxx_flag target_name type flag)
3333
endif()
3434
endfunction()
3535

36+
# We test to see if C++ compiler options exist using try-compiles in the CXX lang, and then reuse those flags as
37+
# -Xcompiler flags for CUDA targets. This requires that the CXX compiler and CUDA_HOST compilers are the same when
38+
# using nvcc.
39+
if (NVBench_TOPLEVEL_PROJECT AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
40+
set(cuda_host_matches_cxx_compiler FALSE)
41+
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.31)
42+
set(host_info "${CMAKE_CUDA_HOST_COMPILER} (${CMAKE_CUDA_HOST_COMPILER_ID} ${CMAKE_CUDA_HOST_COMPILER_VERSION})")
43+
set(cxx_info "${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})")
44+
if (CMAKE_CUDA_HOST_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID AND
45+
CMAKE_CUDA_HOST_COMPILER_VERSION VERSION_EQUAL CMAKE_CXX_COMPILER_VERSION)
46+
set(cuda_host_matches_cxx_compiler TRUE)
47+
endif()
48+
else() # CMake < 3.31 doesn't have the CMAKE_CUDA_HOST_COMPILER_ID/VERSION variables
49+
set(host_info "${CMAKE_CUDA_HOST_COMPILER}")
50+
set(cxx_info "${CMAKE_CXX_COMPILER}")
51+
if (CMAKE_CUDA_HOST_COMPILER STREQUAL CMAKE_CXX_COMPILER)
52+
set(cuda_host_matches_cxx_compiler TRUE)
53+
endif()
54+
endif()
55+
56+
if (NOT cuda_host_matches_cxx_compiler)
57+
message(FATAL_ERROR
58+
"NVBench developer builds require that CMAKE_CUDA_HOST_COMPILER matches "
59+
"CMAKE_CXX_COMPILER when using nvcc:\n"
60+
"CMAKE_CUDA_COMPILER: ${CMAKE_CUDA_COMPILER}\n"
61+
"CMAKE_CUDA_HOST_COMPILER: ${host_info}\n"
62+
"CMAKE_CXX_COMPILER: ${cxx_info}\n"
63+
"Rerun cmake with \"-DCMAKE_CUDA_HOST_COMPILER=${CMAKE_CXX_COMPILER}\".\n"
64+
"Alternatively, configure the CUDAHOSTCXX and CXX environment variables to match.\n"
65+
)
66+
endif()
67+
endif()
68+
3669
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wall")
3770
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wextra")
3871
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wconversion")
3972
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Woverloaded-virtual")
4073
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wcast-qual")
4174
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wpointer-arith")
42-
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wunused-local-typedef")
75+
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wunused-local-typedefs")
4376
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wunused-parameter")
4477
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wvla")
4578
nvbench_add_cxx_flag(nvbench.build_interface INTERFACE "-Wgnu")

cmake/NVBenchDependencies.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ if(NOT BUILD_SHARED_LIBS AND NVBench_ENABLE_INSTALL_RULES)
99
endif()
1010

1111
rapids_cpm_find(fmt 11.2.0 ${export_set_details}
12-
GLOBAL_TARGETS fmt::fmt fmt::fmt-header-only
1312
CPM_ARGS
1413
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
1514
GIT_TAG "11.2.0"

cmake/NVBenchRapidsCMake.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Called before project(...)
2-
macro(nvbench_load_rapids_cmake)
2+
macro(nvbench_load_rapids_cmake version)
33
# - Including directly, see https://github.com/rapidsai/rmm/pull/1886
44
# - Versioned download URL:
55
# https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-XX.YY/RAPIDS.cmake
66
# - This macro is always called before project() in the root CMakeLists.txt, so:
77
# - we can't just use NVBench_SOURCE_DIR, it's not defined yet.
88
# - We can't rely on CMAKE_CURRENT_LIST_DIR because of macro expansion.
99
# - We can fallback to CURRENT_SOURCE_DIR because we know this will be expanded in the root:
10+
set(rapids-cmake-version ${version})
1011
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/RAPIDS.cmake")
1112

1213
include(rapids-cmake)

cmake/RAPIDS.cmake

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#
1717
# This is the preferred entry point for projects using rapids-cmake
1818
#
19+
# Enforce the minimum required CMake version for all users
20+
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
1921

2022
# Allow users to control which version is used
21-
if(NOT rapids-cmake-version)
22-
# Define a default version if the user doesn't set one
23-
set(rapids-cmake-version 25.04)
23+
if(NOT (rapids-cmake-branch OR rapids-cmake-version))
24+
message(FATAL_ERROR "The CMake variable `rapids-cmake-branch` or `rapids-cmake-version` must be defined"
25+
)
2426
endif()
2527

2628
# Allow users to control which GitHub repo is fetched
@@ -66,26 +68,18 @@ if(NOT rapids-cmake-url)
6668
endif()
6769
endif()
6870

69-
if(POLICY CMP0135)
70-
cmake_policy(PUSH)
71-
cmake_policy(SET CMP0135 NEW)
72-
endif()
7371
include(FetchContent)
7472
if(rapids-cmake-fetch-via-git)
75-
FetchContent_Declare(rapids-cmake
76-
GIT_REPOSITORY "${rapids-cmake-url}"
77-
GIT_TAG "${rapids-cmake-value-to-clone}")
73+
FetchContent_Declare(rapids-cmake GIT_REPOSITORY "${rapids-cmake-url}"
74+
GIT_TAG "${rapids-cmake-value-to-clone}")
7875
else()
7976
string(APPEND rapids-cmake-url "${rapids-cmake-value-to-clone}")
8077
FetchContent_Declare(rapids-cmake URL "${rapids-cmake-url}")
8178
endif()
82-
if(POLICY CMP0135)
83-
cmake_policy(POP)
84-
endif()
8579
FetchContent_GetProperties(rapids-cmake)
8680
if(rapids-cmake_POPULATED)
87-
# Something else has already populated rapids-cmake, only thing
88-
# we need to do is setup the CMAKE_MODULE_PATH
81+
# Something else has already populated rapids-cmake, only thing we need to do is setup the
82+
# CMAKE_MODULE_PATH
8983
if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
9084
list(APPEND CMAKE_MODULE_PATH "${rapids-cmake-dir}")
9185
endif()

scripts/nvbench_compare.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import sys
77

8+
import jsondiff
89
import tabulate
910
from colorama import Fore
1011
from nvbench_json import reader
@@ -371,9 +372,13 @@ def main():
371372
global all_devices
372373
all_devices = cmp_root["devices"]
373374

374-
# This is blunt but works for now:
375375
if ref_root["devices"] != cmp_root["devices"]:
376376
print("Device sections do not match.")
377+
print(
378+
jsondiff.diff(
379+
ref_root["devices"], cmp_root["devices"], syntax="symmetric"
380+
)
381+
)
377382
sys.exit(1)
378383

379384
compare_benches(

0 commit comments

Comments
 (0)