Skip to content

Commit a1f8a65

Browse files
authored
Optimize K-Truss (#4375)
This PR leverages our existing edge triangle count to implement both SG and MG K-Truss as our initial version. This PR also: - Exposes the `rx count` in several as our shuffling functions - Add C and C++ tests for MG K-Truss Closes #4500 Authors: - Joseph Nke (https://github.com/jnke2016) - Brad Rees (https://github.com/BradReesWork) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Seunghwa Kang (https://github.com/seunghwak) - Chuck Hastings (https://github.com/ChuckHastings) URL: #4375
1 parent 4fb6470 commit a1f8a65

35 files changed

+719
-684
lines changed

cpp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ set(CUGRAPH_SOURCES
284284
src/community/k_truss_sg_v64_e64.cu
285285
src/community/k_truss_sg_v32_e32.cu
286286
src/community/k_truss_sg_v32_e64.cu
287+
src/community/k_truss_mg_v64_e64.cu
288+
src/community/k_truss_mg_v32_e32.cu
289+
src/community/k_truss_mg_v32_e64.cu
287290
src/lookup/lookup_src_dst_mg_v32_e32.cu
288291
src/lookup/lookup_src_dst_mg_v32_e64.cu
289292
src/lookup/lookup_src_dst_mg_v64_e64.cu

cpp/include/cugraph/detail/shuffle_wrappers.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ std::tuple<rmm::device_uvector<vertex_t>,
5353
rmm::device_uvector<vertex_t>,
5454
std::optional<rmm::device_uvector<weight_t>>,
5555
std::optional<rmm::device_uvector<edge_t>>,
56-
std::optional<rmm::device_uvector<edge_type_id_t>>>
56+
std::optional<rmm::device_uvector<edge_type_id_t>>,
57+
std::vector<size_t>>
5758
shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
5859
raft::handle_t const& handle,
5960
rmm::device_uvector<vertex_t>&& majors,
@@ -86,14 +87,15 @@ shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
8687
* (exclusive) vertex ID.
8788
*
8889
* @return Tuple of vectors storing shuffled major vertices, minor vertices and optional weights,
89-
* edge ids and edge types
90+
* edge ids and edge types and rx counts
9091
*/
9192
template <typename vertex_t, typename edge_t, typename weight_t, typename edge_type_id_t>
9293
std::tuple<rmm::device_uvector<vertex_t>,
9394
rmm::device_uvector<vertex_t>,
9495
std::optional<rmm::device_uvector<weight_t>>,
9596
std::optional<rmm::device_uvector<edge_t>>,
96-
std::optional<rmm::device_uvector<edge_type_id_t>>>
97+
std::optional<rmm::device_uvector<edge_type_id_t>>,
98+
std::vector<size_t>>
9799
shuffle_int_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
98100
raft::handle_t const& handle,
99101
rmm::device_uvector<vertex_t>&& majors,

cpp/include/cugraph/mtmg/detail/per_device_edgelist.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ class per_device_edgelist_t {
251251
store_transposed ? src_[0] : dst_[0],
252252
tmp_wgt,
253253
tmp_edge_id,
254-
tmp_edge_type) =
254+
tmp_edge_type,
255+
std::ignore) =
255256
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
256257
handle.raft_handle(),
257258
store_transposed ? std::move(dst_[0]) : std::move(src_[0]),

cpp/src/c_api/graph_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct create_vertex_pairs_functor : public cugraph::c_api::abstract_functor {
7272
second_copy.data(), second_->as_type<vertex_t>(), second_->size_, handle_.get_stream());
7373

7474
if constexpr (multi_gpu) {
75-
std::tie(first_copy, second_copy, std::ignore, std::ignore, std::ignore) =
75+
std::tie(first_copy, second_copy, std::ignore, std::ignore, std::ignore, std::ignore) =
7676
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning<
7777
vertex_t,
7878
edge_t,

cpp/src/c_api/graph_mg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor {
167167
store_transposed ? edgelist_srcs : edgelist_dsts,
168168
edgelist_weights,
169169
edgelist_edge_ids,
170-
edgelist_edge_types) =
170+
edgelist_edge_types,
171+
std::ignore) =
171172
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
172173
handle_,
173174
std::move(store_transposed ? edgelist_dsts : edgelist_srcs),

cpp/src/c_api/k_truss.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ struct k_truss_functor : public cugraph::c_api::abstract_functor {
6060
{
6161
if constexpr (!cugraph::is_candidate<vertex_t, edge_t, weight_t>::value) {
6262
unsupported();
63-
} else if constexpr (multi_gpu) {
64-
unsupported();
6563
} else {
66-
// k_truss expects store_transposed == false
6764
if constexpr (store_transposed) {
6865
error_code_ = cugraph::c_api::
6966
transpose_storage<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>(

cpp/src/community/detail/refine_impl.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ refine_clustering(
627627
store_transposed ? d_srcs : d_dsts,
628628
d_weights,
629629
std::ignore,
630+
std::ignore,
630631
std::ignore) =
631632
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning<
632633
vertex_t,

cpp/src/community/edge_triangle_count_impl.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ edge_property_t<graph_view_t<vertex_t, edge_t, false, multi_gpu>, edge_t> edge_t
250250
handle.get_stream());
251251

252252
// There are still multiple copies here but is it worth sorting and reducing again?
253-
std::tie(pair_srcs, pair_dsts, std::ignore, pair_count, std::ignore) =
253+
std::tie(pair_srcs, pair_dsts, std::ignore, pair_count, std::ignore, std::ignore) =
254254
shuffle_int_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning<vertex_t,
255255
edge_t,
256256
weight_t,

0 commit comments

Comments
 (0)