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 support to create temporal graphs #4819

Merged
merged 16 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
# Copyright (c) 2018-2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -396,6 +396,14 @@ set(CUGRAPH_SOURCES
src/structure/create_graph_from_edgelist_sg_v32_e32.cu
src/structure/create_graph_from_edgelist_mg_v64_e64.cu
src/structure/create_graph_from_edgelist_mg_v32_e32.cu
src/structure/create_graph_from_edgelist_sg_v64_e64_t32.cu
src/structure/create_graph_from_edgelist_sg_v32_e32_t32.cu
src/structure/create_graph_from_edgelist_mg_v64_e64_t32.cu
src/structure/create_graph_from_edgelist_mg_v32_e32_t32.cu
src/structure/create_graph_from_edgelist_sg_v64_e64_t64.cu
src/structure/create_graph_from_edgelist_sg_v32_e32_t64.cu
src/structure/create_graph_from_edgelist_mg_v64_e64_t64.cu
src/structure/create_graph_from_edgelist_mg_v32_e32_t64.cu
src/structure/symmetrize_edgelist_sg_v64_e64.cu
src/structure/symmetrize_edgelist_sg_v32_e32.cu
src/structure/symmetrize_edgelist_mg_v64_e64.cu
Expand Down
50 changes: 42 additions & 8 deletions cpp/include/cugraph/detail/shuffle_wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace detail {
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @tparam edge_type_t Type of edge type identifiers. Needs to be an integral type.
* @tparam edge_time_t The type of the edge time stamp. Needs to be an integral type.
*
* @param[in] handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator,
* and handles to various CUDA libraries) to run graph algorithms.
Expand All @@ -51,24 +52,34 @@ namespace detail {
* @param[in] weights Optional vector of vertex pair weight values.
* @param[in] edge_ids Optional vector of vertex pair edge id values.
* @param[in] edge_types Optional vector of vertex pair edge type values.
* @param[in] edge_start_times Optional vector of vertex pair edge start time values.
* @param[in] edge_end_times Optional vector of vertex pair edge end time values.
*
* @return Tuple of vectors storing shuffled major vertices, minor vertices and optional weights,
* edge ids and edge types
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename edge_type_id_t>
template <typename vertex_t,
typename edge_t,
typename weight_t,
typename edge_type_t,
typename edge_time_t>
std::tuple<rmm::device_uvector<vertex_t>,
rmm::device_uvector<vertex_t>,
std::optional<rmm::device_uvector<weight_t>>,
std::optional<rmm::device_uvector<edge_t>>,
std::optional<rmm::device_uvector<edge_type_id_t>>,
std::optional<rmm::device_uvector<edge_type_t>>,
std::optional<rmm::device_uvector<edge_time_t>>,
std::optional<rmm::device_uvector<edge_time_t>>,
std::vector<size_t>>
shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& majors,
rmm::device_uvector<vertex_t>&& minors,
std::optional<rmm::device_uvector<weight_t>>&& weights,
std::optional<rmm::device_uvector<edge_t>>&& edge_ids,
std::optional<rmm::device_uvector<edge_type_id_t>>&& edge_types);
std::optional<rmm::device_uvector<edge_type_t>>&& edge_types,
std::optional<rmm::device_uvector<edge_time_t>>&& edge_start_times,
std::optional<rmm::device_uvector<edge_time_t>>&& edge_end_times);

/**
* @brief Shuffle internal (i.e. renumbered) vertex pairs (which can be edge end points) to their
Expand All @@ -78,6 +89,7 @@ shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @tparam edge_type_t Type of edge type identifiers. Needs to be an integral type.
* @tparam edge_time_t Type of edge time. Needs to be an integral type.
*
* @param[in] handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator,
* and handles to various CUDA libraries) to run graph algorithms.
Expand All @@ -89,27 +101,37 @@ shuffle_ext_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
* @param[in] weights Optional vector of vertex pair weight values.
* @param[in] edge_ids Optional vector of vertex pair edge id values.
* @param[in] edge_types Optional vector of vertex pair edge type values.
* @param[in] edge_start_times Optional vector of vertex pair edge start time values.
* @param[in] edge_end_times Optional vector of vertex pair edge end time values.
*
* @param[in] vertex_partition_range_lasts Vector of each GPU's vertex partition range's last
* (exclusive) vertex ID.
*
* @return Tuple of vectors storing shuffled major vertices, minor vertices and optional weights,
* edge ids and edge types and rx counts
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename edge_type_id_t>
template <typename vertex_t,
typename edge_t,
typename weight_t,
typename edge_type_t,
typename edge_time_t>
std::tuple<rmm::device_uvector<vertex_t>,
rmm::device_uvector<vertex_t>,
std::optional<rmm::device_uvector<weight_t>>,
std::optional<rmm::device_uvector<edge_t>>,
std::optional<rmm::device_uvector<edge_type_id_t>>,
std::optional<rmm::device_uvector<edge_type_t>>,
std::optional<rmm::device_uvector<edge_time_t>>,
std::optional<rmm::device_uvector<edge_time_t>>,
std::vector<size_t>>
shuffle_int_vertex_pairs_with_values_to_local_gpu_by_edge_partitioning(
raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& majors,
rmm::device_uvector<vertex_t>&& minors,
std::optional<rmm::device_uvector<weight_t>>&& weights,
std::optional<rmm::device_uvector<edge_t>>&& edge_ids,
std::optional<rmm::device_uvector<edge_type_id_t>>&& edge_types,
std::optional<rmm::device_uvector<edge_type_t>>&& edge_types,
std::optional<rmm::device_uvector<edge_time_t>>&& edge_start_times,
std::optional<rmm::device_uvector<edge_time_t>>&& edge_end_times,
std::vector<vertex_t> const& vertex_partition_range_lasts);

/**
Expand Down Expand Up @@ -218,7 +240,10 @@ shuffle_int_vertex_value_pairs_to_local_gpu_by_vertex_partitioning(
* ID for an edge.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @tparam edge_type_t Type of edge type identifiers. Needs to be an integral type.
* @tparam edge_time_t Type of edge time. Needs to be an integral type.
*
* @param[in] handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator,
* and handles to various CUDA libraries) to run graph algorithms.
Expand All @@ -227,7 +252,10 @@ shuffle_int_vertex_value_pairs_to_local_gpu_by_vertex_partitioning(
* @param[in,out] d_edgelist_minors Vertex IDs for destinations (if we are internally storing edges
* in the sparse 2D matrix using sources as major indices) or sources (otherwise)
* @param[in,out] d_edgelist_weights Optional edge weights
ChuckHastings marked this conversation as resolved.
Show resolved Hide resolved
* @param[in,out] d_edgelist_id_type_pairs Optional edge (ID, type) pairs
* @param[in,out] d_edgelist_ids Optional edge ids
* @param[in,out] d_edgelist_types Optional edge types
* @param[in,out] d_edgelist_start_times Optional edge start times
* @param[in,out] d_edgelist_end_times Optional edge end times
* @param[in] groupby_and_count_local_partition_by_minor If set to true, groupby and count edges
* based on (local partition ID, GPU ID) pairs (where GPU IDs are computed by applying the
* compute_gpu_id_from_vertex_t function to the minor vertex ID). If set to false, groupby and count
Expand All @@ -237,14 +265,20 @@ shuffle_int_vertex_value_pairs_to_local_gpu_by_vertex_partitioning(
* groupby_and_count_local_partition is false) or in each segment with the same (local partition ID,
* GPU ID) pair.
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename edge_type_t>
template <typename vertex_t,
typename edge_t,
typename weight_t,
typename edge_type_t,
typename edge_time_t>
rmm::device_uvector<size_t> groupby_and_count_edgelist_by_local_partition_id(
raft::handle_t const& handle,
rmm::device_uvector<vertex_t>& d_edgelist_majors,
rmm::device_uvector<vertex_t>& d_edgelist_minors,
std::optional<rmm::device_uvector<weight_t>>& d_edgelist_weights,
std::optional<rmm::device_uvector<edge_t>>& d_edgelist_edge_ids,
std::optional<rmm::device_uvector<edge_type_t>>& d_edgelist_edge_types,
std::optional<rmm::device_uvector<edge_time_t>>& d_edgelist_edge_start_times,
std::optional<rmm::device_uvector<edge_time_t>>& d_edgelist_edge_end_times,
bool groupby_and_count_local_partition_by_minor = false);

/**
Expand Down
Loading
Loading