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

Deprecate thrust::numeric_limits #3366

Merged
merged 1 commit into from
Jan 15, 2025
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
15 changes: 12 additions & 3 deletions thrust/testing/unittest/testframework.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
#include <thrust/mr/host_memory_resource.h>
#include <thrust/mr/universal_memory_resource.h>

#include <cuda/std/limits>

#include <cstdio>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <string>
Expand Down Expand Up @@ -199,22 +202,28 @@ class custom_numeric
}
};

THRUST_NAMESPACE_BEGIN
namespace std
{
template <>
struct numeric_limits<custom_numeric> : numeric_limits<int>
{};
} // namespace std

_LIBCUDACXX_BEGIN_NAMESPACE_STD
template <>
struct numeric_limits<custom_numeric> : numeric_limits<int>
{};
_LIBCUDACXX_END_NAMESPACE_STD

THRUST_NAMESPACE_BEGIN
namespace detail
{

// For random number generation
template <>
class integer_traits<custom_numeric> : public integer_traits_base<int, INT_MIN, INT_MAX>
{};

} // namespace detail

THRUST_NAMESPACE_END

using NumericTypes = unittest::type_list<
Expand Down
4 changes: 2 additions & 2 deletions thrust/testing/unittest/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ typename THRUST_NS_QUALIFIER::detail::disable_if<::cuda::std::is_floating_point<
truncate_to_max_representable(std::size_t n)
{
return static_cast<T>(
THRUST_NS_QUALIFIER::min<std::size_t>(n, static_cast<std::size_t>(THRUST_NS_QUALIFIER::numeric_limits<T>::max())));
THRUST_NS_QUALIFIER::min<std::size_t>(n, static_cast<std::size_t>(::cuda::std::numeric_limits<T>::max())));
}

// TODO: This probably won't work for `half`.
template <typename T>
typename ::cuda::std::enable_if_t<::cuda::std::is_floating_point<T>::value, T>
truncate_to_max_representable(std::size_t n)
{
return THRUST_NS_QUALIFIER::min<T>(static_cast<T>(n), THRUST_NS_QUALIFIER::numeric_limits<T>::max());
return THRUST_NS_QUALIFIER::min<T>(static_cast<T>(n), ::cuda::std::numeric_limits<T>::max());
}

} // namespace unittest
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
THRUST_NAMESPACE_BEGIN

template <typename T>
struct numeric_limits : std::numeric_limits<T>
struct CCCL_DEPRECATED_BECAUSE("Use cuda::std::numeric_limits") numeric_limits : std::numeric_limits<T>
{};

THRUST_NAMESPACE_END
Loading