Skip to content

Commit

Permalink
Deprecate Thrust's cpp_compatibility.h macros
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Jan 9, 2025
1 parent d76eed5 commit 6e8c5fc
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 55 deletions.
2 changes: 1 addition & 1 deletion thrust/thrust/async/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct copy_fn final

} // namespace copy_detail

THRUST_INLINE_CONSTANT copy_detail::copy_fn copy{};
_CCCL_GLOBAL_CONSTANT copy_detail::copy_fn copy{};

/*! \endcond
*/
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/async/for_each.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct for_each_fn final

} // namespace for_each_detail

THRUST_INLINE_CONSTANT for_each_detail::for_each_fn for_each{};
_CCCL_GLOBAL_CONSTANT for_each_detail::for_each_fn for_each{};

/*! \endcond
*/
Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/async/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct reduce_fn final

} // namespace reduce_detail

THRUST_INLINE_CONSTANT reduce_detail::reduce_fn reduce{};
_CCCL_GLOBAL_CONSTANT reduce_detail::reduce_fn reduce{};

///////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -296,7 +296,7 @@ struct reduce_into_fn final

} // namespace reduce_into_detail

THRUST_INLINE_CONSTANT reduce_into_detail::reduce_into_fn reduce_into{};
_CCCL_GLOBAL_CONSTANT reduce_into_detail::reduce_into_fn reduce_into{};

/*! \endcond
*/
Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/async/scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ struct inclusive_scan_fn final

} // namespace inclusive_scan_detail

THRUST_INLINE_CONSTANT inclusive_scan_detail::inclusive_scan_fn inclusive_scan{};
_CCCL_GLOBAL_CONSTANT inclusive_scan_detail::inclusive_scan_fn inclusive_scan{};

namespace exclusive_scan_detail
{
Expand Down Expand Up @@ -288,7 +288,7 @@ struct exclusive_scan_fn final

} // namespace exclusive_scan_detail

THRUST_INLINE_CONSTANT exclusive_scan_detail::exclusive_scan_fn exclusive_scan{};
_CCCL_GLOBAL_CONSTANT exclusive_scan_detail::exclusive_scan_fn exclusive_scan{};

} // namespace async

Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/async/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ struct stable_sort_fn final

} // namespace stable_sort_detail

THRUST_INLINE_CONSTANT stable_sort_detail::stable_sort_fn stable_sort{};
_CCCL_GLOBAL_CONSTANT stable_sort_detail::stable_sort_fn stable_sort{};

namespace fallback
{
Expand Down Expand Up @@ -259,7 +259,7 @@ struct sort_fn final

} // namespace sort_detail

THRUST_INLINE_CONSTANT sort_detail::sort_fn sort{};
_CCCL_GLOBAL_CONSTANT sort_detail::sort_fn sort{};

/*! \endcond
*/
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/async/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct transform_fn final

} // namespace transform_detail

THRUST_INLINE_CONSTANT transform_detail::transform_fn transform{};
_CCCL_GLOBAL_CONSTANT transform_detail::transform_fn transform{};

/*! \endcond
*/
Expand Down
32 changes: 6 additions & 26 deletions thrust/thrust/detail/config/cpp_compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

// Internal config header that is only included through thrust/detail/config/config.h
#include <cuda/__cccl_config>

#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
Expand All @@ -26,29 +26,9 @@
# pragma system_header
#endif // no system header

#include <thrust/detail/config/cpp_dialect.h> // IWYU pragma: export

#include <cuda/std/cstddef>

// deprecated [Since 2.8.0]
#define THRUST_NODISCARD _CCCL_NODISCARD

// FIXME: Combine THRUST_INLINE_CONSTANT and
// THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT into one macro when NVCC properly
// supports `constexpr` globals in host and device code.
#if defined(__CUDA_ARCH__) || defined(_NVHPC_CUDA)
// FIXME: Add this when NVCC supports inline variables.
// # if _CCCL_STD_VER >= 2017
// # define THRUST_INLINE_CONSTANT inline constexpr
// # define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr
# define THRUST_INLINE_CONSTANT static const _CCCL_DEVICE
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr

#else
// FIXME: Add this when NVCC supports inline variables.
// # if _CCCL_STD_VER >= 2017
// # define THRUST_INLINE_CONSTANT inline constexpr
// # define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr
# define THRUST_INLINE_CONSTANT static constexpr
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr

#endif
// deprecated [Since 2.8.0]
#define THRUST_INLINE_CONSTANT _CCCL_GLOBAL_CONSTANT
// deprecated [Since 2.8.0]
#define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
2 changes: 1 addition & 1 deletion thrust/thrust/detail/select_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct select_system_fn final

} // namespace select_system_detail

THRUST_INLINE_CONSTANT select_system_detail::select_system_fn select_system{};
_CCCL_GLOBAL_CONSTANT select_system_detail::select_system_fn select_system{};

} // namespace detail

Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/detail/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ struct seq_t

} // namespace detail

THRUST_INLINE_CONSTANT detail::seq_t seq;
_CCCL_GLOBAL_CONSTANT detail::seq_t seq;

THRUST_NAMESPACE_END
2 changes: 1 addition & 1 deletion thrust/thrust/detail/static_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace detail
template <typename, bool x>
struct depend_on_instantiation
{
THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT bool value = x;
static constexpr bool value = x;
};

#if _CCCL_STD_VER >= 2017
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/execution_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static const detail::host_t host;
* \see host_execution_policy
* \see thrust::device
*/
THRUST_INLINE_CONSTANT detail::device_t device;
_CCCL_GLOBAL_CONSTANT detail::device_t device;

// define seq for the purpose of Doxygenating it
// it is actually defined elsewhere
Expand Down
20 changes: 10 additions & 10 deletions thrust/thrust/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,43 +1046,43 @@ namespace placeholders

/*! \p thrust::placeholders::_1 is the placeholder for the first function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<0>::type _1;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<0>::type _1;

/*! \p thrust::placeholders::_2 is the placeholder for the second function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<1>::type _2;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<1>::type _2;

/*! \p thrust::placeholders::_3 is the placeholder for the third function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<2>::type _3;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<2>::type _3;

/*! \p thrust::placeholders::_4 is the placeholder for the fourth function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<3>::type _4;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<3>::type _4;

/*! \p thrust::placeholders::_5 is the placeholder for the fifth function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<4>::type _5;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<4>::type _5;

/*! \p thrust::placeholders::_6 is the placeholder for the sixth function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<5>::type _6;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<5>::type _6;

/*! \p thrust::placeholders::_7 is the placeholder for the seventh function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<6>::type _7;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<6>::type _7;

/*! \p thrust::placeholders::_8 is the placeholder for the eighth function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<7>::type _8;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<7>::type _8;

/*! \p thrust::placeholders::_9 is the placeholder for the ninth function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<8>::type _9;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<8>::type _9;

/*! \p thrust::placeholders::_10 is the placeholder for the tenth function parameter.
*/
THRUST_INLINE_CONSTANT thrust::detail::functional::placeholder<9>::type _10;
_CCCL_GLOBAL_CONSTANT thrust::detail::functional::placeholder<9>::type _10;

} // namespace placeholders

Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/future.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ using device_future = device_unique_eager_future<T>;
struct new_stream_t final
{};

THRUST_INLINE_CONSTANT new_stream_t new_stream{};
_CCCL_GLOBAL_CONSTANT new_stream_t new_stream{};

///////////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/system/cpp/detail/par.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct par_t

} // namespace detail

THRUST_INLINE_CONSTANT detail::par_t par;
_CCCL_GLOBAL_CONSTANT detail::par_t par;

} // namespace cpp
} // namespace system
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/system/cuda/detail/future.inl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace detail
struct nonowning_t final
{};

THRUST_INLINE_CONSTANT nonowning_t nonowning{};
_CCCL_GLOBAL_CONSTANT nonowning_t nonowning{};

///////////////////////////////////////////////////////////////////////////////

Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/system/cuda/detail/par.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct par_nosync_t
}
};

THRUST_INLINE_CONSTANT par_t par;
_CCCL_GLOBAL_CONSTANT par_t par;

/*! \p thrust::cuda::par_nosync is a parallel execution policy targeting Thrust's CUDA device backend.
* Similar to \p thrust::cuda::par it allows execution of Thrust algorithms in a specific CUDA stream.
Expand Down Expand Up @@ -215,7 +215,7 @@ THRUST_INLINE_CONSTANT par_t par;
* \endcode
*
*/
THRUST_INLINE_CONSTANT par_nosync_t par_nosync;
_CCCL_GLOBAL_CONSTANT par_nosync_t par_nosync;
} // namespace cuda_cub

namespace system
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/system/detail/sequential/execution_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct execution_policy : thrust::execution_policy<Derived>
}
};

THRUST_INLINE_CONSTANT tag seq;
_CCCL_GLOBAL_CONSTANT tag seq;

} // namespace sequential
} // namespace detail
Expand Down

0 comments on commit 6e8c5fc

Please sign in to comment.