Skip to content

Commit

Permalink
bug fix (vertex_partition_segment_offsets)
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghwak committed Oct 5, 2020
1 parent 59fadef commit a006b99
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
42 changes: 30 additions & 12 deletions cpp/src/experimental/graph.cu
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,41 @@ graph_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enable_if_
d_thresholds.end(),
segment_offsets.begin() + 1);

rmm::device_uvector<vertex_t> aggregate_segment_offsets(row_comm_size * segment_offsets.size(),
default_stream);
row_comm.allgather(segment_offsets.data(),
aggregate_segment_offsets.data(),
segment_offsets.size(),
default_stream);

vertex_partition_segment_offsets_.resize(row_comm_size * (segment_offsets.size()));
rmm::device_uvector<vertex_t> aggregate_segment_offsets(0, default_stream);
if (partition.is_hypergraph_partitioned()) {
rmm::device_uvector<vertex_t> aggregate_segment_offsets(
col_comm_size * segment_offsets.size(), default_stream);
col_comm.allgather(segment_offsets.data(),
aggregate_segment_offsets.data(),
segment_offsets.size(),
default_stream);
} else {
rmm::device_uvector<vertex_t> aggregate_segment_offsets(
row_comm_size * segment_offsets.size(), default_stream);
row_comm.allgather(segment_offsets.data(),
aggregate_segment_offsets.data(),
segment_offsets.size(),
default_stream);
}

vertex_partition_segment_offsets_.resize(aggregate_segment_offsets.size());
raft::update_host(vertex_partition_segment_offsets_.data(),
aggregate_segment_offsets.data(),
aggregate_segment_offsets.size(),
default_stream);

auto status = handle.get_comms().sync_stream(
default_stream); // this is necessary as degrees, d_thresholds, and segment_offsets will
// become out-of-scope once control flow exits this block and
// vertex_partition_segment_offsets_ can be used right after return.
raft::comms::status_t status{};
if (partition.is_hypergraph_partitioned()) {
status = col_comm.sync_stream(
default_stream); // this is necessary as degrees, d_thresholds, and segment_offsets will
// become out-of-scope once control flow exits this block and
// vertex_partition_segment_offsets_ can be used right after return.
} else {
status = row_comm.sync_stream(
default_stream); // this is necessary as degrees, d_thresholds, and segment_offsets will
// become out-of-scope once control flow exits this block and
// vertex_partition_segment_offsets_ can be used right after return.
}
CUGRAPH_EXPECTS(status == raft::comms::status_t::SUCCESS, "sync_stream() failure.");
}

Expand Down
20 changes: 9 additions & 11 deletions cpp/src/experimental/graph_view.cu
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <experimental/detail/graph_utils.cuh>
#include <experimental/graph_view.hpp>
#include <partition_manager.hpp>
#include <utilities/comm_utils.cuh>
#include <utilities/error.hpp>

#include <raft/cudart_utils.h>
Expand Down Expand Up @@ -101,7 +102,8 @@ graph_view_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enabl

CUGRAPH_EXPECTS((sorted_by_global_degree_within_vertex_partition &&
(vertex_partition_segment_offsets.size() ==
comm_size * (detail::num_segments_per_vertex_partition + 1))) ||
(partition.is_hypergraph_partitioned() ? col_comm_size : row_comm_size) *
(detail::num_segments_per_vertex_partition + 1))) ||
(!sorted_by_global_degree_within_vertex_partition &&
(vertex_partition_segment_offsets.size() == 0)),
"Invalid API parameter: vertex_partition_segment_offsets.size() does not match "
Expand Down Expand Up @@ -148,13 +150,8 @@ graph_view_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enabl
out_of_range_t<vertex_t>{minor_first, minor_last}) == 0,
"Invalid API parameter: adj_matrix_partition_indices[] have out-of-range vertex IDs.");
}
this->get_handle_ptr()->get_comms().allreduce(&number_of_local_edges_sum,
&number_of_local_edges_sum,
1,
raft::comms::op_t::SUM,
default_stream);
auto status = handle.get_comms().sync_stream(default_stream);
CUGRAPH_EXPECTS(status == raft::comms::status_t::SUCCESS, "sync_stream() failure.");
number_of_local_edges_sum = host_scalar_allreduce(
this->get_handle_ptr()->get_comms(), number_of_local_edges_sum, default_stream);
CUGRAPH_EXPECTS(number_of_local_edges_sum == this->get_number_of_edges(),
"Invalid API parameter: the sum of local edges doe counts not match with "
"number_of_local_edges.");
Expand All @@ -168,7 +165,8 @@ graph_view_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enabl
"Invalid API parameter: sorted_by_global_degree_within_vertex_partition is "
"set to true, but degrees are not non-ascending.");

for (int i = 0; i < col_comm_size; ++i) {
for (int i = 0; i < (partition.is_hypergraph_partitioned() ? col_comm_size : row_comm_size);
++i) {
CUGRAPH_EXPECTS(std::is_sorted(vertex_partition_segment_offsets.begin() +
(detail::num_segments_per_vertex_partition + 1) * i,
vertex_partition_segment_offsets.begin() +
Expand All @@ -180,11 +178,11 @@ graph_view_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enabl
"Invalid API parameter: erroneous vertex_partition_segment_offsets.");
auto vertex_partition_idx = partition.is_hypergraph_partitioned()
? row_comm_size * i + row_comm_rank
: col_comm_size * row_comm_rank + i;
: col_comm_rank * row_comm_size + i;
CUGRAPH_EXPECTS(
vertex_partition_segment_offsets[(detail::num_segments_per_vertex_partition + 1) * i +
detail::num_segments_per_vertex_partition] ==
partition.get_vertex_partition_first(vertex_partition_idx),
partition.get_vertex_partition_size(vertex_partition_idx),
"Invalid API parameter: erroneous vertex_partition_segment_offsets.");
}
}
Expand Down

0 comments on commit a006b99

Please sign in to comment.