Skip to content

Commit

Permalink
Enable edge masking in the remaining primitives (#4186)
Browse files Browse the repository at this point in the history
This PR will update all the remaining primitives to support edge masking.

This PR pulls updates from #4126 and better be reviewed/merged after PR #4126.

Authors:
  - Seunghwa Kang (https://github.com/seunghwak)

Approvers:
  - Chuck Hastings (https://github.com/ChuckHastings)
  - Naim (https://github.com/naimnv)
  - Joseph Nke (https://github.com/jnke2016)

URL: #4186
  • Loading branch information
seunghwak authored Mar 13, 2024
1 parent fdc6aa5 commit 120e5b8
Show file tree
Hide file tree
Showing 15 changed files with 2,189 additions and 457 deletions.
4 changes: 2 additions & 2 deletions cpp/include/cugraph/graph_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ class graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu, std::enable_if
major_value_range_start_offset);
}

// FIXME: deprecated, replaced with copmute_number_of_edges (which works with or without edge
// FIXME: deprecated, replaced with compute_number_of_edges (which works with or without edge
// masking)
edge_t number_of_edges() const
{
Expand Down Expand Up @@ -923,7 +923,7 @@ class graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu, std::enable_if
offsets_, indices_, this->number_of_vertices());
}

// FIXME: deprecated, replaced with copmute_number_of_edges (which works with or without edge
// FIXME: deprecated, replaced with compute_number_of_edges (which works with or without edge
// masking)
edge_t number_of_edges() const
{
Expand Down
8 changes: 8 additions & 0 deletions cpp/include/cugraph/utilities/misc_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ thrust::optional<T> to_thrust_optional(std::optional<T> val)
return ret;
}

template <typename T>
std::optional<T> to_std_optional(thrust::optional<T> val)
{
std::optional<T> ret{std::nullopt};
if (val) { ret = *val; }
return ret;
}

template <typename idx_t, typename offset_t>
rmm::device_uvector<idx_t> expand_sparse_offsets(raft::device_span<offset_t const> offsets,
idx_t base_idx,
Expand Down
11 changes: 7 additions & 4 deletions cpp/src/prims/detail/nbr_intersection.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/optional.h>
#include <thrust/reduce.h>
#include <thrust/remove.h>
#include <thrust/scan.h>
#include <thrust/set_operations.h>
Expand Down Expand Up @@ -1232,9 +1233,11 @@ nbr_intersection(raft::handle_t const& handle,
rx_v_pair_nbr_intersection_sizes.size() + 1, handle.get_stream());
rx_v_pair_nbr_intersection_offsets.set_element_to_zero_async(size_t{0},
handle.get_stream());
auto size_first = thrust::make_transform_iterator(
rx_v_pair_nbr_intersection_sizes.begin(), cugraph::detail::typecast_t<edge_t, size_t>{});
thrust::inclusive_scan(handle.get_thrust_policy(),
rx_v_pair_nbr_intersection_sizes.begin(),
rx_v_pair_nbr_intersection_sizes.end(),
size_first,
size_first + rx_v_pair_nbr_intersection_sizes.size(),
rx_v_pair_nbr_intersection_offsets.begin() + 1);

rx_v_pair_nbr_intersection_indices.resize(
Expand Down Expand Up @@ -1344,8 +1347,8 @@ nbr_intersection(raft::handle_t const& handle,
}

thrust::inclusive_scan(handle.get_thrust_policy(),
rx_v_pair_nbr_intersection_sizes.begin(),
rx_v_pair_nbr_intersection_sizes.end(),
size_first,
size_first + rx_v_pair_nbr_intersection_sizes.size(),
rx_v_pair_nbr_intersection_offsets.begin() + 1);

std::vector<size_t> h_rx_v_pair_lasts(rx_v_pair_counts.size());
Expand Down
529 changes: 375 additions & 154 deletions cpp/src/prims/per_v_transform_reduce_dst_key_aggregated_outgoing_e.cuh

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "prims/detail/nbr_intersection.cuh"
#include "prims/property_op_utils.cuh"

#include <cugraph/detail/decompress_edge_partition.cuh>
#include <cugraph/edge_partition_device_view.cuh>
#include <cugraph/edge_partition_endpoint_property_device_view.cuh>
#include <cugraph/edge_src_dst_property.hpp>
Expand Down Expand Up @@ -130,7 +131,9 @@ std::tuple<rmm::device_uvector<vertex_t>, ValueBuffer> sort_and_reduce_by_vertic
vertices.end(),
get_dataframe_buffer_begin(value_buffer),
reduced_vertices.begin(),
get_dataframe_buffer_begin(reduced_value_buffer));
get_dataframe_buffer_begin(reduced_value_buffer),
thrust::equal_to<vertex_t>{},
property_op<value_t, thrust::plus>{});

vertices.resize(size_t{0}, handle.get_stream());
resize_dataframe_buffer(value_buffer, size_t{0}, handle.get_stream());
Expand Down Expand Up @@ -201,14 +204,14 @@ struct accumulate_vertex_property_t {
* @param graph_view Non-owning graph object.
* @param edge_src_value_input Wrapper used to access source input property values (for the edge
* sources assigned to this process in multi-GPU). Use either cugraph::edge_src_property_t::view()
* (if @p e_op needs to access source property values) or cugraph::edge_src_dummy_property_t::view()
* (if @p e_op does not access source property values). Use update_edge_src_property to fill the
* wrapper.
* (if @p intersection_op needs to access source property values) or
* cugraph::edge_src_dummy_property_t::view() (if @p intersection_op does not access source property
* values). Use update_edge_src_property to fill the wrapper.
* @param edge_dst_value_input Wrapper used to access destination input property values (for the
* edge destinations assigned to this process in multi-GPU). Use either
* cugraph::edge_dst_property_t::view() (if @p e_op needs to access destination property values) or
* cugraph::edge_dst_dummy_property_t::view() (if @p e_op does not access destination property
* values). Use update_edge_dst_property to fill the wrapper.
* cugraph::edge_dst_property_t::view() (if @p intersection_op needs to access destination property
* values) or cugraph::edge_dst_dummy_property_t::view() (if @p intersection_op does not access
* destination property values). Use update_edge_dst_property to fill the wrapper.
* @param intersection_op quinary operator takes edge source, edge destination, property values for
* the source, property values for the destination, and a list of vertices in the intersection of
* edge source & destination vertices' destination neighbors and returns a thrust::tuple of three
Expand Down Expand Up @@ -260,8 +263,6 @@ void transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v(
typename EdgeDstValueInputWrapper::value_iterator,
typename EdgeDstValueInputWrapper::value_type>>;

CUGRAPH_EXPECTS(!graph_view.has_edge_mask(), "unimplemented.");

if (do_expensive_check) {
// currently, nothing to do.
}
Expand All @@ -272,6 +273,7 @@ void transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v(
init);

auto edge_mask_view = graph_view.edge_mask_view();

for (size_t i = 0; i < graph_view.number_of_local_edge_partitions(); ++i) {
auto edge_partition =
edge_partition_device_view_t<vertex_t, edge_t, GraphViewType::is_multi_gpu>(
Expand Down Expand Up @@ -484,7 +486,9 @@ void transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v(
merged_vertices.end(),
get_dataframe_buffer_begin(merged_value_buffer),
reduced_vertices.begin(),
get_dataframe_buffer_begin(reduced_value_buffer));
get_dataframe_buffer_begin(reduced_value_buffer),
thrust::equal_to<vertex_t>{},
property_op<T, thrust::plus>{});
merged_vertices.resize(size_t{0}, handle.get_stream());
merged_vertices.shrink_to_fit(handle.get_stream());
resize_dataframe_buffer(merged_value_buffer, size_t{0}, handle.get_stream());
Expand Down
Loading

0 comments on commit 120e5b8

Please sign in to comment.