Graph Utility Wrappers#

template<typename new_type_t>
void copy_or_transform(
raft::device_span<new_type_t> output,
cugraph_type_erased_device_array_view_t const *input,
rmm::cuda_stream_view const &stream_view
)#

Cast the values of a cugraph_type_erased_device_array_view_t to the new type.

Template Parameters:

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

Parameters:
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 (currently supports int32_t, int64_t, float and double)

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 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 transform_not_equal(
raft::device_span<value_t> values,
raft::device_span<bool> result,
value_t compare,
rmm::cuda_stream_view const &stream_view
)#

Update the values of device span to 0 if it matches the compare value or 1.

Template Parameters:

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

Parameters:
  • values[out] device span with the values to compare

  • result[out] device span with the result of the comparison

  • compare[in] value to be querriedm in the values array

  • stream_view[in] stream view

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 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

template<typename InputIterator, typename OutputIterator>
OutputIterator inclusive_scan_impl(
rmm::exec_policy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result
)#

Inclusive prefix sum on [first, last) (out-of-line; default plus).

template<typename InputIterator, typename OutputIterator>
OutputIterator exclusive_scan_impl(
rmm::exec_policy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result
)#

Exclusive prefix sum on [first, last) (out-of-line; default plus and zero init).

template<typename InputIterator, typename OutputIterator, typename T>
OutputIterator exclusive_scan_impl(
rmm::exec_policy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result,
T init
)#

Exclusive prefix sum on [first, last) with initial value (out-of-line; default plus).

template<typename ExecutionPolicy, typename InputIterator, typename OutputIterator, typename BinaryFunction>
inline OutputIterator operator()(
ExecutionPolicy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result,
BinaryFunction binary_op
) const#

Inclusive prefix sum on [first, last) with a custom associative operator.

Similar to thrust::inclusive_scan.

template<typename ExecutionPolicy, typename InputIterator, typename OutputIterator, typename T, typename BinaryFunction>
inline OutputIterator operator()(
ExecutionPolicy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result,
T init,
BinaryFunction binary_op
) const#

Inclusive prefix sum on [first, last) with initial value and associative operator.

Similar to thrust::inclusive_scan.

template<typename ExecutionPolicy, typename InputIterator, typename OutputIterator, typename T>
inline OutputIterator operator()(
ExecutionPolicy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result,
T init
) const#

Exclusive prefix sum on [first, last) with initial value.

Similar to thrust::exclusive_scan.

template<typename ExecutionPolicy, typename InputIterator, typename OutputIterator, typename T, typename BinaryFunction>
inline OutputIterator operator()(
ExecutionPolicy const &policy,
InputIterator first,
InputIterator last,
OutputIterator result,
T init,
BinaryFunction binary_op
) const

Exclusive prefix sum on [first, last) with initial value and associative operator.

Similar to thrust::exclusive_scan.

template<typename InputIterator, typename OutputIterator, typename MapType>
void scatter_impl(
rmm::exec_policy const &policy,
InputIterator input_first,
InputIterator input_last,
MapType const *map_first,
OutputIterator output_first
)#

Scatter [input_first, input_last) to output_first using map_first (out-of-line implementation).

template<typename InputIterator, typename OutputIterator, typename MapIterator>
void scatter_shift_left_impl(
rmm::exec_policy const &policy,
InputIterator input_first,
InputIterator input_last,
MapIterator map_first,
OutputIterator output_first
)#

Scatter using a cuda::transform_iterator map with shift_left_t (out-of-line implementation).

template<typename ExecutionPolicy, typename ForwardIterator, typename T>
inline void operator()(
ExecutionPolicy const &policy,
ForwardIterator first,
ForwardIterator last,
T init
) const#

Fill [first, last) with consecutive integers starting at init.

Similar to thrust::sequence.

template<typename ExecutionPolicy, typename ForwardIterator, typename T>
inline void operator()(
ExecutionPolicy const &policy,
ForwardIterator first,
ForwardIterator last,
T init,
T step
) const#

Fill [first, last) with consecutive integers starting at init with step step.

Similar to thrust::sequence.

template<typename RandomAccessIterator>
void sort_impl(
rmm::exec_policy const &policy,
RandomAccessIterator first,
RandomAccessIterator last
)#

Sort elements in [first, last) on the given CUDA stream (out-of-line implementation).

template<typename ExecutionPolicy, typename RandomAccessIterator, typename Compare>
inline void operator()(
ExecutionPolicy const &policy,
RandomAccessIterator first,
RandomAccessIterator last,
Compare compare
) const#

Sort elements in [first, last) with a custom comparison.

Similar to thrust::sort.

template<typename RandomAccessIterator>
RandomAccessIterator unique_impl(
rmm::exec_policy const &policy,
RandomAccessIterator first,
RandomAccessIterator last
)#

Keep unique elements in [first, last) on the given CUDA stream (out-of-line implementation).

template<typename ExecutionPolicy, typename ForwardIterator, typename BinaryPredicate>
inline ForwardIterator operator()(
ExecutionPolicy const &policy,
ForwardIterator first,
ForwardIterator last,
BinaryPredicate pred
) const#

Keep unique elements in [first, last) with a custom equivalence predicate.

Similar to thrust::unique.

struct fill_t
#include <fill.hpp>

Assign value to every element in [first, last).

Similar to thrust::fill; dispatches to an explicitly instantiated backend for supported scalar ranges on rmm::exec_policy and rmm::exec_policy_nosync.

struct gather_t
#include <gather.hpp>

Gather from input_first into output_first using map_first.

Similar to thrust::gather; dispatches to an explicitly instantiated backend when policy is rmm::exec_policy or rmm::exec_policy_nosync, map_first is a pointer to size_t, int32_t, or int64_t, a cuda::transform_iterator over shift_left_t, or the input/output ranges are supported scalar or zip iterators.

struct inclusive_scan_t
#include <scan.hpp>

Inclusive prefix sum on [first, last).

Similar to thrust::inclusive_scan; dispatches to an explicitly instantiated backend when policy is rmm::exec_policy or rmm::exec_policy_nosync and first, last, and result are pointers to the same supported scalar type (size_t, int32_t, or int64_t).

struct exclusive_scan_t
#include <scan.hpp>

Exclusive prefix sum on [first, last).

Similar to thrust::exclusive_scan; dispatches to an explicitly instantiated backend when policy is rmm::exec_policy or rmm::exec_policy_nosync and first, last, and result are pointers to the same supported scalar type (size_t, int32_t, or int64_t).

struct scatter_t
#include <scatter.hpp>

Scatter [input_first, input_last) to output_first using map_first.

Similar to thrust::scatter; dispatches to an explicitly instantiated backend when policy is rmm::exec_policy or rmm::exec_policy_nosync, map_first is a pointer to size_t, int32_t, or int64_t, a cuda::transform_iterator over shift_left_t, or the input/output ranges are supported scalar or zip iterators.

struct sequence_t
#include <sequence.hpp>

Fill [first, last) with consecutive integers starting at 0.

Similar to thrust::sequence; dispatches to an explicitly instantiated backend for supported scalar ranges on rmm::exec_policy and rmm::exec_policy_nosync.

struct sort_t
#include <sort.hpp>

Sort elements in [first, last).

Similar to thrust::sort; dispatches to an explicitly instantiated backend for supported scalar and zip-iterator ranges.

struct unique_t
#include <unique.hpp>

Keep unique elements in [first, last).

Similar to thrust::unique; dispatches to an explicitly instantiated backend for supported scalar and zip-iterator ranges.