Skip to content

Commit

Permalink
Fix bug in MG Neighborhood sampling (#4827)
Browse files Browse the repository at this point in the history
This PR fixes a bug when computing the global start vertex labels

Authors:
  - Joseph Nke (https://github.com/jnke2016)

Approvers:
  - Alex Barghi (https://github.com/alexbarghi-nv)
  - Seunghwa Kang (https://github.com/seunghwak)
  - Naim (https://github.com/naimnv)
  - Chuck Hastings (https://github.com/ChuckHastings)

URL: #4827
  • Loading branch information
jnke2016 authored Jan 7, 2025
1 parent 04f0984 commit c522baf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cpp/src/c_api/neighbor_sampling.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
* Copyright (c) 2022-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -880,7 +880,6 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor {
handle_.get_stream());

std::optional<rmm::device_uvector<label_t>> start_vertex_labels{std::nullopt};
std::optional<rmm::device_uvector<label_t>> local_label_to_comm_rank{std::nullopt};
std::optional<rmm::device_uvector<label_t>> label_to_comm_rank{
std::nullopt}; // global after allgatherv

Expand Down Expand Up @@ -932,12 +931,13 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor {
handle_.get_stream(),
raft::device_span<label_t>{unique_labels.data(), unique_labels.size()});

(*local_label_to_comm_rank).resize(num_unique_labels, handle_.get_stream());
rmm::device_uvector<label_t> local_label_to_comm_rank(num_unique_labels,
handle_.get_stream());

cugraph::detail::scalar_fill(
handle_.get_stream(),
(*local_label_to_comm_rank).begin(), // This should be rename to rank
(*local_label_to_comm_rank).size(),
local_label_to_comm_rank.begin(), // This should be rename to rank
local_label_to_comm_rank.size(),
label_t{handle_.get_comms().get_rank()});

// Perform allgather to get global_label_to_comm_rank_d_vector
Expand All @@ -948,11 +948,11 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor {
std::exclusive_scan(
recvcounts.begin(), recvcounts.end(), displacements.begin(), size_t{0});

(*label_to_comm_rank)
.resize(displacements.back() + recvcounts.back(), handle_.get_stream());
label_to_comm_rank = rmm::device_uvector<label_t>(
displacements.back() + recvcounts.back(), handle_.get_stream());

cugraph::device_allgatherv(handle_.get_comms(),
(*local_label_to_comm_rank).begin(),
local_label_to_comm_rank.begin(),
(*label_to_comm_rank).begin(),
recvcounts,
displacements,
Expand Down

0 comments on commit c522baf

Please sign in to comment.