Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some cleanup in Thrust config headers #1934

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/repo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ doxygen_predefined = [
"THRUST_NAMESPACE_END=}",
"THRUST_INLINE_CONSTANT",
"THRUST_PREVENT_MACRO_SUBSTITUTION",
"THRUST_TRAILING_RETURN(x)= -> x",
"THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION_OP(x,y)=",
"THRUST_UNARY_FUNCTOR_VOID_SPECIALIZATION(x, y)=",
"THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION(x, y)=",
Expand Down
1 change: 0 additions & 1 deletion thrust/thrust/detail/config/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#define THRUST_DEVICE_COMPILER_NVCC 4

// figure out which host compiler we're using
// XXX we should move the definition of THRUST_DEPRECATED out of this logic
#if defined(_CCCL_COMPILER_MSVC)
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_MSVC
# define THRUST_MSVC_VERSION _MSC_VER
Expand Down
14 changes: 6 additions & 8 deletions thrust/thrust/detail/config/compiler_fence.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@

#include <thrust/detail/preprocessor.h>

// TODO: Enable this or remove this file once nvGRAPH/CUSP migrates off of it.
// #if defined(_CCCL_COMPILER_MSVC)
// #pragma message("warning: The functionality in this header is unsafe, deprecated, and will soon be removed. Use
// C++11 or C11 atomics instead.")
// #else
// #warning The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 or C11 atomics
// instead.
// #endif
#if defined(_CCCL_COMPILER_MSVC)
# pragma message( \
"warning: The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 atomics instead.")
#else
#warning The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 or C11 atomics instead.
#endif

// msvc case
#if defined(_CCCL_COMPILER_MSVC)
Expand Down
4 changes: 1 addition & 3 deletions thrust/thrust/detail/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@
#include <thrust/detail/config/cpp_dialect.h>
#include <thrust/detail/config/deprecated.h>
#include <thrust/detail/config/simple_defines.h>
// host_system.h & device_system.h must be #included as early as possible
// because other config headers depend on it
// host_system.h & device_system.h must be #included as early as possible because other config headers depend on it
#include <thrust/detail/config/host_system.h>

#include <thrust/detail/config/debug.h>
#include <thrust/detail/config/device_system.h>
#include <thrust/detail/config/global_workarounds.h>
#include <thrust/detail/config/namespace.h>
8 changes: 0 additions & 8 deletions thrust/thrust/detail/config/cpp_compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
# define __has_cpp_attribute(X) 0
#endif

// Trailing return types seem to confuse Doxygen, and cause it to interpret
// parts of the function's body as new function signatures.
#if defined(THRUST_DOXYGEN)
# define THRUST_TRAILING_RETURN(...)
#else
# define THRUST_TRAILING_RETURN(...) ->__VA_ARGS__
#endif

#define THRUST_NODISCARD _CCCL_NODISCARD

// FIXME: Combine THRUST_INLINE_CONSTANT and
Expand Down
41 changes: 0 additions & 41 deletions thrust/thrust/detail/config/debug.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct unary_plus
_CCCL_EXEC_CHECK_DISABLE
template <typename T1>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1) const noexcept(noexcept(+THRUST_FWD(t1)))
THRUST_TRAILING_RETURN(decltype(+THRUST_FWD(t1)))
-> decltype(+THRUST_FWD(t1))
{
return +THRUST_FWD(t1);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ struct prefix_increment
_CCCL_EXEC_CHECK_DISABLE
template <typename T1>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1) const noexcept(noexcept(++THRUST_FWD(t1)))
THRUST_TRAILING_RETURN(decltype(++THRUST_FWD(t1)))
-> decltype(++THRUST_FWD(t1))
{
return ++THRUST_FWD(t1);
}
Expand All @@ -203,7 +203,7 @@ struct postfix_increment
_CCCL_EXEC_CHECK_DISABLE
template <typename T1>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1) const noexcept(noexcept(THRUST_FWD(t1)++))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1)++))
-> decltype(THRUST_FWD(t1)++)
{
return THRUST_FWD(t1)++;
}
Expand All @@ -224,7 +224,7 @@ struct prefix_decrement
_CCCL_EXEC_CHECK_DISABLE
template <typename T1>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1) const noexcept(noexcept(--THRUST_FWD(t1)))
THRUST_TRAILING_RETURN(decltype(--THRUST_FWD(t1)))
-> decltype(--THRUST_FWD(t1))
{
return --THRUST_FWD(t1);
}
Expand All @@ -245,7 +245,7 @@ struct postfix_decrement
_CCCL_EXEC_CHECK_DISABLE
template <typename T1>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1) const noexcept(noexcept(THRUST_FWD(t1)--))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1)--))
-> decltype(THRUST_FWD(t1)--)
{
return THRUST_FWD(t1)--;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ struct assign
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) = THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) = THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) = THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) = THRUST_FWD(t2))
{
return THRUST_FWD(t1) = THRUST_FWD(t2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct bit_not
_CCCL_EXEC_CHECK_DISABLE
template <typename T1>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1) const noexcept(noexcept(~THRUST_FWD(t1)))
THRUST_TRAILING_RETURN(decltype(~THRUST_FWD(t1)))
-> decltype(~THRUST_FWD(t1))
{
return ~THRUST_FWD(t1);
}
Expand All @@ -128,8 +128,7 @@ struct bit_lshift
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) << THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) << THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) << THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) << THRUST_FWD(t2))
{
return THRUST_FWD(t1) << THRUST_FWD(t2);
}
Expand Down Expand Up @@ -164,8 +163,7 @@ struct bit_rshift
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) >> THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) >> THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) >> THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) >> THRUST_FWD(t2))
{
return THRUST_FWD(t1) >> THRUST_FWD(t2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ struct plus_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) += THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) += THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) += THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) += THRUST_FWD(t2))
{
return THRUST_FWD(t1) += THRUST_FWD(t2);
}
Expand Down Expand Up @@ -72,8 +71,7 @@ struct minus_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) -= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) -= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) -= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) -= THRUST_FWD(t2))
{
return THRUST_FWD(t1) -= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -101,8 +99,7 @@ struct multiplies_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) *= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) *= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) *= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) *= THRUST_FWD(t2))
{
return THRUST_FWD(t1) *= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -130,8 +127,7 @@ struct divides_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) /= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) /= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) /= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) /= THRUST_FWD(t2))
{
return THRUST_FWD(t1) /= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -159,8 +155,7 @@ struct modulus_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) %= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) %= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) %= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) %= THRUST_FWD(t2))
{
return THRUST_FWD(t1) %= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -188,8 +183,7 @@ struct bit_and_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) &= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) &= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) &= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) &= THRUST_FWD(t2))
{
return THRUST_FWD(t1) &= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -217,8 +211,7 @@ struct bit_or_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) |= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) |= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) |= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) |= THRUST_FWD(t2))
{
return THRUST_FWD(t1) |= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -246,8 +239,7 @@ struct bit_xor_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) ^= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) ^= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) ^= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) ^= THRUST_FWD(t2))
{
return THRUST_FWD(t1) ^= THRUST_FWD(t2);
}
Expand Down Expand Up @@ -275,8 +267,7 @@ struct bit_lshift_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) <<= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) <<= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) <<= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) <<= THRUST_FWD(t2))
{
return THRUST_FWD(t1) <<= THRUST_FWD(t2);
}
Expand All @@ -303,8 +294,7 @@ struct bit_rshift_equal
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const
noexcept(noexcept(THRUST_FWD(t1) >>= THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) >>= THRUST_FWD(t2)))
noexcept(noexcept(THRUST_FWD(t1) >>= THRUST_FWD(t2))) -> decltype(THRUST_FWD(t1) >>= THRUST_FWD(t2))
{
return THRUST_FWD(t1) >>= THRUST_FWD(t2);
}
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/device_make_unique.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ THRUST_NAMESPACE_BEGIN

template <typename T, typename... Args>
_CCCL_HOST auto device_make_unique(Args&&... args)
THRUST_TRAILING_RETURN(decltype(uninitialized_allocate_unique<T>(::cuda::std::declval<device_allocator<T>>())))
-> decltype(uninitialized_allocate_unique<T>(::cuda::std::declval<device_allocator<T>>()))
{
// FIXME: This is crude - we construct an unnecessary T on the host for
// `device_new`. We need a proper dispatched `construct` algorithm to
Expand Down
50 changes: 24 additions & 26 deletions thrust/thrust/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,30 @@ struct binary_function
* \{
*/

#define THRUST_UNARY_FUNCTOR_VOID_SPECIALIZATION(func, impl) \
template <> \
struct func<void> \
{ \
using is_transparent = void; \
_CCCL_EXEC_CHECK_DISABLE \
template <typename T> \
_CCCL_HOST_DEVICE constexpr auto operator()(T&& x) const noexcept(noexcept(impl)) \
THRUST_TRAILING_RETURN(decltype(impl)) \
{ \
return impl; \
} \
#define THRUST_UNARY_FUNCTOR_VOID_SPECIALIZATION(func, impl) \
template <> \
struct func<void> \
{ \
using is_transparent = void; \
_CCCL_EXEC_CHECK_DISABLE \
template <typename T> \
_CCCL_HOST_DEVICE constexpr auto operator()(T&& x) const noexcept(noexcept(impl)) -> decltype(impl) \
{ \
return impl; \
} \
}

#define THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION(func, impl) \
template <> \
struct func<void> \
{ \
using is_transparent = void; \
_CCCL_EXEC_CHECK_DISABLE \
template <typename T1, typename T2> \
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const noexcept(noexcept(impl)) \
THRUST_TRAILING_RETURN(decltype(impl)) \
{ \
return impl; \
} \
#define THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION(func, impl) \
template <> \
struct func<void> \
{ \
using is_transparent = void; \
_CCCL_EXEC_CHECK_DISABLE \
template <typename T1, typename T2> \
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&& t2) const noexcept(noexcept(impl)) -> decltype(impl) \
{ \
return impl; \
} \
}

#define THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION_OP(func, op) \
Expand Down Expand Up @@ -1400,7 +1398,7 @@ struct project1st<void, void>
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&& t1, T2&&) const noexcept(noexcept(THRUST_FWD(t1)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1)))
-> decltype(THRUST_FWD(t1))
{
return THRUST_FWD(t1);
}
Expand Down Expand Up @@ -1457,7 +1455,7 @@ struct project2nd<void, void>
_CCCL_EXEC_CHECK_DISABLE
template <typename T1, typename T2>
_CCCL_HOST_DEVICE constexpr auto operator()(T1&&, T2&& t2) const noexcept(noexcept(THRUST_FWD(t2)))
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t2)))
-> decltype(THRUST_FWD(t2))
{
return THRUST_FWD(t2);
}
Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ template <
int = 0>
_CCCL_HOST_DEVICE constexpr auto
invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::mem_fn(f)(std::forward<Args>(args)...)))
THRUST_TRAILING_RETURN(decltype(std::mem_fn(f)(std::forward<Args>(args)...)))
-> decltype(std::mem_fn(f)(std::forward<Args>(args)...))
{
return std::mem_fn(f)(std::forward<Args>(args)...);
}
Expand All @@ -163,7 +163,7 @@ _CCCL_EXEC_CHECK_DISABLE
template <typename Fn, typename... Args, typename = enable_if_t<!std::is_member_pointer<decay_t<Fn>>::value>>
_CCCL_HOST_DEVICE constexpr auto
invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::forward<Fn>(f)(std::forward<Args>(args)...)))
THRUST_TRAILING_RETURN(decltype(std::forward<Fn>(f)(std::forward<Args>(args)...)))
-> decltype(std::forward<Fn>(f)(std::forward<Args>(args)...))
{
return std::forward<Fn>(f)(std::forward<Args>(args)...);
}
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/zip_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class zip_function
template <typename Tuple>
_CCCL_HOST_DEVICE auto operator()(Tuple&& args) const
noexcept(noexcept(detail::zip_detail::apply(std::declval<Function>(), THRUST_FWD(args))))
THRUST_TRAILING_RETURN(decltype(detail::zip_detail::apply(std::declval<Function>(), THRUST_FWD(args))))
-> decltype(detail::zip_detail::apply(std::declval<Function>(), THRUST_FWD(args)))
{
return detail::zip_detail::apply(func, THRUST_FWD(args));
}
Expand Down
Loading