Skip to content

Commit

Permalink
Deprecate and reduce use of old functional stuff
Browse files Browse the repository at this point in the history
Add:
* not_fn

Deprecate:
* unary_function
* binary_function
* unary_negate
* binary_negate
* not1
* not2
* unary_traits
* binary_traits

Remove:
* detail::unary_negate
* detail::binary_negate
* detail::not1
* detail::not2
* detail::equal_to
  • Loading branch information
bernhardmgruber committed Jul 1, 2024
1 parent 91b78d8 commit fcc4cb6
Show file tree
Hide file tree
Showing 48 changed files with 172 additions and 166 deletions.
4 changes: 2 additions & 2 deletions cub/test/catch2_large_array_sort_helper.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace detail
{

template <typename KeyType>
class key_sort_ref_key_transform : public thrust::unary_function<std::size_t, KeyType>
class key_sort_ref_key_transform
{
static constexpr double max_key = static_cast<double>(::cuda::std::numeric_limits<KeyType>::max());
const double m_conversion;
Expand Down Expand Up @@ -120,7 +120,7 @@ struct index_to_summary
};

template <typename KeyType>
class pair_sort_ref_key_transform : public thrust::unary_function<std::size_t, KeyType>
class pair_sort_ref_key_transform
{
static constexpr KeyType max_key = ::cuda::std::numeric_limits<KeyType>::max();

Expand Down
2 changes: 2 additions & 0 deletions docs/repo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ doxygen_predefined = [
"THRUST_UNARY_FUNCTOR_VOID_SPECIALIZATION(x, y)=",
"THRUST_BINARY_FUNCTOR_VOID_SPECIALIZATION(x, y)=",
"THRUST_FWD(x)=x",
"THRUST_DEPRECATED_BECAUSE(x)=",
"THRUST_DEPRECATED="
]

# make sure to use ./fetch_imgs.sh
Expand Down
3 changes: 3 additions & 0 deletions libcudacxx/include/cuda/std/__functional/binary_negate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# pragma system_header
#endif // no system header

#include <cuda/std/__cccl/diagnostic.h>
#include <cuda/std/__functional/binary_function.h>

_LIBCUDACXX_BEGIN_NAMESPACE_STD
Expand All @@ -46,12 +47,14 @@ class _LIBCUDACXX_TEMPLATE_VIS _LIBCUDACXX_DEPRECATED_IN_CXX17 binary_negate
}
};

_CCCL_SUPPRESS_DEPRECATED_PUSH
template <class _Predicate>
_LIBCUDACXX_DEPRECATED_IN_CXX17 inline _CCCL_CONSTEXPR_CXX14 _LIBCUDACXX_INLINE_VISIBILITY binary_negate<_Predicate>
not2(const _Predicate& __pred)
{
return binary_negate<_Predicate>(__pred);
}
_CCCL_SUPPRESS_DEPRECATED_POP

#endif // _CCCL_STD_VER <= 2017 || defined(_LIBCUDACXX_ENABLE_CXX20_REMOVED_NEGATORS)

Expand Down
3 changes: 3 additions & 0 deletions libcudacxx/include/cuda/std/__functional/unary_negate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# pragma system_header
#endif // no system header

#include <cuda/std/__cccl/diagnostic.h>
#include <cuda/std/__functional/unary_function.h>

_LIBCUDACXX_BEGIN_NAMESPACE_STD
Expand All @@ -47,12 +48,14 @@ class _LIBCUDACXX_TEMPLATE_VIS _LIBCUDACXX_DEPRECATED_IN_CXX17 unary_negate
}
};

_CCCL_SUPPRESS_DEPRECATED_PUSH
template <class _Predicate>
_LIBCUDACXX_DEPRECATED_IN_CXX17 inline _CCCL_CONSTEXPR_CXX14 _LIBCUDACXX_INLINE_VISIBILITY unary_negate<_Predicate>
not1(const _Predicate& __pred)
{
return unary_negate<_Predicate>(__pred);
}
_CCCL_SUPPRESS_DEPRECATED_POP

_CCCL_SUPPRESS_DEPRECATED_POP

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/bounding_box.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct bbox
};

// reduce a pair of bounding boxes (a,b) to a bounding box containing a and b
struct bbox_reduction : public thrust::binary_function<bbox, bbox, bbox>
struct bbox_reduction
{
__host__ __device__ bbox operator()(bbox a, bbox b)
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/bucket_sort2d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vec2 make_random_vec2()

// hash a point in the unit square to the index of
// the grid bucket that contains it
struct point_to_bucket_index : public thrust::unary_function<vec2, unsigned int>
struct point_to_bucket_index
{
unsigned int width; // buckets in the x dimension (grid spacing = 1/width)
unsigned int height; // buckets in the y dimension (grid spacing = 1/height)
Expand Down
4 changes: 2 additions & 2 deletions thrust/examples/cuda/range_view.cu
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ range_view<typename Vector::iterator> __host__ make_range_view(Vector& v)
// This saxpy functor stores view of X, Y, Z array, and accesses them in
// vector-like way
template <class View1, class View2, class View3>
struct saxpy_functor : public thrust::unary_function<int, void>
struct saxpy_functor
{
const float a;
View1 x;
Expand Down Expand Up @@ -165,7 +165,7 @@ __host__ __device__ void saxpy(float A, View1 X, View2 Y, View3 Z)
saxpy_functor<View1, View2, View3>(A, X, Y, Z));
}

struct f1 : public thrust::unary_function<float, float>
struct f1
{
__host__ __device__ float operator()(float x) const
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/dot_products_with_zip.cu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using Float3 = thrust::tuple<float, float, float>;

// This functor implements the dot product between 3d vectors
struct DotProduct : public thrust::binary_function<Float3, Float3, float>
struct DotProduct
{
__host__ __device__ float operator()(const Float3& a, const Float3& b) const
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/lambda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using namespace thrust::placeholders;

// implementing SAXPY with a functor is cumbersome and verbose
struct saxpy_functor : public thrust::binary_function<float, float, float>
struct saxpy_functor
{
float a;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/max_abs_diff.cu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// between the elements of two vectors

template <typename T>
struct abs_diff : public thrust::binary_function<T, T, T>
struct abs_diff
{
__host__ __device__ T operator()(const T& a, const T& b)
{
Expand Down
4 changes: 2 additions & 2 deletions thrust/examples/minmax.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct minmax_pair
// returns a minmax_pair whose minimum and maximum values
// are initialized to x.
template <typename T>
struct minmax_unary_op : public thrust::unary_function<T, minmax_pair<T>>
struct minmax_unary_op
{
__host__ __device__ minmax_pair<T> operator()(const T& x) const
{
Expand All @@ -38,7 +38,7 @@ struct minmax_unary_op : public thrust::unary_function<T, minmax_pair<T>>
// maximum values are the min() and max() respectively of
// the minimums and maximums of the input pairs
template <typename T>
struct minmax_binary_op : public thrust::binary_function<minmax_pair<T>, minmax_pair<T>, minmax_pair<T>>
struct minmax_binary_op
{
__host__ __device__ minmax_pair<T> operator()(const minmax_pair<T>& x, const minmax_pair<T>& y) const
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/monte_carlo.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ __host__ __device__ unsigned int hash(unsigned int a)
return a;
}

struct estimate_pi : public thrust::unary_function<unsigned int, float>
struct estimate_pi
{
__host__ __device__ float operator()(unsigned int thread_id)
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/monte_carlo_disjoint_sequences.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// past n states of the RNG. This function is accelerated and executes
// in O(lg n) time.

struct estimate_pi : public thrust::unary_function<unsigned int, float>
struct estimate_pi
{
__host__ __device__ float operator()(unsigned int thread_id)
{
Expand Down
4 changes: 0 additions & 4 deletions thrust/examples/padded_grid_reduction.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// values in the padded region of the grid
template <typename IndexType, typename ValueType>
struct transform_tuple
: public thrust::unary_function<thrust::tuple<IndexType, ValueType>, thrust::tuple<bool, ValueType, ValueType>>
{
using InputTuple = typename thrust::tuple<IndexType, ValueType>;
using OutputTuple = typename thrust::tuple<bool, ValueType, ValueType>;
Expand All @@ -45,9 +44,6 @@ struct transform_tuple
// contains the smallest and largest *valid* values.
template <typename IndexType, typename ValueType>
struct reduce_tuple
: public thrust::binary_function<thrust::tuple<bool, ValueType, ValueType>,
thrust::tuple<bool, ValueType, ValueType>,
thrust::tuple<bool, ValueType, ValueType>>
{
using Tuple = typename thrust::tuple<bool, ValueType, ValueType>;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/repeated_range.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class repeated_range
public:
using difference_type = typename thrust::iterator_difference<Iterator>::type;

struct repeat_functor : public thrust::unary_function<difference_type, difference_type>
struct repeat_functor
{
difference_type repeats;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/saxpy.cu
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// implements the operation with a single transformation
// and represents "best practice".

struct saxpy_functor : public thrust::binary_function<float, float, float>
struct saxpy_functor
{
const float a;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/scan_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// BinaryPredicate for the head flag segment representation
// equivalent to thrust::not2(thrust::project2nd<int,int>()));
template <typename HeadFlagType>
struct head_flag_predicate : public thrust::binary_function<HeadFlagType, HeadFlagType, bool>
struct head_flag_predicate
{
__host__ __device__ bool operator()(HeadFlagType, HeadFlagType right) const
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/scan_matrix_by_rows.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __host__ void scan_matrix_by_rows0(thrust::device_vector<int>& u, int n, int m)
// So first, we define an unary function object which takes the index of an
// element and returns the row that it belongs to.

struct which_row : thrust::unary_function<int, int>
struct which_row
{
int row_length;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/simple_moving_average.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// compute the difference of two positions in the cumumulative sum and
// divide by the SMA window size w.
template <typename T>
struct minus_and_divide : public thrust::binary_function<T, T, T>
struct minus_and_divide
{
T w;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/stream_compaction.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// this functor returns true if the argument is odd, and false otherwise
template <typename T>
struct is_odd : public thrust::unary_function<T, bool>
struct is_odd
{
__host__ __device__ bool operator()(T x)
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/strided_range.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class strided_range
public:
using difference_type = typename thrust::iterator_difference<Iterator>::type;

struct stride_functor : public thrust::unary_function<difference_type, difference_type>
struct stride_functor
{
difference_type stride;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/sum_rows.cu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// convert a linear index to a row index
template <typename T>
struct linear_index_to_row_index : public thrust::unary_function<T, T>
struct linear_index_to_row_index
{
T C; // number of columns

Expand Down
1 change: 0 additions & 1 deletion thrust/examples/summary_statistics.cu
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ struct summary_stats_unary_op
// all values that have been agregated so far
template <typename T>
struct summary_stats_binary_op
: public thrust::binary_function<const summary_stats_data<T>&, const summary_stats_data<T>&, summary_stats_data<T>>
{
__host__ __device__ summary_stats_data<T>
operator()(const summary_stats_data<T>& x, const summary_stats_data<T>& y) const
Expand Down
4 changes: 2 additions & 2 deletions thrust/examples/summed_area_table.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// http://en.wikipedia.org/wiki/Summed_area_table

// convert a linear index to a linear index in the transpose
struct transpose_index : public thrust::unary_function<size_t, size_t>
struct transpose_index
{
size_t m, n;

Expand All @@ -34,7 +34,7 @@ struct transpose_index : public thrust::unary_function<size_t, size_t>
};

// convert a linear index to a row index
struct row_index : public thrust::unary_function<size_t, size_t>
struct row_index
{
size_t n;

Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/tiled_range.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class tiled_range
public:
using difference_type = typename thrust::iterator_difference<Iterator>::type;

struct tile_functor : public thrust::unary_function<difference_type, difference_type>
struct tile_functor
{
difference_type tile_size;

Expand Down
4 changes: 2 additions & 2 deletions thrust/examples/transform_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// this functor clamps a value to the range [lo, hi]
template <typename T>
struct clamp : public thrust::unary_function<T, T>
struct clamp
{
T lo, hi;

Expand All @@ -39,7 +39,7 @@ struct clamp : public thrust::unary_function<T, T>
};

template <typename T>
struct simple_negate : public thrust::unary_function<T, T>
struct simple_negate
{
__host__ __device__ T operator()(T x)
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/examples/word_count.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __host__ __device__ bool is_alpha(const char c)
}

// determines whether the right character begins a new word
struct is_word_start : public thrust::binary_function<const char&, const char&, bool>
struct is_word_start
{
__host__ __device__ bool operator()(const char& left, const char& right) const
{
Expand Down
4 changes: 2 additions & 2 deletions thrust/testing/cuda/reduce_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void TestReduceByKeyCudaStreamsNoSync()
DECLARE_UNITTEST(TestReduceByKeyCudaStreamsNoSync);

// Maps indices to key ids
class div_op : public thrust::unary_function<std::int64_t, std::int64_t>
class div_op
{
std::int64_t m_divisor;

Expand All @@ -363,7 +363,7 @@ public:
};

// Produces unique sequence for key
class mod_op : public thrust::unary_function<std::int64_t, std::int64_t>
class mod_op
{
std::int64_t m_divisor;

Expand Down
4 changes: 2 additions & 2 deletions thrust/testing/cuda/remove.cu
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ __global__ void remove_copy_if_kernel(
#endif

template <typename T>
struct is_even : thrust::unary_function<T, bool>
struct is_even
{
_CCCL_HOST_DEVICE bool operator()(T x)
{
Expand All @@ -66,7 +66,7 @@ struct is_even : thrust::unary_function<T, bool>
};

template <typename T>
struct is_true : thrust::unary_function<T, bool>
struct is_true
{
_CCCL_HOST_DEVICE bool operator()(T x)
{
Expand Down
2 changes: 1 addition & 1 deletion thrust/testing/cuda/transform.cu
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void TestTransformIfBinaryDevice(ExecutionPolicy exec)
stencil.begin(),
output.begin(),
thrust::minus<T>(),
thrust::not1(identity),
thrust::not_fn(identity),
iter_vec.begin());
cudaError_t const err = cudaDeviceSynchronize();
ASSERT_EQUAL(cudaSuccess, err);
Expand Down
4 changes: 2 additions & 2 deletions thrust/testing/functional.cu
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestNot1()

Vector output(5);

thrust::transform(input.begin(), input.end(), output.begin(), thrust::not1(thrust::identity<T>()));
thrust::transform(input.begin(), input.end(), output.begin(), thrust::not_fn(thrust::identity<T>()));

ASSERT_EQUAL(output[0], 0);
ASSERT_EQUAL(output[1], 1);
Expand Down Expand Up @@ -350,7 +350,7 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestNot2()

Vector output(5);

thrust::transform(input1.begin(), input1.end(), input2.begin(), output.begin(), thrust::not2(thrust::equal_to<T>()));
thrust::transform(input1.begin(), input1.end(), input2.begin(), output.begin(), thrust::not_fn(thrust::equal_to<T>()));

ASSERT_EQUAL(output[0], 0);
ASSERT_EQUAL(output[1], 1);
Expand Down
Loading

0 comments on commit fcc4cb6

Please sign in to comment.