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

Add new primitives: compute_in|out_degrees, compute_in|out_weight_sums to graph_view_t #1394

Merged
merged 10 commits into from
Feb 25, 2021
Prev Previous commit
Next Next commit
add SG version of compute_major_degrees
  • Loading branch information
seunghwak committed Feb 9, 2021
commit 5919ddceeecb09d49eb05483f8de89292d15bcd3
16 changes: 16 additions & 0 deletions cpp/include/experimental/detail/graph_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <rmm/device_uvector.hpp>

#include <thrust/sort.h>
#include <thrust/tabulate.h>
#include <thrust/transform.h>
#include <cuco/detail/hash_functions.cuh>

Expand Down Expand Up @@ -134,6 +135,21 @@ rmm::device_uvector<edge_t> compute_major_degrees(
return compute_major_degrees(handle, tmp_offsets, partition);
}

// compute the numbers of nonzeros in rows (of the graph adjacency matrix, if store_transposed =
// false) or columns (of the graph adjacency matrix, if store_transposed = true)
template <typename vertex_t, typename edge_t>
rmm::device_uvector<edge_t> compute_major_degrees(raft::handle_t const &handle,
edge_t const *offsets,
vertex_t number_of_vertices)
{
rmm::device_uvector<edge_t> degrees(number_of_vertices, handle.get_stream());
thrust::tabulate(rmm::exec_policy(handle.get_stream())->on(handle.get_stream()),
degrees.begin(),
degrees.end(),
[offsets] __device__(auto i) { return offsets[i + 1] - offsets[i]; });
return std::move(degrees);
}

template <typename vertex_t, typename edge_t>
struct degree_from_offsets_t {
edge_t const *offsets{nullptr};
Expand Down