Skip to content

Commit e7c9915

Browse files
authored
Replace Thrust iterator facilities with libcu++ ones (#5013)
They do the same and we should use the standard ones Authors: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) Approvers: - Chuck Hastings (https://github.com/ChuckHastings) - Seunghwa Kang (https://github.com/seunghwak) URL: #5013
1 parent afb563e commit e7c9915

File tree

101 files changed

+1252
-1184
lines changed

Some content is hidden

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

101 files changed

+1252
-1184
lines changed

cpp/include/cugraph/edge_partition_device_view.cuh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include <rmm/device_uvector.hpp>
2727
#include <rmm/exec_policy.hpp>
2828

29+
#include <cuda/std/iterator>
2930
#include <cuda/std/optional>
3031
#include <thrust/binary_search.h>
31-
#include <thrust/distance.h>
3232
#include <thrust/execution_policy.h>
3333
#include <thrust/transform.h>
3434
#include <thrust/transform_reduce.h>
@@ -52,7 +52,7 @@ __device__ cuda::std::optional<vertex_t> major_hypersparse_idx_from_major_nochec
5252
thrust::lower_bound(thrust::seq, dcs_nzd_vertices.begin(), dcs_nzd_vertices.end(), major);
5353
return it != dcs_nzd_vertices.end()
5454
? (*it == major ? cuda::std::optional<vertex_t>{static_cast<vertex_t>(
55-
thrust::distance(dcs_nzd_vertices.begin(), it))}
55+
cuda::std::distance(dcs_nzd_vertices.begin(), it))}
5656
: cuda::std::nullopt)
5757
: cuda::std::nullopt;
5858
}
@@ -161,7 +161,7 @@ class edge_partition_device_view_base_t {
161161

162162
__device__ vertex_t major_idx_from_local_edge_idx_nocheck(edge_t local_edge_idx) const noexcept
163163
{
164-
return static_cast<vertex_t>(thrust::distance(
164+
return static_cast<vertex_t>(cuda::std::distance(
165165
offsets_.begin() + 1,
166166
thrust::upper_bound(thrust::seq, offsets_.begin() + 1, offsets_.end(), local_edge_idx)));
167167
}
@@ -219,7 +219,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
219219
MajorIterator major_last,
220220
rmm::cuda_stream_view stream) const
221221
{
222-
if (thrust::distance(major_first, major_last) == 0) return size_t{0};
222+
if (cuda::std::distance(major_first, major_last) == 0) return size_t{0};
223223
return dcs_nzd_vertices_ ? thrust::transform_reduce(
224224
rmm::exec_policy(stream),
225225
major_first,
@@ -258,7 +258,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
258258
raft::device_span<size_t> count /* size = 1 */,
259259
rmm::cuda_stream_view stream) const
260260
{
261-
if (thrust::distance(major_first, major_last) == 0) {
261+
if (cuda::std::distance(major_first, major_last) == 0) {
262262
RAFT_CUDA_TRY(cudaMemsetAsync(count.data(), 0, sizeof(size_t), stream));
263263
}
264264

@@ -278,14 +278,14 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
278278
tmp_storage_bytes,
279279
local_degree_first,
280280
count.data(),
281-
thrust::distance(major_first, major_last),
281+
cuda::std::distance(major_first, major_last),
282282
stream);
283283
d_tmp_storage.resize(tmp_storage_bytes, stream);
284284
cub::DeviceReduce::Sum(d_tmp_storage.data(),
285285
tmp_storage_bytes,
286286
local_degree_first,
287287
count.data(),
288-
thrust::distance(major_first, major_last),
288+
cuda::std::distance(major_first, major_last),
289289
stream);
290290
} else {
291291
auto local_degree_first = thrust::make_transform_iterator(
@@ -300,14 +300,14 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
300300
tmp_storage_bytes,
301301
local_degree_first,
302302
count.data(),
303-
thrust::distance(major_first, major_last),
303+
cuda::std::distance(major_first, major_last),
304304
stream);
305305
d_tmp_storage.resize(tmp_storage_bytes, stream);
306306
cub::DeviceReduce::Sum(d_tmp_storage.data(),
307307
tmp_storage_bytes,
308308
local_degree_first,
309309
count.data(),
310-
thrust::distance(major_first, major_last),
310+
cuda::std::distance(major_first, major_last),
311311
stream);
312312
}
313313
}
@@ -343,7 +343,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
343343
MajorIterator major_last,
344344
rmm::cuda_stream_view stream) const
345345
{
346-
rmm::device_uvector<edge_t> local_degrees(thrust::distance(major_first, major_last), stream);
346+
rmm::device_uvector<edge_t> local_degrees(cuda::std::distance(major_first, major_last), stream);
347347
if (dcs_nzd_vertices_) {
348348
assert(major_hypersparse_first_);
349349
thrust::transform(rmm::exec_policy_nosync(stream),
@@ -373,7 +373,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
373373
MajorIterator major_last,
374374
rmm::cuda_stream_view stream) const
375375
{
376-
if (thrust::distance(major_first, major_last) == 0) return size_t{0};
376+
if (cuda::std::distance(major_first, major_last) == 0) return size_t{0};
377377
return dcs_nzd_vertices_ ? thrust::transform_reduce(
378378
rmm::exec_policy(stream),
379379
major_first,
@@ -453,7 +453,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
453453
MajorIterator major_last,
454454
rmm::cuda_stream_view stream) const
455455
{
456-
rmm::device_uvector<edge_t> local_degrees(thrust::distance(major_first, major_last), stream);
456+
rmm::device_uvector<edge_t> local_degrees(cuda::std::distance(major_first, major_last), stream);
457457
if (dcs_nzd_vertices_) {
458458
assert(major_hypersparse_first_);
459459
thrust::transform(
@@ -634,7 +634,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
634634
MajorIterator major_last,
635635
rmm::cuda_stream_view stream) const
636636
{
637-
if (thrust::distance(major_first, major_last) == 0) return size_t{0};
637+
if (cuda::std::distance(major_first, major_last) == 0) return size_t{0};
638638
return thrust::transform_reduce(
639639
rmm::exec_policy(stream),
640640
major_first,
@@ -657,7 +657,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
657657
raft::device_span<size_t> count /* size = 1 */,
658658
rmm::cuda_stream_view stream) const
659659
{
660-
if (thrust::distance(major_first, major_last) == 0) {
660+
if (cuda::std::distance(major_first, major_last) == 0) {
661661
RAFT_CUDA_TRY(cudaMemsetAsync(count.data(), 0, sizeof(size_t), stream));
662662
}
663663

@@ -678,14 +678,14 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
678678
tmp_storage_bytes,
679679
local_degree_first,
680680
count.data(),
681-
thrust::distance(major_first, major_last),
681+
cuda::std::distance(major_first, major_last),
682682
stream);
683683
d_tmp_storage.resize(tmp_storage_bytes, stream);
684684
cub::DeviceReduce::Sum(d_tmp_storage.data(),
685685
tmp_storage_bytes,
686686
local_degree_first,
687687
count.data(),
688-
thrust::distance(major_first, major_last),
688+
cuda::std::distance(major_first, major_last),
689689
stream);
690690
}
691691

@@ -709,7 +709,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
709709
MajorIterator major_last,
710710
rmm::cuda_stream_view stream) const
711711
{
712-
rmm::device_uvector<edge_t> local_degrees(thrust::distance(major_first, major_last), stream);
712+
rmm::device_uvector<edge_t> local_degrees(cuda::std::distance(major_first, major_last), stream);
713713
thrust::transform(rmm::exec_policy_nosync(stream),
714714
major_first,
715715
major_last,
@@ -728,7 +728,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
728728
MajorIterator major_last,
729729
rmm::cuda_stream_view stream) const
730730
{
731-
if (thrust::distance(major_first, major_last) == 0) return size_t{0};
731+
if (cuda::std::distance(major_first, major_last) == 0) return size_t{0};
732732
return thrust::transform_reduce(
733733
rmm::exec_policy(stream),
734734
major_first,
@@ -774,7 +774,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
774774
MajorIterator major_last,
775775
rmm::cuda_stream_view stream) const
776776
{
777-
rmm::device_uvector<edge_t> local_degrees(thrust::distance(major_first, major_last), stream);
777+
rmm::device_uvector<edge_t> local_degrees(cuda::std::distance(major_first, major_last), stream);
778778
thrust::transform(
779779
rmm::exec_policy_nosync(stream),
780780
major_first,

cpp/include/cugraph/edge_partition_endpoint_property_device_view.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
#include <raft/core/device_span.hpp>
2525

26+
#include <cuda/std/iterator>
2627
#include <cuda/std/optional>
2728
#include <thrust/binary_search.h>
28-
#include <thrust/distance.h>
2929
#include <thrust/execution_policy.h>
3030
#include <thrust/fill.h>
3131
#include <thrust/iterator/iterator_traits.h>
@@ -204,7 +204,7 @@ class edge_partition_endpoint_property_device_view_t {
204204
assert((it != (*keys_).begin() + (*key_chunk_start_offsets_)[chunk_idx + 1]) &&
205205
(*it == (range_first_ + offset)));
206206
val_offset = (*key_chunk_start_offsets_)[chunk_idx] +
207-
static_cast<vertex_t>(thrust::distance(
207+
static_cast<vertex_t>(cuda::std::distance(
208208
(*keys_).begin() + (*key_chunk_start_offsets_)[chunk_idx], it));
209209
}
210210
return val_offset;

cpp/include/cugraph/utilities/mask_utils.cuh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
2+
* Copyright (c) 2023-2025, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
#include <raft/core/handle.hpp>
2222

2323
#include <cuda/functional>
24+
#include <cuda/std/iterator>
2425
#include <thrust/copy.h>
2526
#include <thrust/functional.h>
2627
#include <thrust/iterator/counting_iterator.h>
@@ -138,7 +139,7 @@ __device__ size_t copy_if_mask_set(InputIterator input_first,
138139
!cugraph::has_packed_bool_element<OutputIterator, output_value_type>(),
139140
"unimplemented.");
140141

141-
return static_cast<size_t>(thrust::distance(
142+
return static_cast<size_t>(cuda::std::distance(
142143
output_first + output_start_offset,
143144
thrust::copy_if(thrust::seq,
144145
input_first + input_start_offset,

0 commit comments

Comments
 (0)