Skip to content

Commit

Permalink
Move compiler version macros into libcu++ (NVIDIA#2250)
Browse files Browse the repository at this point in the history
* Move compiler version macros into libcu++
* Drop some pre-C++11 code paths around thrust::complex
  • Loading branch information
bernhardmgruber authored and pciolkosz committed Aug 21, 2024
1 parent a8bfe6a commit 1776671
Show file tree
Hide file tree
Showing 66 changed files with 180 additions and 268 deletions.
2 changes: 1 addition & 1 deletion cub/cmake/header_test.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Define CUB_MACRO_CHECK(macro, header), which emits a diagnostic indicating
// a potential macro collision and halts.
//
// Use raw platform checks instead of the CUB_HOST_COMPILER macros since we
// Use raw platform macros instead of the CCCL macros since we
// don't want to #include any headers other than the one being tested.
//
// This is only implemented for MSVC/GCC/Clang.
Expand Down
46 changes: 34 additions & 12 deletions cub/cub/util_compiler.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -44,45 +44,67 @@
#endif // no system header

// enumerate host compilers we know about
//! deprecated [Since 2.7]
#define CUB_HOST_COMPILER_UNKNOWN 0
#define CUB_HOST_COMPILER_MSVC 1
#define CUB_HOST_COMPILER_GCC 2
#define CUB_HOST_COMPILER_CLANG 3
//! deprecated [Since 2.7]
#define CUB_HOST_COMPILER_MSVC 1
//! deprecated [Since 2.7]
#define CUB_HOST_COMPILER_GCC 2
//! deprecated [Since 2.7]
#define CUB_HOST_COMPILER_CLANG 3

// enumerate device compilers we know about
//! deprecated [Since 2.7]
#define CUB_DEVICE_COMPILER_UNKNOWN 0
#define CUB_DEVICE_COMPILER_MSVC 1
#define CUB_DEVICE_COMPILER_GCC 2
#define CUB_DEVICE_COMPILER_NVCC 3
#define CUB_DEVICE_COMPILER_CLANG 4
//! deprecated [Since 2.7]
#define CUB_DEVICE_COMPILER_MSVC 1
//! deprecated [Since 2.7]
#define CUB_DEVICE_COMPILER_GCC 2
//! deprecated [Since 2.7]
#define CUB_DEVICE_COMPILER_NVCC 3
//! deprecated [Since 2.7]
#define CUB_DEVICE_COMPILER_CLANG 4

// figure out which host compiler we're using
#if defined(_CCCL_COMPILER_MSVC)
# define CUB_HOST_COMPILER CUB_HOST_COMPILER_MSVC
# define CUB_MSVC_VERSION _MSC_VER
# define CUB_MSVC_VERSION_FULL _MSC_FULL_VER
//! deprecated [Since 2.7]
# define CUB_HOST_COMPILER CUB_HOST_COMPILER_MSVC
//! deprecated [Since 2.7]
# define CUB_MSVC_VERSION _CCCL_MSVC_VERSION
//! deprecated [Since 2.7]
# define CUB_MSVC_VERSION_FULL _CCCL_MSVC_VERSION_FULL
#elif defined(_CCCL_COMPILER_CLANG)
//! deprecated [Since 2.7]
# define CUB_HOST_COMPILER CUB_HOST_COMPILER_CLANG
# define CUB_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
//! deprecated [Since 2.7]
# define CUB_CLANG_VERSION _CCCL_CLANG_VERSION
#elif defined(_CCCL_COMPILER_GCC)
//! deprecated [Since 2.7]
# define CUB_HOST_COMPILER CUB_HOST_COMPILER_GCC
# define CUB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
//! deprecated [Since 2.7]
# define CUB_GCC_VERSION _CCCL_GCC_VERSION
#endif

// figure out which device compiler we're using
#if defined(_CCCL_CUDA_COMPILER_NVCC) || defined(_CCCL_CUDA_COMPILER_NVHPC)
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_NVCC
#elif defined(_CCCL_COMPILER_MSVC)
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_MSVC
#elif defined(_CCCL_COMPILER_GCC)
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_GCC
#elif defined(_CCCL_COMPILER_CLANG)
// CUDA-capable clang should behave similar to NVCC.
# if defined(_CCCL_CUDA_COMPILER_NVCC)
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_NVCC
# else
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_CLANG
# endif
#else
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_UNKNOWN
#endif
8 changes: 4 additions & 4 deletions cub/cub/util_cpp_dialect.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@
# ifndef CUB_IGNORE_DEPRECATED_COMPILER

// Compiler checks:
# if defined(_CCCL_COMPILER_GCC) && CUB_GCC_VERSION < 50000
# if defined(_CCCL_COMPILER_GCC) && _CCCL_GCC_VERSION < 50000
CUB_COMPILER_DEPRECATION(GCC 5.0);
# elif defined(_CCCL_COMPILER_CLANG) && CUB_CLANG_VERSION < 70000
# elif defined(_CCCL_COMPILER_CLANG) && _CCCL_CLANG_VERSION < 70000
CUB_COMPILER_DEPRECATION(Clang 7.0);
# elif defined(_CCCL_COMPILER_MSVC) && CUB_MSVC_VERSION < 1910
# elif defined(_CCCL_COMPILER_MSVC) && _CCCL_MSVC_VERSION < 1910
// <2017. Hard upgrade message:
CUB_COMPILER_DEPRECATION(MSVC 2019(19.20 / 16.0 / 14.20));
# elif defined(_CCCL_COMPILER_MSVC) && CUB_MSVC_VERSION < 1920
# elif defined(_CCCL_COMPILER_MSVC) && _CCCL_MSVC_VERSION < 1920
// >=2017, <2019. Soft deprecation message:
CUB_COMPILER_DEPRECATION_SOFT(MSVC 2019(19.20 / 16.0 / 14.20), MSVC 2017);
# endif
Expand Down
4 changes: 4 additions & 0 deletions libcudacxx/include/cuda/std/__cccl/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
# define _CCCL_COMPILER_NVHPC
#elif defined(__clang__)
# define _CCCL_COMPILER_CLANG
# define _CCCL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#elif defined(__GNUC__)
# define _CCCL_COMPILER_GCC
# define _CCCL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#elif defined(_MSC_VER)
# define _CCCL_COMPILER_MSVC
# define _CCCL_MSVC_VERSION _MSC_VER
# define _CCCL_MSVC_VERSION_FULL _MSC_FULL_VER
#elif defined(__IBMCPP__)
# define _CCCL_COMPILER_IBM
#elif defined(__CUDACC_RTC__)
Expand Down
18 changes: 7 additions & 11 deletions libcudacxx/include/cuda/std/__variant/monostate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if _CCCL_STD_VER >= 2011

struct _LIBCUDACXX_TEMPLATE_VIS monostate
{};

Expand All @@ -38,23 +36,23 @@ _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(monostate, monostate) no
return true;
}

# if _CCCL_STD_VER < 2020
#if _CCCL_STD_VER < 2020

_LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(monostate, monostate) noexcept
{
return false;
}

# endif // _CCCL_STD_VER < 2020
#endif // _CCCL_STD_VER < 2020

# if _CCCL_STD_VER >= 2020 && !defined(_LIBCUDACXX_HAS_NO_SPACESHIP_OPERATOR)
#if _CCCL_STD_VER >= 2020 && !defined(_LIBCUDACXX_HAS_NO_SPACESHIP_OPERATOR)

_LIBCUDACXX_INLINE_VISIBILITY constexpr strong_ordering operator<=>(monostate, monostate) noexcept
{
return strong_ordering::equal;
}

# else // _CCCL_STD_VER >= 2020
#else // _CCCL_STD_VER >= 2020

_LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<(monostate, monostate) noexcept
{
Expand All @@ -76,9 +74,9 @@ _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>=(monostate, monostate) no
return true;
}

# endif // _CCCL_STD_VER >= 2020
#endif // _CCCL_STD_VER >= 2020

# ifndef __cuda_std__
#ifndef __cuda_std__
template <>
struct _LIBCUDACXX_TEMPLATE_VIS hash<monostate>
{
Expand All @@ -90,9 +88,7 @@ struct _LIBCUDACXX_TEMPLATE_VIS hash<monostate>
return 66740831; // return a fundamentally attractive random value.
}
};
# endif // __cuda_std__

#endif // _CCCL_STD_VER >= 2011
#endif // __cuda_std__

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion thrust/cmake/header_test.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
THRUST_MACRO_CHECK_IMPL(Identifier MACRO should not be used from Thrust \
headers due to conflicts with HEADER macros.)

// Use raw platform checks instead of the THRUST_HOST_COMPILER macros since we
// Use raw platform macros instead of the CCCL macros since we
// don't want to #include any headers other than the one being tested.
//
// This is only implemented for MSVC/GCC/Clang.
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/include/host_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#if THRUST_DEVICE_COMPILER != THRUST_DEVICE_COMPILER_NVCC
#ifndef _CCCL_CUDA_COMPILER

# ifndef __host__
# define __host__
Expand Down
2 changes: 1 addition & 1 deletion thrust/testing/async_sort.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <thrust/detail/config.h>

// Disabled on MSVC && NVCC < 11.1 for GH issue #1098.
#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && defined(__CUDACC__)
#if defined(_CCCL_COMPILER_MSVC) && defined(__CUDACC__)
# if (__CUDACC_VER_MAJOR__ < 11) || (__CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ < 1)
# define THRUST_BUG_1098_ACTIVE
# endif // NVCC version check
Expand Down
Loading

0 comments on commit 1776671

Please sign in to comment.