Skip to content

Commit

Permalink
Merge branch 'branch-24.04' into mg-test-replicate-failures
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-rliu authored Mar 13, 2024
2 parents 8e2e672 + 120e5b8 commit 5d7f355
Show file tree
Hide file tree
Showing 50 changed files with 5,798 additions and 717 deletions.
14 changes: 10 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ endif()
# which should give us a better parallel schedule.

set(CUGRAPH_SOURCES
src/detail/shuffle_vertices.cu
src/utilities/shuffle_vertices.cu
src/detail/permute_range.cu
src/detail/shuffle_vertex_pairs.cu
src/utilities/shuffle_vertex_pairs.cu
src/detail/collect_local_vertex_values.cu
src/detail/groupby_and_count.cu
src/detail/collect_comm_wrapper.cu
Expand All @@ -197,8 +197,8 @@ set(CUGRAPH_SOURCES
src/community/detail/common_methods_sg.cu
src/community/detail/refine_sg.cu
src/community/detail/refine_mg.cu
src/community/detail/mis_sg.cu
src/community/detail/mis_mg.cu
src/community/detail/maximal_independent_moves_sg.cu
src/community/detail/maximal_independent_moves_mg.cu
src/detail/utility_wrappers.cu
src/structure/graph_view_mg.cu
src/structure/remove_self_loops.cu
Expand Down Expand Up @@ -295,6 +295,10 @@ set(CUGRAPH_SOURCES
src/tree/legacy/mst.cu
src/components/weakly_connected_components_sg.cu
src/components/weakly_connected_components_mg.cu
src/components/mis_sg.cu
src/components/mis_mg.cu
src/components/vertex_coloring_sg.cu
src/components/vertex_coloring_mg.cu
src/structure/create_graph_from_edgelist_sg.cu
src/structure/create_graph_from_edgelist_mg.cu
src/structure/symmetrize_edgelist_sg.cu
Expand Down Expand Up @@ -411,6 +415,8 @@ endif()
add_library(cugraph_c
src/c_api/resource_handle.cpp
src/c_api/array.cpp
src/c_api/degrees.cu
src/c_api/degrees_result.cpp
src/c_api/error.cpp
src/c_api/graph_sg.cpp
src/c_api/graph_mg.cpp
Expand Down
30 changes: 28 additions & 2 deletions cpp/include/cugraph/algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2340,15 +2340,41 @@ std::tuple<rmm::device_uvector<size_t>, rmm::device_uvector<vertex_t>> k_hop_nbr
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param rng_state The RngState instance holding pseudo-random number generator state.
* @return A device vector containing vertices found in the maximal independent set
* @return A device vector containing vertices in the maximal independent set.
*/

template <typename vertex_t, typename edge_t, bool multi_gpu>
rmm::device_uvector<vertex_t> maximal_independent_set(
raft::handle_t const& handle,
graph_view_t<vertex_t, edge_t, false, multi_gpu> const& graph_view,
raft::random::RngState& rng_state);

/*
* @brief Find a Greedy Vertex Coloring
*
* A vertex coloring is an assignment of colors or labels to each vertex of a graph so that
* no two adjacent vertices have the same color or label. Finding the minimum number of colors
* needed to color the vertices of a graph is an NP-hard problem and therefore for practical
* use cases greedy coloring is used. Here we provide an implementation of greedy vertex
* coloring based on maximal independent set.
* See
* https://research.nvidia.com/sites/default/files/pubs/2015-05_Parallel-Graph-Coloring/nvr-2015-001.pdf
* for further information.
*
* @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 multi_gpu Flag indicating whether template instantiation should target single-GPU (false)
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param rng_state The RngState instance holding pseudo-random number generator state.
* @return A device vector containing color for each vertex.
*/
template <typename vertex_t, typename edge_t, bool multi_gpu>
rmm::device_uvector<vertex_t> vertex_coloring(
raft::handle_t const& handle,
graph_view_t<vertex_t, edge_t, false, multi_gpu> const& graph_view,
raft::random::RngState& rng_state);

} // namespace cugraph

/**
Expand Down
63 changes: 63 additions & 0 deletions cpp/include/cugraph/graph_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,4 +1052,67 @@ remove_multi_edges(raft::handle_t const& handle,
std::optional<rmm::device_uvector<edge_type_t>>&& edgelist_edge_types,
bool keep_min_value_edge = false);

/**
* @brief Shuffle external vertex ids to the proper GPU.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
*
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param vertices List of vertex ids
* @return Vector of vertex ids mapped to this GPU.
*/
template <typename vertex_t>
rmm::device_uvector<vertex_t> shuffle_external_vertices(raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& vertices);

/**
* @brief Shuffle external vertex ids and values to the proper GPU.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam value_t Type of values. currently supported types are int32_t,
* int64_t, size_t, float and double.
*
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param vertices List of vertex ids
* @param values List of values
* @return Tuple of vectors storing vertex ids and values mapped to this GPU.
*/
template <typename vertex_t, typename value_t>
std::tuple<rmm::device_uvector<vertex_t>, rmm::device_uvector<value_t>>
shuffle_external_vertex_value_pairs(raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& vertices,
rmm::device_uvector<value_t>&& values);

/**
* @brief Shuffle external edges to the proper GPU.
*
* @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 weight. Currently float and double are supported.
*
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param edge_srcs List of source vertex ids
* @param edge_dsts List of destination vertex ids
* @param edge_weights Optional list of edge weights
* @param edge_ids Optional list of edge ids
* @param edge_types Optional list of edge types
* @return Tuple of vectors storing edge sources, destinations, optional weights,
* optional edge ids, optional edge types mapped to this GPU.
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename edge_type_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_t>>>
shuffle_external_edges(raft::handle_t const& handle,
rmm::device_uvector<vertex_t>&& edge_srcs,
rmm::device_uvector<vertex_t>&& edge_dsts,
std::optional<rmm::device_uvector<weight_t>>&& edge_weights,
std::optional<rmm::device_uvector<edge_t>>&& edge_ids,
std::optional<rmm::device_uvector<edge_type_t>>&& edge_types);

} // namespace cugraph
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
112 changes: 112 additions & 0 deletions cpp/include/cugraph_c/graph_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,118 @@ cugraph_error_code_t cugraph_allgather(const cugraph_resource_handle_t* handle,
cugraph_induced_subgraph_result_t** result,
cugraph_error_t** error);

/**
* @brief Opaque degree result type
*/
typedef struct {
int32_t align_;
} cugraph_degrees_result_t;

/**
* @brief Compute in degrees
*
* Compute the in degrees for the vertices in the graph.
*
* @param [in] handle Handle for accessing resources.
* @param [in] graph Pointer to graph
* @param [in] source_vertices Device array of vertices we want to compute in degrees for.
* @param [in] do_expensive_check A flag to run expensive checks for input arguments (if set to
* true)
* @param [out] result Opaque pointer to degrees result
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_in_degrees(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_view_t* source_vertices,
bool_t do_expensive_check,
cugraph_degrees_result_t** result,
cugraph_error_t** error);

/**
* @brief Compute out degrees
*
* Compute the out degrees for the vertices in the graph.
*
* @param [in] handle Handle for accessing resources.
* @param [in] graph Pointer to graph
* @param [in] source_vertices Device array of vertices we want to compute out degrees for.
* @param [in] do_expensive_check A flag to run expensive checks for input arguments (if set to
* true)
* @param [out] result Opaque pointer to degrees result
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_out_degrees(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_view_t* source_vertices,
bool_t do_expensive_check,
cugraph_degrees_result_t** result,
cugraph_error_t** error);

/**
* @brief Compute degrees
*
* Compute the degrees for the vertices in the graph.
*
* @param [in] handle Handle for accessing resources.
* @param [in] graph Pointer to graph
* @param [in] source_vertices Device array of vertices we want to compute degrees for.
* @param [in] do_expensive_check A flag to run expensive checks for input arguments (if set to
* true)
* @param [out] result Opaque pointer to degrees result
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_degrees(const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_view_t* source_vertices,
bool_t do_expensive_check,
cugraph_degrees_result_t** result,
cugraph_error_t** error);

/**
* @brief Get the vertex ids
*
* @param [in] degrees_result Opaque pointer to degree result
* @return type erased array view of vertex ids
*/
cugraph_type_erased_device_array_view_t* cugraph_degrees_result_get_vertices(
cugraph_degrees_result_t* degrees_result);

/**
* @brief Get the in degrees
*
* @param [in] degrees_result Opaque pointer to degree result
* @return type erased array view of vertex ids
*/
cugraph_type_erased_device_array_view_t* cugraph_degrees_result_get_in_degrees(
cugraph_degrees_result_t* degrees_result);

/**
* @brief Get the out degrees
*
* If the graph is symmetric, in degrees and out degrees will be equal (and
* will be stored in the same memory).
*
* @param [in] degrees_result Opaque pointer to degree result
* @return type erased array view of vertex ids
*/
cugraph_type_erased_device_array_view_t* cugraph_degrees_result_get_out_degrees(
cugraph_degrees_result_t* degrees_result);

/**
* @brief Free degree result
*
* @param [in] degrees_result Opaque pointer to degree result
*/
void cugraph_degrees_result_free(cugraph_degrees_result_t* degrees_result);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion cpp/src/c_api/abstract_functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace c_api {
struct abstract_functor {
// Move to abstract functor... make operator a void, add cugraph_graph_t * result to functor
// try that with instantiation questions
std::unique_ptr<cugraph_error_t> error_{std::make_unique<cugraph_error_t>("")};
std::unique_ptr<cugraph_error_t> error_ = {std::make_unique<cugraph_error_t>("")};
cugraph_error_code_t error_code_{CUGRAPH_SUCCESS};

void unsupported()
Expand Down
Loading

0 comments on commit 5d7f355

Please sign in to comment.