Skip to content

Commit

Permalink
bug fix (graph construction)
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghwak committed Oct 5, 2020
1 parent 790549f commit 59fadef
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 26 deletions.
64 changes: 39 additions & 25 deletions cpp/include/experimental/detail/graph_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -51,51 +51,65 @@ rmm::device_uvector<edge_t> compute_major_degree(
rmm::device_uvector<edge_t> degrees(0, handle.get_stream());

vertex_t max_num_local_degrees{0};
for (int i = 0; i < col_comm_size; ++i) {
auto vertex_partition_idx =
partition.is_hypergraph_partitioned()
? static_cast<size_t>(row_comm_size) * static_cast<size_t>(i) +
static_cast<size_t>(row_comm_rank)
: static_cast<size_t>(col_comm_size) * static_cast<size_t>(row_comm_rank) +
static_cast<size_t>(i);
for (int i = 0; i < (partition.is_hypergraph_partitioned() ? col_comm_size : row_comm_size);
++i) {
auto vertex_partition_idx = partition.is_hypergraph_partitioned()
? static_cast<size_t>(i * row_comm_size + row_comm_rank)
: static_cast<size_t>(col_comm_rank * row_comm_size + i);
vertex_t major_first{};
vertex_t major_last{};
std::tie(major_first, major_last) = partition.get_vertex_partition_range(vertex_partition_idx);
max_num_local_degrees = std::max(max_num_local_degrees, major_last - major_first);
if (i == col_comm_rank) { degrees.resize(major_last - major_first, handle.get_stream()); }
if (i == (partition.is_hypergraph_partitioned() ? col_comm_rank : row_comm_rank)) {
degrees.resize(major_last - major_first, handle.get_stream());
}
}
local_degrees.resize(max_num_local_degrees, handle.get_stream());
for (int i = 0; i < col_comm_size; ++i) {
auto vertex_partition_idx =
partition.is_hypergraph_partitioned()
? static_cast<size_t>(row_comm_size) * static_cast<size_t>(i) +
static_cast<size_t>(row_comm_rank)
: static_cast<size_t>(col_comm_size) * static_cast<size_t>(row_comm_rank) +
static_cast<size_t>(i);
for (int i = 0; i < (partition.is_hypergraph_partitioned() ? col_comm_size : row_comm_size);
++i) {
auto vertex_partition_idx = partition.is_hypergraph_partitioned()
? static_cast<size_t>(i * row_comm_size + row_comm_rank)
: static_cast<size_t>(col_comm_rank * row_comm_size + i);
vertex_t major_first{};
vertex_t major_last{};
std::tie(major_first, major_last) = partition.get_vertex_partition_range(vertex_partition_idx);
auto p_offsets =
partition.is_hypergraph_partitioned()
? adj_matrix_partition_offsets[i]
: adj_matrix_partition_offsets[0] +
(major_first - partition.get_vertex_partition_first(col_comm_size * row_comm_rank));
(major_first - partition.get_vertex_partition_first(col_comm_rank * row_comm_size));
thrust::transform(rmm::exec_policy(handle.get_stream())->on(handle.get_stream()),
thrust::make_counting_iterator(vertex_t{0}),
thrust::make_counting_iterator(major_last - major_first),
local_degrees.data(),
[p_offsets] __device__(auto i) { return p_offsets[i + 1] - p_offsets[i]; });
row_comm.reduce(local_degrees.data(),
i == col_comm_rank ? degrees.data() : static_cast<edge_t *>(nullptr),
degrees.size(),
raft::comms::op_t::SUM,
col_comm_rank,
handle.get_stream());
if (partition.is_hypergraph_partitioned()) {
col_comm.reduce(local_degrees.data(),
i == col_comm_rank ? degrees.data() : static_cast<edge_t *>(nullptr),
static_cast<size_t>(major_last - major_first),
raft::comms::op_t::SUM,
i,
handle.get_stream());
} else {
row_comm.reduce(local_degrees.data(),
i == row_comm_rank ? degrees.data() : static_cast<edge_t *>(nullptr),
static_cast<size_t>(major_last - major_first),
raft::comms::op_t::SUM,
i,
handle.get_stream());
}
}

auto status = handle.get_comms().sync_stream(
handle.get_stream()); // this is neessary as local_degrees will become out-of-scope once this
// function returns.
raft::comms::status_t status{};
if (partition.is_hypergraph_partitioned()) {
status =
col_comm.sync_stream(handle.get_stream()); // this is neessary as local_degrees will become
// out-of-scope once this function returns.
} else {
status =
row_comm.sync_stream(handle.get_stream()); // this is neessary as local_degrees will become
// out-of-scope once this function returns.
}
CUGRAPH_EXPECTS(status == raft::comms::status_t::SUCCESS, "sync_stream() failure.");

return degrees;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/experimental/graph.cu
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ graph_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enable_if_
"is nullptr) or should not be nullptr (otherwise).");

CUGRAPH_EXPECTS((partition.is_hypergraph_partitioned() &&
(edgelists.size() == static_cast<size_t>(row_comm_size))) ||
(edgelists.size() == static_cast<size_t>(col_comm_size))) ||
(!(partition.is_hypergraph_partitioned()) && (edgelists.size() == 1)),
"Invalid API parameter: errneous edgelists.size().");

Expand Down

0 comments on commit 59fadef

Please sign in to comment.