Skip to content

Commit 4c800d2

Browse files
authored
Merge 7caf341 into ef34496
2 parents ef34496 + 7caf341 commit 4c800d2

File tree

7 files changed

+62
-67
lines changed

7 files changed

+62
-67
lines changed

cpp/include/cugraph/graph_functions.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,7 @@ extract_induced_subgraphs(
347347
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
348348
* handles to various CUDA libraries) to run graph algorithms.
349349
* @param vertex_span If valid, part of the entire set of vertices in the graph to be renumbered.
350-
* The first tuple element is the pointer to the array and the second tuple element is the size of
351-
* the array. This parameter can be used to include isolated vertices. If multi-GPU, applying the
350+
* This parameter can be used to include isolated vertices. If multi-GPU, applying the
352351
* compute_gpu_id_from_vertex_t to every vertex should return the local GPU ID for this function to
353352
* work (vertices should be pre-shuffled).
354353
* @param edgelist_rows Vector of edge row (source) vertex IDs.
@@ -369,7 +368,7 @@ template <typename vertex_t,
369368
std::tuple<cugraph::graph_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>,
370369
std::optional<rmm::device_uvector<vertex_t>>>
371370
create_graph_from_edgelist(raft::handle_t const& handle,
372-
std::optional<std::tuple<vertex_t const*, vertex_t>> vertex_span,
371+
std::optional<rmm::device_uvector<vertex_t>>&& vertex_span,
373372
rmm::device_uvector<vertex_t>&& edgelist_rows,
374373
rmm::device_uvector<vertex_t>&& edgelist_cols,
375374
std::optional<rmm::device_uvector<weight_t>>&& edgelist_weights,

cpp/src/structure/create_graph_from_edgelist.cpp

Lines changed: 39 additions & 38 deletions
Large diffs are not rendered by default.

cpp/src/structure/renumber_edgelist.cu

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,13 @@ std::tuple<rmm::device_uvector<vertex_t>, std::vector<vertex_t>> compute_renumbe
276276
labels.shrink_to_fit(handle.get_stream());
277277
counts.shrink_to_fit(handle.get_stream());
278278

279-
// 4. if vertices != nullptr, add isolated vertices
279+
auto num_non_isolated_vertices = static_cast<vertex_t>(labels.size());
280+
281+
// 4. if vertex_span.has_value() == true, append isolated vertices
280282

281-
rmm::device_uvector<vertex_t> isolated_vertices(0, handle.get_stream());
282283
if (vertex_span) {
284+
rmm::device_uvector<vertex_t> isolated_vertices(0, handle.get_stream());
285+
283286
auto [vertices, num_vertices] = *vertex_span;
284287
auto num_isolated_vertices = thrust::count_if(
285288
rmm::exec_policy(handle.get_stream_view()),
@@ -296,30 +299,25 @@ std::tuple<rmm::device_uvector<vertex_t>, std::vector<vertex_t>> compute_renumbe
296299
[label_first = labels.begin(), label_last = labels.end()] __device__(auto v) {
297300
return !thrust::binary_search(thrust::seq, label_first, label_last, v);
298301
});
299-
}
300302

301-
if (isolated_vertices.size() > 0) {
302-
labels.resize(labels.size() + isolated_vertices.size(), handle.get_stream());
303-
counts.resize(labels.size(), handle.get_stream());
304-
thrust::copy(rmm::exec_policy(handle.get_stream_view()),
305-
isolated_vertices.begin(),
306-
isolated_vertices.end(),
307-
labels.end() - isolated_vertices.size());
308-
thrust::fill(rmm::exec_policy(handle.get_stream_view()),
309-
counts.end() - isolated_vertices.size(),
310-
counts.end(),
311-
edge_t{0});
303+
if (isolated_vertices.size() > 0) {
304+
labels.resize(labels.size() + isolated_vertices.size(), handle.get_stream());
305+
thrust::copy(rmm::exec_policy(handle.get_stream_view()),
306+
isolated_vertices.begin(),
307+
isolated_vertices.end(),
308+
labels.end() - isolated_vertices.size());
309+
}
312310
}
313311

314-
// 6. sort by degree
312+
// 5. sort non-isolated vertices by degree
315313

316314
thrust::sort_by_key(rmm::exec_policy(handle.get_stream_view()),
317315
counts.begin(),
318-
counts.end(),
316+
counts.begin() + num_non_isolated_vertices,
319317
labels.begin(),
320318
thrust::greater<edge_t>());
321319

322-
// 7. compute segment_offsets
320+
// 6. compute segment_offsets
323321

324322
static_assert(detail::num_sparse_segments_per_vertex_partition == 3);
325323
static_assert((detail::low_degree_threshold <= detail::mid_degree_threshold) &&
@@ -353,7 +351,7 @@ std::tuple<rmm::device_uvector<vertex_t>, std::vector<vertex_t>> compute_renumbe
353351
handle.get_stream());
354352

355353
auto zero_vertex = vertex_t{0};
356-
auto vertex_count = static_cast<vertex_t>(counts.size());
354+
auto vertex_count = static_cast<vertex_t>(labels.size());
357355
d_segment_offsets.set_element_async(0, zero_vertex, handle.get_stream());
358356
d_segment_offsets.set_element_async(
359357
num_segments_per_vertex_partition, vertex_count, handle.get_stream());
@@ -668,6 +666,7 @@ renumber_edgelist(
668666
edgelist_const_major_vertices,
669667
edgelist_const_minor_vertices,
670668
edgelist_edge_counts);
669+
671670
// 2. initialize partition_t object, number_of_vertices, and number_of_edges for the coarsened
672671
// graph
673672

cpp/tests/community/mg_louvain_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ class Louvain_MG_Testfixture : public ::testing::TestWithParam<Louvain_Usecase>
129129
std::tie(*sg_graph, std::ignore) =
130130
cugraph::create_graph_from_edgelist<vertex_t, edge_t, weight_t, false, false>(
131131
handle,
132-
std::optional<std::tuple<vertex_t const*, vertex_t>>{
133-
std::make_tuple(d_vertices.data(), static_cast<vertex_t>(d_vertices.size()))},
132+
std::move(d_vertices),
134133
std::move(d_edgelist_rows),
135134
std::move(d_edgelist_cols),
136135
std::move(d_edgelist_weights),

cpp/tests/components/wcc_graphs.cu

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ LineGraph_Usecase::construct_graph(raft::handle_t const& handle,
7171
return cugraph::
7272
create_graph_from_edgelist<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>(
7373
handle,
74-
std::optional<std::tuple<vertex_t const*, vertex_t>>{
75-
std::make_tuple(vertices_v.data(), static_cast<vertex_t>(vertices_v.size()))},
74+
std::move(vertices_v),
7675
std::move(src_v),
7776
std::move(dst_v),
7877
std::nullopt,

cpp/tests/utilities/matrix_market_file_utilities.cu

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ read_graph_from_matrix_market_file(raft::handle_t const& handle,
408408
return cugraph::
409409
create_graph_from_edgelist<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>(
410410
handle,
411-
std::optional<std::tuple<vertex_t const*, vertex_t>>{
412-
std::make_tuple(d_vertices.data(), static_cast<vertex_t>(d_vertices.size()))},
411+
std::move(d_vertices),
413412
std::move(d_edgelist_rows),
414413
std::move(d_edgelist_cols),
415414
std::move(d_edgelist_weights),

cpp/tests/utilities/rmat_utilities.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ generate_graph_from_rmat_params(raft::handle_t const& handle,
184184
return cugraph::
185185
create_graph_from_edgelist<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>(
186186
handle,
187-
std::optional<std::tuple<vertex_t const*, vertex_t>>{
188-
std::make_tuple(d_vertices.data(), static_cast<vertex_t>(d_vertices.size()))},
187+
std::move(d_vertices),
189188
std::move(d_edgelist_rows),
190189
std::move(d_edgelist_cols),
191190
std::move(d_edgelist_weights),

0 commit comments

Comments
 (0)