21 #include <boost/range/combine.hpp>
22 #include <cugraph/algorithms.hpp>
23 #include <cugraph/graph.hpp>
24 #include <cugraph/graph_functions.hpp>
25 #include <cugraph/graph_view.hpp>
26 #include <cugraph/partition_manager.hpp>
27 #include <cugraph/utilities/error.hpp>
28 #include <raft/cudart_utils.h>
29 #include <raft/handle.hpp>
32 #define CUDA_RT_CALL(call) \
34 cudaError_t cudaStatus = call; \
35 if (cudaSuccess != cudaStatus) { \
37 "ERROR: CUDA RT call \"%s\" in line %d of file %s failed with " \
39 #call, __LINE__, __FILE__, cudaGetErrorString(cudaStatus), \
43 #endif // CUDA_RT_CALL
45 template <
typename vertex_t,
typename edge_t,
typename weight_t>
47 std::vector<vertex_t>& colIndices,
48 std::vector<weight_t>& edgeWeights,
49 std::vector<vertex_t>& trackLabels,
55 ACTS_VERBOSE(
"edge size: " << rowIndices.size() <<
" " << colIndices.size());
56 raft::handle_t handle{stream};
58 cugraph::graph_t<vertex_t, edge_t, weight_t, false, false>
graph(handle);
61 vertex_t maxVertexID_row =
62 *std::max_element(rowIndices.begin(), rowIndices.end());
63 vertex_t maxVertexID_col =
64 *std::max_element(colIndices.begin(), colIndices.end());
65 vertex_t maxVertex = std::max(maxVertexID_row, maxVertexID_col);
67 vertex_t number_of_vertices = maxVertex;
68 rmm::device_uvector<vertex_t> d_vertices(number_of_vertices,
70 std::vector<vertex_t> vertex_idx(number_of_vertices);
71 for (vertex_t
idx = 0;
idx < number_of_vertices;
idx++) {
75 rmm::device_uvector<vertex_t> src_v(rowIndices.size(), handle.get_stream());
76 rmm::device_uvector<vertex_t> dst_v(colIndices.size(), handle.get_stream());
77 rmm::device_uvector<weight_t> weights_v(edgeWeights.size(),
80 raft::update_device(src_v.data(), rowIndices.data(), rowIndices.size(),
82 raft::update_device(dst_v.data(), colIndices.data(), colIndices.size(),
84 raft::update_device(weights_v.data(), edgeWeights.data(), edgeWeights.size(),
86 raft::update_device(d_vertices.data(), vertex_idx.data(), vertex_idx.size(),
89 std::tie(graph, std::ignore) =
90 cugraph::create_graph_from_edgelist<vertex_t, edge_t, weight_t,
false,
93 std::move(weights_v), cugraph::graph_properties_t{
true,
false},
96 auto graph_view = graph.view();
97 CUDA_TRY(cudaDeviceSynchronize());
99 rmm::device_uvector<vertex_t> d_components(
100 graph_view.get_number_of_vertices(), handle.get_stream());
103 cugraph::weakly_connected_components(handle, graph_view, d_components.data());
105 ACTS_VERBOSE(
"number of components: " << d_components.size());
106 raft::update_host(trackLabels.data(), d_components.data(),
107 d_components.size(), handle.get_stream());