Skip to content

Commit e9ef2f3

Browse files
robertmaynardbdiceKyleFromNVIDIA
authored
Apply test refactoring suggestions from code review
Co-authored-by: Bradley Dice <[email protected]> Co-authored-by: Kyle Edwards <[email protected]>
1 parent 88ef39a commit e9ef2f3

File tree

3 files changed

+55
-92
lines changed

3 files changed

+55
-92
lines changed

rapids-cmake/cuda/enable_fatbin_compression.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#=============================================================================
2-
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

testing/cuda/enable_fatbin_compression-target.cmake

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,58 +33,37 @@ endforeach()
3333

3434
# Validate all the targets now have the proper values
3535
foreach(suffix mode option IN ZIP_LISTS name_suffix modes compile_options)
36-
get_target_property(compile_opts not_yet_${suffix} INTERFACE_COMPILE_OPTIONS)
37-
if(NOT compile_opts MATCHES "-Xfatbin=-compress-all")
38-
message(FATAL_ERROR "not_yet_${suffix} missing the compress-all compile flag")
39-
endif()
40-
if(NOT compile_opts MATCHES "--compress-mode=${option}")
41-
message(FATAL_ERROR "not_yet_${suffix} missing the proper compress-mode flag of ${option} instead has ${compile_opts}"
42-
)
43-
endif()
44-
45-
get_target_property(compile_opts exists_${suffix} COMPILE_OPTIONS)
46-
if(NOT compile_opts MATCHES "-Xfatbin=-compress-all")
47-
message(FATAL_ERROR "exists_${suffix} missing the compress-all compile flag")
48-
endif()
49-
if(NOT compile_opts MATCHES "--compress-mode=${option}")
50-
message(FATAL_ERROR "exists_${suffix} missing the proper compress-mode flag of ${option} instead has ${compile_opts}"
51-
)
52-
endif()
36+
foreach(target IN ITEMS not_yet_${suffix} exists_${suffix})
37+
get_target_property(compile_opts ${target} INTERFACE_COMPILE_OPTIONS)
38+
if(NOT compile_opts MATCHES "-Xfatbin=-compress-all")
39+
message(FATAL_ERROR "${target} missing the compress-all compile flag")
40+
endif()
41+
if(NOT compile_opts MATCHES "--compress-mode=${option}")
42+
message(FATAL_ERROR "${target} missing the proper compress-mode flag of ${option} instead has ${compile_opts}"
43+
)
44+
endif()
45+
endforeach()
5346
endforeach()
5447

5548
# Handle checking all the tune types that map to `rapids`
56-
rapids_cuda_enable_fatbin_compression(TARGET not_yet)
57-
rapids_cuda_enable_fatbin_compression(TARGET not_yet_rapids TUNE_FOR rapids)
58-
59-
get_target_property(compile_opts_a not_yet INTERFACE_COMPILE_OPTIONS)
60-
get_target_property(compile_opts_b not_yet_rapids INTERFACE_COMPILE_OPTIONS)
61-
if(NOT compile_opts_a STREQUAL compile_opts_b)
62-
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression without any TUNE_FOR should match 'rapids'"
63-
)
64-
endif()
65-
if(NOT compile_opts_a MATCHES "-Xfatbin=-compress-all")
66-
message(FATAL_ERROR "not_yet missing the compress-all compile flag")
67-
endif()
68-
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0 AND NOT compile_opts_a MATCHES
69-
"--compress-mode")
70-
message(FATAL_ERROR "not_yet missing the compress-mode compile flag")
71-
endif()
72-
7349
add_library(exists SHARED ${stub_file})
7450
add_library(exists_rapids SHARED ${stub_file})
75-
rapids_cuda_enable_fatbin_compression(TARGET exists)
76-
rapids_cuda_enable_fatbin_compression(TARGET exists_rapids TUNE_FOR rapids)
7751

78-
get_target_property(compile_opts_a exists COMPILE_OPTIONS)
79-
get_target_property(compile_opts_b exists_rapids COMPILE_OPTIONS)
80-
if(NOT compile_opts_a STREQUAL compile_opts_b)
81-
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression without any TUNE_FOR should match 'rapids'"
82-
)
83-
endif()
84-
if(NOT compile_opts_a MATCHES "-Xfatbin=-compress-all")
85-
message(FATAL_ERROR "not_yet missing the compress-all compile flag")
86-
endif()
87-
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0 AND NOT compile_opts_a MATCHES
88-
"--compress-mode")
89-
message(FATAL_ERROR "not_yet missing the compress-mode compile flag")
90-
endif()
52+
foreach(target IN ITEMS not_yet exists)
53+
rapids_cuda_enable_fatbin_compression(TARGET ${target})
54+
rapids_cuda_enable_fatbin_compression(TARGET ${target}_rapids TUNE_FOR rapids)
55+
56+
get_target_property(compile_opts_a ${target} INTERFACE_COMPILE_OPTIONS)
57+
get_target_property(compile_opts_b ${target}_rapids INTERFACE_COMPILE_OPTIONS)
58+
if(NOT compile_opts_a STREQUAL compile_opts_b)
59+
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression without any TUNE_FOR should match 'rapids'"
60+
)
61+
endif()
62+
if(NOT compile_opts_a MATCHES "-Xfatbin=-compress-all")
63+
message(FATAL_ERROR "${target} missing the compress-all compile flag")
64+
endif()
65+
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0 AND NOT compile_opts_a MATCHES
66+
"--compress-mode")
67+
message(FATAL_ERROR "${target} missing the compress-mode compile flag")
68+
endif()
69+
endforeach()

testing/cuda/enable_fatbin_compression-var.cmake

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,60 +31,44 @@ endforeach()
3131
# Validate all the targets now have the proper values
3232
foreach(suffix mode option IN ZIP_LISTS name_suffix modes compile_options)
3333

34-
if(NOT not_yet_${suffix} MATCHES "-Xfatbin=-compress-all")
35-
message(FATAL_ERROR "not_yet_${suffix} missing the compress-all compile flag")
36-
endif()
37-
if(NOT not_yet_${suffix} MATCHES "--compress-mode=${option}")
38-
message(FATAL_ERROR "not_yet_${suffix} missing the proper compress-mode flag of ${option} instead has ${compile_opts}"
39-
)
40-
endif()
34+
foreach(var IN ITEMS not_yet_${suffix} exists_${suffix})
35+
if(NOT ${var} MATCHES "-Xfatbin=-compress-all")
36+
message(FATAL_ERROR "${var} missing the compress-all compile flag")
37+
endif()
38+
if(NOT ${var} MATCHES "--compress-mode=${option}")
39+
message(FATAL_ERROR "${var} missing the proper compress-mode flag of ${option} instead has ${compile_opts}"
40+
)
41+
endif()
42+
endforeach()
4143

4244
if(NOT exists_${suffix} MATCHES "-extra-flag")
4345
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression cleared existing values in a variable"
4446
)
4547
endif()
46-
if(NOT exists_${suffix} MATCHES "-Xfatbin=-compress-all")
47-
message(FATAL_ERROR "exists_${suffix} missing the compress-all compile flag")
48-
endif()
49-
if(NOT exists_${suffix} MATCHES "--compress-mode=${option}")
50-
message(FATAL_ERROR "exists_${suffix} missing the proper compress-mode flag of ${option} instead has ${compile_opts}"
51-
)
52-
endif()
5348

5449
endforeach()
5550

5651
# Handle checking all the tune types that map to `rapids`
57-
rapids_cuda_enable_fatbin_compression(VARIABLE not_yet)
58-
rapids_cuda_enable_fatbin_compression(VARIABLE not_yet_rapids TUNE_FOR rapids)
59-
60-
if(NOT not_yet STREQUAL not_yet_rapids)
61-
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression without any TUNE_FOR should match 'rapids'"
62-
)
63-
endif()
64-
if(NOT not_yet MATCHES "-Xfatbin=-compress-all")
65-
message(FATAL_ERROR "not_yet missing the compress-all compile flag")
66-
endif()
67-
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0 AND NOT not_yet MATCHES
68-
"--compress-mode")
69-
message(FATAL_ERROR "not_yet missing the compress-mode compile flag")
70-
endif()
71-
7252
set(exists "-extra-flag")
7353
set(exists_rapids "-extra-flag")
74-
rapids_cuda_enable_fatbin_compression(VARIABLE exists)
75-
rapids_cuda_enable_fatbin_compression(VARIABLE exists_rapids TUNE_FOR rapids)
7654

77-
if(NOT exists STREQUAL exists_rapids)
78-
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression without any TUNE_FOR should match 'rapids'"
79-
)
80-
endif()
55+
foreach(var IN ITEMS not_yet exists)
56+
rapids_cuda_enable_fatbin_compression(VARIABLE ${var})
57+
rapids_cuda_enable_fatbin_compression(VARIABLE ${var}_rapids TUNE_FOR rapids)
58+
59+
if(NOT ${var} STREQUAL ${var}_rapids)
60+
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression without any TUNE_FOR should match 'rapids'"
61+
)
62+
endif()
63+
if(NOT ${var} MATCHES "-Xfatbin=-compress-all")
64+
message(FATAL_ERROR "${var} missing the compress-all compile flag")
65+
endif()
66+
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0 AND NOT ${var} MATCHES
67+
"--compress-mode")
68+
message(FATAL_ERROR "${var} missing the compress-mode compile flag")
69+
endif()
70+
endforeach()
71+
8172
if(NOT exists MATCHES "-extra-flag")
8273
message(FATAL_ERROR "rapids_cuda_enable_fatbin_compression cleared existing values in a variable")
8374
endif()
84-
if(NOT exists MATCHES "-Xfatbin=-compress-all")
85-
message(FATAL_ERROR "not_yet missing the compress-all compile flag")
86-
endif()
87-
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0 AND NOT exists MATCHES
88-
"--compress-mode")
89-
message(FATAL_ERROR "not_yet missing the compress-mode compile flag")
90-
endif()

0 commit comments

Comments
 (0)