Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement has_edge() & compute_multiplicity() #4096

Merged
merged 21 commits into from
Jan 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dfbc33a
add an empty line between two functions
seunghwak Jan 16, 2024
e6f6784
added major_idx_from_major_nocheck
seunghwak Jan 16, 2024
c9c3a2b
add initial implementation of has_edge() and compute_multiplicity
seunghwak Jan 17, 2024
e827457
Merge branch 'branch-24.02' of https://github.com/rapidsai/cugraph in…
seunghwak Jan 17, 2024
06d4f77
move count_invalid_vertex_pairs to error_check_utils.cuh
seunghwak Jan 17, 2024
4b4fb46
refactor has_edge() and compute_multiplicity()
seunghwak Jan 17, 2024
7f25cfc
Merge branch 'branch-24.02' of https://github.com/rapidsai/cugraph in…
seunghwak Jan 17, 2024
a7d0fff
clang-format and copyright year
seunghwak Jan 17, 2024
becf133
to_host, to_device specialization for std::vector<bool>
seunghwak Jan 17, 2024
5d3ed2a
remove repetitive tests
seunghwak Jan 17, 2024
e8d0ccc
fix compile error
seunghwak Jan 17, 2024
737f438
add bool specialization for device_gatherv and device_allgatherv
seunghwak Jan 17, 2024
00789bf
add tests for has_edge() and compute_multiplicity
seunghwak Jan 17, 2024
0b45356
copyright year
seunghwak Jan 17, 2024
49f46d0
Merge branch 'branch-24.02' of https://github.com/rapidsai/cugraph in…
seunghwak Jan 17, 2024
7cfe60a
bug fix
seunghwak Jan 18, 2024
c81655d
Merge branch 'branch-24.02' of https://github.com/rapidsai/cugraph in…
seunghwak Jan 18, 2024
43f8485
bug fix in tests
seunghwak Jan 19, 2024
8ff673a
test bug fix
seunghwak Jan 20, 2024
7b0d132
Merge branch 'branch-24.02' of https://github.com/rapidsai/cugraph in…
seunghwak Jan 20, 2024
9ee207f
Merge branch 'branch-24.02' of https://github.com/rapidsai/cugraph in…
seunghwak Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bug fix
seunghwak committed Jan 18, 2024
commit 7cfe60ac43fd936f894af8c82b5fa2536f3e1c63
4 changes: 2 additions & 2 deletions cpp/src/structure/graph_view_impl.cuh
Original file line number Diff line number Diff line change
@@ -866,7 +866,7 @@ graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu, std::enable_if_t<mul
edge_partition.local_edges(*major_idx);
auto it = thrust::lower_bound(
thrust::seq, indices, indices + local_degree, minor);
if (*it == minor) {
if ((it != indices + local_degree) && *it == minor) {
if (edge_partition_e_mask) {
return (*edge_partition_e_mask)
.get(local_edge_offset + thrust::distance(indices, it));
@@ -935,7 +935,7 @@ graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu, std::enable_if_t<!mu
thrust::tie(indices, local_edge_offset, local_degree) =
edge_partition.local_edges(major_offset);
auto it = thrust::lower_bound(thrust::seq, indices, indices + local_degree, minor);
if (*it == minor) {
if ((it != indices + local_degree) && *it == minor) {
if (edge_partition_e_mask) {
return (*edge_partition_e_mask).get(local_edge_offset + thrust::distance(indices, it));
} else {
Original file line number Diff line number Diff line change
@@ -178,16 +178,16 @@ class Tests_HasEdgeAndComputeMultiplicity
auto h_cugraph_edge_exists = cugraph::test::to_host(handle, edge_exists);
auto h_cugraph_edge_multiplicities = cugraph::test::to_host(handle, edge_multiplicities);
std::vector<bool> h_reference_edge_exists(edge_srcs.size());
std::vector<bool> h_reference_edge_multiplicities(edge_srcs.size());
std::vector<edge_t> h_reference_edge_multiplicities(edge_srcs.size());
for (size_t i = 0; i < edge_srcs.size(); ++i) {
auto src = h_unrenumbered_edge_srcs[i];
auto dst = h_unrenumbered_edge_dsts[i];
auto major = store_transposed ? dst : src;
auto minor = store_transposed ? src : dst;
auto lower_it = std::lower_bound(
h_indices.begin() + h_offsets[i], h_indices.begin() + h_offsets[i + 1], minor);
h_indices.begin() + h_offsets[major], h_indices.begin() + h_offsets[major + 1], minor);
auto upper_it = std::upper_bound(
h_indices.begin() + h_offsets[i], h_indices.begin() + h_offsets[i + 1], minor);
h_indices.begin() + h_offsets[major], h_indices.begin() + h_offsets[major + 1], minor);
auto multiplicity = static_cast<edge_t>(std::distance(lower_it, upper_it));
h_reference_edge_exists[i] = multiplicity > 0 ? true : false;
h_reference_edge_multiplicities[i] = multiplicity;
Original file line number Diff line number Diff line change
@@ -91,6 +91,8 @@ class Tests_MGHasEdgeAndComputeMultiplicity

auto mg_graph_view = mg_graph.view();

// 2. create an edge list to query

raft::random::RngState rng_state{0};
auto d_mg_edge_srcs = cugraph::select_random_vertices<vertex_t>(
*handle_,
@@ -126,7 +128,7 @@ class Tests_MGHasEdgeAndComputeMultiplicity
std::nullopt,
mg_graph_view.vertex_partition_range_lasts());

// 2. run MG has_edge & compute_multiplicity
// 3. run MG has_edge & compute_multiplicity

if (cugraph::test::g_perf) {
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
@@ -164,10 +166,10 @@ class Tests_MGHasEdgeAndComputeMultiplicity
hr_timer.display_and_clear(std::cout);
}

// 3. copmare SG & MG results
// 4. copmare SG & MG results

if (has_edge_and_compute_multiplicity_usecase.check_correctness) {
// 3-1. aggregate MG results
// 4-1. aggregate MG results

cugraph::unrenumber_int_vertices<vertex_t, true>(
*handle_,
@@ -205,7 +207,7 @@ class Tests_MGHasEdgeAndComputeMultiplicity
if (handle_->get_comms().get_rank() == 0) {
auto sg_graph_view = sg_graph.view();

// 3-2. run SG count_self_loops & count_multi_edges
// 4-2. run SG count_self_loops & count_multi_edges

auto d_sg_edge_exists = sg_graph_view.has_edge(
*handle_,
@@ -220,7 +222,7 @@ class Tests_MGHasEdgeAndComputeMultiplicity
raft::device_span<vertex_t const>(d_mg_aggregate_edge_dsts.data(),
d_mg_aggregate_edge_dsts.size()));

// 3-3. compare
// 4-3. compare

auto h_mg_aggregate_edge_exists =
cugraph::test::to_host(*handle_, d_mg_aggregate_edge_exists);