Skip to content

Commit 2d06510

Browse files
committed
Replace internal uses of thrust::tuple with cuda::std::tuple
1 parent b2c826f commit 2d06510

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+433
-412
lines changed

cub/test/catch2_test_device_merge.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void test_pairs(
250250
zip(keys2_h.end(), values2_h.end()),
251251
zip(reference_keys_h.begin(), reference_values_h.begin()),
252252
[&](const value_t& a, const value_t& b) {
253-
return compare_op(thrust::get<0>(a), thrust::get<0>(b));
253+
return compare_op(cuda::std::get<0>(a), cuda::std::get<0>(b));
254254
});
255255
}
256256

cub/test/catch2_test_device_merge_sort.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ template <typename CustomT>
9393
struct tuple_to_custom_op_t
9494
{
9595
template <typename KeyT, typename ValueT>
96-
__device__ __host__ CustomT operator()(const thrust::tuple<KeyT, ValueT>& val)
96+
__device__ __host__ CustomT operator()(const cuda::std::tuple<KeyT, ValueT>& val)
9797
{
9898
CustomT custom_val{};
99-
custom_val.key = static_cast<std::size_t>(thrust::get<0>(val));
100-
custom_val.val = static_cast<std::size_t>(thrust::get<1>(val));
99+
custom_val.key = static_cast<std::size_t>(cuda::std::get<0>(val));
100+
custom_val.val = static_cast<std::size_t>(cuda::std::get<1>(val));
101101
return custom_val;
102102
}
103103
};

cub/test/catch2_test_device_merge_sort_common.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ struct compare_first_lt_op_t
2222
{
2323
/**
2424
* We need to be able to have two different types for lhs and rhs, as the call to std::stable_sort with a
25-
* zip-iterator, will pass a thrust::tuple for lhs and a tuple_of_iterator_references for rhs.
25+
* zip-iterator, will pass a cuda::std::tuple for lhs and a tuple_of_iterator_references for rhs.
2626
*/
2727
template <typename LhsT, typename RhsT>
2828
__host__ __device__ bool operator()(const LhsT& lhs, const RhsT& rhs) const
2929
{
30-
return thrust::get<0>(lhs) < thrust::get<0>(rhs);
30+
return cuda::std::get<0>(lhs) < cuda::std::get<0>(rhs);
3131
}
3232
};
3333

cub/test/catch2_test_device_merge_sort_iterators.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ C2H_TEST("DeviceMergeSort::StableSortKeysCopy works with iterators and is stable
6262
auto keys_in_it = cuda::make_zip_iterator(sort_key_it, key_idx_it);
6363

6464
// Perform sort
65-
c2h::device_vector<thrust::tuple<key_t, offset_t>> keys_out(
66-
num_items, thrust::tuple<key_t, offset_t>{static_cast<key_t>(42), static_cast<offset_t>(42)});
65+
c2h::device_vector<cuda::std::tuple<key_t, offset_t>> keys_out(
66+
num_items, cuda::std::tuple<key_t, offset_t>{static_cast<key_t>(42), static_cast<offset_t>(42)});
6767
stable_sort_keys_copy(keys_in_it, keys_out.begin(), num_items, compare_first_lt_op_t{});
6868

6969
// Verify results
70-
c2h::host_vector<thrust::tuple<key_t, offset_t>> keys_expected(num_items);
70+
c2h::host_vector<cuda::std::tuple<key_t, offset_t>> keys_expected(num_items);
7171
thrust::copy(keys_in_it, keys_in_it + num_items, keys_expected.begin());
7272
std::stable_sort(keys_expected.begin(), keys_expected.end(), compare_first_lt_op_t{});
7373

cub/test/catch2_test_device_select_flagged_if.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ struct predicate_op_wrapper_t
1919
{
2020
PredOpT if_pred;
2121
template <typename FlagT, typename ItemT>
22-
__host__ __device__ bool operator()(thrust::tuple<FlagT, ItemT> tuple) const
22+
__host__ __device__ bool operator()(cuda::std::tuple<FlagT, ItemT> tuple) const
2323
{
24-
const auto flag = thrust::get<0>(tuple);
24+
const auto flag = cuda::std::get<0>(tuple);
2525
return static_cast<bool>(if_pred(flag));
2626
}
2727
};

cub/test/catch2_test_device_select_unique_by_key.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ struct project_first
228228
template <typename Tuple>
229229
__host__ __device__ bool operator()(const Tuple& lhs, const Tuple& rhs) const
230230
{
231-
return equality_op(thrust::get<0>(lhs), thrust::get<0>(rhs));
231+
return equality_op(cuda::std::get<0>(lhs), cuda::std::get<0>(rhs));
232232
}
233233
};
234234

cub/test/catch2_test_warp_merge_sort.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ C2H_TEST("Warp sort on key-value pairs of a partial warp-tile works",
515515
cpu_kv_pairs,
516516
segment_sizes,
517517
params::total_warps,
518-
thrust::make_tuple(oob_default, value_type{}),
518+
cuda::std::tuple(oob_default, value_type{}),
519519
params::logical_warp_items);
520520

521521
// Verify results

cub/test/test_device_batch_copy.cu

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#include <thrust/logical.h>
88
#include <thrust/sequence.h>
9-
#include <thrust/tuple.h>
109

1110
#include <cuda/iterator>
11+
#include <cuda/std/tuple>
1212

1313
#include <algorithm>
1414
#include <cstdint>
@@ -90,19 +90,19 @@ GetShuffledRangeOffsets(const c2h::host_vector<RangeSizeT>& range_sizes, const s
9090
}
9191

9292
template <size_t n, typename... T>
93-
std::enable_if_t<n >= thrust::tuple_size<thrust::tuple<T...>>::value>
94-
print_tuple(std::ostream&, const thrust::tuple<T...>&)
93+
std::enable_if_t<n >= cuda::std::tuple_size<cuda::std::tuple<T...>>::value>
94+
print_tuple(std::ostream&, const cuda::std::tuple<T...>&)
9595
{}
9696

9797
template <size_t n, typename... T>
98-
std::enable_if_t<n + 1 <= thrust::tuple_size<thrust::tuple<T...>>::value>
99-
print_tuple(std::ostream& os, const thrust::tuple<T...>& tup)
98+
std::enable_if_t<n + 1 <= cuda::std::tuple_size<cuda::std::tuple<T...>>::value>
99+
print_tuple(std::ostream& os, const cuda::std::tuple<T...>& tup)
100100
{
101101
if constexpr (n != 0)
102102
{
103103
os << ", ";
104104
}
105-
os << thrust::get<n>(tup);
105+
os << cuda::std::get<n>(tup);
106106
print_tuple<n + 1>(os, tup);
107107
}
108108

@@ -399,7 +399,7 @@ int main(int argc, char** argv)
399399
for (const auto& size_range : size_ranges)
400400
{
401401
// The most granular type being copied.
402-
using AtomicCopyT = thrust::tuple<int64_t, int32_t, int16_t, char, char>;
402+
using AtomicCopyT = cuda::std::tuple<int64_t, int32_t, int16_t, char, char>;
403403
RangeSizeT min_range_size = static_cast<RangeSizeT>(cuda::round_up(size_range.first, sizeof(AtomicCopyT)));
404404
RangeSizeT max_range_size =
405405
static_cast<RangeSizeT>(cuda::round_up(size_range.second, static_cast<RangeSizeT>(sizeof(AtomicCopyT))));

cudax/examples/stf/thrust_zip_iterator.cu

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ using namespace cuda::experimental::stf;
3030
// Functor to apply the transformation
3131
struct my_transform_functor
3232
{
33-
__host__ __device__ int operator()(const thrust::tuple<int, char>& t) const
33+
__host__ __device__ int operator()(const cuda::std::tuple<int, char>& t) const
3434
{
35-
int a = thrust::get<0>(t);
36-
char b = thrust::get<1>(t);
35+
int a = cuda::std::get<0>(t);
36+
char b = cuda::std::get<1>(t);
3737
return a + static_cast<int>(b); // Example operation
3838
}
3939
};
@@ -50,10 +50,10 @@ void thrust_algorithm(context& ctx, ZippedIt& first, ZippedIt& last, OutIt& outp
5050
size_t num_elements = cuda::std::distance(first, last);
5151

5252
// Extract underlying iterators from the zip iterator
53-
auto itA = thrust::get<0>(first.get_iterator_tuple());
53+
auto itA = cuda::std::get<0>(first.get_iterator_tuple());
5454
int* A = thrust::raw_pointer_cast(&(*itA));
5555

56-
auto itB = thrust::get<1>(first.get_iterator_tuple());
56+
auto itB = cuda::std::get<1>(first.get_iterator_tuple());
5757
char* B = thrust::raw_pointer_cast(&(*itB));
5858

5959
int* C = thrust::raw_pointer_cast(output.data());
@@ -66,7 +66,7 @@ void thrust_algorithm(context& ctx, ZippedIt& first, ZippedIt& last, OutIt& outp
6666
ctx.task(lA.read(), lB.read(), lC.write())->*[](cudaStream_t stream, auto dA, auto dB, auto dC) {
6767
// Reconstruct a zipped iterator from the data instances passed to the lambda function
6868
size_t num_elements = dA.size();
69-
auto dfirst = thrust::make_zip_iterator(thrust::make_tuple(dA.data_handle(), dB.data_handle()));
69+
auto dfirst = thrust::make_zip_iterator(cuda::std::tuple(dA.data_handle(), dB.data_handle()));
7070
auto dlast = dfirst + num_elements;
7171

7272
// Create a device pointer from the raw pointer
@@ -94,8 +94,8 @@ int main()
9494
B[1] = 'y';
9595
B[2] = 'z';
9696

97-
auto first = thrust::make_zip_iterator(thrust::make_tuple(A.begin(), B.begin()));
98-
auto last = thrust::make_zip_iterator(thrust::make_tuple(A.end(), B.end()));
97+
auto first = thrust::make_zip_iterator(cuda::std::tuple(A.begin(), B.begin()));
98+
auto last = thrust::make_zip_iterator(cuda::std::tuple(A.end(), B.end()));
9999

100100
thrust_algorithm(ctx, first, last, C, data_place::current_device());
101101

@@ -114,8 +114,8 @@ int main()
114114
hB[1] = 'y';
115115
hB[2] = 'z';
116116

117-
auto hfirst = thrust::make_zip_iterator(thrust::make_tuple(hA.begin(), hB.begin()));
118-
auto hlast = thrust::make_zip_iterator(thrust::make_tuple(hA.end(), hB.end()));
117+
auto hfirst = thrust::make_zip_iterator(cuda::std::tuple(hA.begin(), hB.begin()));
118+
auto hlast = thrust::make_zip_iterator(cuda::std::tuple(hA.end(), hB.end()));
119119

120120
thrust_algorithm(ctx, hfirst, hlast, hC, data_place::host());
121121

thrust/examples/arbitrary_transformation.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct arbitrary_functor1
4545
__host__ __device__ void operator()(Tuple t)
4646
{
4747
// D[i] = A[i] + B[i] * C[i];
48-
thrust::get<3>(t) = thrust::get<0>(t) + thrust::get<1>(t) * thrust::get<2>(t);
48+
cuda::std::get<3>(t) = cuda::std::get<0>(t) + cuda::std::get<1>(t) * cuda::std::get<2>(t);
4949
}
5050
};
5151

0 commit comments

Comments
 (0)