Graph Utility Wrappers#

template<typename value_t>
void uniform_random_fill(rmm::cuda_stream_view const &stream_view, value_t *d_value, size_t size, value_t min_value, value_t max_value, raft::random::RngState &rng_state)#

Fill a buffer with uniformly distributed random values.

Fills a buffer with uniformly distributed random values between the specified minimum and maximum values.

Template Parameters:

value_t – type of the value to operate on

Parameters:
  • stream_view[in] stream view

  • d_value[out] device array to fill

  • size[in] number of elements in array

  • min_value[in] minimum value (inclusive)

  • max_value[in] maximum value (exclusive)

  • rng_state[in] The RngState instance holding pseudo-random number generator state.

template<typename value_t>
void scalar_fill(raft::handle_t const &handle, value_t *d_value, size_t size, value_t value)#

Fill a buffer with a constant value.

Template Parameters:

value_t – type of the value to operate on

Parameters:
  • handle[in] RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • d_value[out] device array to fill

  • size[in] number of elements in array

  • value[in] value

template<typename value_t>
void sort_ints(raft::handle_t const &handle, raft::device_span<value_t> values)#

Sort a device span.

Template Parameters:

value_t – type of the value to operate on. Must be either int32_t or int64_t.

Parameters:
  • handle[in] RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • values[out] device span to sort

template<typename value_t>
size_t unique_ints(raft::handle_t const &handle, raft::device_span<value_t> values)#

Keep unique element from a device span.

Template Parameters:

value_t – type of the value to operate on. Must be either int32_t or int64_t.

Parameters:
  • handle[in] RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • values[in] device span of unique elements.

Returns:

the number of unique elements.

template<typename value_t>
void transform_increment_ints(raft::device_span<value_t> values, value_t value, rmm::cuda_stream_view const &stream_view)#

Increment the values of a device span by a constant value.

Template Parameters:

value_t – type of the value to operate on. Must be either int32_t or int64_t.

Parameters:
  • values[out] device span to update

  • value[in] value to be added to each element of the buffer

  • stream_view[in] stream view

template<typename value_t>
void sequence_fill(rmm::cuda_stream_view const &stream_view, value_t *d_value, size_t size, value_t start_value)#

Fill a buffer with a sequence of values.

Fills the buffer with the sequence: {start_value, start_value+1, start_value+2, …, start_value+size-1}

Similar to the function std::iota, wraps the function thrust::sequence

Template Parameters:

value_t – type of the value to operate on.

Parameters:
  • stream_view[in] stream view

  • d_value[out] device array to fill

  • size[in] number of elements in array

  • start_value[in] starting value for sequence

template<typename value_t>
void stride_fill(rmm::cuda_stream_view const &stream_view, value_t *d_value, size_t size, value_t start_value, value_t stride)#

Fill a buffer with a sequence of values with the input stride.

Fills the buffer with the sequence with the input stride: {start_value, start_value+stride, start_value+stride*2, …, start_value+stride*(size-1)}

Template Parameters:

value_t – type of the value to operate on

Parameters:
  • stream_view[in] stream view

  • d_value[out] device array to fill

  • size[in] number of elements in array

  • start_value[in] starting value for sequence

  • stride[in] input stride

template<typename vertex_t>
vertex_t compute_maximum_vertex_id(rmm::cuda_stream_view const &stream_view, vertex_t const *d_edgelist_srcs, vertex_t const *d_edgelist_dsts, size_t num_edges)#

Compute the maximum vertex id of an edge list.

max(d_edgelist_srcs.max(), d_edgelist_dsts.max())

Template Parameters:

vertex_t – vertex type

Parameters:
  • stream_view[in] stream view

  • d_edgelist_srcs[in] device array storing edge source IDs

  • d_edgelist_dsts[in] device array storing edge destination IDs

  • num_edges[in] number of edges in the input source & destination arrays

  • the – maximum value occurring in the edge list

template<typename vertex_t>
vertex_t compute_maximum_vertex_id(rmm::cuda_stream_view const &stream_view, rmm::device_uvector<vertex_t> const &d_edgelist_srcs, rmm::device_uvector<vertex_t> const &d_edgelist_dsts)#

Compute the maximum vertex id of an edge list.

max(d_edgelist_srcs.max(), d_edgelist_dsts.max())

Template Parameters:

vertex_t – vertex type

Parameters:
  • stream_view[in] stream view

  • d_edgelist_srcs[in] device array storing source IDs

  • d_edgelist_dsts[in] device array storing destination IDs

  • the – maximum value occurring in the edge list

template<typename vertex_t, typename edge_t>
std::tuple<rmm::device_uvector<vertex_t>, rmm::device_uvector<edge_t>> filter_degree_0_vertices(raft::handle_t const &handle, rmm::device_uvector<vertex_t> &&d_vertices, rmm::device_uvector<edge_t> &&d_out_degs)#

Filter zero degree vertices from this frontier.

Template Parameters:
  • vertex_t – vertex type

  • edge_t – edge type

Parameters:
  • handle – RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • d_vertices – The input list of vertices

  • d_out_degs – The output degree of each vertex

Returns:

A tuple of device vectors the updated list of vertices and output degrees

template<typename data_t>
bool is_sorted(raft::handle_t const &handle, raft::device_span<data_t> span)#

Check if device span is sorted.

Template Parameters:

data_t – type of data in span

Parameters:
  • handle – RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • span – The span of data to check

Returns:

true if sorted, false if not sorted

template<typename data_t>
bool is_equal(raft::handle_t const &handle, raft::device_span<data_t> span1, raft::device_span<data_t> span2)#

Check if two device spans are equal. Returns true if every element in the spans are equal.

Template Parameters:

data_t – type of data in span

Parameters:
  • handle – RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • span1 – The span of data to compare

  • span2 – The span of data to compare

Returns:

true if equal, false if not equal

template<typename data_t>
size_t count_values(raft::handle_t const &handle, raft::device_span<data_t const> span, data_t value)#

Count the number of times a value appears in a span.

Template Parameters:

data_t – type of data in span

Parameters:
  • handle – RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and handles to various CUDA libraries) to run graph algorithms.

  • span – The span of data to compare

  • value – The value to count

Returns:

The count of how many instances of that value occur