Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit b4f7e23

Browse files
authored
Merge pull request #630 from senior-zero/fix-main/github/int128
Cleanup CTK version checks
2 parents 5d12837 + 5dce195 commit b4f7e23

File tree

8 files changed

+45
-27
lines changed

8 files changed

+45
-27
lines changed

cmake/CubHeaderTesting.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function(cub_add_header_test label definitions)
3030
target_compile_definitions(${headertest_target} PRIVATE ${definitions})
3131
cub_clone_target_properties(${headertest_target} ${cub_target})
3232

33+
if (CUB_IN_THRUST)
34+
thrust_fix_clang_nvcc_build_for(${headertest_target})
35+
endif()
36+
3337
add_dependencies(cub.all.headers ${headertest_target})
3438
add_dependencies(${config_prefix}.all ${headertest_target})
3539
endforeach()

cub/util_type.cuh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@
3939
#include <limits>
4040
#include <type_traits>
4141

42-
#if (__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
42+
#include <cuda.h>
43+
44+
#if !_NVHPC_CUDA
4345
#include <cuda_fp16.h>
4446
#endif
45-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA && \
46-
!defined(CUB_DISABLE_BF16_SUPPORT)
47-
#include <cuda_bf16.h>
47+
#if !_NVHPC_CUDA && !defined(CUB_DISABLE_BF16_SUPPORT)
48+
#include <cuda_bf16.h>
4849
#endif
4950

5051
#include <cub/detail/uninitialized_copy.cuh>
@@ -62,7 +63,7 @@ CUB_NAMESPACE_BEGIN
6263
#define CUB_IS_INT128_ENABLED 1
6364
#endif // !defined(__CUDACC_RTC_INT128__)
6465
#else // !defined(__CUDACC_RTC__)
65-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11050)
66+
#if CUDA_VERSION >= 11050
6667
#if (CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC) || \
6768
(CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG) || \
6869
defined(__ICC) || defined(_NVHPC_CUDA)
@@ -1107,7 +1108,7 @@ struct FpLimits<double>
11071108
}
11081109
};
11091110

1110-
#if (__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
1111+
#if !_NVHPC_CUDA
11111112
template <>
11121113
struct FpLimits<__half>
11131114
{
@@ -1123,8 +1124,7 @@ struct FpLimits<__half>
11231124
};
11241125
#endif
11251126

1126-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA && \
1127-
!defined(CUB_DISABLE_BF16_SUPPORT)
1127+
#if !_NVHPC_CUDA && !defined(CUB_DISABLE_BF16_SUPPORT)
11281128
template <>
11291129
struct FpLimits<__nv_bfloat16>
11301130
{
@@ -1278,11 +1278,10 @@ struct NumericTraits<__int128_t>
12781278

12791279
template <> struct NumericTraits<float> : BaseTraits<FLOATING_POINT, true, false, unsigned int, float> {};
12801280
template <> struct NumericTraits<double> : BaseTraits<FLOATING_POINT, true, false, unsigned long long, double> {};
1281-
#if (__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
1281+
#if !_NVHPC_CUDA
12821282
template <> struct NumericTraits<__half> : BaseTraits<FLOATING_POINT, true, false, unsigned short, __half> {};
12831283
#endif
1284-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA && \
1285-
!defined(CUB_DISABLE_BF16_SUPPORT)
1284+
#if !_NVHPC_CUDA && !defined(CUB_DISABLE_BF16_SUPPORT)
12861285
template <> struct NumericTraits<__nv_bfloat16> : BaseTraits<FLOATING_POINT, true, false, unsigned short, __nv_bfloat16> {};
12871286
#endif
12881287

examples/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ function(cub_add_example target_name_var example_name example_src cub_target)
4242
cub_clone_target_properties(${example_target} ${cub_target})
4343
target_include_directories(${example_target} PRIVATE "${CUB_SOURCE_DIR}/examples")
4444

45+
if (CUB_IN_THRUST)
46+
thrust_fix_clang_nvcc_build_for(${example_target})
47+
endif()
48+
4549
# Add to the active configuration's meta target
4650
add_dependencies(${config_meta_target} ${example_target})
4751

test/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ function(cub_add_test target_name_var test_name test_src cub_target)
163163

164164
cub_clone_target_properties(${config_c2h_target} ${cub_target})
165165
target_link_libraries(${config_c2h_target} PRIVATE CUDA::curand ${cub_target})
166+
167+
if (CUB_IN_THRUST)
168+
thrust_fix_clang_nvcc_build_for(${config_c2h_target})
169+
endif()
166170
endif() # config_c2h_target
167171

168172
if (CUB_SEPARATE_CATCH2)
@@ -191,6 +195,10 @@ function(cub_add_test target_name_var test_name test_src cub_target)
191195
target_link_options(${config_c2run_target} PRIVATE "-cuda")
192196
endif()
193197

198+
if (CUB_IN_THRUST)
199+
thrust_fix_clang_nvcc_build_for(${config_c2run_target})
200+
endif()
201+
194202
add_test(NAME ${config_c2run_target}
195203
COMMAND "$<TARGET_FILE:${config_c2run_target}>"
196204
)
@@ -200,6 +208,10 @@ function(cub_add_test target_name_var test_name test_src cub_target)
200208
target_link_libraries(${config_c2run_target} PRIVATE ${test_target})
201209
endif() # CUB_SEPARATE_CATCH2
202210

211+
if (CUB_IN_THRUST)
212+
thrust_fix_clang_nvcc_build_for(${test_target})
213+
endif()
214+
203215
target_link_libraries(${test_target} PRIVATE
204216
${cub_target}
205217
${config_c2h_target}
@@ -220,6 +232,10 @@ function(cub_add_test target_name_var test_name test_src cub_target)
220232
target_include_directories(${test_target} PRIVATE "${CUB_SOURCE_DIR}/test")
221233
target_compile_definitions(${test_target} PRIVATE CUB_DEBUG_HOST_ASSERTIONS)
222234

235+
if (CUB_IN_THRUST)
236+
thrust_fix_clang_nvcc_build_for(${test_target})
237+
endif()
238+
223239
# Add to the active configuration's meta target
224240
add_dependencies(${config_meta_target} ${test_target})
225241

test/test_device_histogram.cu

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444

4545
#include "test_util.h"
4646

47-
#define TEST_HALF_T \
48-
(__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
47+
#define TEST_HALF_T !_NVHPC_CUDA
4948

5049
#if TEST_HALF_T
5150
#include <cuda_fp16.h>

test/test_device_radix_sort.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
#include <typeinfo>
4444
#include <vector>
4545

46-
#if (__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
46+
#if !_NVHPC_CUDA
4747
#include <cuda_fp16.h>
4848
#endif
4949

50-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA
50+
#if !_NVHPC_CUDA
5151
#include <cuda_bf16.h>
5252
#endif
5353

@@ -984,14 +984,14 @@ struct UnwrapHalfAndBfloat16 {
984984
using Type = T;
985985
};
986986

987-
#if (__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
987+
#if !_NVHPC_CUDA
988988
template <>
989989
struct UnwrapHalfAndBfloat16<half_t> {
990990
using Type = __half;
991991
};
992992
#endif
993993

994-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA
994+
#if !_NVHPC_CUDA
995995
template <>
996996
struct UnwrapHalfAndBfloat16<bfloat16_t> {
997997
using Type = __nv_bfloat16;
@@ -1962,11 +1962,11 @@ int main(int argc, char** argv)
19621962
#ifdef TEST_EXTENDED_KEY_TYPES
19631963
TestGen<short, false> (num_items, num_segments);
19641964

1965-
#if (__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
1965+
#if !_NVHPC_CUDA
19661966
TestGen<half_t, false> (num_items, num_segments);
19671967
#endif // CTK >= 9
19681968

1969-
#if (__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA
1969+
#if !_NVHPC_CUDA
19701970
#if !defined(__ICC)
19711971
// Fails with `-0 != 0` with ICC for unknown reasons. See #333.
19721972
TestGen<bfloat16_t, false> (num_items, num_segments);

test/test_device_reduce.cu

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@
5555
#include "test_util.h"
5656
#include <nv/target>
5757

58-
#define TEST_HALF_T \
59-
(__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
58+
#define TEST_HALF_T !_NVHPC_CUDA
6059

61-
#define TEST_BF_T \
62-
(__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA
60+
#define TEST_BF_T !_NVHPC_CUDA
6361

6462
#if TEST_HALF_T
6563
#include <cuda_fp16.h>

test/test_device_segmented_sort.cu

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@
4545

4646
#include <fstream>
4747

48-
#define TEST_HALF_T \
49-
(__CUDACC_VER_MAJOR__ >= 9 || CUDA_VERSION >= 9000) && !_NVHPC_CUDA
48+
#define TEST_HALF_T !_NVHPC_CUDA
5049

51-
#define TEST_BF_T \
52-
(__CUDACC_VER_MAJOR__ >= 11 || CUDA_VERSION >= 11000) && !_NVHPC_CUDA
50+
#define TEST_BF_T !_NVHPC_CUDA
5351

5452
#if TEST_HALF_T
5553
#include <cuda_fp16.h>

0 commit comments

Comments
 (0)