Skip to content

Commit

Permalink
Optimize K-Truss (#4375)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jnke2016 authored Jul 30, 2024
1 parent 4fb6470 commit a1f8a65
Show file tree
Hide file tree
Showing 35 changed files with 719 additions and 684 deletions.
3 changes: 3 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ set(CUGRAPH_SOURCES
src/community/k_truss_sg_v64_e64.cu
src/community/k_truss_sg_v32_e32.cu
src/community/k_truss_sg_v32_e64.cu
src/community/k_truss_mg_v64_e64.cu
src/community/k_truss_mg_v32_e32.cu
src/community/k_truss_mg_v32_e64.cu
src/lookup/lookup_src_dst_mg_v32_e32.cu
src/lookup/lookup_src_dst_mg_v32_e64.cu
src/lookup/lookup_src_dst_mg_v64_e64.cu
Expand Down
8 changes: 5 additions & 3 deletions cpp/include/cugraph/detail/shuffle_wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ std::tuple<rmm::device_uvector<vertex_t>,
rmm::device_uvector<vertex_t>,
std::optional<rmm::device_uvector<weight_t>>,
std::optional<rmm::device_uvector<edge_t>>,
std::optional<rmm::device_uvector<edge_type_id_t>>>
std::optional<rmm::device_uvector<edge_type_id_t>>,
std::vector<size_t>>
shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& majors,
Expand Down Expand Up @@ -86,14 +87,15 @@ shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
* (exclusive) vertex ID.
*
* @return Tuple of vectors storing shuffled major vertices, minor vertices and optional weights,
* edge ids and edge types
* edge ids and edge types and rx counts
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename edge_type_id_t>
std::tuple<rmm::device_uvector<vertex_t>,
rmm::device_uvector<vertex_t>,
std::optional<rmm::device_uvector<weight_t>>,
std::optional<rmm::device_uvector<edge_t>>,
std::optional<rmm::device_uvector<edge_type_id_t>>>
std::optional<rmm::device_uvector<edge_type_id_t>>,
std::vector<size_t>>
shuffle_int_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& majors,
Expand Down
3 changes: 2 additions & 1 deletion cpp/include/cugraph/mtmg/detail/per_device_edgelist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ class per_device_edgelist_t {
store_transposed ? src_[0] : dst_[0],
tmp_wgt,
tmp_edge_id,
tmp_edge_type) =
tmp_edge_type,
std::ignore) =
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
handle.raft_handle(),
store_transposed ? std::move(dst_[0]) : std::move(src_[0]),
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/c_api/graph_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct create_vertex_pairs_functor : public cugraph::c_api::abstract_functor {
second_copy.data(), second_->as_type<vertex_t>(), second_->size_, handle_.get_stream());

if constexpr (multi_gpu) {
std::tie(first_copy, second_copy, std::ignore, std::ignore, std::ignore) =
std::tie(first_copy, second_copy, std::ignore, std::ignore, std::ignore, std::ignore) =
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning<
vertex_t,
edge_t,
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/c_api/graph_mg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor {
store_transposed ? edgelist_srcs : edgelist_dsts,
edgelist_weights,
edgelist_edge_ids,
edgelist_edge_types) =
edgelist_edge_types,
std::ignore) =
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
handle_,
std::move(store_transposed ? edgelist_dsts : edgelist_srcs),
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/c_api/k_truss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ struct k_truss_functor : public cugraph::c_api::abstract_functor {
{
if constexpr (!cugraph::is_candidate<vertex_t, edge_t, weight_t>::value) {
unsupported();
} else if constexpr (multi_gpu) {
unsupported();
} else {
// k_truss expects store_transposed == false
if constexpr (store_transposed) {
error_code_ = cugraph::c_api::
transpose_storage<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>(
Expand Down
1 change: 1 addition & 0 deletions cpp/src/community/detail/refine_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ refine_clustering(
store_transposed ? d_srcs : d_dsts,
d_weights,
std::ignore,
std::ignore,
std::ignore) =
cugraph::detail::shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning<
vertex_t,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/community/edge_triangle_count_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ edge_property_t<graph_view_t<vertex_t, edge_t, false, multi_gpu>, edge_t> edge_t
handle.get_stream());

// There are still multiple copies here but is it worth sorting and reducing again?
std::tie(pair_srcs, pair_dsts, std::ignore, pair_count, std::ignore) =
std::tie(pair_srcs, pair_dsts, std::ignore, pair_count, std::ignore, std::ignore) =
shuffle_int_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning<vertex_t,
edge_t,
weight_t,
Expand Down
Loading

0 comments on commit a1f8a65

Please sign in to comment.