Skip to content

Commit

Permalink
respond to PR comment, remove debug print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHastings committed Dec 4, 2023
1 parent c2612e3 commit e265578
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 143 deletions.
1 change: 0 additions & 1 deletion cpp/include/cugraph/mtmg/detail/device_shared_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class device_shared_wrapper_t {
objects_.insert(std::make_pair(local_rank, std::move(obj)));
}

public:
/**
* @brief Get reference to an object for a particular thread
*
Expand Down
23 changes: 21 additions & 2 deletions cpp/include/cugraph/mtmg/graph_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,27 @@ namespace mtmg {
* @brief Graph view for each GPU
*/
template <typename vertex_t, typename edge_t, bool store_transposed, bool multi_gpu>
using graph_view_t = detail::device_shared_wrapper_t<
cugraph::graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu>>;
class graph_view_t : public detail::device_shared_wrapper_t<
cugraph::graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu>> {
public:
/**
* @brief Get the vertex_partition_view for this graph
*/
vertex_partition_view_t<vertex_t, multi_gpu> get_vertex_partition_view(
cugraph::mtmg::handle_t const& handle) const
{
return this->get(handle).local_vertex_partition_view();
}

/**
* @brief Get the vertex_partition_view for this graph
*/
std::vector<vertex_t> get_vertex_partition_range_lasts(
cugraph::mtmg::handle_t const& handle) const
{
return this->get(handle).vertex_partition_range_lasts();
}
};

} // namespace mtmg
} // namespace cugraph
5 changes: 3 additions & 2 deletions cpp/include/cugraph/mtmg/vertex_result_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ class vertex_result_view_t : public detail::device_shared_device_span_t<result_t
/**
* @brief Gather results from specified vertices into a device vector
*/
template <typename vertex_t, typename edge_t, bool store_transposed, bool multi_gpu>
template <typename vertex_t, bool multi_gpu>
rmm::device_uvector<result_t> gather(
handle_t const& handle,
raft::device_span<vertex_t const> vertices,
cugraph::mtmg::graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu> const& graph_view,
std::vector<vertex_t> const& vertex_partition_range_lasts,
cugraph::vertex_partition_view_t<vertex_t, multi_gpu> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<vertex_t>>& renumber_map_view);
};

Expand Down
139 changes: 39 additions & 100 deletions cpp/src/mtmg/vertex_result.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ namespace cugraph {
namespace mtmg {

template <typename result_t>
template <typename vertex_t, typename edge_t, bool store_transposed, bool multi_gpu>
template <typename vertex_t, bool multi_gpu>
rmm::device_uvector<result_t> vertex_result_view_t<result_t>::gather(
handle_t const& handle,
raft::device_span<vertex_t const> vertices,
cugraph::mtmg::graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu> const& graph_view,
std::vector<vertex_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<vertex_t, multi_gpu> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<vertex_t>>& renumber_map_view)
{
auto this_gpu_graph_view = graph_view.get(handle);

rmm::device_uvector<vertex_t> local_vertices(vertices.size(), handle.get_stream());
rmm::device_uvector<int> vertex_gpu_ids(vertices.size(), handle.get_stream());
rmm::device_uvector<size_t> vertex_pos(vertices.size(), handle.get_stream());
Expand All @@ -47,11 +46,11 @@ rmm::device_uvector<result_t> vertex_result_view_t<result_t>::gather(
cugraph::detail::sequence_fill(
handle.get_stream(), vertex_pos.data(), vertex_pos.size(), size_t{0});

rmm::device_uvector<vertex_t> d_vertex_partition_range_lasts(
this_gpu_graph_view.vertex_partition_range_lasts().size(), handle.get_stream());
rmm::device_uvector<vertex_t> d_vertex_partition_range_lasts(vertex_partition_range_lasts.size(),
handle.get_stream());
raft::update_device(d_vertex_partition_range_lasts.data(),
this_gpu_graph_view.vertex_partition_range_lasts().data(),
this_gpu_graph_view.vertex_partition_range_lasts().size(),
vertex_partition_range_lasts.data(),
vertex_partition_range_lasts.size(),
handle.get_stream());

if (renumber_map_view) {
Expand All @@ -60,8 +59,8 @@ rmm::device_uvector<result_t> vertex_result_view_t<result_t>::gather(
local_vertices.data(),
local_vertices.size(),
renumber_map_view->get(handle).data(),
this_gpu_graph_view.local_vertex_partition_range_first(),
this_gpu_graph_view.local_vertex_partition_range_last());
vertex_partition_view.local_vertex_partition_range_first(),
vertex_partition_view.local_vertex_partition_range_last());
}

auto const major_comm_size =
Expand Down Expand Up @@ -89,8 +88,8 @@ rmm::device_uvector<result_t> vertex_result_view_t<result_t>::gather(

auto& wrapped = this->get(handle);

auto vertex_partition = vertex_partition_device_view_t<vertex_t, multi_gpu>(
this_gpu_graph_view.local_vertex_partition_view());
auto vertex_partition =
vertex_partition_device_view_t<vertex_t, multi_gpu>(vertex_partition_view);

auto iter =
thrust::make_transform_iterator(local_vertices.begin(), [vertex_partition] __device__(auto v) {
Expand Down Expand Up @@ -130,145 +129,85 @@ rmm::device_uvector<result_t> vertex_result_view_t<result_t>::gather(
template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, true, false> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, true, false> const& graph_view,
std::vector<int32_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int32_t, false> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, true, false> const& graph_view,
std::vector<int64_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int64_t, false> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, true, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, true, true> const& graph_view,
std::vector<int32_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int32_t, true> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, true, true> const& graph_view,
std::vector<int64_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int64_t, true> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
template rmm::device_uvector<double> vertex_result_view_t<double>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, false, false> const& graph_view,
std::vector<int32_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int32_t, false> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, false, false> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
template rmm::device_uvector<double> vertex_result_view_t<double>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, false, false> const& graph_view,
std::vector<int64_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int64_t, false> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, false, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
template rmm::device_uvector<double> vertex_result_view_t<double>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, false, true> const& graph_view,
std::vector<int32_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int32_t, true> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<float> vertex_result_view_t<float>::gather(
template rmm::device_uvector<double> vertex_result_view_t<double>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, false, true> const& graph_view,
std::vector<int64_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int64_t, true> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, true, false> const& graph_view,
std::vector<int32_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int32_t, false> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, true, false> const& graph_view,
std::vector<int32_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int32_t, true> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int64_t> vertex_result_view_t<int64_t>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, true, false> const& graph_view,
std::vector<int64_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int64_t, false> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, true, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, true, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int64_t> vertex_result_view_t<int64_t>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, true, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, false, false> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, false, false> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int64_t> vertex_result_view_t<int64_t>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, false, false> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int32_t, false, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int32_t> vertex_result_view_t<int32_t>::gather(
handle_t const& handle,
raft::device_span<int32_t const> vertices,
cugraph::mtmg::graph_view_t<int32_t, int64_t, false, true> const& graph_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int32_t>>& renumber_map_view);

template rmm::device_uvector<int64_t> vertex_result_view_t<int64_t>::gather(
handle_t const& handle,
raft::device_span<int64_t const> vertices,
cugraph::mtmg::graph_view_t<int64_t, int64_t, false, true> const& graph_view,
std::vector<int64_t> const& vertex_partition_range_lasts,
vertex_partition_view_t<int64_t, true> vertex_partition_view,
std::optional<cugraph::mtmg::renumber_map_view_t<int64_t>>& renumber_map_view);

} // namespace mtmg
Expand Down
3 changes: 2 additions & 1 deletion cpp/tests/mtmg/multi_node_threaded_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ class Tests_Multithreaded
auto d_my_pageranks = pageranks_view.gather(
thread_handle,
raft::device_span<vertex_t const>{d_my_vertex_list.data(), d_my_vertex_list.size()},
graph_view,
graph_view.get_vertex_partition_range_lasts(thread_handle),
graph_view.get_vertex_partition_view(thread_handle),
renumber_map_view);

std::vector<result_t> my_pageranks(d_my_pageranks.size());
Expand Down
3 changes: 2 additions & 1 deletion cpp/tests/mtmg/threaded_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ class Tests_Multithreaded
auto d_my_pageranks = pageranks_view.gather(
thread_handle,
raft::device_span<vertex_t const>{d_my_vertex_list.data(), d_my_vertex_list.size()},
graph_view,
graph_view.get_vertex_partition_range_lasts(thread_handle),
graph_view.get_vertex_partition_view(thread_handle),
renumber_map_view);

std::vector<result_t> my_pageranks(d_my_pageranks.size());
Expand Down
Loading

0 comments on commit e265578

Please sign in to comment.