From e2ac46790a4272fceaf7bdd68794b23b5f79307d Mon Sep 17 00:00:00 2001 From: Conor Hoekstra <36027403+codereport@users.noreply.github.com> Date: Wed, 7 Jul 2021 10:13:50 -0400 Subject: [PATCH] Updating Clang Version to 11.0.0 (#1688) Follow up PR to: https://github.com/rapidsai/cudf/pull/6695. Performing the same changes but for `rapidsai/cugraph` Depends on: https://github.com/rapidsai/integration/pull/304 Authors: - Conor Hoekstra (https://github.com/codereport) Approvers: - Dillon Cullinan (https://github.com/dillon-cullinan) - Chuck Hastings (https://github.com/ChuckHastings) URL: https://github.com/rapidsai/cugraph/pull/1688 --- conda/environments/cugraph_dev_cuda11.0.yml | 4 +- conda/environments/cugraph_dev_cuda11.1.yml | 4 +- conda/environments/cugraph_dev_cuda11.2.yml | 4 +- cpp/.clang-format | 20 +- cpp/include/cugraph/algorithms.hpp | 262 +++++++++--------- cpp/include/cugraph/compute_partition.cuh | 18 +- cpp/include/cugraph/dendrogram.hpp | 14 +- .../experimental/detail/graph_utils.cuh | 28 +- cpp/include/cugraph/experimental/graph.hpp | 48 ++-- cpp/include/cugraph/functions.hpp | 6 +- cpp/include/cugraph/graph_generators.hpp | 46 +-- cpp/include/cugraph/internals.hpp | 6 +- cpp/include/cugraph/legacy/graph.hpp | 88 +++--- .../cugraph/matrix_partition_device_view.cuh | 16 +- .../copy_v_transform_reduce_in_out_nbr.cuh | 72 ++--- ...orm_reduce_by_adj_matrix_row_col_key_e.cuh | 22 +- .../cugraph/prims/transform_reduce_e.cuh | 72 ++--- .../update_frontier_v_push_if_out_nbr.cuh | 2 +- cpp/include/cugraph/prims/vertex_frontier.cuh | 4 +- .../cugraph/utilities/collect_comm.cuh | 4 +- .../cugraph/utilities/host_scalar_comm.cuh | 4 +- .../cugraph/utilities/path_retrieval.hpp | 20 +- .../cugraph/utilities/shuffle_comm.cuh | 12 +- .../cugraph/vertex_partition_device.cuh | 112 ++++++++ .../cugraph/vertex_partition_device_view.cuh | 4 +- cpp/scripts/run-clang-format.py | 5 +- cpp/src/centrality/betweenness_centrality.cu | 94 +++---- cpp/src/centrality/betweenness_centrality.cuh | 62 ++--- .../betweenness_centrality_kernels.cuh | 40 +-- cpp/src/centrality/katz_centrality.cu | 6 +- cpp/src/community/ecg.cu | 26 +- cpp/src/community/egonet.cu | 48 ++-- .../community/extract_subgraph_by_vertex.cu | 26 +- cpp/src/community/flatten_dendrogram.cuh | 12 +- cpp/src/community/ktruss.cu | 14 +- cpp/src/community/leiden.cu | 18 +- cpp/src/community/leiden.cuh | 20 +- cpp/src/community/louvain.cu | 174 ++++++------ cpp/src/community/louvain.cuh | 82 +++--- cpp/src/community/spectral_clustering.cu | 76 ++--- cpp/src/community/triangles_counting.cu | 104 +++---- cpp/src/components/connectivity.cu | 12 +- cpp/src/components/utils.h | 4 +- cpp/src/components/weak_cc.cuh | 54 ++-- .../components/weakly_connected_components.cu | 120 ++++---- cpp/src/converters/COOtoCSR.cu | 46 +-- cpp/src/converters/COOtoCSR.cuh | 64 ++--- cpp/src/converters/permute_graph.cuh | 14 +- cpp/src/cores/core_number.cu | 50 ++-- cpp/src/experimental/bfs.cu | 110 ++++---- cpp/src/experimental/coarsen_graph.cu | 215 +++++++------- cpp/src/experimental/graph.cu | 22 +- cpp/src/experimental/induced_subgraph.cu | 114 ++++---- cpp/src/experimental/katz_centrality.cu | 112 ++++---- cpp/src/experimental/louvain.cuh | 38 +-- cpp/src/experimental/pagerank.cu | 6 +- cpp/src/experimental/sssp.cu | 116 ++++---- cpp/src/generators/generator_tools.cu | 107 +++---- cpp/src/layout/barnes_hut.hpp | 61 ++-- cpp/src/layout/bh_kernels.hpp | 120 ++++---- cpp/src/layout/exact_fa2.hpp | 30 +- cpp/src/layout/exact_repulsion.hpp | 24 +- cpp/src/layout/fa2_kernels.hpp | 140 +++++----- cpp/src/layout/force_atlas2.cu | 36 +-- cpp/src/linear_assignment/hungarian.cu | 118 ++++---- cpp/src/link_analysis/gunrock_hits.cpp | 16 +- cpp/src/link_prediction/jaccard.cu | 134 ++++----- cpp/src/link_prediction/overlap.cu | 138 ++++----- cpp/src/sampling/random_walks.cuh | 2 +- cpp/src/sampling/rw_traversals.hpp | 10 +- cpp/src/structure/graph.cu | 20 +- cpp/src/traversal/bfs.cu | 84 +++--- cpp/src/traversal/bfs.cuh | 46 +-- cpp/src/traversal/bfs_kernels.cuh | 186 ++++++------- cpp/src/traversal/mg/bfs.cuh | 22 +- cpp/src/traversal/mg/common_utils.cuh | 128 ++++----- cpp/src/traversal/mg/frontier_expand.cuh | 12 +- .../traversal/mg/frontier_expand_kernels.cuh | 56 ++-- .../traversal/mg/vertex_binning_kernels.cuh | 38 +-- cpp/src/traversal/sssp.cu | 36 +-- cpp/src/traversal/traversal_common.cuh | 4 +- cpp/src/traversal/tsp.cu | 36 +-- cpp/src/traversal/tsp.hpp | 50 ++-- cpp/src/traversal/tsp_solver.hpp | 74 ++--- cpp/src/traversal/tsp_utils.hpp | 7 +- cpp/src/traversal/two_hop_neighbors.cu | 14 +- cpp/src/traversal/two_hop_neighbors.cuh | 26 +- cpp/src/tree/mst.cu | 24 +- cpp/src/utilities/cython.cu | 2 +- cpp/src/utilities/graph_utils.cuh | 76 ++--- cpp/src/utilities/high_res_timer.hpp | 8 +- cpp/src/utilities/path_retrieval.cu | 74 ++--- cpp/src/utilities/spmv_1D.cu | 20 +- .../centrality/betweenness_centrality_test.cu | 90 +++--- .../edge_betweenness_centrality_test.cu | 58 ++-- cpp/tests/centrality/katz_centrality_test.cu | 4 +- cpp/tests/community/ecg_test.cpp | 4 +- cpp/tests/community/mg_louvain_helper.cu | 67 +++-- cpp/tests/community/mg_louvain_helper.hpp | 28 +- cpp/tests/community/mg_louvain_test.cpp | 4 +- .../mg_weakly_connected_components_test.cpp | 4 +- cpp/tests/components/scc_test.cu | 3 +- cpp/tests/experimental/mg_bfs_test.cpp | 4 +- .../experimental/mg_katz_centrality_test.cpp | 14 +- cpp/tests/experimental/mg_sssp_test.cpp | 4 +- cpp/tests/generators/erdos_renyi_test.cpp | 2 +- cpp/tests/layout/force_atlas2_test.cu | 3 +- cpp/tests/layout/knn.h | 8 +- cpp/tests/layout/trust_worthiness.h | 15 +- cpp/tests/linear_assignment/hungarian_test.cu | 4 +- cpp/tests/pagerank/mg_pagerank_test.cpp | 4 +- cpp/tests/sampling/random_walks_profiling.cu | 4 +- cpp/tests/traversal/bfs_ref.h | 18 +- cpp/tests/traversal/bfs_test.cu | 8 +- cpp/tests/utilities/base_fixture.hpp | 14 +- cpp/tests/utilities/cxxopts.hpp | 26 +- cpp/tests/utilities/device_comm_wrapper.cu | 18 +- cpp/tests/utilities/device_comm_wrapper.hpp | 2 +- 118 files changed, 2697 insertions(+), 2488 deletions(-) create mode 100644 cpp/include/cugraph/vertex_partition_device.cuh diff --git a/conda/environments/cugraph_dev_cuda11.0.yml b/conda/environments/cugraph_dev_cuda11.0.yml index 91e640ea50b..7d38f73eb1f 100644 --- a/conda/environments/cugraph_dev_cuda11.0.yml +++ b/conda/environments/cugraph_dev_cuda11.0.yml @@ -19,8 +19,8 @@ dependencies: - ucx-proc=*=gpu - scipy - networkx>=2.5.1 -- clang=8.0.1 -- clang-tools=8.0.1 +- clang=11.0.0 +- clang-tools=11.0.0 - cmake>=3.20.1 - python>=3.6,<3.9 - notebook>=0.5.0 diff --git a/conda/environments/cugraph_dev_cuda11.1.yml b/conda/environments/cugraph_dev_cuda11.1.yml index 39fb0ca5811..26ecf04f0ea 100644 --- a/conda/environments/cugraph_dev_cuda11.1.yml +++ b/conda/environments/cugraph_dev_cuda11.1.yml @@ -19,8 +19,8 @@ dependencies: - ucx-proc=*=gpu - scipy - networkx>=2.5.1 -- clang=8.0.1 -- clang-tools=8.0.1 +- clang=11.0.0 +- clang-tools=11.0.0 - cmake>=3.20.1 - python>=3.6,<3.9 - notebook>=0.5.0 diff --git a/conda/environments/cugraph_dev_cuda11.2.yml b/conda/environments/cugraph_dev_cuda11.2.yml index 80fdf63a8e9..11e826d784d 100644 --- a/conda/environments/cugraph_dev_cuda11.2.yml +++ b/conda/environments/cugraph_dev_cuda11.2.yml @@ -19,8 +19,8 @@ dependencies: - ucx-proc=*=gpu - scipy - networkx>=2.5.1 -- clang=8.0.1 -- clang-tools=8.0.1 +- clang=11.0.0 +- clang-tools=11.0.0 - cmake>=3.20.1 - python>=3.6,<3.9 - notebook>=0.5.0 diff --git a/cpp/.clang-format b/cpp/.clang-format index 6f48df58b74..0c05436e922 100644 --- a/cpp/.clang-format +++ b/cpp/.clang-format @@ -6,16 +6,22 @@ Language: Cpp AccessModifierOffset: -1 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: true +AlignConsecutiveBitFields: true AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: true AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: true -AllowShortLoopsOnASingleLine: true +AllowShortLambdasOnASingleLine: true +AllowShortLoopsOnASingleLine: false # This is deprecated AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None @@ -40,14 +46,14 @@ BraceWrapping: SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false +BreakAfterJavaFieldAnnotations: false BreakBeforeBinaryOperators: None BreakBeforeBraces: WebKit BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false +BreakInheritanceList: BeforeColon BreakStringLiterals: true ColumnLimit: 100 CommentPragmas: '^ IWYU pragma:' @@ -57,7 +63,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 2 ContinuationIndentWidth: 2 Cpp11BracedListStyle: true -DerivePointerAlignment: true +DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true @@ -139,18 +145,20 @@ SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 SpacesInAngles: false +SpacesInConditionalStatement: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp11 +Standard: c++17 StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION # Be consistent with indent-width, even for people who use tab for indentation! TabWidth: 2 UseTab: Never - diff --git a/cpp/include/cugraph/algorithms.hpp b/cpp/include/cugraph/algorithms.hpp index 12776f1f8c7..2e0d0f055c8 100644 --- a/cpp/include/cugraph/algorithms.hpp +++ b/cpp/include/cugraph/algorithms.hpp @@ -45,7 +45,7 @@ namespace cugraph { * caller */ template -void jaccard(legacy::GraphCSRView const &graph, WT const *weights, WT *result); +void jaccard(legacy::GraphCSRView const& graph, WT const* weights, WT* result); /** * @brief Compute jaccard similarity coefficient for selected vertex pairs @@ -69,12 +69,12 @@ void jaccard(legacy::GraphCSRView const &graph, WT const *weights, W * caller */ template -void jaccard_list(legacy::GraphCSRView const &graph, - WT const *weights, +void jaccard_list(legacy::GraphCSRView const& graph, + WT const* weights, ET num_pairs, - VT const *first, - VT const *second, - WT *result); + VT const* first, + VT const* second, + WT* result); /** * @brief Compute overlap coefficient for all vertices in the graph @@ -95,7 +95,7 @@ void jaccard_list(legacy::GraphCSRView const &graph, * caller */ template -void overlap(legacy::GraphCSRView const &graph, WT const *weights, WT *result); +void overlap(legacy::GraphCSRView const& graph, WT const* weights, WT* result); /** * @brief Compute overlap coefficient for select pairs of vertices @@ -119,12 +119,12 @@ void overlap(legacy::GraphCSRView const &graph, WT const *weights, W * caller */ template -void overlap_list(legacy::GraphCSRView const &graph, - WT const *weights, +void overlap_list(legacy::GraphCSRView const& graph, + WT const* weights, ET num_pairs, - VT const *first, - VT const *second, - WT *result); + VT const* first, + VT const* second, + WT* result); /** * @@ -180,12 +180,12 @@ void overlap_list(legacy::GraphCSRView const &graph, * */ template -void force_atlas2(raft::handle_t const &handle, - legacy::GraphCOOView &graph, - float *pos, +void force_atlas2(raft::handle_t const& handle, + legacy::GraphCOOView& graph, + float* pos, const int max_iter = 500, - float *x_start = nullptr, - float *y_start = nullptr, + float* x_start = nullptr, + float* y_start = nullptr, bool outbound_attraction_distribution = true, bool lin_log_mode = false, bool prevent_overlapping = false, @@ -197,7 +197,7 @@ void force_atlas2(raft::handle_t const &handle, bool strong_gravity_mode = false, const float gravity = 1.0, bool verbose = false, - internals::GraphBasedDimRedCallback *callback = nullptr); + internals::GraphBasedDimRedCallback* callback = nullptr); /** * @brief Finds an approximate solution to the traveling salesperson problem (TSP). @@ -225,17 +225,17 @@ void force_atlas2(raft::handle_t const &handle, * @param[out] route Device array containing the returned route. * */ -float traveling_salesperson(raft::handle_t const &handle, - int const *vtx_ptr, - float const *x_pos, - float const *y_pos, +float traveling_salesperson(raft::handle_t const& handle, + int const* vtx_ptr, + float const* x_pos, + float const* y_pos, int nodes, int restarts, bool beam_search, int k, int nstart, bool verbose, - int *route); + int* route); /** * @brief Compute betweenness centrality for a graph @@ -275,14 +275,14 @@ float traveling_salesperson(raft::handle_t const &handle, * */ template -void betweenness_centrality(const raft::handle_t &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void betweenness_centrality(const raft::handle_t& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalized = true, bool endpoints = false, - weight_t const *weight = nullptr, + weight_t const* weight = nullptr, vertex_t k = 0, - vertex_t const *vertices = nullptr); + vertex_t const* vertices = nullptr); /** * @brief Compute edge betweenness centrality for a graph @@ -319,13 +319,13 @@ void betweenness_centrality(const raft::handle_t &handle, * */ template -void edge_betweenness_centrality(const raft::handle_t &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void edge_betweenness_centrality(const raft::handle_t& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalized = true, - weight_t const *weight = nullptr, + weight_t const* weight = nullptr, vertex_t k = 0, - vertex_t const *vertices = nullptr); + vertex_t const* vertices = nullptr); enum class cugraph_cc_t { CUGRAPH_WEAK = 0, ///> Weakly Connected Components @@ -363,9 +363,9 @@ enum class cugraph_cc_t { * associated with vertex id i. */ template -void connected_components(legacy::GraphCSRView const &graph, +void connected_components(legacy::GraphCSRView const& graph, cugraph_cc_t connectivity_type, - VT *labels); + VT* labels); /** * @brief Compute k truss for a graph @@ -393,9 +393,9 @@ void connected_components(legacy::GraphCSRView const &graph, */ template std::unique_ptr> k_truss_subgraph( - legacy::GraphCOOView const &graph, + legacy::GraphCOOView const& graph, int k, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** * @brief Compute the Katz centrality for the nodes of the graph G @@ -430,8 +430,8 @@ std::unique_ptr> k_truss_subgraph( * @param[in] normalized If True normalize the resulting katz centrality values */ template -void katz_centrality(legacy::GraphCSRView const &graph, - result_t *result, +void katz_centrality(legacy::GraphCSRView const& graph, + result_t* result, double alpha, int max_iter, double tol, @@ -448,7 +448,7 @@ void katz_centrality(legacy::GraphCSRView const &graph, */ /* ----------------------------------------------------------------------------*/ template -void core_number(legacy::GraphCSRView const &graph, VT *core_number); +void core_number(legacy::GraphCSRView const& graph, VT* core_number); /** * @brief Compute K Core of the graph G @@ -473,12 +473,12 @@ void core_number(legacy::GraphCSRView const &graph, VT *core_number) */ template std::unique_ptr> k_core( - legacy::GraphCOOView const &graph, + legacy::GraphCOOView const& graph, int k, - VT const *vertex_id, - VT const *core_number, + VT const* vertex_id, + VT const* core_number, VT num_vertex_ids, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** * @brief Find all 2-hop neighbors in the graph @@ -499,7 +499,7 @@ std::unique_ptr> k_core( */ template std::unique_ptr> get_two_hop_neighbors( - legacy::GraphCSRView const &graph); + legacy::GraphCSRView const& graph); /** * @Synopsis Performs a single source shortest path traversal of a graph starting from a vertex. @@ -526,9 +526,9 @@ std::unique_ptr> get_two_hop_neighbors( * */ template -void sssp(legacy::GraphCSRView const &graph, - WT *distances, - VT *predecessors, +void sssp(legacy::GraphCSRView const& graph, + WT* distances, + VT* predecessors, const VT source_vertex); // FIXME: Internally distances is of int (signed 32-bit) data type, but current @@ -567,11 +567,11 @@ void sssp(legacy::GraphCSRView const &graph, * */ template -void bfs(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - VT *distances, - VT *predecessors, - double *sp_counters, +void bfs(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + VT* distances, + VT* predecessors, + double* sp_counters, const VT start_vertex, bool directed = true, bool mg_batch = false); @@ -601,11 +601,11 @@ void bfs(raft::handle_t const &handle, * assigned to that worker */ template -weight_t hungarian(raft::handle_t const &handle, - legacy::GraphCOOView const &graph, +weight_t hungarian(raft::handle_t const& handle, + legacy::GraphCOOView const& graph, vertex_t num_workers, - vertex_t const *workers, - vertex_t *assignments); + vertex_t const* workers, + vertex_t* assignments); /** * @brief Compute Hungarian algorithm on a weighted bipartite graph @@ -634,11 +634,11 @@ weight_t hungarian(raft::handle_t const &handle, * in reducing weights to zero. */ template -weight_t hungarian(raft::handle_t const &handle, - legacy::GraphCOOView const &graph, +weight_t hungarian(raft::handle_t const& handle, + legacy::GraphCOOView const& graph, vertex_t num_workers, - vertex_t const *workers, - vertex_t *assignments, + vertex_t const* workers, + vertex_t* assignments, weight_t epsilon); /** @@ -673,9 +673,9 @@ weight_t hungarian(raft::handle_t const &handle, */ template std::pair louvain( - raft::handle_t const &handle, - graph_view_t const &graph_view, - typename graph_view_t::vertex_type *clustering, + raft::handle_t const& handle, + graph_view_t const& graph_view, + typename graph_view_t::vertex_type* clustering, size_t max_level = 100, typename graph_view_t::weight_type resolution = typename graph_view_t::weight_type{1}); @@ -711,8 +711,8 @@ std::pair louvain( template std::pair>, typename graph_view_t::weight_type> -louvain(raft::handle_t const &handle, - graph_view_t const &graph_view, +louvain(raft::handle_t const& handle, + graph_view_t const& graph_view, size_t max_level = 100, typename graph_view_t::weight_type resolution = typename graph_view_t::weight_type{1}); @@ -735,10 +735,10 @@ louvain(raft::handle_t const &handle, * */ template -void flatten_dendrogram(raft::handle_t const &handle, - graph_view_t const &graph_view, - Dendrogram const &dendrogram, - typename graph_view_t::vertex_type *clustering); +void flatten_dendrogram(raft::handle_t const& handle, + graph_view_t const& graph_view, + Dendrogram const& dendrogram, + typename graph_view_t::vertex_type* clustering); /** * @brief Leiden implementation @@ -775,9 +775,9 @@ void flatten_dendrogram(raft::handle_t const &handle, * 2) modularity of the returned clustering */ template -std::pair leiden(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - vertex_t *clustering, +std::pair leiden(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + vertex_t* clustering, size_t max_iter = 100, weight_t resolution = weight_t{1}); @@ -807,11 +807,11 @@ std::pair leiden(raft::handle_t const &handle, * written */ template -void ecg(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, +void ecg(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, weight_t min_weight, vertex_t ensemble_size, - vertex_t *clustering); + vertex_t* clustering); /** * @brief Generate edges in a minimum spanning forest of an undirected weighted graph. @@ -835,9 +835,9 @@ void ecg(raft::handle_t const &handle, */ template std::unique_ptr> minimum_spanning_tree( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); namespace triangle { /** @@ -856,7 +856,7 @@ namespace triangle { * @return The number of triangles */ template -uint64_t triangle_count(legacy::GraphCSRView const &graph); +uint64_t triangle_count(legacy::GraphCSRView const& graph); } // namespace triangle namespace subgraph { @@ -882,7 +882,7 @@ namespace subgraph { */ template std::unique_ptr> extract_subgraph_vertex( - legacy::GraphCOOView const &graph, VT const *vertices, VT num_vertices); + legacy::GraphCOOView const& graph, VT const* vertices, VT num_vertices); } // namespace subgraph /** @@ -909,14 +909,14 @@ std::unique_ptr> extract_subgraph_vertex( namespace ext_raft { template -void balancedCutClustering(legacy::GraphCSRView const &graph, +void balancedCutClustering(legacy::GraphCSRView const& graph, VT num_clusters, VT num_eigen_vects, WT evs_tolerance, int evs_max_iter, WT kmean_tolerance, int kmean_max_iter, - VT *clustering); + VT* clustering); /** * @brief Wrapper function for Nvgraph spectral modularity maximization algorithm @@ -940,14 +940,14 @@ void balancedCutClustering(legacy::GraphCSRView const &graph, * be stored */ template -void spectralModularityMaximization(legacy::GraphCSRView const &graph, +void spectralModularityMaximization(legacy::GraphCSRView const& graph, VT n_clusters, VT n_eig_vects, WT evs_tolerance, int evs_max_iter, WT kmean_tolerance, int kmean_max_iter, - VT *clustering); + VT* clustering); /** * @brief Wrapper function for Nvgraph clustering modularity metric @@ -966,10 +966,10 @@ void spectralModularityMaximization(legacy::GraphCSRView const &grap * @param[out] score Pointer to a float in which the result will be written */ template -void analyzeClustering_modularity(legacy::GraphCSRView const &graph, +void analyzeClustering_modularity(legacy::GraphCSRView const& graph, int n_clusters, - VT const *clustering, - WT *score); + VT const* clustering, + WT* score); /** * @brief Wrapper function for Nvgraph clustering edge cut metric @@ -988,10 +988,10 @@ void analyzeClustering_modularity(legacy::GraphCSRView const &graph, * @param[out] score Pointer to a float in which the result will be written */ template -void analyzeClustering_edge_cut(legacy::GraphCSRView const &graph, +void analyzeClustering_edge_cut(legacy::GraphCSRView const& graph, int n_clusters, - VT const *clustering, - WT *score); + VT const* clustering, + WT* score); /** * @brief Wrapper function for Nvgraph clustering ratio cut metric @@ -1010,10 +1010,10 @@ void analyzeClustering_edge_cut(legacy::GraphCSRView const &graph, * @param[out] score Pointer to a float in which the result will be written */ template -void analyzeClustering_ratio_cut(legacy::GraphCSRView const &graph, +void analyzeClustering_ratio_cut(legacy::GraphCSRView const& graph, int n_clusters, - VT const *clustering, - WT *score); + VT const* clustering, + WT* score); } // namespace ext_raft @@ -1046,13 +1046,13 @@ namespace gunrock { * */ template -void hits(legacy::GraphCSRView const &graph, +void hits(legacy::GraphCSRView const& graph, int max_iter, WT tolerance, - WT const *starting_value, + WT const* starting_value, bool normalized, - WT *hubs, - WT *authorities); + WT* hubs, + WT* authorities); } // namespace gunrock @@ -1080,11 +1080,11 @@ namespace dense { * which vertex id (job) is assigned to that worker */ template -weight_t hungarian(raft::handle_t const &handle, - weight_t const *costs, +weight_t hungarian(raft::handle_t const& handle, + weight_t const* costs, vertex_t num_rows, vertex_t num_columns, - vertex_t *assignments); + vertex_t* assignments); /** * @brief Compute Hungarian algorithm on a weighted bipartite graph @@ -1111,11 +1111,11 @@ weight_t hungarian(raft::handle_t const &handle, * in reducing weights to zero. */ template -weight_t hungarian(raft::handle_t const &handle, - weight_t const *costs, +weight_t hungarian(raft::handle_t const& handle, + weight_t const* costs, vertex_t num_rows, vertex_t num_columns, - vertex_t *assignments, + vertex_t* assignments, weight_t epsilon); } // namespace dense @@ -1153,10 +1153,10 @@ namespace experimental { * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). */ template -void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t *distances, - vertex_t *predecessors, +void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t* distances, + vertex_t* predecessors, vertex_t source_vertex, bool direction_optimizing = false, vertex_t depth_limit = std::numeric_limits::max(), @@ -1188,10 +1188,10 @@ void bfs(raft::handle_t const &handle, * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). */ template -void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - weight_t *distances, - vertex_t *predecessors, +void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + weight_t* distances, + vertex_t* predecessors, vertex_t source_vertex, weight_t cutoff = std::numeric_limits::max(), bool do_expensive_check = false); @@ -1238,13 +1238,13 @@ void sssp(raft::handle_t const &handle, * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). */ template -void pagerank(raft::handle_t const &handle, - graph_view_t const &graph_view, - std::optional precomputed_vertex_out_weight_sums, - std::optional personalization_vertices, - std::optional personalization_values, +void pagerank(raft::handle_t const& handle, + graph_view_t const& graph_view, + std::optional precomputed_vertex_out_weight_sums, + std::optional personalization_vertices, + std::optional personalization_values, std::optional personalization_vector_size, - result_t *pageranks, + result_t* pageranks, result_t alpha, result_t epsilon, size_t max_iterations = 500, @@ -1288,10 +1288,10 @@ void pagerank(raft::handle_t const &handle, * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). */ template -void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - result_t const *betas, - result_t *katz_centralities, +void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + result_t const* betas, + result_t* katz_centralities, result_t alpha, result_t beta, result_t epsilon, @@ -1324,9 +1324,9 @@ std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t *source_vertex, +extract_ego(raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t* source_vertex, vertex_t n_subgraphs, vertex_t radius); @@ -1360,9 +1360,9 @@ template std::tuple, rmm::device_uvector, rmm::device_uvector> -random_walks(raft::handle_t const &handle, - graph_t const &graph, - typename graph_t::vertex_type const *ptr_d_start, +random_walks(raft::handle_t const& handle, + graph_t const& graph, + typename graph_t::vertex_type const* ptr_d_start, index_t num_paths, index_t max_depth, bool use_padding = false); @@ -1385,9 +1385,9 @@ random_walks(raft::handle_t const &handle, */ template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t* components, bool do_expensive_check = false); } // namespace experimental diff --git a/cpp/include/cugraph/compute_partition.cuh b/cpp/include/cugraph/compute_partition.cuh index 6405d239adc..b8ad0fc19ab 100644 --- a/cpp/include/cugraph/compute_partition.cuh +++ b/cpp/include/cugraph/compute_partition.cuh @@ -39,20 +39,20 @@ class compute_partition_t { using graph_view_t = graph_view_type; using vertex_t = typename graph_view_type::vertex_type; - compute_partition_t(raft::handle_t const &handle, graph_view_t const &graph_view) + compute_partition_t(raft::handle_t const& handle, graph_view_t const& graph_view) : vertex_partition_offsets_v_(0, handle.get_stream()) { init(handle, graph_view); } private: - template * = nullptr> - void init(raft::handle_t const &handle, graph_view_t const &graph_view) + template * = nullptr> + void init(raft::handle_t const& handle, graph_view_t const& graph_view) { } - template * = nullptr> - void init(raft::handle_t const &handle, graph_view_t const &graph_view) + template * = nullptr> + void init(raft::handle_t const& handle, graph_view_t const& graph_view) { auto partition = graph_view.get_partition(); row_size_ = partition.get_row_size(); @@ -81,7 +81,7 @@ class compute_partition_t { */ class vertex_device_view_t { public: - vertex_device_view_t(vertex_t const *d_vertex_partition_offsets, int size) + vertex_device_view_t(vertex_t const* d_vertex_partition_offsets, int size) : d_vertex_partition_offsets_(d_vertex_partition_offsets), size_(size) { } @@ -106,13 +106,13 @@ class compute_partition_t { } private: - vertex_t const *d_vertex_partition_offsets_; + vertex_t const* d_vertex_partition_offsets_; int size_; }; class edge_device_view_t { public: - edge_device_view_t(vertex_t const *d_vertex_partition_offsets, + edge_device_view_t(vertex_t const* d_vertex_partition_offsets, int row_size, int col_size, int size) @@ -158,7 +158,7 @@ class compute_partition_t { } private: - vertex_t const *d_vertex_partition_offsets_; + vertex_t const* d_vertex_partition_offsets_; int row_size_; int col_size_; int size_; diff --git a/cpp/include/cugraph/dendrogram.hpp b/cpp/include/cugraph/dendrogram.hpp index 2640944dc09..beebec4fd3f 100644 --- a/cpp/include/cugraph/dendrogram.hpp +++ b/cpp/include/cugraph/dendrogram.hpp @@ -28,7 +28,7 @@ class Dendrogram { void add_level(vertex_t first_index, vertex_t num_verts, rmm::cuda_stream_view stream_view, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()) + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { level_ptr_.push_back( std::make_unique>(num_verts, stream_view, mr)); @@ -39,21 +39,21 @@ class Dendrogram { size_t num_levels() const { return level_ptr_.size(); } - vertex_t const *get_level_ptr_nocheck(size_t level) const { return level_ptr_[level]->data(); } + vertex_t const* get_level_ptr_nocheck(size_t level) const { return level_ptr_[level]->data(); } - vertex_t *get_level_ptr_nocheck(size_t level) { return level_ptr_[level]->data(); } + vertex_t* get_level_ptr_nocheck(size_t level) { return level_ptr_[level]->data(); } size_t get_level_size_nocheck(size_t level) const { return level_ptr_[level]->size(); } vertex_t get_level_first_index_nocheck(size_t level) const { return level_first_index_[level]; } - vertex_t const *current_level_begin() const { return get_level_ptr_nocheck(current_level()); } + vertex_t const* current_level_begin() const { return get_level_ptr_nocheck(current_level()); } - vertex_t const *current_level_end() const { return current_level_begin() + current_level_size(); } + vertex_t const* current_level_end() const { return current_level_begin() + current_level_size(); } - vertex_t *current_level_begin() { return get_level_ptr_nocheck(current_level()); } + vertex_t* current_level_begin() { return get_level_ptr_nocheck(current_level()); } - vertex_t *current_level_end() { return current_level_begin() + current_level_size(); } + vertex_t* current_level_end() { return current_level_begin() + current_level_size(); } size_t current_level_size() const { return get_level_size_nocheck(current_level()); } diff --git a/cpp/include/cugraph/experimental/detail/graph_utils.cuh b/cpp/include/cugraph/experimental/detail/graph_utils.cuh index e9f86eb9d62..c384e2842ab 100644 --- a/cpp/include/cugraph/experimental/detail/graph_utils.cuh +++ b/cpp/include/cugraph/experimental/detail/graph_utils.cuh @@ -41,14 +41,14 @@ namespace detail { // false) or columns (of the graph adjacency matrix, if store_transposed = true) template rmm::device_uvector compute_major_degrees( - raft::handle_t const &handle, - std::vector const &adj_matrix_partition_offsets, - partition_t const &partition) + raft::handle_t const& handle, + std::vector const& adj_matrix_partition_offsets, + partition_t const& partition) { - auto &row_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); + auto& row_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); auto const row_comm_rank = row_comm.get_rank(); auto const row_comm_size = row_comm.get_size(); - auto &col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); + auto& col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); auto const col_comm_rank = col_comm.get_rank(); auto const col_comm_size = col_comm.get_size(); @@ -75,7 +75,7 @@ rmm::device_uvector compute_major_degrees( local_degrees.data(), [p_offsets] __device__(auto i) { return p_offsets[i + 1] - p_offsets[i]; }); col_comm.reduce(local_degrees.data(), - i == col_comm_rank ? degrees.data() : static_cast(nullptr), + i == col_comm_rank ? degrees.data() : static_cast(nullptr), static_cast(major_last - major_first), raft::comms::op_t::SUM, i, @@ -89,24 +89,24 @@ rmm::device_uvector compute_major_degrees( // false) or columns (of the graph adjacency matrix, if store_transposed = true) template rmm::device_uvector compute_major_degrees( - raft::handle_t const &handle, - std::vector> const &adj_matrix_partition_offsets, - partition_t const &partition) + raft::handle_t const& handle, + std::vector> const& adj_matrix_partition_offsets, + partition_t const& partition) { // we can avoid creating this temporary with "if constexpr" supported from C++17 - std::vector tmp_offsets(adj_matrix_partition_offsets.size(), nullptr); + std::vector tmp_offsets(adj_matrix_partition_offsets.size(), nullptr); std::transform(adj_matrix_partition_offsets.begin(), adj_matrix_partition_offsets.end(), tmp_offsets.begin(), - [](auto const &offsets) { return offsets.data(); }); + [](auto const& offsets) { return offsets.data(); }); return compute_major_degrees(handle, tmp_offsets, partition); } // compute the numbers of nonzeros in rows (of the graph adjacency matrix, if store_transposed = // false) or columns (of the graph adjacency matrix, if store_transposed = true) template -rmm::device_uvector compute_major_degrees(raft::handle_t const &handle, - edge_t const *offsets, +rmm::device_uvector compute_major_degrees(raft::handle_t const& handle, + edge_t const* offsets, vertex_t number_of_vertices) { rmm::device_uvector degrees(number_of_vertices, handle.get_stream()); @@ -119,7 +119,7 @@ rmm::device_uvector compute_major_degrees(raft::handle_t const &handle, template struct degree_from_offsets_t { - edge_t const *offsets{nullptr}; + edge_t const* offsets{nullptr}; __device__ edge_t operator()(vertex_t v) { return offsets[v + 1] - offsets[v]; } }; diff --git a/cpp/include/cugraph/experimental/graph.hpp b/cpp/include/cugraph/experimental/graph.hpp index 0f93abb1635..9b0849c704f 100644 --- a/cpp/include/cugraph/experimental/graph.hpp +++ b/cpp/include/cugraph/experimental/graph.hpp @@ -32,9 +32,9 @@ namespace experimental { template struct edgelist_t { - vertex_t const *p_src_vertices{nullptr}; - vertex_t const *p_dst_vertices{nullptr}; - std::optional p_edge_weights{std::nullopt}; + vertex_t const* p_src_vertices{nullptr}; + vertex_t const* p_dst_vertices{nullptr}; + std::optional p_edge_weights{std::nullopt}; edge_t number_of_edges{0}; }; @@ -62,29 +62,29 @@ class graph_t() {} + graph_t(raft::handle_t const& handle) : detail::graph_base_t() {} - graph_t(raft::handle_t const &handle, - std::vector> const &edgelists, - partition_t const &partition, + graph_t(raft::handle_t const& handle, + std::vector> const& edgelists, + partition_t const& partition, vertex_t number_of_vertices, edge_t number_of_edges, graph_properties_t properties, - std::optional> const &segment_offsets, + std::optional> const& segment_offsets, bool do_expensive_check = false); bool is_weighted() const { return adj_matrix_partition_weights_.has_value(); } graph_view_t view() const { - std::vector offsets(adj_matrix_partition_offsets_.size(), nullptr); - std::vector indices(adj_matrix_partition_indices_.size(), nullptr); - auto weights = adj_matrix_partition_weights_ - ? std::make_optional>( + std::vector offsets(adj_matrix_partition_offsets_.size(), nullptr); + std::vector indices(adj_matrix_partition_indices_.size(), nullptr); + auto weights = adj_matrix_partition_weights_ + ? std::make_optional>( (*adj_matrix_partition_weights_).size(), nullptr) - : std::nullopt; + : std::nullopt; auto dcs_nzd_vertices = adj_matrix_partition_dcs_nzd_vertices_ - ? std::make_optional>( + ? std::make_optional>( (*adj_matrix_partition_dcs_nzd_vertices_).size(), nullptr) : std::nullopt; auto dcs_nzd_vertex_counts = @@ -149,16 +149,16 @@ class graph_t(), offsets_(0, handle.get_stream()), indices_(0, handle.get_stream()){}; - graph_t(raft::handle_t const &handle, - edgelist_t const &edgelist, + graph_t(raft::handle_t const& handle, + edgelist_t const& edgelist, vertex_t number_of_vertices, graph_properties_t properties, - std::optional> const &segment_offsets, + std::optional> const& segment_offsets, bool do_expensive_check = false); bool is_weighted() const { return weights_.has_value(); } @@ -169,7 +169,7 @@ class graph_tget_handle_ptr()), offsets_.data(), indices_.data(), - weights_ ? std::optional{(*weights_).data()} : std::nullopt, + weights_ ? std::optional{(*weights_).data()} : std::nullopt, this->get_number_of_vertices(), this->get_number_of_edges(), this->get_graph_properties(), @@ -182,14 +182,14 @@ class graph_t &&offsets, - rmm::device_uvector &&indices, - std::optional> &&weights, - std::optional> &&segment_offsets) + rmm::device_uvector&& offsets, + rmm::device_uvector&& indices, + std::optional>&& weights, + std::optional>&& segment_offsets) : detail::graph_base_t( handle, number_of_vertices, number_of_edges, properties), offsets_(std::move(offsets)), diff --git a/cpp/include/cugraph/functions.hpp b/cpp/include/cugraph/functions.hpp index bb1adcf818b..23edd204c3b 100644 --- a/cpp/include/cugraph/functions.hpp +++ b/cpp/include/cugraph/functions.hpp @@ -41,8 +41,8 @@ namespace cugraph { */ template std::unique_ptr> coo_to_csr( - legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); + legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** * @brief Broadcast using handle communicator @@ -60,7 +60,7 @@ std::unique_ptr> coo_to_csr( // FIXME: It would be better to expose it in RAFT template -void comms_bcast(const raft::handle_t &handle, value_t *value, size_t count) +void comms_bcast(const raft::handle_t& handle, value_t* value, size_t count) { handle.get_comms().bcast(value, count, 0, handle.get_stream()); } diff --git a/cpp/include/cugraph/graph_generators.hpp b/cpp/include/cugraph/graph_generators.hpp index 9bd002b4299..94ae5d2cf81 100644 --- a/cpp/include/cugraph/graph_generators.hpp +++ b/cpp/include/cugraph/graph_generators.hpp @@ -67,7 +67,7 @@ namespace cugraph { */ template std::tuple, rmm::device_uvector> generate_rmat_edgelist( - raft::handle_t const &handle, + raft::handle_t const& handle, size_t scale, size_t num_edges, double a = 0.57, @@ -114,7 +114,7 @@ enum class generator_distribution_t { POWER_LAW = 0, UNIFORM }; template std::vector, rmm::device_uvector>> generate_rmat_edgelists( - raft::handle_t const &handle, + raft::handle_t const& handle, size_t n_edgelists, size_t min_scale, size_t max_scale, @@ -150,8 +150,8 @@ generate_rmat_edgelists( template std::tuple, rmm::device_uvector> generate_path_graph_edgelist( - raft::handle_t const &handle, - std::vector> const &component_parameters_v); + raft::handle_t const& handle, + std::vector> const& component_parameters_v); /** * @brief generate an edge list for a 2D Mesh Graph @@ -175,8 +175,8 @@ generate_path_graph_edgelist( template std::tuple, rmm::device_uvector> generate_2d_mesh_graph_edgelist( - raft::handle_t const &handle, - std::vector> const &component_parameters_v); + raft::handle_t const& handle, + std::vector> const& component_parameters_v); /** * @brief generate an edge list for a 3D Mesh Graph @@ -200,8 +200,8 @@ generate_2d_mesh_graph_edgelist( template std::tuple, rmm::device_uvector> generate_3d_mesh_graph_edgelist( - raft::handle_t const &handle, - std::vector> const &component_parameters_v); + raft::handle_t const& handle, + std::vector> const& component_parameters_v); /** * @brief generate an edge lists for some complete graphs @@ -225,8 +225,8 @@ generate_3d_mesh_graph_edgelist( template std::tuple, rmm::device_uvector> generate_complete_graph_edgelist( - raft::handle_t const &handle, - std::vector> const &component_parameters_v); + raft::handle_t const& handle, + std::vector> const& component_parameters_v); /** * @brief generate an edge lists for an Erdos-Renyi graph @@ -249,7 +249,7 @@ generate_complete_graph_edgelist( */ template std::tuple, rmm::device_uvector> -generate_erdos_renyi_graph_edgelist_gnp(raft::handle_t const &handle, +generate_erdos_renyi_graph_edgelist_gnp(raft::handle_t const& handle, vertex_t num_vertices, float p, vertex_t base_vertex_id, @@ -276,7 +276,7 @@ generate_erdos_renyi_graph_edgelist_gnp(raft::handle_t const &handle, */ template std::tuple, rmm::device_uvector> -generate_erdos_renyi_graph_edgelist_gnm(raft::handle_t const &handle, +generate_erdos_renyi_graph_edgelist_gnm(raft::handle_t const& handle, vertex_t num_vertices, size_t m, vertex_t base_vertex_id, @@ -304,10 +304,10 @@ template std::tuple, rmm::device_uvector, std::optional>> -symmetrize_edgelist(raft::handle_t const &handle, - rmm::device_uvector &&d_src_v, - rmm::device_uvector &&d_dst_v, - std::optional> &&optional_d_weights_v); +symmetrize_edgelist(raft::handle_t const& handle, + rmm::device_uvector&& d_src_v, + rmm::device_uvector&& d_dst_v, + std::optional>&& optional_d_weights_v); /** * @brief scramble vertex ids in a graph @@ -327,9 +327,9 @@ symmetrize_edgelist(raft::handle_t const &handle, * @param seed Used to initialize random number generator */ template -void scramble_vertex_ids(raft::handle_t const &handle, - rmm::device_uvector &d_src_v, - rmm::device_uvector &d_dst_v, +void scramble_vertex_ids(raft::handle_t const& handle, + rmm::device_uvector& d_src_v, + rmm::device_uvector& d_dst_v, vertex_t vertex_id_offset, uint64_t seed = 0); @@ -355,10 +355,10 @@ template std::tuple, rmm::device_uvector, std::optional>> -combine_edgelists(raft::handle_t const &handle, - std::vector> &&d_sources, - std::vector> &&d_dests, - std::optional>> &&optional_d_weights, +combine_edgelists(raft::handle_t const& handle, + std::vector>&& d_sources, + std::vector>&& d_dests, + std::optional>>&& optional_d_weights, bool remove_multi_edges = true); } // namespace cugraph diff --git a/cpp/include/cugraph/internals.hpp b/cpp/include/cugraph/internals.hpp index cc6b3031079..1c311304ae4 100644 --- a/cpp/include/cugraph/internals.hpp +++ b/cpp/include/cugraph/internals.hpp @@ -35,9 +35,9 @@ class GraphBasedDimRedCallback : public Callback { this->n_components = n_components; this->isFloat = std::is_same::value; } - virtual void on_preprocess_end(void *positions) = 0; - virtual void on_epoch_end(void *positions) = 0; - virtual void on_train_end(void *positions) = 0; + virtual void on_preprocess_end(void* positions) = 0; + virtual void on_epoch_end(void* positions) = 0; + virtual void on_train_end(void* positions) = 0; protected: int n; diff --git a/cpp/include/cugraph/legacy/graph.hpp b/cpp/include/cugraph/legacy/graph.hpp index 4b009bc7a25..4345fd225c1 100644 --- a/cpp/include/cugraph/legacy/graph.hpp +++ b/cpp/include/cugraph/legacy/graph.hpp @@ -58,17 +58,17 @@ class GraphViewBase { using edge_type = edge_t; using weight_type = weight_t; - raft::handle_t *handle; - weight_t *edge_data; ///< edge weight + raft::handle_t* handle; + weight_t* edge_data; ///< edge weight GraphProperties prop; vertex_t number_of_vertices; edge_t number_of_edges; - vertex_t *local_vertices; - edge_t *local_edges; - vertex_t *local_offsets; + vertex_t* local_vertices; + edge_t* local_edges; + vertex_t* local_offsets; vertex_t get_number_of_vertices() const { return number_of_vertices; } @@ -80,18 +80,18 @@ class GraphViewBase { * @param[out] identifiers Pointer to device memory to store the vertex * identifiers */ - void get_vertex_identifiers(vertex_t *identifiers) const; + void get_vertex_identifiers(vertex_t* identifiers) const; - void set_local_data(vertex_t *vertices, edge_t *edges, vertex_t *offsets) + void set_local_data(vertex_t* vertices, edge_t* edges, vertex_t* offsets) { local_vertices = vertices; local_edges = edges; local_offsets = offsets; } - void set_handle(raft::handle_t *handle_in) { handle = handle_in; } + void set_handle(raft::handle_t* handle_in) { handle = handle_in; } - GraphViewBase(weight_t *edge_data, vertex_t number_of_vertices, edge_t number_of_edges) + GraphViewBase(weight_t* edge_data, vertex_t number_of_vertices, edge_t number_of_edges) : handle(nullptr), edge_data(edge_data), prop(), @@ -116,8 +116,8 @@ class GraphViewBase { template class GraphCOOView : public GraphViewBase { public: - vertex_t *src_indices{nullptr}; ///< rowInd - vertex_t *dst_indices{nullptr}; ///< colInd + vertex_t* src_indices{nullptr}; ///< rowInd + vertex_t* dst_indices{nullptr}; ///< colInd /** * @brief Computes degree(in, out, in+out) of all the nodes of a Graph @@ -129,7 +129,7 @@ class GraphCOOView : public GraphViewBase { * to zeros. Will contain the computed degree of every vertex. * @param[in] direction IN_PLUS_OUT, IN or OUT */ - void degree(edge_t *degree, DegreeDirection direction) const; + void degree(edge_t* degree, DegreeDirection direction) const; /** * @brief Default constructor @@ -156,9 +156,9 @@ class GraphCOOView : public GraphViewBase { * @param number_of_vertices The number of vertices in the graph * @param number_of_edges The number of edges in the graph */ - GraphCOOView(vertex_t *src_indices, - vertex_t *dst_indices, - weight_t *edge_data, + GraphCOOView(vertex_t* src_indices, + vertex_t* dst_indices, + weight_t* edge_data, vertex_t number_of_vertices, edge_t number_of_edges) : GraphViewBase(edge_data, number_of_vertices, number_of_edges), @@ -180,8 +180,8 @@ class GraphCOOView : public GraphViewBase { template class GraphCompressedSparseBaseView : public GraphViewBase { public: - edge_t *offsets{nullptr}; ///< CSR offsets - vertex_t *indices{nullptr}; ///< CSR indices + edge_t* offsets{nullptr}; ///< CSR offsets + vertex_t* indices{nullptr}; ///< CSR indices /** * @brief Fill the identifiers in the array with the source vertex @@ -190,7 +190,7 @@ class GraphCompressedSparseBaseView : public GraphViewBase(edge_data, number_of_vertices, number_of_edges), @@ -280,9 +280,9 @@ class GraphCSRView : public GraphCompressedSparseBaseView( @@ -331,9 +331,9 @@ class GraphCSCView : public GraphCompressedSparseBaseView( @@ -399,7 +399,7 @@ class GraphCOO { edge_t number_of_edges, bool has_data = false, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()) + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) : number_of_vertices_p(number_of_vertices), number_of_edges_p(number_of_edges), src_indices_p(sizeof(vertex_t) * number_of_edges, stream, mr), @@ -408,9 +408,9 @@ class GraphCOO { { } - GraphCOO(GraphCOOView const &graph, + GraphCOO(GraphCOOView const& graph, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()) + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) : number_of_vertices_p(graph.number_of_vertices), number_of_edges_p(graph.number_of_edges), src_indices_p(graph.src_indices, graph.number_of_edges * sizeof(vertex_t), stream, mr), @@ -421,7 +421,7 @@ class GraphCOO { rmm::device_buffer{graph.edge_data, graph.number_of_edges * sizeof(weight_t), stream, mr}; } } - GraphCOO(GraphCOOContents &&contents) + GraphCOO(GraphCOOContents&& contents) : number_of_vertices_p(contents.number_of_vertices), number_of_edges_p(contents.number_of_edges), src_indices_p(std::move(*(contents.src_indices.release()))), @@ -432,9 +432,9 @@ class GraphCOO { vertex_t number_of_vertices(void) { return number_of_vertices_p; } edge_t number_of_edges(void) { return number_of_edges_p; } - vertex_t *src_indices(void) { return static_cast(src_indices_p.data()); } - vertex_t *dst_indices(void) { return static_cast(dst_indices_p.data()); } - weight_t *edge_data(void) { return static_cast(edge_data_p.data()); } + vertex_t* src_indices(void) { return static_cast(src_indices_p.data()); } + vertex_t* dst_indices(void) { return static_cast(dst_indices_p.data()); } + weight_t* edge_data(void) { return static_cast(edge_data_p.data()); } GraphCOOContents release() noexcept { @@ -505,7 +505,7 @@ class GraphCompressedSparseBase { edge_t number_of_edges, bool has_data, cudaStream_t stream, - rmm::mr::device_memory_resource *mr) + rmm::mr::device_memory_resource* mr) : number_of_vertices_p(number_of_vertices), number_of_edges_p(number_of_edges), offsets_p(sizeof(edge_t) * (number_of_vertices + 1), stream, mr), @@ -514,7 +514,7 @@ class GraphCompressedSparseBase { { } - GraphCompressedSparseBase(GraphSparseContents &&contents) + GraphCompressedSparseBase(GraphSparseContents&& contents) : number_of_vertices_p(contents.number_of_vertices), number_of_edges_p(contents.number_of_edges), offsets_p(std::move(*contents.offsets.release())), @@ -525,9 +525,9 @@ class GraphCompressedSparseBase { vertex_t number_of_vertices(void) { return number_of_vertices_p; } edge_t number_of_edges(void) { return number_of_edges_p; } - edge_t *offsets(void) { return static_cast(offsets_p.data()); } - vertex_t *indices(void) { return static_cast(indices_p.data()); } - weight_t *edge_data(void) { return static_cast(edge_data_p.data()); } + edge_t* offsets(void) { return static_cast(offsets_p.data()); } + vertex_t* indices(void) { return static_cast(indices_p.data()); } + weight_t* edge_data(void) { return static_cast(edge_data_p.data()); } GraphSparseContents release() noexcept { @@ -575,13 +575,13 @@ class GraphCSR : public GraphCompressedSparseBase { edge_t number_of_edges_, bool has_data_ = false, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()) + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) : GraphCompressedSparseBase( number_of_vertices_, number_of_edges_, has_data_, stream, mr) { } - GraphCSR(GraphSparseContents &&contents) + GraphCSR(GraphSparseContents&& contents) : GraphCompressedSparseBase(std::move(contents)) { } @@ -626,13 +626,13 @@ class GraphCSC : public GraphCompressedSparseBase { edge_t number_of_edges_in, bool has_data_in = false, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()) + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) : GraphCompressedSparseBase( number_of_vertices_in, number_of_edges_in, has_data_in, stream, mr) { } - GraphCSC(GraphSparseContents &&contents) + GraphCSC(GraphSparseContents&& contents) : GraphCompressedSparseBase( std::forward>(contents)) { diff --git a/cpp/include/cugraph/matrix_partition_device_view.cuh b/cpp/include/cugraph/matrix_partition_device_view.cuh index aa7bb6f97ba..9653e5c94d9 100644 --- a/cpp/include/cugraph/matrix_partition_device_view.cuh +++ b/cpp/include/cugraph/matrix_partition_device_view.cuh @@ -142,14 +142,14 @@ class matrix_partition_device_view_t(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; + ? minor + : matrix_partition.get_major_from_major_offset_nocheck(major_offset); + auto col = GraphViewType::is_adj_matrix_transposed + ? matrix_partition.get_major_from_major_offset_nocheck(major_offset) + : minor; + auto row_offset = GraphViewType::is_adj_matrix_transposed + ? minor_offset + : static_cast(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; return evaluate_edge_op(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; - auto e_op_result = evaluate_edge_op(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; + auto e_op_result = evaluate_edge_op(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; - auto e_op_result = evaluate_edge_op(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; + auto e_op_result = evaluate_edge_op(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; + ? minor + : matrix_partition.get_major_from_major_offset_nocheck(major_offset); + auto col = GraphViewType::is_adj_matrix_transposed + ? matrix_partition.get_major_from_major_offset_nocheck(major_offset) + : minor; + auto row_offset = GraphViewType::is_adj_matrix_transposed + ? minor_offset + : static_cast(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; auto key = *(adj_matrix_row_col_key_first + diff --git a/cpp/include/cugraph/prims/transform_reduce_e.cuh b/cpp/include/cugraph/prims/transform_reduce_e.cuh index 8eac2ac4f07..9bc7fe1cdf1 100644 --- a/cpp/include/cugraph/prims/transform_reduce_e.cuh +++ b/cpp/include/cugraph/prims/transform_reduce_e.cuh @@ -85,17 +85,17 @@ __global__ void for_all_major_for_all_nbr_low_degree( auto weight = weights ? (*weights)[i] : weight_t{1.0}; auto minor_offset = matrix_partition.get_minor_offset_from_minor_nocheck(minor); auto row = GraphViewType::is_adj_matrix_transposed - ? minor - : matrix_partition.get_major_from_major_offset_nocheck(major_offset); - auto col = GraphViewType::is_adj_matrix_transposed - ? matrix_partition.get_major_from_major_offset_nocheck(major_offset) - : minor; - auto row_offset = GraphViewType::is_adj_matrix_transposed - ? minor_offset - : static_cast(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; + ? minor + : matrix_partition.get_major_from_major_offset_nocheck(major_offset); + auto col = GraphViewType::is_adj_matrix_transposed + ? matrix_partition.get_major_from_major_offset_nocheck(major_offset) + : minor; + auto row_offset = GraphViewType::is_adj_matrix_transposed + ? minor_offset + : static_cast(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; return evaluate_edge_op(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; - auto e_op_result = evaluate_edge_op(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; + auto e_op_result = evaluate_edge_op(major_offset); - auto col_offset = GraphViewType::is_adj_matrix_transposed - ? static_cast(major_offset) - : minor_offset; - auto e_op_result = evaluate_edge_op(major_offset); + auto col_offset = GraphViewType::is_adj_matrix_transposed + ? static_cast(major_offset) + : minor_offset; + auto e_op_result = evaluate_edge_op h_thresholds(detail::num_sparse_segments_per_vertex_partition - 1); diff --git a/cpp/include/cugraph/prims/vertex_frontier.cuh b/cpp/include/cugraph/prims/vertex_frontier.cuh index bfe23882088..22c7ca867f5 100644 --- a/cpp/include/cugraph/prims/vertex_frontier.cuh +++ b/cpp/include/cugraph/prims/vertex_frontier.cuh @@ -300,7 +300,9 @@ class VertexFrontier { VertexFrontier(raft::handle_t const& handle) : handle_ptr_(&handle) { - for (size_t i = 0; i < num_buckets; ++i) { buckets_.emplace_back(handle); } + for (size_t i = 0; i < num_buckets; ++i) { + buckets_.emplace_back(handle); + } } SortedUniqueKeyBucket& get_bucket(size_t bucket_idx) diff --git a/cpp/include/cugraph/utilities/collect_comm.cuh b/cpp/include/cugraph/utilities/collect_comm.cuh index 76eff8afc71..1e15afea1e5 100644 --- a/cpp/include/cugraph/utilities/collect_comm.cuh +++ b/cpp/include/cugraph/utilities/collect_comm.cuh @@ -43,7 +43,7 @@ template decltype(allocate_dataframe_buffer::value_type>( 0, cudaStream_t{nullptr})) -collect_values_for_keys(raft::comms::comms_t const &comm, +collect_values_for_keys(raft::comms::comms_t const& comm, VertexIterator0 map_key_first, VertexIterator0 map_key_last, ValueIterator map_value_first, @@ -158,7 +158,7 @@ template decltype(allocate_dataframe_buffer::value_type>( 0, cudaStream_t{nullptr})) -collect_values_for_unique_keys(raft::comms::comms_t const &comm, +collect_values_for_unique_keys(raft::comms::comms_t const& comm, VertexIterator0 map_key_first, VertexIterator0 map_key_last, ValueIterator map_value_first, diff --git a/cpp/include/cugraph/utilities/host_scalar_comm.cuh b/cpp/include/cugraph/utilities/host_scalar_comm.cuh index 85994ed22bf..26994ebde14 100644 --- a/cpp/include/cugraph/utilities/host_scalar_comm.cuh +++ b/cpp/include/cugraph/utilities/host_scalar_comm.cuh @@ -274,7 +274,9 @@ host_scalar_allgather(raft::comms::comms_t const& comm, T input, cudaStream_t st size_t constexpr tuple_size = thrust::tuple_size::value; std::vector rx_counts(comm.get_size(), tuple_size); std::vector displacements(rx_counts.size(), size_t{0}); - for (size_t i = 0; i < displacements.size(); ++i) { displacements[i] = i * tuple_size; } + for (size_t i = 0; i < displacements.size(); ++i) { + displacements[i] = i * tuple_size; + } std::vector h_tuple_scalar_elements(tuple_size); rmm::device_uvector d_allgathered_tuple_scalar_elements(comm.get_size() * tuple_size, stream); diff --git a/cpp/include/cugraph/utilities/path_retrieval.hpp b/cpp/include/cugraph/utilities/path_retrieval.hpp index 3b2408d9037..b4789c14c4b 100644 --- a/cpp/include/cugraph/utilities/path_retrieval.hpp +++ b/cpp/include/cugraph/utilities/path_retrieval.hpp @@ -35,11 +35,11 @@ namespace cugraph { * @param num_vertices Number of vertices. **/ template -void get_traversed_cost(raft::handle_t const &handle, - vertex_t const *vertices, - vertex_t const *preds, - weight_t const *info_weights, - weight_t *out, +void get_traversed_cost(raft::handle_t const& handle, + vertex_t const* vertices, + vertex_t const* preds, + weight_t const* info_weights, + weight_t* out, vertex_t stop_vertex, vertex_t num_vertices); @@ -62,11 +62,11 @@ namespace experimental { template std:: tuple, rmm::device_uvector, rmm::device_uvector> - convert_paths_to_coo(raft::handle_t const &handle, + convert_paths_to_coo(raft::handle_t const& handle, index_t coalesced_sz_v, index_t num_paths, - rmm::device_buffer &&d_coalesced_v, - rmm::device_buffer &&d_sizes); + rmm::device_buffer&& d_coalesced_v, + rmm::device_buffer&& d_sizes); /** * @brief returns additional RW information on vertex paths offsets and weight path sizes and @@ -82,7 +82,7 @@ std:: */ template std::tuple, rmm::device_uvector, rmm::device_uvector> -query_rw_sizes_offsets(raft::handle_t const &handle, index_t num_paths, index_t const *ptr_d_sizes); +query_rw_sizes_offsets(raft::handle_t const& handle, index_t num_paths, index_t const* ptr_d_sizes); } // namespace experimental namespace broadcast { @@ -96,7 +96,7 @@ namespace broadcast { * @return graph_t object that was sent/received */ template -graph_t graph_broadcast(raft::handle_t const &handle, graph_t *graph_ptr); +graph_t graph_broadcast(raft::handle_t const& handle, graph_t* graph_ptr); }; // namespace broadcast } // namespace cugraph diff --git a/cpp/include/cugraph/utilities/shuffle_comm.cuh b/cpp/include/cugraph/utilities/shuffle_comm.cuh index e4f7067cfdf..18752897a58 100644 --- a/cpp/include/cugraph/utilities/shuffle_comm.cuh +++ b/cpp/include/cugraph/utilities/shuffle_comm.cuh @@ -44,8 +44,8 @@ inline std::tuple, std::vector, std::vector, std::vector> -compute_tx_rx_counts_offsets_ranks(raft::comms::comms_t const &comm, - rmm::device_uvector const &d_tx_value_counts, +compute_tx_rx_counts_offsets_ranks(raft::comms::comms_t const& comm, + rmm::device_uvector const& d_tx_value_counts, rmm::cuda_stream_view stream_view) { auto const comm_size = comm.get_size(); @@ -191,9 +191,9 @@ rmm::device_uvector groupby_and_count(VertexIterator tx_key_first /* [IN } template -auto shuffle_values(raft::comms::comms_t const &comm, +auto shuffle_values(raft::comms::comms_t const& comm, TxValueIterator tx_value_first, - std::vector const &tx_value_counts, + std::vector const& tx_value_counts, rmm::cuda_stream_view stream_view) { auto const comm_size = comm.get_size(); @@ -243,7 +243,7 @@ auto shuffle_values(raft::comms::comms_t const &comm, } template -auto groupby_gpuid_and_shuffle_values(raft::comms::comms_t const &comm, +auto groupby_gpuid_and_shuffle_values(raft::comms::comms_t const& comm, ValueIterator tx_value_first /* [INOUT */, ValueIterator tx_value_last /* [INOUT */, ValueToGPUIdOp value_to_gpu_id_op, @@ -294,7 +294,7 @@ auto groupby_gpuid_and_shuffle_values(raft::comms::comms_t const &comm, } template -auto groupby_gpuid_and_shuffle_kv_pairs(raft::comms::comms_t const &comm, +auto groupby_gpuid_and_shuffle_kv_pairs(raft::comms::comms_t const& comm, VertexIterator tx_key_first /* [INOUT */, VertexIterator tx_key_last /* [INOUT */, ValueIterator tx_value_first /* [INOUT */, diff --git a/cpp/include/cugraph/vertex_partition_device.cuh b/cpp/include/cugraph/vertex_partition_device.cuh new file mode 100644 index 00000000000..f598c7d89d8 --- /dev/null +++ b/cpp/include/cugraph/vertex_partition_device.cuh @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include +#include + +#include + +namespace cugraph { +namespace experimental { + +template +class vertex_partition_device_base_t { + public: + vertex_partition_device_base_t(vertex_t number_of_vertices) + : number_of_vertices_(number_of_vertices) + { + } + + template + __host__ __device__ std::enable_if_t::value, bool> is_valid_vertex( + vertex_type v) const noexcept + { + return ((v >= 0) && (v < number_of_vertices_)); + } + + template + __host__ __device__ std::enable_if_t::value, bool> is_valid_vertex( + vertex_type v) const noexcept + { + return (v < number_of_vertices_); + } + + private: + // should be trivially copyable to device + vertex_t number_of_vertices_{0}; +}; + +template +class vertex_partition_device_t; + +// multi-GPU version +template +class vertex_partition_device_t> + : public vertex_partition_device_base_t { + public: + vertex_partition_device_t(GraphViewType const& graph_view) + : vertex_partition_device_base_t( + graph_view.get_number_of_vertices()), + first_(graph_view.get_local_vertex_first()), + last_(graph_view.get_local_vertex_last()) + { + } + + __host__ __device__ bool is_local_vertex_nocheck( + typename GraphViewType::vertex_type v) const noexcept + { + return (v >= first_) && (v < last_); + } + + __host__ __device__ typename GraphViewType::vertex_type + get_local_vertex_offset_from_vertex_nocheck(typename GraphViewType::vertex_type v) const noexcept + { + return v - first_; + } + + private: + // should be trivially copyable to device + typename GraphViewType::vertex_type first_{0}; + typename GraphViewType::vertex_type last_{0}; +}; + +// single-GPU version +template +class vertex_partition_device_t> + : public vertex_partition_device_base_t { + public: + vertex_partition_device_t(GraphViewType const& graph_view) + : vertex_partition_device_base_t( + graph_view.get_number_of_vertices()) + { + } + + __host__ __device__ constexpr bool is_local_vertex_nocheck( + typename GraphViewType::vertex_type v) const noexcept + { + return true; + } + + __host__ __device__ constexpr typename GraphViewType::vertex_type + get_local_vertex_offset_from_vertex_nocheck(typename GraphViewType::vertex_type v) const noexcept + { + return v; + } +}; + +} // namespace experimental +} // namespace cugraph diff --git a/cpp/include/cugraph/vertex_partition_device_view.cuh b/cpp/include/cugraph/vertex_partition_device_view.cuh index 046c89e62a2..39eb3e7238a 100644 --- a/cpp/include/cugraph/vertex_partition_device_view.cuh +++ b/cpp/include/cugraph/vertex_partition_device_view.cuh @@ -73,8 +73,8 @@ class vertex_partition_device_view_t= local_vertex_first_) && (v < local_vertex_last_); } - __host__ __device__ vertex_t get_local_vertex_offset_from_vertex_nocheck(vertex_t v) const - noexcept + __host__ __device__ vertex_t + get_local_vertex_offset_from_vertex_nocheck(vertex_t v) const noexcept { return v - local_vertex_first_; } diff --git a/cpp/scripts/run-clang-format.py b/cpp/scripts/run-clang-format.py index 9bd3c364329..02434278343 100644 --- a/cpp/scripts/run-clang-format.py +++ b/cpp/scripts/run-clang-format.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import tempfile -EXPECTED_VERSION = "8.0.1" +EXPECTED_VERSION = "11.0.0" VERSION_REGEX = re.compile(r"clang-format version ([0-9.]+)") # NOTE: populate this list with more top-level dirs as we add more of them to the cugraph repo DEFAULT_DIRS = ["cpp/include", @@ -139,4 +139,3 @@ def main(): if __name__ == "__main__": main() - diff --git a/cpp/src/centrality/betweenness_centrality.cu b/cpp/src/centrality/betweenness_centrality.cu index 2af0710d1ec..6949399b4b7 100644 --- a/cpp/src/centrality/betweenness_centrality.cu +++ b/cpp/src/centrality/betweenness_centrality.cu @@ -35,14 +35,14 @@ namespace cugraph { namespace detail { namespace { template -void betweenness_centrality_impl(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void betweenness_centrality_impl(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalize, bool endpoints, - weight_t const *weight, + weight_t const* weight, vertex_t number_of_sources, - vertex_t const *sources, + vertex_t const* sources, vertex_t total_number_of_sources) { // Current Implementation relies on BFS @@ -59,13 +59,13 @@ void betweenness_centrality_impl(raft::handle_t const &handle, } template -void edge_betweenness_centrality_impl(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void edge_betweenness_centrality_impl(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalize, - weight_t const *weight, + weight_t const* weight, vertex_t number_of_sources, - vertex_t const *sources, + vertex_t const* sources, vertex_t total_number_of_sources) { // Current Implementation relies on BFS @@ -84,7 +84,7 @@ void edge_betweenness_centrality_impl(raft::handle_t const &handle, // bc.rescale_by_total_sources_used(total_number_of_sources); } template -vertex_t get_total_number_of_sources(raft::handle_t const &handle, vertex_t local_number_of_sources) +vertex_t get_total_number_of_sources(raft::handle_t const& handle, vertex_t local_number_of_sources) { vertex_t total_number_of_sources_used = local_number_of_sources; if (handle.comms_initialized()) { @@ -103,13 +103,13 @@ vertex_t get_total_number_of_sources(raft::handle_t const &handle, vertex_t loca } // namespace template -void verify_betweenness_centrality_input(result_t *result, +void verify_betweenness_centrality_input(result_t* result, bool is_edge_betweenness, bool normalize, bool endpoints, - weight_t const *weights, + weight_t const* weights, vertex_t const number_of_sources, - vertex_t const *sources) + vertex_t const* sources) { static_assert(std::is_same::value, "vertex_t should be int"); static_assert(std::is_same::value, "edge_t should be int"); @@ -139,12 +139,12 @@ void BC::setup() } template -void BC::configure(result_t *betweenness, +void BC::configure(result_t* betweenness, bool is_edge_betweenness, bool normalized, bool endpoints, - weight_t const *weights, - vertex_t const *sources, + weight_t const* weights, + vertex_t const* sources, vertex_t number_of_sources) { // --- Bind betweenness output vector to internal --- @@ -448,14 +448,14 @@ void BC::rescale_by_total_sources_used( } // namespace detail template -void betweenness_centrality(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void betweenness_centrality(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalize, bool endpoints, - weight_t const *weight, + weight_t const* weight, vertex_t k, - vertex_t const *vertices) + vertex_t const* vertices) { vertex_t total_number_of_sources_used = detail::get_total_number_of_sources(handle, k); if (handle.comms_initialized()) { @@ -489,32 +489,32 @@ void betweenness_centrality(raft::handle_t const &handle, } template void betweenness_centrality( - const raft::handle_t &, - legacy::GraphCSRView const &, - float *, + const raft::handle_t&, + legacy::GraphCSRView const&, + float*, bool, bool, - float const *, + float const*, int, - int const *); + int const*); template void betweenness_centrality( - const raft::handle_t &, - legacy::GraphCSRView const &, - double *, + const raft::handle_t&, + legacy::GraphCSRView const&, + double*, bool, bool, - double const *, + double const*, int, - int const *); + int const*); template -void edge_betweenness_centrality(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void edge_betweenness_centrality(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalize, - weight_t const *weight, + weight_t const* weight, vertex_t k, - vertex_t const *vertices) + vertex_t const* vertices) { vertex_t total_number_of_sources_used = detail::get_total_number_of_sources(handle, k); if (handle.comms_initialized()) { @@ -540,20 +540,20 @@ void edge_betweenness_centrality(raft::handle_t const &handle, } template void edge_betweenness_centrality( - const raft::handle_t &, - legacy::GraphCSRView const &, - float *, + const raft::handle_t&, + legacy::GraphCSRView const&, + float*, bool, - float const *, + float const*, int, - int const *); + int const*); template void edge_betweenness_centrality( - raft::handle_t const &handle, - legacy::GraphCSRView const &, - double *, + raft::handle_t const& handle, + legacy::GraphCSRView const&, + double*, bool, - double const *, + double const*, int, - int const *); + int const*); } // namespace cugraph diff --git a/cpp/src/centrality/betweenness_centrality.cuh b/cpp/src/centrality/betweenness_centrality.cuh index 9e3abca3e78..706b8bfebac 100644 --- a/cpp/src/centrality/betweenness_centrality.cuh +++ b/cpp/src/centrality/betweenness_centrality.cuh @@ -22,69 +22,69 @@ namespace cugraph { namespace detail { template -void betweenness_centrality(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - result_t *result, +void betweenness_centrality(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + result_t* result, bool normalize, bool endpoints, - weight_t const *weight, + weight_t const* weight, vertex_t const number_of_sources, - vertex_t const *sources); + vertex_t const* sources); template -void edge_betweenness_centrality(legacy::GraphCSRView const &graph, - result_t *result, +void edge_betweenness_centrality(legacy::GraphCSRView const& graph, + result_t* result, bool normalize, - weight_t const *weight, + weight_t const* weight, vertex_t const number_of_sources, - vertex_t const *sources); + vertex_t const* sources); template -void verify_betweenness_centrality_input(result_t *result, +void verify_betweenness_centrality_input(result_t* result, bool is_edge_betweenness, bool normalize, bool endpoints, - weight_t const *weights, + weight_t const* weights, vertex_t const number_of_sources, - vertex_t const *sources); + vertex_t const* sources); template class BC { public: virtual ~BC(void) {} - BC(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, + BC(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, cudaStream_t stream = 0) : handle_(handle), graph_(graph) { setup(); } - void configure(result_t *betweenness, + void configure(result_t* betweenness, bool is_edge_betweenness, bool normalize, bool endpoints, - weight_t const *weight, - vertex_t const *sources, + weight_t const* weight, + vertex_t const* sources, vertex_t const number_of_sources); - void configure_edge(result_t *betweenness, + void configure_edge(result_t* betweenness, bool normalize, - weight_t const *weight, - vertex_t const *sources, + weight_t const* weight, + vertex_t const* sources, vertex_t const number_of_sources); void compute(); void rescale_by_total_sources_used(vertex_t total_number_of_sources_used); private: // --- RAFT handle --- - raft::handle_t const &handle_; + raft::handle_t const& handle_; // --- Information concerning the graph --- - const legacy::GraphCSRView &graph_; + const legacy::GraphCSRView& graph_; // --- These information are extracted on setup --- vertex_t number_of_vertices_; // Number of vertices in the graph vertex_t number_of_edges_; // Number of edges in the graph - edge_t const *offsets_ptr_; // Pointer to the offsets - vertex_t const *indices_ptr_; // Pointers to the indices + edge_t const* offsets_ptr_; // Pointer to the offsets + vertex_t const* indices_ptr_; // Pointers to the indices // --- Information from configuration --- bool configured_ = false; // Flag to ensure configuration was called @@ -92,14 +92,14 @@ class BC { bool is_edge_betweenness_ = false; // If True compute edge_betweeness // FIXME: For weighted version - weight_t const *edge_weights_ptr_ = nullptr; // Pointer to the weights + weight_t const* edge_weights_ptr_ = nullptr; // Pointer to the weights bool endpoints_ = false; // If True normalize the betweenness - vertex_t const *sources_ = nullptr; // Subset of vertices to gather information from + vertex_t const* sources_ = nullptr; // Subset of vertices to gather information from vertex_t number_of_sources_; // Number of vertices in sources // --- Output ---- // betweenness is set/read by users - using Vectors - result_t *betweenness_ = nullptr; + result_t* betweenness_ = nullptr; // --- Data required to perform computation ---- rmm::device_vector distances_vec_; @@ -107,13 +107,13 @@ class BC { rmm::device_vector sp_counters_vec_; rmm::device_vector deltas_vec_; - vertex_t *distances_ = + vertex_t* distances_ = nullptr; // array(|V|) stores the distances gathered by the latest SSSP - vertex_t *predecessors_ = + vertex_t* predecessors_ = nullptr; // array(|V|) stores the predecessors of the latest SSSP - double *sp_counters_ = + double* sp_counters_ = nullptr; // array(|V|) stores the shortest path counter for the latest SSSP - double *deltas_ = nullptr; // array(|V|) stores the dependencies for the latest SSSP + double* deltas_ = nullptr; // array(|V|) stores the dependencies for the latest SSSP int max_grid_dim_1D_ = 0; int max_block_dim_1D_ = 0; diff --git a/cpp/src/centrality/betweenness_centrality_kernels.cuh b/cpp/src/centrality/betweenness_centrality_kernels.cuh index 3cb5add8ad6..27666095375 100644 --- a/cpp/src/centrality/betweenness_centrality_kernels.cuh +++ b/cpp/src/centrality/betweenness_centrality_kernels.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,13 +25,13 @@ namespace detail { // Should look into forAllEdge type primitive for different // load balancing template -__global__ void edges_accumulation_kernel(result_t *betweenness, +__global__ void edges_accumulation_kernel(result_t* betweenness, vertex_t number_vertices, - vertex_t const *indices, - edge_t const *offsets, - vertex_t *distances, - double *sp_counters, - double *deltas, + vertex_t const* indices, + edge_t const* offsets, + vertex_t* distances, + double* sp_counters, + double* deltas, vertex_t depth) { for (int thread_idx = blockIdx.x * blockDim.x + threadIdx.x; thread_idx < number_vertices; @@ -58,13 +58,13 @@ __global__ void edges_accumulation_kernel(result_t *betweenness, } template -__global__ void endpoints_accumulation_kernel(result_t *betweenness, +__global__ void endpoints_accumulation_kernel(result_t* betweenness, vertex_t number_vertices, - vertex_t const *indices, - edge_t const *offsets, - vertex_t *distances, - double *sp_counters, - double *deltas, + vertex_t const* indices, + edge_t const* offsets, + vertex_t* distances, + double* sp_counters, + double* deltas, vertex_t depth) { for (int thread_idx = blockIdx.x * blockDim.x + threadIdx.x; thread_idx < number_vertices; @@ -88,13 +88,13 @@ __global__ void endpoints_accumulation_kernel(result_t *betweenness, } } template -__global__ void accumulation_kernel(result_t *betweenness, +__global__ void accumulation_kernel(result_t* betweenness, vertex_t number_vertices, - vertex_t const *indices, - edge_t const *offsets, - vertex_t *distances, - double *sp_counters, - double *deltas, + vertex_t const* indices, + edge_t const* offsets, + vertex_t* distances, + double* sp_counters, + double* deltas, vertex_t depth) { for (int thread_idx = blockIdx.x * blockDim.x + threadIdx.x; thread_idx < number_vertices; @@ -117,4 +117,4 @@ __global__ void accumulation_kernel(result_t *betweenness, } } } // namespace detail -} // namespace cugraph \ No newline at end of file +} // namespace cugraph diff --git a/cpp/src/centrality/katz_centrality.cu b/cpp/src/centrality/katz_centrality.cu index 608e617e3af..320d76e5c03 100644 --- a/cpp/src/centrality/katz_centrality.cu +++ b/cpp/src/centrality/katz_centrality.cu @@ -29,8 +29,8 @@ namespace cugraph { template -void katz_centrality(legacy::GraphCSRView const &graph, - result_t *result, +void katz_centrality(legacy::GraphCSRView const& graph, + result_t* result, double alpha, int max_iter, double tol, @@ -52,6 +52,6 @@ void katz_centrality(legacy::GraphCSRView const &graph, } template void katz_centrality( - legacy::GraphCSRView const &, double *, double, int, double, bool, bool); + legacy::GraphCSRView const&, double*, double, int, double, bool, bool); } // namespace cugraph diff --git a/cpp/src/community/ecg.cu b/cpp/src/community/ecg.cu index 196998b38c1..ca0f50c4801 100644 --- a/cpp/src/community/ecg.cu +++ b/cpp/src/community/ecg.cu @@ -28,7 +28,7 @@ namespace { template __device__ IndexType -binsearch_maxle(const IndexType *vec, const IndexType val, IndexType low, IndexType high) +binsearch_maxle(const IndexType* vec, const IndexType val, IndexType low, IndexType high) { while (true) { if (low == high) return low; // we know it exists @@ -47,7 +47,7 @@ binsearch_maxle(const IndexType *vec, const IndexType val, IndexType low, IndexT // seems like it should just be a thrust::transform template __global__ void match_check_kernel( - IdxT size, IdxT num_verts, IdxT *offsets, IdxT *indices, IdxT *parts, ValT *weights) + IdxT size, IdxT num_verts, IdxT* offsets, IdxT* indices, IdxT* parts, ValT* weights) { IdxT tid = blockIdx.x * blockDim.x + threadIdx.x; while (tid < size) { @@ -90,7 +90,7 @@ struct update_functor { * responsible for freeing the allocated memory using ALLOC_FREE_TRY(). */ template -void get_permutation_vector(T size, T seed, T *permutation, rmm::cuda_stream_view stream_view) +void get_permutation_vector(T size, T seed, T* permutation, rmm::cuda_stream_view stream_view) { rmm::device_uvector randoms_v(size, stream_view); @@ -109,7 +109,7 @@ class EcgLouvain : public cugraph::Louvain { using edge_t = typename graph_type::edge_type; using weight_t = typename graph_type::weight_type; - EcgLouvain(raft::handle_t const &handle, graph_type const &graph, vertex_t seed) + EcgLouvain(raft::handle_t const& handle, graph_type const& graph, vertex_t seed) : cugraph::Louvain(handle, graph), seed_(seed) { } @@ -133,11 +133,11 @@ class EcgLouvain : public cugraph::Louvain { namespace cugraph { template -void ecg(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, +void ecg(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, weight_t min_weight, vertex_t ensemble_size, - vertex_t *clustering) + vertex_t* clustering) { using graph_type = legacy::GraphCSRView; @@ -202,15 +202,15 @@ void ecg(raft::handle_t const &handle, // Explicit template instantiations. template void ecg( - raft::handle_t const &, - legacy::GraphCSRView const &graph, + raft::handle_t const&, + legacy::GraphCSRView const& graph, float min_weight, int32_t ensemble_size, - int32_t *clustering); + int32_t* clustering); template void ecg( - raft::handle_t const &, - legacy::GraphCSRView const &graph, + raft::handle_t const&, + legacy::GraphCSRView const& graph, double min_weight, int32_t ensemble_size, - int32_t *clustering); + int32_t* clustering); } // namespace cugraph diff --git a/cpp/src/community/egonet.cu b/cpp/src/community/egonet.cu index 72dc0eebc42..1e4569715af 100644 --- a/cpp/src/community/egonet.cu +++ b/cpp/src/community/egonet.cu @@ -60,9 +60,9 @@ std::tuple, std::optional>, rmm::device_uvector> extract( - raft::handle_t const &handle, - cugraph::experimental::graph_view_t const &csr_view, - vertex_t *source_vertex, + raft::handle_t const& handle, + cugraph::experimental::graph_view_t const& csr_view, + vertex_t* source_vertex, vertex_t n_subgraphs, vertex_t radius) { @@ -187,9 +187,9 @@ std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t *source_vertex, +extract_ego(raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t* source_vertex, vertex_t n_subgraphs, vertex_t radius) { @@ -216,27 +216,27 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &, - graph_view_t const &, - int32_t *, +extract_ego(raft::handle_t const&, + graph_view_t const&, + int32_t*, int32_t, int32_t); template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &, - graph_view_t const &, - int32_t *, +extract_ego(raft::handle_t const&, + graph_view_t const&, + int32_t*, int32_t, int32_t); template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &, - graph_view_t const &, - int64_t *, +extract_ego(raft::handle_t const&, + graph_view_t const&, + int64_t*, int64_t, int64_t); @@ -245,27 +245,27 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &, - graph_view_t const &, - int32_t *, +extract_ego(raft::handle_t const&, + graph_view_t const&, + int32_t*, int32_t, int32_t); template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &, - graph_view_t const &, - int32_t *, +extract_ego(raft::handle_t const&, + graph_view_t const&, + int32_t*, int32_t, int32_t); template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_ego(raft::handle_t const &, - graph_view_t const &, - int64_t *, +extract_ego(raft::handle_t const&, + graph_view_t const&, + int64_t*, int64_t, int64_t); } // namespace experimental diff --git a/cpp/src/community/extract_subgraph_by_vertex.cu b/cpp/src/community/extract_subgraph_by_vertex.cu index 305bb566af6..224a3417caf 100644 --- a/cpp/src/community/extract_subgraph_by_vertex.cu +++ b/cpp/src/community/extract_subgraph_by_vertex.cu @@ -25,8 +25,8 @@ namespace { template std::unique_ptr> extract_subgraph_by_vertices( - cugraph::legacy::GraphCOOView const &graph, - vertex_t const *vertices, + cugraph::legacy::GraphCOOView const& graph, + vertex_t const* vertices, vertex_t num_vertices, cudaStream_t stream) { @@ -35,8 +35,8 @@ std::unique_ptr> extract_s rmm::device_vector error_count_v{1, 0}; rmm::device_vector vertex_used_v{graph_num_verts, num_vertices}; - vertex_t *d_vertex_used = vertex_used_v.data().get(); - int64_t *d_error_count = error_count_v.data().get(); + vertex_t* d_vertex_used = vertex_used_v.data().get(); + int64_t* d_error_count = error_count_v.data().get(); thrust::for_each( rmm::exec_policy(stream)->on(stream), @@ -54,9 +54,9 @@ std::unique_ptr> extract_s CUGRAPH_EXPECTS(error_count_v[0] == 0, "Input error... vertices specifies vertex id out of range"); - vertex_t *graph_src = graph.src_indices; - vertex_t *graph_dst = graph.dst_indices; - weight_t *graph_weight = graph.edge_data; + vertex_t* graph_src = graph.src_indices; + vertex_t* graph_dst = graph.dst_indices; + weight_t* graph_weight = graph.edge_data; // iterate over the edges and count how many make it into the output int64_t count = thrust::count_if( @@ -73,9 +73,9 @@ std::unique_ptr> extract_s auto result = std::make_unique>( num_vertices, count, has_weight); - vertex_t *d_new_src = result->src_indices(); - vertex_t *d_new_dst = result->dst_indices(); - weight_t *d_new_weight = result->edge_data(); + vertex_t* d_new_src = result->src_indices(); + vertex_t* d_new_dst = result->dst_indices(); + weight_t* d_new_weight = result->edge_data(); // reusing error_count as a vertex counter... thrust::for_each(rmm::exec_policy(stream)->on(stream), @@ -117,7 +117,7 @@ namespace subgraph { template std::unique_ptr> extract_subgraph_vertex( - legacy::GraphCOOView const &graph, VT const *vertices, VT num_vertices) + legacy::GraphCOOView const& graph, VT const* vertices, VT num_vertices) { CUGRAPH_EXPECTS(vertices != nullptr, "Invalid input argument: vertices must be non null"); @@ -132,10 +132,10 @@ std::unique_ptr> extract_subgraph_vertex( template std::unique_ptr> extract_subgraph_vertex( - legacy::GraphCOOView const &, int32_t const *, int32_t); + legacy::GraphCOOView const&, int32_t const*, int32_t); template std::unique_ptr> extract_subgraph_vertex( - legacy::GraphCOOView const &, int32_t const *, int32_t); + legacy::GraphCOOView const&, int32_t const*, int32_t); } // namespace subgraph } // namespace cugraph diff --git a/cpp/src/community/flatten_dendrogram.cuh b/cpp/src/community/flatten_dendrogram.cuh index ff6446b0e5f..9a8d214f883 100644 --- a/cpp/src/community/flatten_dendrogram.cuh +++ b/cpp/src/community/flatten_dendrogram.cuh @@ -24,10 +24,10 @@ namespace cugraph { template -void partition_at_level(raft::handle_t const &handle, - Dendrogram const &dendrogram, - vertex_t const *d_vertex_ids, - vertex_t *d_partition, +void partition_at_level(raft::handle_t const& handle, + Dendrogram const& dendrogram, + vertex_t const* d_vertex_ids, + vertex_t* d_partition, size_t level) { vertex_t local_num_verts = dendrogram.get_level_size_nocheck(0); @@ -47,8 +47,8 @@ void partition_at_level(raft::handle_t const &handle, cugraph::experimental::relabel( handle, - std::tuple(local_vertex_ids_v.data(), - dendrogram.get_level_ptr_nocheck(l)), + std::tuple(local_vertex_ids_v.data(), + dendrogram.get_level_ptr_nocheck(l)), dendrogram.get_level_size_nocheck(l), d_partition, local_num_verts, diff --git a/cpp/src/community/ktruss.cu b/cpp/src/community/ktruss.cu index 9297e416287..2216278add8 100644 --- a/cpp/src/community/ktruss.cu +++ b/cpp/src/community/ktruss.cu @@ -36,7 +36,7 @@ namespace detail { template std::unique_ptr> ktruss_subgraph_impl( - legacy::GraphCOOView const &graph, int k, rmm::mr::device_memory_resource *mr) + legacy::GraphCOOView const& graph, int k, rmm::mr::device_memory_resource* mr) { using HornetGraph = hornet::gpu::Hornet; using UpdatePtr = hornet::BatchUpdatePtr; @@ -79,7 +79,7 @@ std::unique_ptr> ktruss_subgraph_impl( } template std::unique_ptr> weighted_ktruss_subgraph_impl( - legacy::GraphCOOView const &graph, int k, rmm::mr::device_memory_resource *mr) + legacy::GraphCOOView const& graph, int k, rmm::mr::device_memory_resource* mr) { using HornetGraph = hornet::gpu::Hornet>; using UpdatePtr = hornet::BatchUpdatePtr, hornet::DeviceType::DEVICE>; @@ -125,7 +125,7 @@ std::unique_ptr> weighted_ktruss_subgraph_impl( template std::unique_ptr> k_truss_subgraph( - legacy::GraphCOOView const &graph, int k, rmm::mr::device_memory_resource *mr) + legacy::GraphCOOView const& graph, int k, rmm::mr::device_memory_resource* mr) { CUGRAPH_EXPECTS(graph.src_indices != nullptr, "Graph source indices cannot be a nullptr"); CUGRAPH_EXPECTS(graph.dst_indices != nullptr, "Graph destination indices cannot be a nullptr"); @@ -138,13 +138,13 @@ std::unique_ptr> k_truss_subgraph( } template std::unique_ptr> -k_truss_subgraph(legacy::GraphCOOView const &, +k_truss_subgraph(legacy::GraphCOOView const&, int, - rmm::mr::device_memory_resource *); + rmm::mr::device_memory_resource*); template std::unique_ptr> -k_truss_subgraph(legacy::GraphCOOView const &, +k_truss_subgraph(legacy::GraphCOOView const&, int, - rmm::mr::device_memory_resource *); + rmm::mr::device_memory_resource*); } // namespace cugraph diff --git a/cpp/src/community/leiden.cu b/cpp/src/community/leiden.cu index 703738fc190..f55321dbebb 100644 --- a/cpp/src/community/leiden.cu +++ b/cpp/src/community/leiden.cu @@ -22,9 +22,9 @@ namespace cugraph { template -std::pair leiden(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - vertex_t *clustering, +std::pair leiden(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + vertex_t* clustering, size_t max_level, weight_t resolution) { @@ -56,15 +56,15 @@ std::pair leiden(raft::handle_t const &handle, } // Explicit template instantations -template std::pair leiden(raft::handle_t const &, - legacy::GraphCSRView const &, - int32_t *, +template std::pair leiden(raft::handle_t const&, + legacy::GraphCSRView const&, + int32_t*, size_t, float); -template std::pair leiden(raft::handle_t const &, - legacy::GraphCSRView const &, - int32_t *, +template std::pair leiden(raft::handle_t const&, + legacy::GraphCSRView const&, + int32_t*, size_t, double); diff --git a/cpp/src/community/leiden.cuh b/cpp/src/community/leiden.cuh index 6f0a0b6e8b0..252fdbf60a7 100644 --- a/cpp/src/community/leiden.cuh +++ b/cpp/src/community/leiden.cuh @@ -29,7 +29,7 @@ class Leiden : public Louvain { using edge_t = typename graph_type::edge_type; using weight_t = typename graph_type::weight_type; - Leiden(raft::handle_t const &handle, graph_type const &graph) + Leiden(raft::handle_t const& handle, graph_type const& graph) : Louvain(handle, graph), constraint_v_(graph.number_of_vertices, handle.get_stream()) { @@ -37,7 +37,7 @@ class Leiden : public Louvain { weight_t update_clustering_constrained(weight_t total_edge_weight, weight_t resolution, - graph_type const &graph) + graph_type const& graph) { this->timer_start("update_clustering_constrained"); @@ -49,14 +49,14 @@ class Leiden : public Louvain { rmm::device_uvector old_cluster_sum_v(graph.number_of_vertices, this->handle_.get_stream_view()); - vertex_t const *d_src_indices = this->src_indices_v_.data(); - vertex_t const *d_dst_indices = graph.indices; - vertex_t *d_cluster_hash = cluster_hash_v.data(); - vertex_t *d_cluster = this->dendrogram_->current_level_begin(); - weight_t const *d_vertex_weights = this->vertex_weights_v_.data(); - weight_t *d_cluster_weights = this->cluster_weights_v_.data(); - weight_t *d_delta_Q = delta_Q_v.data(); - vertex_t *d_constraint = constraint_v_.data(); + vertex_t const* d_src_indices = this->src_indices_v_.data(); + vertex_t const* d_dst_indices = graph.indices; + vertex_t* d_cluster_hash = cluster_hash_v.data(); + vertex_t* d_cluster = this->dendrogram_->current_level_begin(); + weight_t const* d_vertex_weights = this->vertex_weights_v_.data(); + weight_t* d_cluster_weights = this->cluster_weights_v_.data(); + weight_t* d_delta_Q = delta_Q_v.data(); + vertex_t* d_constraint = constraint_v_.data(); thrust::copy(rmm::exec_policy(this->handle_.get_stream_view()), this->dendrogram_->current_level_begin(), diff --git a/cpp/src/community/louvain.cu b/cpp/src/community/louvain.cu index 3fee1f58577..c3df4207283 100644 --- a/cpp/src/community/louvain.cu +++ b/cpp/src/community/louvain.cu @@ -30,8 +30,8 @@ namespace detail { template std::pair>, weight_t> louvain( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph_view, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph_view, size_t max_level, weight_t resolution) { @@ -46,8 +46,8 @@ std::pair>, weight_t> louvain( template std::pair>, weight_t> louvain( - raft::handle_t const &handle, - experimental::graph_view_t const &graph_view, + raft::handle_t const& handle, + experimental::graph_view_t const& graph_view, size_t max_level, weight_t resolution) { @@ -60,10 +60,10 @@ std::pair>, weight_t> louvain( } template -void flatten_dendrogram(raft::handle_t const &handle, - legacy::GraphCSRView const &graph_view, - Dendrogram const &dendrogram, - vertex_t *clustering) +void flatten_dendrogram(raft::handle_t const& handle, + legacy::GraphCSRView const& graph_view, + Dendrogram const& dendrogram, + vertex_t* clustering) { rmm::device_uvector vertex_ids_v(graph_view.number_of_vertices, handle.get_stream()); @@ -78,10 +78,10 @@ void flatten_dendrogram(raft::handle_t const &handle, template void flatten_dendrogram( - raft::handle_t const &handle, - experimental::graph_view_t const &graph_view, - Dendrogram const &dendrogram, - vertex_t *clustering) + raft::handle_t const& handle, + experimental::graph_view_t const& graph_view, + Dendrogram const& dendrogram, + vertex_t* clustering) { rmm::device_uvector vertex_ids_v(graph_view.get_number_of_vertices(), handle.get_stream()); @@ -100,8 +100,8 @@ void flatten_dendrogram( template std::pair>, typename graph_view_t::weight_type> -louvain(raft::handle_t const &handle, - graph_view_t const &graph_view, +louvain(raft::handle_t const& handle, + graph_view_t const& graph_view, size_t max_level, typename graph_view_t::weight_type resolution) { @@ -109,19 +109,19 @@ louvain(raft::handle_t const &handle, } template -void flatten_dendrogram(raft::handle_t const &handle, - graph_view_t const &graph_view, - Dendrogram const &dendrogram, - typename graph_view_t::vertex_type *clustering) +void flatten_dendrogram(raft::handle_t const& handle, + graph_view_t const& graph_view, + Dendrogram const& dendrogram, + typename graph_view_t::vertex_type* clustering) { detail::flatten_dendrogram(handle, graph_view, dendrogram, clustering); } template std::pair louvain( - raft::handle_t const &handle, - graph_view_t const &graph_view, - typename graph_view_t::vertex_type *clustering, + raft::handle_t const& handle, + graph_view_t const& graph_view, + typename graph_view_t::vertex_type* clustering, size_t max_level, typename graph_view_t::weight_type resolution) { @@ -142,149 +142,149 @@ std::pair louvain( // Explicit template instantations template std::pair>, float> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, float); template std::pair>, float> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, float); template std::pair>, float> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, float); template std::pair>, double> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, double); template std::pair>, double> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, double); template std::pair>, double> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, double); template std::pair>, float> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, float); template std::pair>, float> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, float); template std::pair>, float> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, float); template std::pair>, double> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, double); template std::pair>, double> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, double); template std::pair>, double> louvain( - raft::handle_t const &, - experimental::graph_view_t const &, + raft::handle_t const&, + experimental::graph_view_t const&, size_t, double); -template std::pair louvain(raft::handle_t const &, - legacy::GraphCSRView const &, - int32_t *, +template std::pair louvain(raft::handle_t const&, + legacy::GraphCSRView const&, + int32_t*, size_t, float); -template std::pair louvain(raft::handle_t const &, - legacy::GraphCSRView const &, - int32_t *, +template std::pair louvain(raft::handle_t const&, + legacy::GraphCSRView const&, + int32_t*, size_t, double); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, float); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, double); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, float); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, double); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int64_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int64_t*, size_t, float); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int64_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int64_t*, size_t, double); // instantations with multi_gpu = true template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, float); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, double); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, float); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int32_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int32_t*, size_t, double); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int64_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int64_t*, size_t, float); template std::pair louvain( - raft::handle_t const &, - experimental::graph_view_t const &, - int64_t *, + raft::handle_t const&, + experimental::graph_view_t const&, + int64_t*, size_t, double); diff --git a/cpp/src/community/louvain.cuh b/cpp/src/community/louvain.cuh index a09f648b37a..31c5a2281ad 100644 --- a/cpp/src/community/louvain.cuh +++ b/cpp/src/community/louvain.cuh @@ -41,7 +41,7 @@ class Louvain { using edge_t = typename graph_type::edge_type; using weight_t = typename graph_type::weight_type; - Louvain(raft::handle_t const &handle, graph_type const &graph) + Louvain(raft::handle_t const& handle, graph_type const& graph) : #ifdef TIMING hr_timer_(), @@ -84,8 +84,8 @@ class Louvain { weight_t modularity(weight_t total_edge_weight, weight_t resolution, - graph_t const &graph, - vertex_t const *d_cluster) + graph_t const& graph, + vertex_t const* d_cluster) { vertex_t n_verts = graph.number_of_vertices; @@ -140,9 +140,9 @@ class Louvain { return Q; } - Dendrogram const &get_dendrogram() const { return *dendrogram_; } + Dendrogram const& get_dendrogram() const { return *dendrogram_; } - Dendrogram &get_dendrogram() { return *dendrogram_; } + Dendrogram& get_dendrogram() { return *dendrogram_; } std::unique_ptr> move_dendrogram() { return std::move(dendrogram_); } @@ -188,7 +188,7 @@ class Louvain { } protected: - void timer_start(std::string const ®ion) + void timer_start(std::string const& region) { #ifdef TIMING hr_timer_.start(region); @@ -203,7 +203,7 @@ class Louvain { #endif } - void timer_display(std::ostream &os) + void timer_display(std::ostream& os) { #ifdef TIMING hr_timer_.display(os); @@ -220,15 +220,15 @@ class Louvain { } public: - void compute_vertex_and_cluster_weights(graph_type const &graph) + void compute_vertex_and_cluster_weights(graph_type const& graph) { timer_start("compute_vertex_and_cluster_weights"); - edge_t const *d_offsets = graph.offsets; - vertex_t const *d_indices = graph.indices; - weight_t const *d_weights = graph.edge_data; - weight_t *d_vertex_weights = vertex_weights_v_.data(); - weight_t *d_cluster_weights = cluster_weights_v_.data(); + edge_t const* d_offsets = graph.offsets; + vertex_t const* d_indices = graph.indices; + weight_t const* d_weights = graph.edge_data; + weight_t* d_vertex_weights = vertex_weights_v_.data(); + weight_t* d_cluster_weights = cluster_weights_v_.data(); // // MNMG: copy_v_transform_reduce_out_nbr, then copy @@ -251,7 +251,7 @@ class Louvain { virtual weight_t update_clustering(weight_t total_edge_weight, weight_t resolution, - graph_type const &graph) + graph_type const& graph) { timer_start("update_clustering"); @@ -262,10 +262,10 @@ class Louvain { rmm::device_uvector old_cluster_sum_v(graph.number_of_vertices, handle_.get_stream_view()); - vertex_t *d_cluster = dendrogram_->current_level_begin(); - weight_t const *d_vertex_weights = vertex_weights_v_.data(); - weight_t *d_cluster_weights = cluster_weights_v_.data(); - weight_t *d_delta_Q = delta_Q_v.data(); + vertex_t* d_cluster = dendrogram_->current_level_begin(); + weight_t const* d_vertex_weights = vertex_weights_v_.data(); + weight_t* d_cluster_weights = cluster_weights_v_.data(); + weight_t* d_delta_Q = delta_Q_v.data(); thrust::copy(rmm::exec_policy(handle_.get_stream_view()), dendrogram_->current_level_begin(), @@ -308,21 +308,21 @@ class Louvain { void compute_delta_modularity(weight_t total_edge_weight, weight_t resolution, - graph_type const &graph, - rmm::device_uvector &cluster_hash_v, - rmm::device_uvector &old_cluster_sum_v, - rmm::device_uvector &delta_Q_v) + graph_type const& graph, + rmm::device_uvector& cluster_hash_v, + rmm::device_uvector& old_cluster_sum_v, + rmm::device_uvector& delta_Q_v) { - edge_t const *d_offsets = graph.offsets; - weight_t const *d_weights = graph.edge_data; - vertex_t const *d_cluster = dendrogram_->current_level_begin(); - weight_t const *d_vertex_weights = vertex_weights_v_.data(); - weight_t const *d_cluster_weights = cluster_weights_v_.data(); + edge_t const* d_offsets = graph.offsets; + weight_t const* d_weights = graph.edge_data; + vertex_t const* d_cluster = dendrogram_->current_level_begin(); + weight_t const* d_vertex_weights = vertex_weights_v_.data(); + weight_t const* d_cluster_weights = cluster_weights_v_.data(); - vertex_t *d_cluster_hash = cluster_hash_v.data(); - weight_t *d_delta_Q = delta_Q_v.data(); - weight_t *d_old_cluster_sum = old_cluster_sum_v.data(); - weight_t *d_new_cluster_sum = d_delta_Q; + vertex_t* d_cluster_hash = cluster_hash_v.data(); + weight_t* d_delta_Q = delta_Q_v.data(); + weight_t* d_old_cluster_sum = old_cluster_sum_v.data(); + weight_t* d_new_cluster_sum = d_delta_Q; thrust::fill(rmm::exec_policy(handle_.get_stream_view()), cluster_hash_v.begin(), @@ -409,10 +409,10 @@ class Louvain { }); } - void assign_nodes(graph_type const &graph, - rmm::device_uvector &cluster_hash_v, - rmm::device_uvector &next_cluster_v, - rmm::device_uvector &delta_Q_v, + void assign_nodes(graph_type const& graph, + rmm::device_uvector& cluster_hash_v, + rmm::device_uvector& next_cluster_v, + rmm::device_uvector& delta_Q_v, bool up_down) { rmm::device_uvector temp_vertices_v(graph.number_of_vertices, @@ -483,7 +483,7 @@ class Louvain { }); } - void shrink_graph(graph_t &graph) + void shrink_graph(graph_t& graph) { timer_start("shrinking graph"); @@ -499,9 +499,9 @@ class Louvain { vertex_t renumber_clusters() { - vertex_t *d_tmp_array = tmp_arr_v_.data(); - vertex_t *d_cluster_inverse = cluster_inverse_v_.data(); - vertex_t *d_cluster = dendrogram_->current_level_begin(); + vertex_t* d_tmp_array = tmp_arr_v_.data(); + vertex_t* d_cluster_inverse = cluster_inverse_v_.data(); + vertex_t* d_cluster = dendrogram_->current_level_begin(); vertex_t old_num_clusters = dendrogram_->current_level_size(); @@ -560,7 +560,7 @@ class Louvain { return new_num_clusters; } - void generate_superverticies_graph(graph_t &graph, vertex_t num_clusters) + void generate_superverticies_graph(graph_t& graph, vertex_t num_clusters) { rmm::device_uvector new_src_v(graph.number_of_edges, handle_.get_stream_view()); rmm::device_uvector new_dst_v(graph.number_of_edges, handle_.get_stream_view()); @@ -627,7 +627,7 @@ class Louvain { } protected: - raft::handle_t const &handle_; + raft::handle_t const& handle_; vertex_t number_of_vertices_; edge_t number_of_edges_; diff --git a/cpp/src/community/spectral_clustering.cu b/cpp/src/community/spectral_clustering.cu index 7fc52d6ed5b..4dd27a56b70 100644 --- a/cpp/src/community/spectral_clustering.cu +++ b/cpp/src/community/spectral_clustering.cu @@ -39,16 +39,16 @@ namespace ext_raft { namespace detail { template -void balancedCutClustering_impl(legacy::GraphCSRView const &graph, +void balancedCutClustering_impl(legacy::GraphCSRView const& graph, vertex_t n_clusters, vertex_t n_eig_vects, weight_t evs_tolerance, int evs_max_iter, weight_t kmean_tolerance, int kmean_max_iter, - vertex_t *clustering, - weight_t *eig_vals, - weight_t *eig_vects) + vertex_t* clustering, + weight_t* eig_vals, + weight_t* eig_vects) { RAFT_EXPECTS(graph.edge_data != nullptr, "API error, graph must have weights"); RAFT_EXPECTS(evs_tolerance >= weight_t{0.0}, @@ -110,16 +110,16 @@ void balancedCutClustering_impl(legacy::GraphCSRView template void spectralModularityMaximization_impl( - legacy::GraphCSRView const &graph, + legacy::GraphCSRView const& graph, vertex_t n_clusters, vertex_t n_eig_vects, weight_t evs_tolerance, int evs_max_iter, weight_t kmean_tolerance, int kmean_max_iter, - vertex_t *clustering, - weight_t *eig_vals, - weight_t *eig_vects) + vertex_t* clustering, + weight_t* eig_vals, + weight_t* eig_vects) { RAFT_EXPECTS(graph.edge_data != nullptr, "API error, graph must have weights"); RAFT_EXPECTS(evs_tolerance >= weight_t{0.0}, @@ -187,10 +187,10 @@ void spectralModularityMaximization_impl( } template -void analyzeModularityClustering_impl(legacy::GraphCSRView const &graph, +void analyzeModularityClustering_impl(legacy::GraphCSRView const& graph, int n_clusters, - vertex_t const *clustering, - weight_t *modularity) + vertex_t const* clustering, + weight_t* modularity) { raft::handle_t handle; auto stream = handle.get_stream(); @@ -208,11 +208,11 @@ void analyzeModularityClustering_impl(legacy::GraphCSRView -void analyzeBalancedCut_impl(legacy::GraphCSRView const &graph, +void analyzeBalancedCut_impl(legacy::GraphCSRView const& graph, vertex_t n_clusters, - vertex_t const *clustering, - weight_t *edgeCut, - weight_t *ratioCut) + vertex_t const* clustering, + weight_t* edgeCut, + weight_t* ratioCut) { raft::handle_t handle; auto stream = handle.get_stream(); @@ -241,14 +241,14 @@ void analyzeBalancedCut_impl(legacy::GraphCSRView co } // namespace detail template -void balancedCutClustering(legacy::GraphCSRView const &graph, +void balancedCutClustering(legacy::GraphCSRView const& graph, VT num_clusters, VT num_eigen_vects, WT evs_tolerance, int evs_max_iter, WT kmean_tolerance, int kmean_max_iter, - VT *clustering) + VT* clustering) { rmm::device_vector eig_vals(num_eigen_vects); rmm::device_vector eig_vects(num_eigen_vects * graph.number_of_vertices); @@ -266,14 +266,14 @@ void balancedCutClustering(legacy::GraphCSRView const &graph, } template -void spectralModularityMaximization(legacy::GraphCSRView const &graph, +void spectralModularityMaximization(legacy::GraphCSRView const& graph, VT n_clusters, VT n_eigen_vects, WT evs_tolerance, int evs_max_iter, WT kmean_tolerance, int kmean_max_iter, - VT *clustering) + VT* clustering) { rmm::device_vector eig_vals(n_eigen_vects); rmm::device_vector eig_vects(n_eigen_vects * graph.number_of_vertices); @@ -291,54 +291,54 @@ void spectralModularityMaximization(legacy::GraphCSRView const &grap } template -void analyzeClustering_modularity(legacy::GraphCSRView const &graph, +void analyzeClustering_modularity(legacy::GraphCSRView const& graph, int n_clusters, - VT const *clustering, - WT *score) + VT const* clustering, + WT* score) { detail::analyzeModularityClustering_impl(graph, n_clusters, clustering, score); } template -void analyzeClustering_edge_cut(legacy::GraphCSRView const &graph, +void analyzeClustering_edge_cut(legacy::GraphCSRView const& graph, int n_clusters, - VT const *clustering, - WT *score) + VT const* clustering, + WT* score) { WT dummy{0.0}; detail::analyzeBalancedCut_impl(graph, n_clusters, clustering, score, &dummy); } template -void analyzeClustering_ratio_cut(legacy::GraphCSRView const &graph, +void analyzeClustering_ratio_cut(legacy::GraphCSRView const& graph, int n_clusters, - VT const *clustering, - WT *score) + VT const* clustering, + WT* score) { WT dummy{0.0}; detail::analyzeBalancedCut_impl(graph, n_clusters, clustering, &dummy, score); } template void balancedCutClustering( - legacy::GraphCSRView const &, int, int, float, int, float, int, int *); + legacy::GraphCSRView const&, int, int, float, int, float, int, int*); template void balancedCutClustering( - legacy::GraphCSRView const &, int, int, double, int, double, int, int *); + legacy::GraphCSRView const&, int, int, double, int, double, int, int*); template void spectralModularityMaximization( - legacy::GraphCSRView const &, int, int, float, int, float, int, int *); + legacy::GraphCSRView const&, int, int, float, int, float, int, int*); template void spectralModularityMaximization( - legacy::GraphCSRView const &, int, int, double, int, double, int, int *); + legacy::GraphCSRView const&, int, int, double, int, double, int, int*); template void analyzeClustering_modularity( - legacy::GraphCSRView const &, int, int const *, float *); + legacy::GraphCSRView const&, int, int const*, float*); template void analyzeClustering_modularity( - legacy::GraphCSRView const &, int, int const *, double *); + legacy::GraphCSRView const&, int, int const*, double*); template void analyzeClustering_edge_cut( - legacy::GraphCSRView const &, int, int const *, float *); + legacy::GraphCSRView const&, int, int const*, float*); template void analyzeClustering_edge_cut( - legacy::GraphCSRView const &, int, int const *, double *); + legacy::GraphCSRView const&, int, int const*, double*); template void analyzeClustering_ratio_cut( - legacy::GraphCSRView const &, int, int const *, float *); + legacy::GraphCSRView const&, int, int const*, float*); template void analyzeClustering_ratio_cut( - legacy::GraphCSRView const &, int, int const *, double *); + legacy::GraphCSRView const&, int, int const*, double*); } // namespace ext_raft } // namespace cugraph diff --git a/cpp/src/community/triangles_counting.cu b/cpp/src/community/triangles_counting.cu index 9aaf79490cb..97543d28c62 100644 --- a/cpp/src/community/triangles_counting.cu +++ b/cpp/src/community/triangles_counting.cu @@ -31,8 +31,8 @@ #include "cub/cub.cuh" #define TH_CENT_K_LOCLEN (34) -#define WP_LEN_TH1 (24) -#define WP_LEN_TH2 (2) +#define WP_LEN_TH1 (24) +#define WP_LEN_TH2 (2) #if WP_LEN_TH1 > 32 #error WP_LEN_TH1 must be <= 32! @@ -41,9 +41,9 @@ #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define MAX(x, y) (((x) > (y)) ? (x) : (y)) -#define THREADS (128) +#define THREADS (128) #define DIV_UP(a, b) (((a) + ((b)-1)) / (b)) -#define BITSOF(x) (sizeof(*x) * 8) +#define BITSOF(x) (sizeof(*x) * 8) #define BLK_BWL0 (128) @@ -73,9 +73,9 @@ struct spmat_t { T N; T nnz; T nrows; - const T *roff_d; - const T *rows_d; - const T *cols_d; + const T* roff_d; + const T* rows_d; + const T* cols_d; bool is_lower_triangular; }; @@ -173,7 +173,9 @@ __device__ __forceinline__ T block_sum(T v) const int wid = threadIdx.x / 32 + ((BDIM_Y > 1) ? threadIdx.y * (BDIM_X / 32) : 0); #pragma unroll - for (int i = WSIZE / 2; i; i >>= 1) { v += __shfl_down_sync(raft::warp_full_mask(), v, i); } + for (int i = WSIZE / 2; i; i >>= 1) { + v += __shfl_down_sync(raft::warp_full_mask(), v, i); + } if (lid == 0) sh[wid] = v; __syncthreads(); @@ -197,13 +199,13 @@ template __global__ void tricnt_b2b_k(const ROW_T ner, - const ROW_T *__restrict__ rows, - const OFF_T *__restrict__ roff, - const ROW_T *__restrict__ cols, - CNT_T *__restrict__ ocnt, - MAP_T *__restrict__ bmapL0, + const ROW_T* __restrict__ rows, + const OFF_T* __restrict__ roff, + const ROW_T* __restrict__ cols, + CNT_T* __restrict__ ocnt, + MAP_T* __restrict__ bmapL0, const size_t bmldL0, - MAP_T *__restrict__ bmapL1, + MAP_T* __restrict__ bmapL1, const size_t bmldL1) { CNT_T __cnt = 0; @@ -277,11 +279,11 @@ __global__ void tricnt_b2b_k(const ROW_T ner, template void tricnt_b2b(T nblock, - spmat_t *m, - uint64_t *ocnt_d, - unsigned int *bmapL0_d, + spmat_t* m, + uint64_t* ocnt_d, + unsigned int* bmapL0_d, size_t bmldL0, - unsigned int *bmapL1_d, + unsigned int* bmapL1_d, size_t bmldL1, cudaStream_t stream) { @@ -294,13 +296,15 @@ void tricnt_b2b(T nblock, ////////////////////////////////////////////////////////////////////////////////////////// template -__device__ __forceinline__ T block_sum_sh(T v, T *sh) +__device__ __forceinline__ T block_sum_sh(T v, T* sh) { const int lid = threadIdx.x % 32; const int wid = threadIdx.x / 32 + ((BDIM_Y > 1) ? threadIdx.y * (BDIM_X / 32) : 0); #pragma unroll - for (int i = WSIZE / 2; i; i >>= 1) { v += __shfl_down_sync(raft::warp_full_mask(), v, i); } + for (int i = WSIZE / 2; i; i >>= 1) { + v += __shfl_down_sync(raft::warp_full_mask(), v, i); + } if (lid == 0) sh[wid] = v; __syncthreads(); @@ -317,10 +321,10 @@ __device__ __forceinline__ T block_sum_sh(T v, T *sh) template __global__ void tricnt_bsh_k(const ROW_T ner, - const ROW_T *__restrict__ rows, - const OFF_T *__restrict__ roff, - const ROW_T *__restrict__ cols, - CNT_T *__restrict__ ocnt, + const ROW_T* __restrict__ rows, + const OFF_T* __restrict__ roff, + const ROW_T* __restrict__ cols, + CNT_T* __restrict__ ocnt, const size_t bmld) { CNT_T __cnt = 0; @@ -374,7 +378,7 @@ __global__ void tricnt_bsh_k(const ROW_T ner, __syncthreads(); if (lastcol - firstcol < rend - rbeg) { for (int i = firstcol; i <= lastcol; i += BDIM) { - if (i + threadIdx.x <= lastcol) { ((unsigned long long *)shm)[i + threadIdx.x] = 0ull; } + if (i + threadIdx.x <= lastcol) { ((unsigned long long*)shm)[i + threadIdx.x] = 0ull; } } } else { for (int i = rbeg; i < rend; i += BDIM) { @@ -383,14 +387,14 @@ __global__ void tricnt_bsh_k(const ROW_T ner, } __syncthreads(); } - __cnt = block_sum_sh(__cnt, (uint64_t *)shm); + __cnt = block_sum_sh(__cnt, (uint64_t*)shm); if (threadIdx.x == 0) ocnt[blockIdx.x] = __cnt; return; } template -void tricnt_bsh(T nblock, spmat_t *m, uint64_t *ocnt_d, size_t bmld, cudaStream_t stream) +void tricnt_bsh(T nblock, spmat_t* m, uint64_t* ocnt_d, size_t bmld, cudaStream_t stream) { tricnt_bsh_k<<>>( m->nrows, m->rows_d, m->roff_d, m->cols_d, ocnt_d, bmld); @@ -408,11 +412,11 @@ template __global__ void tricnt_wrp_ps_k(const ROW_T ner, - const ROW_T *__restrict__ rows, - const OFF_T *__restrict__ roff, - const ROW_T *__restrict__ cols, - CNT_T *__restrict__ ocnt, - MAP_T *__restrict__ bmap, + const ROW_T* __restrict__ rows, + const OFF_T* __restrict__ roff, + const ROW_T* __restrict__ cols, + CNT_T* __restrict__ ocnt, + MAP_T* __restrict__ bmap, const size_t bmld) { __shared__ OFF_T sho[NWARP][WSIZE]; @@ -520,7 +524,7 @@ __global__ void tricnt_wrp_ps_k(const ROW_T ner, if (lastcol - firstcol < rend - rbeg) { for (int i = firstcol; i <= lastcol; i += WSIZE) { - if (i + threadIdx.x <= lastcol) { ((unsigned long long *)bmap)[i + threadIdx.x] = 0ull; } + if (i + threadIdx.x <= lastcol) { ((unsigned long long*)bmap)[i + threadIdx.x] = 0ull; } } } else { for (int i = rbeg; i < rend; i += WSIZE) { @@ -537,7 +541,7 @@ __global__ void tricnt_wrp_ps_k(const ROW_T ner, template void tricnt_wrp( - T nblock, spmat_t *m, uint64_t *ocnt_d, unsigned int *bmap_d, size_t bmld, cudaStream_t stream) + T nblock, spmat_t* m, uint64_t* ocnt_d, unsigned int* bmap_d, size_t bmld, cudaStream_t stream) { dim3 block(32, THREADS / 32); tricnt_wrp_ps_k<32, THREADS / 32, WP_LEN_TH1, WP_LEN_TH2> @@ -549,10 +553,10 @@ void tricnt_wrp( ////////////////////////////////////////////////////////////////////////////////////////// template __global__ void tricnt_thr_k(const ROW_T ner, - const ROW_T *__restrict__ rows, - const OFF_T *__restrict__ roff, - const ROW_T *__restrict__ cols, - CNT_T *__restrict__ ocnt) + const ROW_T* __restrict__ rows, + const OFF_T* __restrict__ roff, + const ROW_T* __restrict__ cols, + CNT_T* __restrict__ ocnt) { CNT_T __cnt = 0; const ROW_T tid = blockIdx.x * BDIM + threadIdx.x; @@ -619,7 +623,7 @@ __global__ void tricnt_thr_k(const ROW_T ner, } template -void tricnt_thr(T nblock, spmat_t *m, uint64_t *ocnt_d, cudaStream_t stream) +void tricnt_thr(T nblock, spmat_t* m, uint64_t* ocnt_d, cudaStream_t stream) { cudaFuncSetCacheConfig(tricnt_thr_k *m, uint64_t *ocnt_d, cudaStream_t stream) ///////////////////////////////////////////////////////////////// template struct NonEmptyRow { - const IndexType *p_roff; - __host__ __device__ NonEmptyRow(const IndexType *roff) : p_roff(roff) {} - __host__ __device__ __forceinline__ bool operator()(const IndexType &a) const + const IndexType* p_roff; + __host__ __device__ NonEmptyRow(const IndexType* roff) : p_roff(roff) {} + __host__ __device__ __forceinline__ bool operator()(const IndexType& a) const { return (p_roff[a] < p_roff[a + 1]); } @@ -647,7 +651,7 @@ struct NonEmptyRow { template void create_nondangling_vector( - const T *roff, T *p_nonempty, T *n_nonempty, size_t n, cudaStream_t stream) + const T* roff, T* p_nonempty, T* n_nonempty, size_t n, cudaStream_t stream) { if (n <= 0) return; thrust::counting_iterator it(0); @@ -660,7 +664,7 @@ void create_nondangling_vector( } template -uint64_t reduce(uint64_t *v_d, T n, cudaStream_t stream) +uint64_t reduce(uint64_t* v_d, T n, cudaStream_t stream) { rmm::device_vector tmp(1); @@ -694,8 +698,8 @@ class TrianglesCount { // Simple constructor TrianglesCount(IndexType num_vertices, IndexType num_edges, - IndexType const *row_offsets, - IndexType const *col_indices, + IndexType const* row_offsets, + IndexType const* col_indices, cudaStream_t stream = NULL); void count(); @@ -705,8 +709,8 @@ class TrianglesCount { template TrianglesCount::TrianglesCount(IndexType num_vertices, IndexType num_edges, - IndexType const *row_offsets, - IndexType const *col_indices, + IndexType const* row_offsets, + IndexType const* col_indices, cudaStream_t stream) : m_mat{num_vertices, num_edges, num_vertices, row_offsets, nullptr, col_indices}, m_stream{stream}, @@ -841,7 +845,7 @@ void TrianglesCount::count() } // namespace template -uint64_t triangle_count(legacy::GraphCSRView const &graph) +uint64_t triangle_count(legacy::GraphCSRView const& graph) { TrianglesCount counter( graph.number_of_vertices, graph.number_of_edges, graph.offsets, graph.indices); @@ -851,7 +855,7 @@ uint64_t triangle_count(legacy::GraphCSRView const &graph) } template uint64_t triangle_count( - legacy::GraphCSRView const &); + legacy::GraphCSRView const&); } // namespace triangle } // namespace cugraph diff --git a/cpp/src/components/connectivity.cu b/cpp/src/components/connectivity.cu index 0c0021d9e43..85134c1ad67 100644 --- a/cpp/src/components/connectivity.cu +++ b/cpp/src/components/connectivity.cu @@ -57,9 +57,9 @@ namespace detail { */ template std::enable_if_t::value> connected_components_impl( - legacy::GraphCSRView const &graph, + legacy::GraphCSRView const& graph, cugraph_cc_t connectivity_type, - VT *labels, + VT* labels, cudaStream_t stream) { using ByteT = unsigned char; // minimum addressable unit @@ -84,9 +84,9 @@ std::enable_if_t::value> connected_components_impl( } // namespace detail template -void connected_components(legacy::GraphCSRView const &graph, +void connected_components(legacy::GraphCSRView const& graph, cugraph_cc_t connectivity_type, - VT *labels) + VT* labels) { cudaStream_t stream{nullptr}; @@ -96,8 +96,8 @@ void connected_components(legacy::GraphCSRView const &graph, } template void connected_components( - legacy::GraphCSRView const &, cugraph_cc_t, int32_t *); + legacy::GraphCSRView const&, cugraph_cc_t, int32_t*); template void connected_components( - legacy::GraphCSRView const &, cugraph_cc_t, int64_t *); + legacy::GraphCSRView const&, cugraph_cc_t, int64_t*); } // namespace cugraph diff --git a/cpp/src/components/utils.h b/cpp/src/components/utils.h index 7b0e3042a97..4e7dbe075da 100644 --- a/cpp/src/components/utils.h +++ b/cpp/src/components/utils.h @@ -73,7 +73,9 @@ class Exception : public std::exception { return; } ///@todo: support for demangling of C++ symbol names - for (int i = 0; i < depth; ++i) { oss << "#" << i << " in " << strings.get()[i] << std::endl; } + for (int i = 0; i < depth; ++i) { + oss << "#" << i << " in " << strings.get()[i] << std::endl; + } msg += oss.str(); #endif // __GNUC__ } diff --git a/cpp/src/components/weak_cc.cuh b/cpp/src/components/weak_cc.cuh index d644a988117..e0da23c2ae8 100644 --- a/cpp/src/components/weak_cc.cuh +++ b/cpp/src/components/weak_cc.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,22 +47,22 @@ namespace Sparse { class WeakCCState { public: - bool *xa; - bool *fa; - bool *m; + bool* xa; + bool* fa; + bool* m; bool owner; - WeakCCState(bool *xa, bool *fa, bool *m) : xa(xa), fa(fa), m(m) {} + WeakCCState(bool* xa, bool* fa, bool* m) : xa(xa), fa(fa), m(m) {} }; template -__global__ void weak_cc_label_device(vertex_t *labels, - edge_t const *offsets, - vertex_t const *indices, +__global__ void weak_cc_label_device(vertex_t* labels, + edge_t const* offsets, + vertex_t const* indices, edge_t nnz, - bool *fa, - bool *xa, - bool *m, + bool* fa, + bool* xa, + bool* m, vertex_t startVertexId, vertex_t batchSize) { @@ -115,7 +115,7 @@ __global__ void weak_cc_label_device(vertex_t *labels, } template -__global__ void weak_cc_init_label_kernel(vertex_t *labels, +__global__ void weak_cc_init_label_kernel(vertex_t* labels, vertex_t startVertexId, vertex_t batchSize, vertex_t MAX_LABEL, @@ -132,7 +132,7 @@ __global__ void weak_cc_init_label_kernel(vertex_t *labels, template __global__ void weak_cc_init_all_kernel( - vertex_t *labels, bool *fa, bool *xa, vertex_t N, vertex_t MAX_LABEL) + vertex_t* labels, bool* fa, bool* xa, vertex_t N, vertex_t MAX_LABEL) { vertex_t tid = threadIdx.x + blockIdx.x * TPB_X; if (tid < N) { @@ -143,12 +143,12 @@ __global__ void weak_cc_init_all_kernel( } template -void weak_cc_label_batched(vertex_t *labels, - edge_t const *offsets, - vertex_t const *indices, +void weak_cc_label_batched(vertex_t* labels, + edge_t const* offsets, + vertex_t const* indices, edge_t nnz, vertex_t N, - WeakCCState &state, + WeakCCState& state, vertex_t startVertexId, vertex_t batchSize, cudaStream_t stream, @@ -217,14 +217,14 @@ template bool> -void weak_cc_batched(vertex_t *labels, - edge_t const *offsets, - vertex_t const *indices, +void weak_cc_batched(vertex_t* labels, + edge_t const* offsets, + vertex_t const* indices, edge_t nnz, vertex_t N, vertex_t startVertexId, vertex_t batchSize, - WeakCCState &state, + WeakCCState& state, cudaStream_t stream, Lambda filter_op) { @@ -273,9 +273,9 @@ template bool> -void weak_cc(vertex_t *labels, - edge_t const *offsets, - vertex_t const *indices, +void weak_cc(vertex_t* labels, + edge_t const* offsets, + vertex_t const* indices, edge_t nnz, vertex_t N, cudaStream_t stream, @@ -315,9 +315,9 @@ void weak_cc(vertex_t *labels, * @param stream Cuda stream to use */ template -void weak_cc_entry(vertex_t *labels, - edge_t const *offsets, - vertex_t const *indices, +void weak_cc_entry(vertex_t* labels, + edge_t const* offsets, + vertex_t const* indices, edge_t nnz, vertex_t N, cudaStream_t stream) diff --git a/cpp/src/components/weakly_connected_components.cu b/cpp/src/components/weakly_connected_components.cu index 848a6d9e615..57441cb9b4f 100644 --- a/cpp/src/components/weakly_connected_components.cu +++ b/cpp/src/components/weakly_connected_components.cu @@ -59,13 +59,13 @@ template std::tuple, typename GraphViewType::vertex_type, typename GraphViewType::edge_type> -accumulate_new_roots(raft::handle_t const &handle, +accumulate_new_roots(raft::handle_t const& handle, vertex_partition_device_view_t vertex_partition, - typename GraphViewType::vertex_type const *components, - typename GraphViewType::edge_type const *degrees, - typename GraphViewType::vertex_type const *candidate_first, - typename GraphViewType::vertex_type const *candidate_last, + typename GraphViewType::vertex_type const* components, + typename GraphViewType::edge_type const* degrees, + typename GraphViewType::vertex_type const* candidate_first, + typename GraphViewType::vertex_type const* candidate_last, typename GraphViewType::vertex_type max_new_roots, typename GraphViewType::edge_type degree_sum_threshold) { @@ -173,12 +173,12 @@ struct v_op_t { vertex_partition_device_view_t vertex_partition{}; - vertex_type *level_components{}; + vertex_type* level_components{}; decltype(thrust::make_zip_iterator(thrust::make_tuple( - static_cast(nullptr), static_cast(nullptr)))) edge_buffer_first{}; + static_cast(nullptr), static_cast(nullptr)))) edge_buffer_first{}; // FIXME: we can use cuda::atomic instead but currently on a system with x86 + GPU, this requires // placing the atomic barrier on managed memory and this adds additional complication. - size_t *num_edge_inserts{}; + size_t* num_edge_inserts{}; size_t next_bucket_idx{}; size_t conflict_bucket_idx{}; // relevant only if GraphViewType::is_multi_gpu is true @@ -214,9 +214,9 @@ struct v_op_t { }; template -void weakly_connected_components_impl(raft::handle_t const &handle, - GraphViewType const &push_graph_view, - typename GraphViewType::vertex_type *components, +void weakly_connected_components_impl(raft::handle_t const& handle, + GraphViewType const& push_graph_view, + typename GraphViewType::vertex_type* components, bool do_expensive_check) { using vertex_t = typename GraphViewType::vertex_type; @@ -346,7 +346,7 @@ void weakly_connected_components_impl(raft::handle_t const &handle, auto init_max_new_roots = max_new_roots; if (GraphViewType::is_multi_gpu) { - auto &comm = handle.get_comms(); + auto& comm = handle.get_comms(); auto const comm_rank = comm.get_rank(); auto const comm_size = comm.get_size(); @@ -401,7 +401,9 @@ void weakly_connected_components_impl(raft::handle_t const &handle, std::shuffle(gpuids.begin(), gpuids.end(), std::mt19937(rd())); gpuids.resize( std::max(static_cast(gpuids.size() * max_new_roots_ratio), vertex_t{1})); - for (size_t i = 0; i < gpuids.size(); ++i) { ++init_max_new_root_counts[gpuids[i]]; } + for (size_t i = 0; i < gpuids.size(); ++i) { + ++init_max_new_root_counts[gpuids[i]]; + } } else { std::fill(init_max_new_root_counts.begin(), init_max_new_root_counts.end(), @@ -560,7 +562,7 @@ void weakly_connected_components_impl(raft::handle_t const &handle, atomicCAS(col_components + col_offset, invalid_component_id::value, tag); if (old != invalid_component_id::value && old != tag) { // conflict static_assert(sizeof(unsigned long long int) == sizeof(size_t)); - auto edge_idx = atomicAdd(reinterpret_cast(num_edge_inserts), + auto edge_idx = atomicAdd(reinterpret_cast(num_edge_inserts), static_cast(1)); // keep only the edges in the lower triangular part *(edge_buffer_first + edge_idx) = @@ -582,7 +584,7 @@ void weakly_connected_components_impl(raft::handle_t const &handle, if (GraphViewType::is_multi_gpu) { auto cur_num_edge_inserts = num_edge_inserts.value(handle.get_stream_view()); - auto &conflict_bucket = vertex_frontier.get_bucket(static_cast(Bucket::conflict)); + auto& conflict_bucket = vertex_frontier.get_bucket(static_cast(Bucket::conflict)); resize_dataframe_buffer>( edge_buffer, cur_num_edge_inserts + conflict_bucket.size(), handle.get_stream()); thrust::for_each( @@ -599,7 +601,7 @@ void weakly_connected_components_impl(raft::handle_t const &handle, auto old = *(level_components + v_offset); auto tag = thrust::get<1>(tagged_v); static_assert(sizeof(unsigned long long int) == sizeof(size_t)); - auto edge_idx = atomicAdd(reinterpret_cast(num_edge_inserts), + auto edge_idx = atomicAdd(reinterpret_cast(num_edge_inserts), static_cast(1)); // keep only the edges in the lower triangular part *(edge_buffer_first + edge_idx) = @@ -663,7 +665,7 @@ void weakly_connected_components_impl(raft::handle_t const &handle, auto num_inserts = num_edge_inserts.value(handle.get_stream_view()); auto aggregate_num_inserts = num_inserts; if (GraphViewType::is_multi_gpu) { - auto &comm = handle.get_comms(); + auto& comm = handle.get_comms(); aggregate_num_inserts = host_scalar_allreduce(comm, num_inserts, handle.get_stream()); } @@ -681,11 +683,11 @@ void weakly_connected_components_impl(raft::handle_t const &handle, output_first); if (GraphViewType::is_multi_gpu) { - auto &comm = handle.get_comms(); + auto& comm = handle.get_comms(); auto const comm_size = comm.get_size(); - auto &row_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); + auto& row_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); auto const row_comm_size = row_comm.get_size(); - auto &col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); + auto& col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); auto const col_comm_size = col_comm.get_size(); std::tie(edge_buffer, std::ignore) = @@ -767,9 +769,9 @@ void weakly_connected_components_impl(raft::handle_t const &handle, template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t* components, bool do_expensive_check) { weakly_connected_components_impl(handle, graph_view, components, do_expensive_check); @@ -778,75 +780,75 @@ void weakly_connected_components( // explicit instantiation template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* components, bool do_expensive_check); template void weakly_connected_components( - raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *components, + raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* components, bool do_expensive_check); } // namespace experimental diff --git a/cpp/src/converters/COOtoCSR.cu b/cpp/src/converters/COOtoCSR.cu index 2f6eac8ce8f..49986810539 100644 --- a/cpp/src/converters/COOtoCSR.cu +++ b/cpp/src/converters/COOtoCSR.cu @@ -21,64 +21,64 @@ namespace cugraph { // Explicit instantiation for uint32_t + float template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // Explicit instantiation for uint32_t + double template std::unique_ptr> coo_to_csr( - legacy::GraphCOOView const &graph, rmm::mr::device_memory_resource *); + legacy::GraphCOOView const& graph, rmm::mr::device_memory_resource*); // Explicit instantiation for int + float template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // Explicit instantiation for int + double template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // Explicit instantiation for int64_t + float template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // Explicit instantiation for int64_t + double template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // in-place versions: // // Explicit instantiation for uint32_t + float template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // Explicit instantiation for uint32_t + double template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // Explicit instantiation for int + float template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // Explicit instantiation for int + double template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // Explicit instantiation for int64_t + float template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // Explicit instantiation for int64_t + double template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); } // namespace cugraph diff --git a/cpp/src/converters/COOtoCSR.cuh b/cpp/src/converters/COOtoCSR.cuh index 10899230b2a..641b037efdd 100644 --- a/cpp/src/converters/COOtoCSR.cuh +++ b/cpp/src/converters/COOtoCSR.cuh @@ -60,7 +60,7 @@ namespace detail { * @param[out] result Total number of vertices */ template -VT sort(legacy::GraphCOOView &graph, rmm::cuda_stream_view stream_view) +VT sort(legacy::GraphCOOView& graph, rmm::cuda_stream_view stream_view) { VT max_src_id; VT max_dst_id; @@ -97,8 +97,8 @@ VT sort(legacy::GraphCOOView &graph, rmm::cuda_stream_view stream_vi } template -void fill_offset(VT *source, - ET *offsets, +void fill_offset(VT* source, + ET* offsets, VT number_of_vertices, ET number_of_edges, rmm::cuda_stream_view stream_view) @@ -125,16 +125,16 @@ void fill_offset(VT *source, } template -rmm::device_buffer create_offset(VT *source, +rmm::device_buffer create_offset(VT* source, VT number_of_vertices, ET number_of_edges, rmm::cuda_stream_view stream_view, - rmm::mr::device_memory_resource *mr) + rmm::mr::device_memory_resource* mr) { // Offset array needs an extra element at the end to contain the ending offsets // of the last vertex rmm::device_buffer offsets_buffer(sizeof(ET) * (number_of_vertices + 1), stream_view, mr); - ET *offsets = static_cast(offsets_buffer.data()); + ET* offsets = static_cast(offsets_buffer.data()); fill_offset(source, offsets, number_of_vertices, number_of_edges, stream_view); @@ -145,7 +145,7 @@ rmm::device_buffer create_offset(VT *source, template std::unique_ptr> coo_to_csr( - legacy::GraphCOOView const &graph, rmm::mr::device_memory_resource *mr) + legacy::GraphCOOView const& graph, rmm::mr::device_memory_resource* mr) { rmm::cuda_stream_view stream_view; @@ -166,8 +166,8 @@ std::unique_ptr> coo_to_csr( } template -void coo_to_csr_inplace(legacy::GraphCOOView &graph, - legacy::GraphCSRView &result) +void coo_to_csr_inplace(legacy::GraphCOOView& graph, + legacy::GraphCSRView& result) { rmm::cuda_stream_view stream_view; @@ -190,64 +190,64 @@ void coo_to_csr_inplace(legacy::GraphCOOView &graph, // // EIDecl for uint32_t + float extern template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // EIDecl for uint32_t + double extern template std::unique_ptr> coo_to_csr( - legacy::GraphCOOView const &graph, rmm::mr::device_memory_resource *); + legacy::GraphCOOView const& graph, rmm::mr::device_memory_resource*); // EIDecl for int + float extern template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // EIDecl for int + double extern template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // EIDecl for int64_t + float extern template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // EIDecl for int64_t + double extern template std::unique_ptr> -coo_to_csr(legacy::GraphCOOView const &graph, - rmm::mr::device_memory_resource *); +coo_to_csr(legacy::GraphCOOView const& graph, + rmm::mr::device_memory_resource*); // in-place versions: // // EIDecl for uint32_t + float extern template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // EIDecl for uint32_t + double extern template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // EIDecl for int + float extern template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // EIDecl for int + double extern template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // EIDecl for int64_t + float extern template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); // EIDecl for int64_t + double extern template void coo_to_csr_inplace( - legacy::GraphCOOView &graph, - legacy::GraphCSRView &result); + legacy::GraphCOOView& graph, + legacy::GraphCSRView& result); } // namespace cugraph diff --git a/cpp/src/converters/permute_graph.cuh b/cpp/src/converters/permute_graph.cuh index 5f9cd8d7d7f..024dfc2f3a7 100644 --- a/cpp/src/converters/permute_graph.cuh +++ b/cpp/src/converters/permute_graph.cuh @@ -24,8 +24,8 @@ namespace detail { template struct permutation_functor { - IdxT const *permutation; - permutation_functor(IdxT const *p) : permutation(p) {} + IdxT const* permutation; + permutation_functor(IdxT const* p) : permutation(p) {} __host__ __device__ IdxT operator()(IdxT in) const { return permutation[in]; } }; @@ -42,8 +42,8 @@ struct permutation_functor { * @return The permuted graph. */ template -void permute_graph(legacy::GraphCSRView const &graph, - vertex_t const *permutation, +void permute_graph(legacy::GraphCSRView const& graph, + vertex_t const* permutation, legacy::GraphCSRView result, cudaStream_t stream = 0) { @@ -52,9 +52,9 @@ void permute_graph(legacy::GraphCSRView const &graph rmm::device_vector dst_vertices_v(graph.number_of_edges); rmm::device_vector weights_v(graph.number_of_edges); - vertex_t *d_src = src_vertices_v.data().get(); - vertex_t *d_dst = dst_vertices_v.data().get(); - weight_t *d_weights = weights_v.data().get(); + vertex_t* d_src = src_vertices_v.data().get(); + vertex_t* d_dst = dst_vertices_v.data().get(); + weight_t* d_weights = weights_v.data().get(); graph.get_source_indices(d_src); diff --git a/cpp/src/cores/core_number.cu b/cpp/src/cores/core_number.cu index 74b3070ca8e..b23e7a25405 100644 --- a/cpp/src/cores/core_number.cu +++ b/cpp/src/cores/core_number.cu @@ -25,7 +25,7 @@ namespace cugraph { namespace detail { template -void core_number(legacy::GraphCSRView const &graph, int *core_number) +void core_number(legacy::GraphCSRView const& graph, int* core_number) { using HornetGraph = hornet::gpu::HornetStatic; using HornetInit = hornet::HornetInit; @@ -38,9 +38,9 @@ void core_number(legacy::GraphCSRView const &graph, int *core_number struct FilterEdges { int k; - int *core_number; + int* core_number; - FilterEdges(int _k, int *d_core_num) : k(_k), core_number(d_core_num) {} + FilterEdges(int _k, int* d_core_num) : k(_k), core_number(d_core_num) {} template __host__ __device__ bool operator()(T t) @@ -52,9 +52,9 @@ struct FilterEdges { }; template -void extract_edges(legacy::GraphCOOView const &i_graph, - legacy::GraphCOOView &o_graph, - VT *d_core, +void extract_edges(legacy::GraphCOOView const& i_graph, + legacy::GraphCOOView& o_graph, + VT* d_core, int k) { cudaStream_t stream{nullptr}; @@ -97,12 +97,12 @@ void extract_edges(legacy::GraphCOOView const &i_graph, // if core_num[s] and core_num[d] are greater than or equal to k. template std::unique_ptr> extract_subgraph( - legacy::GraphCOOView const &in_graph, - int const *vid, - int const *core_num, + legacy::GraphCOOView const& in_graph, + int const* vid, + int const* core_num, int k, int len, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()) + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { cudaStream_t stream{nullptr}; @@ -112,7 +112,7 @@ std::unique_ptr> extract_subgraph( thrust::scatter( rmm::exec_policy(stream)->on(stream), core_num, core_num + len, vid, sorted_core_num.begin()); - VT *d_sorted_core_num = sorted_core_num.data().get(); + VT* d_sorted_core_num = sorted_core_num.data().get(); // Count number of edges in the input graph that satisfy kcore conditions // i.e. core_num[src] and core_num[dst] are both greater than or equal to k @@ -138,19 +138,19 @@ std::unique_ptr> extract_subgraph( } // namespace detail template -void core_number(legacy::GraphCSRView const &graph, VT *core_number) +void core_number(legacy::GraphCSRView const& graph, VT* core_number) { return detail::core_number(graph, core_number); } template std::unique_ptr> k_core( - legacy::GraphCOOView const &in_graph, + legacy::GraphCOOView const& in_graph, int k, - VT const *vertex_id, - VT const *core_number, + VT const* vertex_id, + VT const* core_number, VT num_vertex_ids, - rmm::mr::device_memory_resource *mr) + rmm::mr::device_memory_resource* mr) { CUGRAPH_EXPECTS(vertex_id != nullptr, "Invalid input argument: vertex_id is NULL"); CUGRAPH_EXPECTS(core_number != nullptr, "Invalid input argument: core_number is NULL"); @@ -160,20 +160,20 @@ std::unique_ptr> k_core( } template void core_number( - legacy::GraphCSRView const &, int32_t *core_number); + legacy::GraphCSRView const&, int32_t* core_number); template std::unique_ptr> k_core( - legacy::GraphCOOView const &, + legacy::GraphCOOView const&, int, - int32_t const *, - int32_t const *, + int32_t const*, + int32_t const*, int32_t, - rmm::mr::device_memory_resource *); + rmm::mr::device_memory_resource*); template std::unique_ptr> -k_core(legacy::GraphCOOView const &, +k_core(legacy::GraphCOOView const&, int, - int32_t const *, - int32_t const *, + int32_t const*, + int32_t const*, int32_t, - rmm::mr::device_memory_resource *); + rmm::mr::device_memory_resource*); } // namespace cugraph diff --git a/cpp/src/experimental/bfs.cu b/cpp/src/experimental/bfs.cu index 24c86fea79f..903228a79f6 100644 --- a/cpp/src/experimental/bfs.cu +++ b/cpp/src/experimental/bfs.cu @@ -42,9 +42,9 @@ namespace experimental { namespace detail { template -void bfs(raft::handle_t const &handle, - GraphViewType const &push_graph_view, - typename GraphViewType::vertex_type *distances, +void bfs(raft::handle_t const& handle, + GraphViewType const& push_graph_view, + typename GraphViewType::vertex_type* distances, PredecessorIterator predecessor_first, typename GraphViewType::vertex_type source_vertex, bool direction_optimizing, @@ -164,10 +164,10 @@ void bfs(raft::handle_t const &handle, } // namespace detail template -void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t *distances, - vertex_t *predecessors, +void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t* distances, + vertex_t* predecessors, vertex_t source_vertex, bool direction_optimizing, vertex_t depth_limit, @@ -196,109 +196,109 @@ void bfs(raft::handle_t const &handle, // explicit instantiation -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *distances, - int64_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* distances, + int64_t* predecessors, int64_t source_vertex, bool direction_optimizing, int64_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *distances, - int64_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* distances, + int64_t* predecessors, int64_t source_vertex, bool direction_optimizing, int64_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t *distances, - int32_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t* distances, + int32_t* predecessors, int32_t source_vertex, bool direction_optimizing, int32_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *distances, - int64_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* distances, + int64_t* predecessors, int64_t source_vertex, bool direction_optimizing, int64_t depth_limit, bool do_expensive_check); -template void bfs(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t *distances, - int64_t *predecessors, +template void bfs(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t* distances, + int64_t* predecessors, int64_t source_vertex, bool direction_optimizing, int64_t depth_limit, diff --git a/cpp/src/experimental/coarsen_graph.cu b/cpp/src/experimental/coarsen_graph.cu index 573e7818c82..e785b770ff7 100644 --- a/cpp/src/experimental/coarsen_graph.cu +++ b/cpp/src/experimental/coarsen_graph.cu @@ -90,9 +90,9 @@ decompress_matrix_partition_to_edgelist( } template -edge_t groupby_e_and_coarsen_edgelist(vertex_t *edgelist_major_vertices /* [INOUT] */, - vertex_t *edgelist_minor_vertices /* [INOUT] */, - std::optional edgelist_weights /* [INOUT] */, +edge_t groupby_e_and_coarsen_edgelist(vertex_t* edgelist_major_vertices /* [INOUT] */, + vertex_t* edgelist_minor_vertices /* [INOUT] */, + std::optional edgelist_weights /* [INOUT] */, edge_t number_of_edges, cudaStream_t stream) { @@ -146,8 +146,8 @@ std::tuple, std::optional>> decompress_matrix_partition_to_relabeled_and_grouped_and_coarsened_edgelist( matrix_partition_device_view_t const matrix_partition, - vertex_t const *p_major_labels, - vertex_t const *p_minor_labels, + vertex_t const* p_major_labels, + vertex_t const* p_minor_labels, cudaStream_t stream) { // FIXME: it might be possible to directly create relabled & coarsened edgelist from the @@ -173,7 +173,7 @@ decompress_matrix_partition_to_relabeled_and_grouped_and_coarsened_edgelist( auto number_of_edges = groupby_e_and_coarsen_edgelist( edgelist_major_vertices.data(), edgelist_minor_vertices.data(), - edgelist_weights ? std::optional{(*edgelist_weights).data()} : std::nullopt, + edgelist_weights ? std::optional{(*edgelist_weights).data()} : std::nullopt, static_cast(edgelist_major_vertices.size()), stream); edgelist_major_vertices.resize(number_of_edges, stream); @@ -201,18 +201,18 @@ std::enable_if_t< std::tuple>, rmm::device_uvector>> coarsen_graph( - raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t const *labels, + raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t const* labels, bool do_expensive_check) { - auto &comm = handle.get_comms(); + auto& comm = handle.get_comms(); auto const comm_size = comm.get_size(); auto const comm_rank = comm.get_rank(); - auto &row_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); + auto& row_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); auto const row_comm_size = row_comm.get_size(); auto const row_comm_rank = row_comm.get_rank(); - auto &col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); + auto& col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); auto const col_comm_size = col_comm.get_size(); auto const col_comm_rank = col_comm.get_rank(); @@ -390,9 +390,8 @@ coarsen_graph( auto number_of_partition_edges = groupby_e_and_coarsen_edgelist( edgelist_major_vertices.begin() + h_displacements[j], edgelist_minor_vertices.begin() + h_displacements[j], - edgelist_weights - ? std::optional{(*edgelist_weights).data() + h_displacements[j]} - : std::nullopt, + edgelist_weights ? std::optional{(*edgelist_weights).data() + h_displacements[j]} + : std::nullopt, h_counts[j], handle.get_stream()); @@ -442,9 +441,8 @@ coarsen_graph( auto number_of_partition_edges = groupby_e_and_coarsen_edgelist( coarsened_edgelist_major_vertices[i].data(), coarsened_edgelist_minor_vertices[i].data(), - coarsened_edgelist_weights - ? std::optional{(*coarsened_edgelist_weights)[i].data()} - : std::nullopt, + coarsened_edgelist_weights ? std::optional{(*coarsened_edgelist_weights)[i].data()} + : std::nullopt, static_cast(coarsened_edgelist_major_vertices[i].size()), handle.get_stream()); coarsened_edgelist_major_vertices[i].resize(number_of_partition_edges, handle.get_stream()); @@ -508,8 +506,8 @@ coarsen_graph( edge_t number_of_edges{}; std::optional> segment_offsets{}; { - std::vector major_ptrs(coarsened_edgelist_major_vertices.size()); - std::vector minor_ptrs(major_ptrs.size()); + std::vector major_ptrs(coarsened_edgelist_major_vertices.size()); + std::vector minor_ptrs(major_ptrs.size()); std::vector counts(major_ptrs.size()); for (size_t i = 0; i < coarsened_edgelist_major_vertices.size(); ++i) { major_ptrs[i] = coarsened_edgelist_major_vertices[i].data(); @@ -519,7 +517,7 @@ coarsen_graph( std::tie(renumber_map_labels, partition, number_of_vertices, number_of_edges, segment_offsets) = renumber_edgelist( handle, - std::optional>{ + std::optional>{ std::make_tuple(unique_labels.data(), static_cast(unique_labels.size()))}, major_ptrs, minor_ptrs, @@ -538,7 +536,7 @@ coarsen_graph( : coarsened_edgelist_minor_vertices[i].data(); edgelists[i].p_edge_weights = coarsened_edgelist_weights - ? std::optional{(*coarsened_edgelist_weights)[i].data()} + ? std::optional{(*coarsened_edgelist_weights)[i].data()} : std::nullopt, edgelists[i].number_of_edges = static_cast(coarsened_edgelist_major_vertices[i].size()); } @@ -566,9 +564,9 @@ std::enable_if_t< std::tuple>, rmm::device_uvector>> coarsen_graph( - raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t const *labels, + raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t const* labels, bool do_expensive_check) { if (do_expensive_check) { @@ -603,7 +601,7 @@ coarsen_graph( auto [renumber_map_labels, segment_offsets] = renumber_edgelist( handle, - std::optional>{ + std::optional>{ std::make_tuple(unique_labels.data(), static_cast(unique_labels.size()))}, coarsened_edgelist_major_vertices.data(), coarsened_edgelist_minor_vertices.data(), @@ -611,14 +609,13 @@ coarsen_graph( do_expensive_check); edgelist_t edgelist{}; - edgelist.p_src_vertices = store_transposed ? coarsened_edgelist_minor_vertices.data() - : coarsened_edgelist_major_vertices.data(); - edgelist.p_dst_vertices = store_transposed ? coarsened_edgelist_major_vertices.data() - : coarsened_edgelist_minor_vertices.data(); - edgelist.p_edge_weights = - coarsened_edgelist_weights - ? std::optional{(*coarsened_edgelist_weights).data()} - : std::nullopt; + edgelist.p_src_vertices = store_transposed ? coarsened_edgelist_minor_vertices.data() + : coarsened_edgelist_major_vertices.data(); + edgelist.p_dst_vertices = store_transposed ? coarsened_edgelist_major_vertices.data() + : coarsened_edgelist_minor_vertices.data(); + edgelist.p_edge_weights = coarsened_edgelist_weights + ? std::optional{(*coarsened_edgelist_weights).data()} + : std::nullopt; edgelist.number_of_edges = static_cast(coarsened_edgelist_major_vertices.size()); return std::make_tuple( @@ -641,9 +638,9 @@ template >, rmm::device_uvector> coarsen_graph( - raft::handle_t const &handle, - graph_view_t const &graph_view, - vertex_t const *labels, + raft::handle_t const& handle, + graph_view_t const& graph_view, + vertex_t const* labels, bool do_expensive_check) { return detail::coarsen_graph(handle, graph_view, labels, do_expensive_check); @@ -653,170 +650,170 @@ coarsen_graph( template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int32_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int32_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); template std::tuple>, rmm::device_uvector> -coarsen_graph(raft::handle_t const &handle, - graph_view_t const &graph_view, - int64_t const *labels, +coarsen_graph(raft::handle_t const& handle, + graph_view_t const& graph_view, + int64_t const* labels, bool do_expensive_check); } // namespace experimental diff --git a/cpp/src/experimental/graph.cu b/cpp/src/experimental/graph.cu index 8e51723fddf..a01537355df 100644 --- a/cpp/src/experimental/graph.cu +++ b/cpp/src/experimental/graph.cu @@ -65,7 +65,7 @@ std::tuple, rmm::device_uvector, std::optional>, std::optional>> -compress_edgelist(edgelist_t const &edgelist, +compress_edgelist(edgelist_t const& edgelist, vertex_t major_first, vertex_t major_hypersparse_first, vertex_t major_last, @@ -196,13 +196,13 @@ template graph_t>:: - graph_t(raft::handle_t const &handle, - std::vector> const &edgelists, - partition_t const &partition, + graph_t(raft::handle_t const& handle, + std::vector> const& edgelists, + partition_t const& partition, vertex_t number_of_vertices, edge_t number_of_edges, graph_properties_t properties, - std::optional> const &segment_offsets, + std::optional> const& segment_offsets, bool do_expensive_check) : detail::graph_base_t( handle, number_of_vertices, number_of_edges, properties), @@ -210,13 +210,13 @@ graph_tget_handle_ptr()->get_comms(); + auto& comm = this->get_handle_ptr()->get_comms(); auto const comm_size = comm.get_size(); - auto &row_comm = + auto& row_comm = this->get_handle_ptr()->get_subcomm(cugraph::partition_2d::key_naming_t().row_name()); auto const row_comm_rank = row_comm.get_rank(); auto const row_comm_size = row_comm.get_size(); - auto &col_comm = + auto& col_comm = this->get_handle_ptr()->get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); auto const col_comm_rank = col_comm.get_rank(); auto const col_comm_size = col_comm.get_size(); @@ -368,11 +368,11 @@ template graph_t>:: - graph_t(raft::handle_t const &handle, - edgelist_t const &edgelist, + graph_t(raft::handle_t const& handle, + edgelist_t const& edgelist, vertex_t number_of_vertices, graph_properties_t properties, - std::optional> const &segment_offsets, + std::optional> const& segment_offsets, bool do_expensive_check) : detail::graph_base_t( handle, number_of_vertices, edgelist.number_of_edges, properties), diff --git a/cpp/src/experimental/induced_subgraph.cu b/cpp/src/experimental/induced_subgraph.cu index fe390690aa6..c43f81bbf39 100644 --- a/cpp/src/experimental/induced_subgraph.cu +++ b/cpp/src/experimental/induced_subgraph.cu @@ -47,10 +47,10 @@ std::tuple, std::optional>, rmm::device_uvector> extract_induced_subgraphs( - raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets /* size == num_subgraphs + 1 */, - vertex_t const *subgraph_vertices /* size == subgraph_offsets[num_subgraphs] */, + raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets /* size == num_subgraphs + 1 */, + vertex_t const* subgraph_vertices /* size == subgraph_offsets[num_subgraphs] */, size_t num_subgraphs, bool do_expensive_check) { @@ -147,8 +147,8 @@ extract_induced_subgraphs( auto subgraph_idx = thrust::distance( subgraph_offsets + 1, thrust::upper_bound(thrust::seq, subgraph_offsets, subgraph_offsets + num_subgraphs, i)); - vertex_t const *indices{nullptr}; - thrust::optional weights{thrust::nullopt}; + vertex_t const* indices{nullptr}; + thrust::optional weights{thrust::nullopt}; edge_t local_degree{}; auto major_offset = matrix_partition.get_major_offset_from_major_nocheck(subgraph_vertices[i]); @@ -199,14 +199,14 @@ extract_induced_subgraphs( subgraph_vertex_output_offsets = subgraph_vertex_output_offsets.data(), edge_majors = edge_majors.data(), edge_minors = edge_minors.data(), - edge_weights = edge_weights ? thrust::optional{(*edge_weights).data()} + edge_weights = edge_weights ? thrust::optional{(*edge_weights).data()} : thrust::nullopt] __device__(auto i) { auto subgraph_idx = thrust::distance( subgraph_offsets + 1, thrust::upper_bound( thrust::seq, subgraph_offsets, subgraph_offsets + num_subgraphs, size_t{i})); - vertex_t const *indices{nullptr}; - thrust::optional weights{thrust::nullopt}; + vertex_t const* indices{nullptr}; + thrust::optional weights{thrust::nullopt}; edge_t local_degree{}; auto major_offset = matrix_partition.get_major_offset_from_major_nocheck(subgraph_vertices[i]); @@ -269,10 +269,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -280,10 +280,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -291,10 +291,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -302,10 +302,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -313,10 +313,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -324,10 +324,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -335,10 +335,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -346,10 +346,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int32_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int32_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -357,10 +357,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int64_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int64_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -368,10 +368,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int64_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int64_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -379,10 +379,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int64_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int64_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); @@ -390,10 +390,10 @@ template std::tuple, rmm::device_uvector, std::optional>, rmm::device_uvector> -extract_induced_subgraphs(raft::handle_t const &handle, - graph_view_t const &graph_view, - size_t const *subgraph_offsets, - int64_t const *subgraph_vertices, +extract_induced_subgraphs(raft::handle_t const& handle, + graph_view_t const& graph_view, + size_t const* subgraph_offsets, + int64_t const* subgraph_vertices, size_t num_subgraphs, bool do_expensive_check); diff --git a/cpp/src/experimental/katz_centrality.cu b/cpp/src/experimental/katz_centrality.cu index 515c49fda00..b8ab45277fc 100644 --- a/cpp/src/experimental/katz_centrality.cu +++ b/cpp/src/experimental/katz_centrality.cu @@ -36,10 +36,10 @@ namespace experimental { namespace detail { template -void katz_centrality(raft::handle_t const &handle, - GraphViewType const &pull_graph_view, - result_t const *betas, - result_t *katz_centralities, +void katz_centrality(raft::handle_t const& handle, + GraphViewType const& pull_graph_view, + result_t const* betas, + result_t* katz_centralities, result_t alpha, result_t beta, // relevant only if betas == nullptr result_t epsilon, @@ -171,10 +171,10 @@ void katz_centrality(raft::handle_t const &handle, } // namespace detail template -void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - result_t const *betas, - result_t *katz_centralities, +void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + result_t const* betas, + result_t* katz_centralities, result_t alpha, result_t beta, // relevant only if beta == nullptr result_t epsilon, @@ -198,10 +198,10 @@ void katz_centrality(raft::handle_t const &handle, // explicit instantiation -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - float const *betas, - float *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + float const* betas, + float* katz_centralities, float alpha, float beta, float epsilon, @@ -210,10 +210,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - double const *betas, - double *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + double const* betas, + double* katz_centralities, double alpha, double beta, double epsilon, @@ -222,10 +222,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - float const *betas, - float *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + float const* betas, + float* katz_centralities, float alpha, float beta, float epsilon, @@ -234,10 +234,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - double const *betas, - double *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + double const* betas, + double* katz_centralities, double alpha, double beta, double epsilon, @@ -246,10 +246,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - float const *betas, - float *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + float const* betas, + float* katz_centralities, float alpha, float beta, float epsilon, @@ -258,10 +258,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - double const *betas, - double *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + double const* betas, + double* katz_centralities, double alpha, double beta, double epsilon, @@ -270,10 +270,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - float const *betas, - float *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + float const* betas, + float* katz_centralities, float alpha, float beta, float epsilon, @@ -282,10 +282,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - double const *betas, - double *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + double const* betas, + double* katz_centralities, double alpha, double beta, double epsilon, @@ -294,10 +294,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - float const *betas, - float *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + float const* betas, + float* katz_centralities, float alpha, float beta, float epsilon, @@ -306,10 +306,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - double const *betas, - double *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + double const* betas, + double* katz_centralities, double alpha, double beta, double epsilon, @@ -318,10 +318,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - float const *betas, - float *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + float const* betas, + float* katz_centralities, float alpha, float beta, float epsilon, @@ -330,10 +330,10 @@ template void katz_centrality(raft::handle_t const &handle, bool normalize, bool do_expensive_check); -template void katz_centrality(raft::handle_t const &handle, - graph_view_t const &graph_view, - double const *betas, - double *katz_centralities, +template void katz_centrality(raft::handle_t const& handle, + graph_view_t const& graph_view, + double const* betas, + double* katz_centralities, double alpha, double beta, double epsilon, diff --git a/cpp/src/experimental/louvain.cuh b/cpp/src/experimental/louvain.cuh index c9e01157628..e3b5bf91ccc 100644 --- a/cpp/src/experimental/louvain.cuh +++ b/cpp/src/experimental/louvain.cuh @@ -53,7 +53,7 @@ class Louvain { graph_view_t::is_adj_matrix_transposed, graph_view_t::is_multi_gpu>; - Louvain(raft::handle_t const &handle, graph_view_t const &graph_view) + Louvain(raft::handle_t const& handle, graph_view_t const& graph_view) : #ifdef TIMING hr_timer_(), @@ -70,9 +70,9 @@ class Louvain { { } - Dendrogram const &get_dendrogram() const { return *dendrogram_; } + Dendrogram const& get_dendrogram() const { return *dendrogram_; } - Dendrogram &get_dendrogram() { return *dendrogram_; } + Dendrogram& get_dendrogram() { return *dendrogram_; } std::unique_ptr> move_dendrogram() { return std::move(dendrogram_); } @@ -111,7 +111,7 @@ class Louvain { } protected: - void timer_start(std::string const ®ion) + void timer_start(std::string const& region) { #ifdef TIMING if (graph_view_t::is_multi_gpu) { @@ -137,7 +137,7 @@ class Louvain { #endif } - void timer_display(std::ostream &os) + void timer_display(std::ostream& os) { #ifdef TIMING if (graph_view_t::is_multi_gpu) { @@ -243,7 +243,7 @@ class Louvain { } template - T *cache_src_vertex_properties(rmm::device_uvector &input, rmm::device_uvector &src_cache_v) + T* cache_src_vertex_properties(rmm::device_uvector& input, rmm::device_uvector& src_cache_v) { if (graph_view_t::is_multi_gpu) { src_cache_v.resize(current_graph_view_.get_number_of_local_adj_matrix_partition_rows(), @@ -256,7 +256,7 @@ class Louvain { } template - T *cache_dst_vertex_properties(rmm::device_uvector &input, rmm::device_uvector &dst_cache_v) + T* cache_dst_vertex_properties(rmm::device_uvector& input, rmm::device_uvector& dst_cache_v) { if (graph_view_t::is_multi_gpu) { dst_cache_v.resize(current_graph_view_.get_number_of_local_adj_matrix_partition_cols(), @@ -312,8 +312,8 @@ class Louvain { return cur_Q; } - void compute_cluster_sum_and_subtract(rmm::device_uvector &old_cluster_sum_v, - rmm::device_uvector &cluster_subtract_v) + void compute_cluster_sum_and_subtract(rmm::device_uvector& old_cluster_sum_v, + rmm::device_uvector& cluster_subtract_v) { auto output_buffer = cugraph::experimental::allocate_dataframe_buffer>( @@ -362,7 +362,7 @@ class Louvain { void update_by_delta_modularity(weight_t total_edge_weight, weight_t resolution, - rmm::device_uvector &next_cluster_v, + rmm::device_uvector& next_cluster_v, bool up_down) { rmm::device_uvector old_cluster_sum_v( @@ -378,9 +378,9 @@ class Louvain { cugraph::experimental::allocate_dataframe_buffer>( current_graph_view_.get_number_of_local_vertices(), handle_.get_stream()); - vertex_t *map_key_first; - vertex_t *map_key_last; - weight_t *map_value_first; + vertex_t* map_key_first; + vertex_t* map_key_last; + weight_t* map_value_first; if (graph_t::is_multi_gpu) { cugraph::experimental::detail::compute_gpu_id_from_vertex_t vertex_to_gpu_id_op{ @@ -521,8 +521,8 @@ class Louvain { relabel( handle_, - std::make_tuple(static_cast(numbering_map.begin()), - static_cast(numbering_indices.begin())), + std::make_tuple(static_cast(numbering_map.begin()), + static_cast(numbering_indices.begin())), current_graph_view_.get_number_of_local_vertices(), dendrogram_->current_level_begin(), dendrogram_->current_level_size(), @@ -532,7 +532,7 @@ class Louvain { } protected: - raft::handle_t const &handle_; + raft::handle_t const& handle_; std::unique_ptr> dendrogram_; @@ -551,9 +551,9 @@ class Louvain { rmm::device_uvector cluster_keys_v_; rmm::device_uvector cluster_weights_v_; - weight_t *d_src_vertex_weights_cache_; - vertex_t *d_src_cluster_cache_; - vertex_t *d_dst_cluster_cache_; + weight_t* d_src_vertex_weights_cache_; + vertex_t* d_src_cluster_cache_; + vertex_t* d_dst_cluster_cache_; #ifdef TIMING HighResTimer hr_timer_; diff --git a/cpp/src/experimental/pagerank.cu b/cpp/src/experimental/pagerank.cu index 64b80c14b2e..999a25b01c9 100644 --- a/cpp/src/experimental/pagerank.cu +++ b/cpp/src/experimental/pagerank.cu @@ -148,9 +148,9 @@ void pagerank( ? std::nullopt : std::optional>{ pull_graph_view.compute_out_weight_sums(handle)}; - auto vertex_out_weight_sums = precomputed_vertex_out_weight_sums - ? *precomputed_vertex_out_weight_sums - : (*tmp_vertex_out_weight_sums).data(); + auto vertex_out_weight_sums = precomputed_vertex_out_weight_sums + ? *precomputed_vertex_out_weight_sums + : (*tmp_vertex_out_weight_sums).data(); // 3. initialize pagerank values diff --git a/cpp/src/experimental/sssp.cu b/cpp/src/experimental/sssp.cu index 4c5dac6065f..b6f85ddb3c2 100644 --- a/cpp/src/experimental/sssp.cu +++ b/cpp/src/experimental/sssp.cu @@ -43,9 +43,9 @@ namespace experimental { namespace detail { template -void sssp(raft::handle_t const &handle, - GraphViewType const &push_graph_view, - typename GraphViewType::weight_type *distances, +void sssp(raft::handle_t const& handle, + GraphViewType const& push_graph_view, + typename GraphViewType::weight_type* distances, PredecessorIterator predecessor_first, typename GraphViewType::vertex_type source_vertex, typename GraphViewType::weight_type cutoff, @@ -201,9 +201,9 @@ void sssp(raft::handle_t const &handle, [near_far_threshold] __device__(auto v, auto v_val, auto pushed_val) { auto new_dist = thrust::get<0>(pushed_val); auto idx = new_dist < v_val - ? (new_dist < near_far_threshold ? static_cast(Bucket::next_near) - : static_cast(Bucket::far)) - : VertexFrontier::kInvalidBucketIdx; + ? (new_dist < near_far_threshold ? static_cast(Bucket::next_near) + : static_cast(Bucket::far)) + : VertexFrontier::kInvalidBucketIdx; return new_dist < v_val ? thrust::optional>{thrust::make_tuple( static_cast(new_dist < near_far_threshold ? Bucket::next_near @@ -261,10 +261,10 @@ void sssp(raft::handle_t const &handle, } // namespace detail template -void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - weight_t *distances, - vertex_t *predecessors, +void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + weight_t* distances, + vertex_t* predecessors, vertex_t source_vertex, weight_t cutoff, bool do_expensive_check) @@ -285,98 +285,98 @@ void sssp(raft::handle_t const &handle, // explicit instantiation -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - float *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + float* distances, + int32_t* predecessors, int32_t source_vertex, float cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - double *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + double* distances, + int32_t* predecessors, int32_t source_vertex, double cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - float *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + float* distances, + int32_t* predecessors, int32_t source_vertex, float cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - double *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + double* distances, + int32_t* predecessors, int32_t source_vertex, double cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - float *distances, - int64_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + float* distances, + int64_t* predecessors, int64_t source_vertex, float cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - double *distances, - int64_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + double* distances, + int64_t* predecessors, int64_t source_vertex, double cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - float *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + float* distances, + int32_t* predecessors, int32_t source_vertex, float cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - double *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + double* distances, + int32_t* predecessors, int32_t source_vertex, double cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - float *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + float* distances, + int32_t* predecessors, int32_t source_vertex, float cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - double *distances, - int32_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + double* distances, + int32_t* predecessors, int32_t source_vertex, double cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - float *distances, - int64_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + float* distances, + int64_t* predecessors, int64_t source_vertex, float cutoff, bool do_expensive_check); -template void sssp(raft::handle_t const &handle, - graph_view_t const &graph_view, - double *distances, - int64_t *predecessors, +template void sssp(raft::handle_t const& handle, + graph_view_t const& graph_view, + double* distances, + int64_t* predecessors, int64_t source_vertex, double cutoff, bool do_expensive_check); diff --git a/cpp/src/generators/generator_tools.cu b/cpp/src/generators/generator_tools.cu index 3ebef13f3b1..375d96b0d99 100644 --- a/cpp/src/generators/generator_tools.cu +++ b/cpp/src/generators/generator_tools.cu @@ -33,17 +33,18 @@ namespace cugraph { namespace detail { template -rmm::device_uvector append_all(raft::handle_t const &handle, - std::vector> &&input) +rmm::device_uvector append_all(raft::handle_t const& handle, + std::vector>&& input) { size_t size{0}; // for (size_t i = 0; i < input.size(); ++i) size += input[i].size(); - for (auto &element : input) size += element.size(); + for (auto& element : input) + size += element.size(); rmm::device_uvector output(size, handle.get_stream()); auto output_iter = output.begin(); - for (auto &element : input) { + for (auto& element : input) { raft::copy(output_iter, element.begin(), element.size(), handle.get_stream()); output_iter += element.size(); } @@ -61,9 +62,9 @@ for (size_t i = 0; i < input.size(); ++i) { } // namespace detail template -void scramble_vertex_ids(raft::handle_t const &handle, - rmm::device_uvector &d_src_v, - rmm::device_uvector &d_dst_v, +void scramble_vertex_ids(raft::handle_t const& handle, + rmm::device_uvector& d_src_v, + rmm::device_uvector& d_dst_v, vertex_t vertex_id_offset, uint64_t seed) { @@ -85,10 +86,10 @@ template std::tuple, rmm::device_uvector, std::optional>> -combine_edgelists(raft::handle_t const &handle, - std::vector> &&sources, - std::vector> &&dests, - std::optional>> &&optional_d_weights, +combine_edgelists(raft::handle_t const& handle, + std::vector>&& sources, + std::vector>&& dests, + std::optional>>&& optional_d_weights, bool remove_multi_edges) { CUGRAPH_EXPECTS(sources.size() == dests.size(), @@ -190,10 +191,10 @@ template std::tuple, rmm::device_uvector, std::optional>> -symmetrize_edgelist(raft::handle_t const &handle, - rmm::device_uvector &&d_src_v, - rmm::device_uvector &&d_dst_v, - std::optional> &&optional_d_weights_v) +symmetrize_edgelist(raft::handle_t const& handle, + rmm::device_uvector&& d_src_v, + rmm::device_uvector&& d_dst_v, + std::optional>&& optional_d_weights_v) { auto offset = d_src_v.size(); d_src_v.resize(offset * 2, handle.get_stream_view()); @@ -220,82 +221,82 @@ symmetrize_edgelist(raft::handle_t const &handle, optional_d_weights_v ? std::move(optional_d_weights_v) : std::nullopt); } -template void scramble_vertex_ids(raft::handle_t const &handle, - rmm::device_uvector &d_src_v, - rmm::device_uvector &d_dst_v, +template void scramble_vertex_ids(raft::handle_t const& handle, + rmm::device_uvector& d_src_v, + rmm::device_uvector& d_dst_v, int32_t vertex_id_offset, uint64_t seed); -template void scramble_vertex_ids(raft::handle_t const &handle, - rmm::device_uvector &d_src_v, - rmm::device_uvector &d_dst_v, +template void scramble_vertex_ids(raft::handle_t const& handle, + rmm::device_uvector& d_src_v, + rmm::device_uvector& d_dst_v, int64_t vertex_id_offset, uint64_t seed); template std::tuple, rmm::device_uvector, std::optional>> -combine_edgelists(raft::handle_t const &handle, - std::vector> &&sources, - std::vector> &&dests, - std::optional>> &&optional_d_weights, +combine_edgelists(raft::handle_t const& handle, + std::vector>&& sources, + std::vector>&& dests, + std::optional>>&& optional_d_weights, bool remove_multi_edges); template std::tuple, rmm::device_uvector, std::optional>> -combine_edgelists(raft::handle_t const &handle, - std::vector> &&sources, - std::vector> &&dests, - std::optional>> &&optional_d_weights, +combine_edgelists(raft::handle_t const& handle, + std::vector>&& sources, + std::vector>&& dests, + std::optional>>&& optional_d_weights, bool remove_multi_edges); template std::tuple, rmm::device_uvector, std::optional>> -combine_edgelists(raft::handle_t const &handle, - std::vector> &&sources, - std::vector> &&dests, - std::optional>> &&optional_d_weights, +combine_edgelists(raft::handle_t const& handle, + std::vector>&& sources, + std::vector>&& dests, + std::optional>>&& optional_d_weights, bool remove_multi_edges); template std::tuple, rmm::device_uvector, std::optional>> -combine_edgelists(raft::handle_t const &handle, - std::vector> &&sources, - std::vector> &&dests, - std::optional>> &&optional_d_weights, +combine_edgelists(raft::handle_t const& handle, + std::vector>&& sources, + std::vector>&& dests, + std::optional>>&& optional_d_weights, bool remove_multi_edges); template std::tuple, rmm::device_uvector, std::optional>> -symmetrize_edgelist(raft::handle_t const &handle, - rmm::device_uvector &&d_src_v, - rmm::device_uvector &&d_dst_v, - std::optional> &&optional_d_weights_v); +symmetrize_edgelist(raft::handle_t const& handle, + rmm::device_uvector&& d_src_v, + rmm::device_uvector&& d_dst_v, + std::optional>&& optional_d_weights_v); template std::tuple, rmm::device_uvector, std::optional>> -symmetrize_edgelist(raft::handle_t const &handle, - rmm::device_uvector &&d_src_v, - rmm::device_uvector &&d_dst_v, - std::optional> &&optional_d_weights_v); +symmetrize_edgelist(raft::handle_t const& handle, + rmm::device_uvector&& d_src_v, + rmm::device_uvector&& d_dst_v, + std::optional>&& optional_d_weights_v); template std::tuple, rmm::device_uvector, std::optional>> -symmetrize_edgelist(raft::handle_t const &handle, - rmm::device_uvector &&d_src_v, - rmm::device_uvector &&d_dst_v, - std::optional> &&optional_d_weights_v); +symmetrize_edgelist(raft::handle_t const& handle, + rmm::device_uvector&& d_src_v, + rmm::device_uvector&& d_dst_v, + std::optional>&& optional_d_weights_v); template std::tuple, rmm::device_uvector, std::optional>> -symmetrize_edgelist(raft::handle_t const &handle, - rmm::device_uvector &&d_src_v, - rmm::device_uvector &&d_dst_v, - std::optional> &&optional_d_weights_v); +symmetrize_edgelist(raft::handle_t const& handle, + rmm::device_uvector&& d_src_v, + rmm::device_uvector&& d_dst_v, + std::optional>&& optional_d_weights_v); } // namespace cugraph diff --git a/cpp/src/layout/barnes_hut.hpp b/cpp/src/layout/barnes_hut.hpp index 2d9265be2d3..57abde2262d 100644 --- a/cpp/src/layout/barnes_hut.hpp +++ b/cpp/src/layout/barnes_hut.hpp @@ -36,12 +36,12 @@ namespace cugraph { namespace detail { template -void barnes_hut(raft::handle_t const &handle, - legacy::GraphCOOView &graph, - float *pos, +void barnes_hut(raft::handle_t const& handle, + legacy::GraphCOOView& graph, + float* pos, const int max_iter = 500, - float *x_start = nullptr, - float *y_start = nullptr, + float* x_start = nullptr, + float* y_start = nullptr, bool outbound_attraction_distribution = true, bool lin_log_mode = false, bool prevent_overlapping = false, @@ -52,7 +52,7 @@ void barnes_hut(raft::handle_t const &handle, bool strong_gravity_mode = false, const float gravity = 1.0, bool verbose = false, - internals::GraphBasedDimRedCallback *callback = nullptr) + internals::GraphBasedDimRedCallback* callback = nullptr) { rmm::cuda_stream_view stream_view(handle.get_stream_view()); const edge_t e = graph.number_of_edges; @@ -64,7 +64,8 @@ void barnes_hut(raft::handle_t const &handle, // We use the same array for nodes and cells. int nnodes = n * 2; if (nnodes < 1024 * blocks) nnodes = 1024 * blocks; - while ((nnodes & (32 - 1)) != 0) nnodes++; + while ((nnodes & (32 - 1)) != 0) + nnodes++; nnodes--; // Allocate more space @@ -74,10 +75,10 @@ void barnes_hut(raft::handle_t const &handle, rmm::device_uvector d_bottomd(1, stream_view); rmm::device_uvector d_radiusd(1, stream_view); - unsigned *limiter = d_limiter.data(); - int *maxdepthd = d_maxdepthd.data(); - int *bottomd = d_bottomd.data(); - float *radiusd = d_radiusd.data(); + unsigned* limiter = d_limiter.data(); + int* maxdepthd = d_maxdepthd.data(); + int* bottomd = d_bottomd.data(); + float* radiusd = d_radiusd.data(); InitializationKernel<<<1, 1, 0, stream_view.value()>>>(limiter, maxdepthd, radiusd); CHECK_CUDA(stream_view.value()); @@ -99,32 +100,32 @@ void barnes_hut(raft::handle_t const &handle, rmm::device_uvector d_minyl(blocks * FACTOR1, stream_view); // Actual mallocs - int *startl = d_startl.data(); - int *childl = d_childl.data(); - int *massl = d_massl.data(); + int* startl = d_startl.data(); + int* childl = d_childl.data(); + int* massl = d_massl.data(); - float *maxxl = d_maxxl.data(); - float *maxyl = d_maxyl.data(); - float *minxl = d_minxl.data(); - float *minyl = d_minyl.data(); + float* maxxl = d_maxxl.data(); + float* maxyl = d_maxyl.data(); + float* minxl = d_minxl.data(); + float* minyl = d_minyl.data(); // SummarizationKernel rmm::device_uvector d_countl(nnodes + 1, stream_view); - int *countl = d_countl.data(); + int* countl = d_countl.data(); // SortKernel rmm::device_uvector d_sortl(nnodes + 1, stream_view); - int *sortl = d_sortl.data(); + int* sortl = d_sortl.data(); // RepulsionKernel rmm::device_uvector d_rep_forces((nnodes + 1) * 2, stream_view); - float *rep_forces = d_rep_forces.data(); + float* rep_forces = d_rep_forces.data(); rmm::device_uvector d_radius_squared(1, stream_view); - float *radiusd_squared = d_radius_squared.data(); + float* radiusd_squared = d_radius_squared.data(); rmm::device_uvector d_nodes_pos((nnodes + 1) * 2, stream_view); - float *nodes_pos = d_nodes_pos.data(); + float* nodes_pos = d_nodes_pos.data(); // Initialize positions with random values int random_state = 0; @@ -139,10 +140,10 @@ void barnes_hut(raft::handle_t const &handle, } // Allocate arrays for force computation - float *attract{nullptr}; - float *old_forces{nullptr}; - float *swinging{nullptr}; - float *traction{nullptr}; + float* attract{nullptr}; + float* old_forces{nullptr}; + float* swinging{nullptr}; + float* traction{nullptr}; rmm::device_uvector d_attract(n * 2, stream_view); rmm::device_uvector d_old_forces(n * 2, stream_view); @@ -163,9 +164,9 @@ void barnes_hut(raft::handle_t const &handle, graph.degree(massl, cugraph::legacy::DegreeDirection::OUT); CHECK_CUDA(stream_view.value()); - const vertex_t *row = graph.src_indices; - const vertex_t *col = graph.dst_indices; - const weight_t *v = graph.edge_data; + const vertex_t* row = graph.src_indices; + const vertex_t* col = graph.dst_indices; + const weight_t* v = graph.edge_data; // Scalars used to adapt global speed. float speed = 1.f; diff --git a/cpp/src/layout/bh_kernels.hpp b/cpp/src/layout/bh_kernels.hpp index 5c170e147c9..8dbc08a6440 100644 --- a/cpp/src/layout/bh_kernels.hpp +++ b/cpp/src/layout/bh_kernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,9 +42,9 @@ namespace detail { /** * Intializes the states of objects. This speeds the overall kernel up. */ -__global__ void InitializationKernel(unsigned *restrict limiter, - int *restrict maxdepthd, - float *restrict radiusd) +__global__ void InitializationKernel(unsigned* restrict limiter, + int* restrict maxdepthd, + float* restrict radiusd) { maxdepthd[0] = 1; limiter[0] = 0; @@ -54,10 +54,10 @@ __global__ void InitializationKernel(unsigned *restrict limiter, /** * Reset root. */ -__global__ void ResetKernel(float *restrict radiusd_squared, - int *restrict bottomd, +__global__ void ResetKernel(float* restrict radiusd_squared, + int* restrict bottomd, const int NNODES, - const float *restrict radiusd) + const float* restrict radiusd) { radiusd_squared[0] = radiusd[0] * radiusd[0]; // create root node @@ -67,20 +67,20 @@ __global__ void ResetKernel(float *restrict radiusd_squared, /** * Figures the bounding boxes for every point in the embedding. */ -__global__ __launch_bounds__(THREADS1, FACTOR1) void BoundingBoxKernel(int *restrict startd, - int *restrict childd, - int *restrict massd, - float *restrict posxd, - float *restrict posyd, - float *restrict maxxd, - float *restrict maxyd, - float *restrict minxd, - float *restrict minyd, +__global__ __launch_bounds__(THREADS1, FACTOR1) void BoundingBoxKernel(int* restrict startd, + int* restrict childd, + int* restrict massd, + float* restrict posxd, + float* restrict posyd, + float* restrict maxxd, + float* restrict maxyd, + float* restrict minxd, + float* restrict minyd, const int FOUR_NNODES, const int NNODES, const int N, - unsigned *restrict limiter, - float *restrict radiusd) + unsigned* restrict limiter, + float* restrict radiusd) { float val, minx, maxx, miny, maxy; __shared__ float sminx[THREADS1], smaxx[THREADS1], sminy[THREADS1], smaxy[THREADS1]; @@ -150,14 +150,15 @@ __global__ __launch_bounds__(THREADS1, FACTOR1) void BoundingBoxKernel(int *rest posyd[NNODES] = (miny + maxy) * 0.5f; #pragma unroll - for (int a = 0; a < 4; a++) childd[FOUR_NNODES + a] = -1; + for (int a = 0; a < 4; a++) + childd[FOUR_NNODES + a] = -1; } } /** * Clear some of the state vectors up. */ -__global__ __launch_bounds__(1024, 1) void ClearKernel1(int *restrict childd, +__global__ __launch_bounds__(1024, 1) void ClearKernel1(int* restrict childd, const int FOUR_NNODES, const int FOUR_N) { @@ -167,21 +168,22 @@ __global__ __launch_bounds__(1024, 1) void ClearKernel1(int *restrict childd, // iterate over all cells assigned to thread #pragma unroll - for (; k < FOUR_NNODES; k += inc) childd[k] = -1; + for (; k < FOUR_NNODES; k += inc) + childd[k] = -1; } /** * Build the actual KD Tree. */ __global__ __launch_bounds__(THREADS2, - FACTOR2) void TreeBuildingKernel(int *restrict childd, - const float *restrict posxd, - const float *restrict posyd, + FACTOR2) void TreeBuildingKernel(int* restrict childd, + const float* restrict posxd, + const float* restrict posyd, const int NNODES, const int N, - int *restrict maxdepthd, - int *restrict bottomd, - const float *restrict radiusd) + int* restrict maxdepthd, + int* restrict bottomd, + const float* restrict radiusd) { int j, depth; float x, y, r; @@ -294,10 +296,10 @@ __global__ __launch_bounds__(THREADS2, /** * Clean more state vectors. */ -__global__ __launch_bounds__(1024, 1) void ClearKernel2(int *restrict startd, - int *restrict massd, +__global__ __launch_bounds__(1024, 1) void ClearKernel2(int* restrict startd, + int* restrict massd, const int NNODES, - const int *restrict bottomd) + const int* restrict bottomd) { const int bottom = bottomd[0]; const int inc = blockDim.x * gridDim.x; @@ -316,14 +318,14 @@ __global__ __launch_bounds__(1024, 1) void ClearKernel2(int *restrict startd, * Summarize the KD Tree via cell gathering */ __global__ __launch_bounds__(THREADS3, - FACTOR3) void SummarizationKernel(int *restrict countd, - const int *restrict childd, - volatile int *restrict massd, - float *restrict posxd, - float *restrict posyd, + FACTOR3) void SummarizationKernel(int* restrict countd, + const int* restrict childd, + volatile int* restrict massd, + float* restrict posxd, + float* restrict posyd, const int NNODES, const int N, - const int *restrict bottomd) + const int* restrict bottomd) { bool flag = 0; float cm, px, py; @@ -451,13 +453,13 @@ __global__ __launch_bounds__(THREADS3, /** * Sort the cells */ -__global__ __launch_bounds__(THREADS4, FACTOR4) void SortKernel(int *restrict sortd, - const int *restrict countd, - volatile int *restrict startd, - int *restrict childd, +__global__ __launch_bounds__(THREADS4, FACTOR4) void SortKernel(int* restrict sortd, + const int* restrict countd, + volatile int* restrict startd, + int* restrict childd, const int NNODES, const int N, - const int *restrict bottomd) + const int* restrict bottomd) { const int bottom = bottomd[0]; const int dec = blockDim.x * gridDim.x; @@ -505,19 +507,19 @@ __global__ __launch_bounds__( const float scaling_ratio, const float theta, const float epssqd, // correction for zero distance - const int *restrict sortd, - const int *restrict childd, - const int *restrict massd, - const float *restrict posxd, - const float *restrict posyd, - float *restrict velxd, - float *restrict velyd, + const int* restrict sortd, + const int* restrict childd, + const int* restrict massd, + const float* restrict posxd, + const float* restrict posyd, + float* restrict velxd, + float* restrict velyd, const float theta_squared, const int NNODES, const int FOUR_NNODES, const int N, - const float *restrict radiusd_squared, - const int *restrict maxdepthd) + const float* restrict radiusd_squared, + const int* restrict maxdepthd) { __shared__ int pos[THREADS5], node[THREADS5]; __shared__ float dq[THREADS5]; @@ -611,15 +613,15 @@ __global__ __launch_bounds__( } __global__ __launch_bounds__(THREADS6, - FACTOR6) void apply_forces_bh(float *restrict Y_x, - float *restrict Y_y, - const float *restrict attract_x, - const float *restrict attract_y, - const float *restrict repel_x, - const float *restrict repel_y, - float *restrict old_dx, - float *restrict old_dy, - const float *restrict swinging, + FACTOR6) void apply_forces_bh(float* restrict Y_x, + float* restrict Y_y, + const float* restrict attract_x, + const float* restrict attract_y, + const float* restrict repel_x, + const float* restrict repel_y, + float* restrict old_dx, + float* restrict old_dy, + const float* restrict swinging, const float speed, const int n) { diff --git a/cpp/src/layout/exact_fa2.hpp b/cpp/src/layout/exact_fa2.hpp index 172ac5b8000..b908a8033e7 100644 --- a/cpp/src/layout/exact_fa2.hpp +++ b/cpp/src/layout/exact_fa2.hpp @@ -34,12 +34,12 @@ namespace cugraph { namespace detail { template -void exact_fa2(raft::handle_t const &handle, - legacy::GraphCOOView &graph, - float *pos, +void exact_fa2(raft::handle_t const& handle, + legacy::GraphCOOView& graph, + float* pos, const int max_iter = 500, - float *x_start = nullptr, - float *y_start = nullptr, + float* x_start = nullptr, + float* y_start = nullptr, bool outbound_attraction_distribution = true, bool lin_log_mode = false, bool prevent_overlapping = false, @@ -49,18 +49,18 @@ void exact_fa2(raft::handle_t const &handle, bool strong_gravity_mode = false, const float gravity = 1.0, bool verbose = false, - internals::GraphBasedDimRedCallback *callback = nullptr) + internals::GraphBasedDimRedCallback* callback = nullptr) { auto stream_view = handle.get_stream_view(); const edge_t e = graph.number_of_edges; const vertex_t n = graph.number_of_vertices; - float *d_repel{nullptr}; - float *d_attract{nullptr}; - float *d_old_forces{nullptr}; - int *d_mass{nullptr}; - float *d_swinging{nullptr}; - float *d_traction{nullptr}; + float* d_repel{nullptr}; + float* d_attract{nullptr}; + float* d_old_forces{nullptr}; + int* d_mass{nullptr}; + float* d_swinging{nullptr}; + float* d_traction{nullptr}; rmm::device_uvector repel(n * 2, stream_view); rmm::device_uvector attract(n * 2, stream_view); @@ -95,9 +95,9 @@ void exact_fa2(raft::handle_t const &handle, graph.degree(d_mass, cugraph::legacy::DegreeDirection::OUT); CHECK_CUDA(stream_view.value()); - const vertex_t *row = graph.src_indices; - const vertex_t *col = graph.dst_indices; - const weight_t *v = graph.edge_data; + const vertex_t* row = graph.src_indices; + const vertex_t* col = graph.dst_indices; + const weight_t* v = graph.edge_data; float speed = 1.f; float speed_efficiency = 1.f; diff --git a/cpp/src/layout/exact_repulsion.hpp b/cpp/src/layout/exact_repulsion.hpp index 583d5c81e30..49b4f46c5c3 100644 --- a/cpp/src/layout/exact_repulsion.hpp +++ b/cpp/src/layout/exact_repulsion.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,18 @@ */ #pragma once -#define restrict __restrict__ +#define restrict __restrict__ #define CUDA_MAX_BLOCKS_2D 256 namespace cugraph { namespace detail { template -__global__ void repulsion_kernel(const float *restrict x_pos, - const float *restrict y_pos, - float *restrict repel_x, - float *restrict repel_y, - const int *restrict mass, +__global__ void repulsion_kernel(const float* restrict x_pos, + const float* restrict y_pos, + float* restrict repel_x, + float* restrict repel_y, + const int* restrict mass, const float scaling_ratio, const vertex_t n) { @@ -50,11 +50,11 @@ __global__ void repulsion_kernel(const float *restrict x_pos, } template -void apply_repulsion(const float *restrict x_pos, - const float *restrict y_pos, - float *restrict repel_x, - float *restrict repel_y, - const int *restrict mass, +void apply_repulsion(const float* restrict x_pos, + const float* restrict y_pos, + float* restrict repel_x, + float* restrict repel_y, + const int* restrict mass, const float scaling_ratio, const vertex_t n, cudaStream_t stream) diff --git a/cpp/src/layout/fa2_kernels.hpp b/cpp/src/layout/fa2_kernels.hpp index 9aec348cec5..c46b249628b 100644 --- a/cpp/src/layout/fa2_kernels.hpp +++ b/cpp/src/layout/fa2_kernels.hpp @@ -23,15 +23,15 @@ namespace cugraph { namespace detail { template -__global__ void attraction_kernel(const vertex_t *restrict row, - const vertex_t *restrict col, - const weight_t *restrict v, +__global__ void attraction_kernel(const vertex_t* restrict row, + const vertex_t* restrict col, + const weight_t* restrict v, const edge_t e, - const float *restrict x_pos, - const float *restrict y_pos, - float *restrict attract_x, - float *restrict attract_y, - const int *restrict mass, + const float* restrict x_pos, + const float* restrict y_pos, + float* restrict attract_x, + float* restrict attract_y, + const int* restrict mass, bool outbound_attraction_distribution, bool lin_log_mode, const float edge_weight_influence, @@ -71,15 +71,15 @@ __global__ void attraction_kernel(const vertex_t *restrict row, } template -void apply_attraction(const vertex_t *restrict row, - const vertex_t *restrict col, - const weight_t *restrict v, +void apply_attraction(const vertex_t* restrict row, + const vertex_t* restrict col, + const weight_t* restrict v, const edge_t e, - const float *restrict x_pos, - const float *restrict y_pos, - float *restrict attract_x, - float *restrict attract_y, - const int *restrict mass, + const float* restrict x_pos, + const float* restrict y_pos, + float* restrict attract_x, + float* restrict attract_y, + const int* restrict mass, bool outbound_attraction_distribution, bool lin_log_mode, const float edge_weight_influence, @@ -116,11 +116,11 @@ void apply_attraction(const vertex_t *restrict row, } template -__global__ void linear_gravity_kernel(const float *restrict x_pos, - const float *restrict y_pos, - float *restrict attract_x, - float *restrict attract_y, - const int *restrict mass, +__global__ void linear_gravity_kernel(const float* restrict x_pos, + const float* restrict y_pos, + float* restrict attract_x, + float* restrict attract_y, + const int* restrict mass, const float gravity, const vertex_t n) { @@ -136,11 +136,11 @@ __global__ void linear_gravity_kernel(const float *restrict x_pos, } template -__global__ void strong_gravity_kernel(const float *restrict x_pos, - const float *restrict y_pos, - float *restrict attract_x, - float *restrict attract_y, - const int *restrict mass, +__global__ void strong_gravity_kernel(const float* restrict x_pos, + const float* restrict y_pos, + float* restrict attract_x, + float* restrict attract_y, + const int* restrict mass, const float gravity, const float scaling_ratio, const vertex_t n) @@ -157,11 +157,11 @@ __global__ void strong_gravity_kernel(const float *restrict x_pos, } template -void apply_gravity(const float *restrict x_pos, - const float *restrict y_pos, - float *restrict attract_x, - float *restrict attract_y, - const int *restrict mass, +void apply_gravity(const float* restrict x_pos, + const float* restrict y_pos, + float* restrict attract_x, + float* restrict attract_y, + const int* restrict mass, const float gravity, bool strong_gravity_mode, const float scaling_ratio, @@ -187,15 +187,15 @@ void apply_gravity(const float *restrict x_pos, } template -__global__ void local_speed_kernel(const float *restrict repel_x, - const float *restrict repel_y, - const float *restrict attract_x, - const float *restrict attract_y, - const float *restrict old_dx, - const float *restrict old_dy, - const int *restrict mass, - float *restrict swinging, - float *restrict traction, +__global__ void local_speed_kernel(const float* restrict repel_x, + const float* restrict repel_y, + const float* restrict attract_x, + const float* restrict attract_y, + const float* restrict old_dx, + const float* restrict old_dy, + const int* restrict mass, + float* restrict swinging, + float* restrict traction, const vertex_t n) { // For every node. @@ -210,15 +210,15 @@ __global__ void local_speed_kernel(const float *restrict repel_x, } template -void compute_local_speed(const float *restrict repel_x, - const float *restrict repel_y, - const float *restrict attract_x, - const float *restrict attract_y, - float *restrict old_dx, - float *restrict old_dy, - const int *restrict mass, - float *restrict swinging, - float *restrict traction, +void compute_local_speed(const float* restrict repel_x, + const float* restrict repel_y, + const float* restrict attract_x, + const float* restrict attract_y, + float* restrict old_dx, + float* restrict old_dy, + const int* restrict mass, + float* restrict swinging, + float* restrict traction, const vertex_t n, cudaStream_t stream) { @@ -237,9 +237,9 @@ void compute_local_speed(const float *restrict repel_x, template void adapt_speed(const float jitter_tolerance, - float *restrict jt, - float *restrict speed, - float *restrict speed_efficiency, + float* restrict jt, + float* restrict speed, + float* restrict speed_efficiency, const float s, const float t, const vertex_t n) @@ -272,15 +272,15 @@ void adapt_speed(const float jitter_tolerance, } template -__global__ void update_positions_kernel(float *restrict x_pos, - float *restrict y_pos, - const float *restrict repel_x, - const float *restrict repel_y, - const float *restrict attract_x, - const float *restrict attract_y, - float *restrict old_dx, - float *restrict old_dy, - const float *restrict swinging, +__global__ void update_positions_kernel(float* restrict x_pos, + float* restrict y_pos, + const float* restrict repel_x, + const float* restrict repel_y, + const float* restrict attract_x, + const float* restrict attract_y, + float* restrict old_dx, + float* restrict old_dy, + const float* restrict swinging, const float speed, const vertex_t n) { @@ -298,15 +298,15 @@ __global__ void update_positions_kernel(float *restrict x_pos, } template -void apply_forces(float *restrict x_pos, - float *restrict y_pos, - const float *restrict repel_x, - const float *restrict repel_y, - const float *restrict attract_x, - const float *restrict attract_y, - float *restrict old_dx, - float *restrict old_dy, - const float *restrict swinging, +void apply_forces(float* restrict x_pos, + float* restrict y_pos, + const float* restrict repel_x, + const float* restrict repel_y, + const float* restrict attract_x, + const float* restrict attract_y, + float* restrict old_dx, + float* restrict old_dy, + const float* restrict swinging, const float speed, const vertex_t n, cudaStream_t stream) diff --git a/cpp/src/layout/force_atlas2.cu b/cpp/src/layout/force_atlas2.cu index 50f01408775..c2db4607b40 100644 --- a/cpp/src/layout/force_atlas2.cu +++ b/cpp/src/layout/force_atlas2.cu @@ -20,12 +20,12 @@ namespace cugraph { template -void force_atlas2(raft::handle_t const &handle, - legacy::GraphCOOView &graph, - float *pos, +void force_atlas2(raft::handle_t const& handle, + legacy::GraphCOOView& graph, + float* pos, const int max_iter, - float *x_start, - float *y_start, + float* x_start, + float* y_start, bool outbound_attraction_distribution, bool lin_log_mode, bool prevent_overlapping, @@ -37,7 +37,7 @@ void force_atlas2(raft::handle_t const &handle, bool strong_gravity_mode, const float gravity, bool verbose, - internals::GraphBasedDimRedCallback *callback) + internals::GraphBasedDimRedCallback* callback) { CUGRAPH_EXPECTS(pos != nullptr, "Invalid input argument: pos array should be of size 2 * V"); CUGRAPH_EXPECTS(graph.number_of_vertices != 0, "Invalid input: Graph is empty"); @@ -80,12 +80,12 @@ void force_atlas2(raft::handle_t const &handle, } } -template void force_atlas2(raft::handle_t const &handle, - legacy::GraphCOOView &graph, - float *pos, +template void force_atlas2(raft::handle_t const& handle, + legacy::GraphCOOView& graph, + float* pos, const int max_iter, - float *x_start, - float *y_start, + float* x_start, + float* y_start, bool outbound_attraction_distribution, bool lin_log_mode, bool prevent_overlapping, @@ -97,14 +97,14 @@ template void force_atlas2(raft::handle_t const &handle, bool strong_gravity_mode, const float gravity, bool verbose, - internals::GraphBasedDimRedCallback *callback); + internals::GraphBasedDimRedCallback* callback); -template void force_atlas2(raft::handle_t const &handle, - legacy::GraphCOOView &graph, - float *pos, +template void force_atlas2(raft::handle_t const& handle, + legacy::GraphCOOView& graph, + float* pos, const int max_iter, - float *x_start, - float *y_start, + float* x_start, + float* y_start, bool outbound_attraction_distribution, bool lin_log_mode, bool prevent_overlapping, @@ -116,6 +116,6 @@ template void force_atlas2(raft::handle_t const &handle, bool strong_gravity_mode, const float gravity, bool verbose, - internals::GraphBasedDimRedCallback *callback); + internals::GraphBasedDimRedCallback* callback); } // namespace cugraph diff --git a/cpp/src/linear_assignment/hungarian.cu b/cpp/src/linear_assignment/hungarian.cu index e7db5082ca1..368e119e93c 100644 --- a/cpp/src/linear_assignment/hungarian.cu +++ b/cpp/src/linear_assignment/hungarian.cu @@ -56,11 +56,11 @@ double default_epsilon() } template -weight_t hungarian(raft::handle_t const &handle, +weight_t hungarian(raft::handle_t const& handle, index_t num_rows, index_t num_cols, - weight_t const *d_original_cost, - index_t *d_assignment, + weight_t const* d_original_cost, + index_t* d_assignment, weight_t epsilon) { if (num_rows == num_cols) { @@ -116,11 +116,11 @@ weight_t hungarian(raft::handle_t const &handle, } template -weight_t hungarian_sparse(raft::handle_t const &handle, - legacy::GraphCOOView const &graph, +weight_t hungarian_sparse(raft::handle_t const& handle, + legacy::GraphCOOView const& graph, vertex_t num_workers, - vertex_t const *workers, - vertex_t *assignment, + vertex_t const* workers, + vertex_t* assignment, weight_t epsilon) { CUGRAPH_EXPECTS(assignment != nullptr, "Invalid input argument: assignment pointer is NULL"); @@ -148,13 +148,13 @@ weight_t hungarian_sparse(raft::handle_t const &handle, rmm::device_uvector temp_tasks_v(graph.number_of_vertices, handle.get_stream_view()); rmm::device_uvector temp_workers_v(graph.number_of_vertices, handle.get_stream_view()); - weight_t *d_cost = cost_v.data(); - vertex_t *d_tasks = tasks_v.data(); - vertex_t *d_temp_tasks = temp_tasks_v.data(); - vertex_t *d_temp_workers = temp_workers_v.data(); - vertex_t *d_src_indices = graph.src_indices; - vertex_t *d_dst_indices = graph.dst_indices; - weight_t *d_edge_data = graph.edge_data; + weight_t* d_cost = cost_v.data(); + vertex_t* d_tasks = tasks_v.data(); + vertex_t* d_temp_tasks = temp_tasks_v.data(); + vertex_t* d_temp_workers = temp_workers_v.data(); + vertex_t* d_src_indices = graph.src_indices; + vertex_t* d_dst_indices = graph.dst_indices; + weight_t* d_edge_data = graph.edge_data; // // Renumber vertices internally. Workers will become @@ -232,7 +232,7 @@ weight_t hungarian_sparse(raft::handle_t const &handle, // bipartite matrix numbering // rmm::device_uvector temp_assignment_v(matrix_dimension, handle.get_stream_view()); - vertex_t *d_temp_assignment = temp_assignment_v.data(); + vertex_t* d_temp_assignment = temp_assignment_v.data(); weight_t min_cost = detail::hungarian( handle, matrix_dimension, matrix_dimension, d_cost, d_temp_assignment, epsilon); @@ -265,106 +265,106 @@ weight_t hungarian_sparse(raft::handle_t const &handle, } // namespace detail template -weight_t hungarian(raft::handle_t const &handle, - legacy::GraphCOOView const &graph, +weight_t hungarian(raft::handle_t const& handle, + legacy::GraphCOOView const& graph, vertex_t num_workers, - vertex_t const *workers, - vertex_t *assignment) + vertex_t const* workers, + vertex_t* assignment) { return detail::hungarian_sparse( handle, graph, num_workers, workers, assignment, detail::default_epsilon()); } template -weight_t hungarian(raft::handle_t const &handle, - legacy::GraphCOOView const &graph, +weight_t hungarian(raft::handle_t const& handle, + legacy::GraphCOOView const& graph, vertex_t num_workers, - vertex_t const *workers, - vertex_t *assignment, + vertex_t const* workers, + vertex_t* assignment, weight_t epsilon) { return detail::hungarian_sparse(handle, graph, num_workers, workers, assignment, epsilon); } template int32_t hungarian( - raft::handle_t const &, - legacy::GraphCOOView const &, + raft::handle_t const&, + legacy::GraphCOOView const&, int32_t, - int32_t const *, - int32_t *, + int32_t const*, + int32_t*, int32_t); template float hungarian( - raft::handle_t const &, - legacy::GraphCOOView const &, + raft::handle_t const&, + legacy::GraphCOOView const&, int32_t, - int32_t const *, - int32_t *, + int32_t const*, + int32_t*, float); template double hungarian( - raft::handle_t const &, - legacy::GraphCOOView const &, + raft::handle_t const&, + legacy::GraphCOOView const&, int32_t, - int32_t const *, - int32_t *, + int32_t const*, + int32_t*, double); template int32_t hungarian( - raft::handle_t const &, - legacy::GraphCOOView const &, + raft::handle_t const&, + legacy::GraphCOOView const&, int32_t, - int32_t const *, - int32_t *); + int32_t const*, + int32_t*); template float hungarian( - raft::handle_t const &, - legacy::GraphCOOView const &, + raft::handle_t const&, + legacy::GraphCOOView const&, int32_t, - int32_t const *, - int32_t *); + int32_t const*, + int32_t*); template double hungarian( - raft::handle_t const &, - legacy::GraphCOOView const &, + raft::handle_t const&, + legacy::GraphCOOView const&, int32_t, - int32_t const *, - int32_t *); + int32_t const*, + int32_t*); namespace dense { template -weight_t hungarian(raft::handle_t const &handle, - weight_t const *costs, +weight_t hungarian(raft::handle_t const& handle, + weight_t const* costs, index_t num_rows, index_t num_cols, - index_t *assignment) + index_t* assignment) { return detail::hungarian( handle, num_rows, num_cols, costs, assignment, detail::default_epsilon()); } template -weight_t hungarian(raft::handle_t const &handle, - weight_t const *costs, +weight_t hungarian(raft::handle_t const& handle, + weight_t const* costs, index_t num_rows, index_t num_cols, - index_t *assignment, + index_t* assignment, weight_t epsilon) { return detail::hungarian(handle, num_rows, num_cols, costs, assignment, epsilon); } template int32_t hungarian( - raft::handle_t const &, int32_t const *, int32_t, int32_t, int32_t *); + raft::handle_t const&, int32_t const*, int32_t, int32_t, int32_t*); template float hungarian( - raft::handle_t const &, float const *, int32_t, int32_t, int32_t *); + raft::handle_t const&, float const*, int32_t, int32_t, int32_t*); template double hungarian( - raft::handle_t const &, double const *, int32_t, int32_t, int32_t *); + raft::handle_t const&, double const*, int32_t, int32_t, int32_t*); template int32_t hungarian( - raft::handle_t const &, int32_t const *, int32_t, int32_t, int32_t *, int32_t); + raft::handle_t const&, int32_t const*, int32_t, int32_t, int32_t*, int32_t); template float hungarian( - raft::handle_t const &, float const *, int32_t, int32_t, int32_t *, float); + raft::handle_t const&, float const*, int32_t, int32_t, int32_t*, float); template double hungarian( - raft::handle_t const &, double const *, int32_t, int32_t, int32_t *, double); + raft::handle_t const&, double const*, int32_t, int32_t, int32_t*, double); } // namespace dense diff --git a/cpp/src/link_analysis/gunrock_hits.cpp b/cpp/src/link_analysis/gunrock_hits.cpp index 6b95418e6b6..a86210cc521 100644 --- a/cpp/src/link_analysis/gunrock_hits.cpp +++ b/cpp/src/link_analysis/gunrock_hits.cpp @@ -34,13 +34,13 @@ const int HOST{1}; // gunrock should expose the device constant at the API le const int DEVICE{2}; // gunrock should expose the device constant at the API level. template -void hits(cugraph::legacy::GraphCSRView const &graph, +void hits(cugraph::legacy::GraphCSRView const& graph, int max_iter, weight_t tolerance, - weight_t const *starting_value, + weight_t const* starting_value, bool normalized, - weight_t *hubs, - weight_t *authorities) + weight_t* hubs, + weight_t* authorities) { CUGRAPH_EXPECTS(hubs != nullptr, "Invalid input argument: hubs array should be of size V"); CUGRAPH_EXPECTS(authorities != nullptr, @@ -61,13 +61,13 @@ void hits(cugraph::legacy::GraphCSRView const &graph DEVICE); } -template void hits(cugraph::legacy::GraphCSRView const &, +template void hits(cugraph::legacy::GraphCSRView const&, int, float, - float const *, + float const*, bool, - float *, - float *); + float*, + float*); } // namespace gunrock } // namespace cugraph diff --git a/cpp/src/link_prediction/jaccard.cu b/cpp/src/link_prediction/jaccard.cu index 2e10cd7e8c3..25186a6492b 100644 --- a/cpp/src/link_prediction/jaccard.cu +++ b/cpp/src/link_prediction/jaccard.cu @@ -32,7 +32,7 @@ namespace detail { // Volume of neighboors (*weight_s) template __global__ void jaccard_row_sum( - vertex_t n, edge_t const *csrPtr, vertex_t const *csrInd, weight_t const *v, weight_t *work) + vertex_t n, edge_t const* csrPtr, vertex_t const* csrInd, weight_t const* v, weight_t* work) { vertex_t row; edge_t start, end, length; @@ -56,12 +56,12 @@ __global__ void jaccard_row_sum( // Volume of intersections (*weight_i) and cumulated volume of neighboors (*weight_s) template __global__ void jaccard_is(vertex_t n, - edge_t const *csrPtr, - vertex_t const *csrInd, - weight_t const *v, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s) + edge_t const* csrPtr, + vertex_t const* csrInd, + weight_t const* v, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s) { edge_t i, j, Ni, Nj; vertex_t row, col; @@ -120,14 +120,14 @@ __global__ void jaccard_is(vertex_t n, // Using list of node pairs template __global__ void jaccard_is_pairs(edge_t num_pairs, - edge_t const *csrPtr, - vertex_t const *csrInd, - vertex_t const *first_pair, - vertex_t const *second_pair, - weight_t const *v, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s) + edge_t const* csrPtr, + vertex_t const* csrInd, + vertex_t const* first_pair, + vertex_t const* second_pair, + weight_t const* v, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s) { edge_t i, idx, Ni, Nj, match; vertex_t row, col, ref, cur, ref_col, cur_col; @@ -184,9 +184,9 @@ __global__ void jaccard_is_pairs(edge_t num_pairs, // Jaccard weights (*weight) template __global__ void jaccard_jw(edge_t e, - weight_t const *weight_i, - weight_t const *weight_s, - weight_t *weight_j) + weight_t const* weight_i, + weight_t const* weight_s, + weight_t* weight_j) { edge_t j; weight_t Wi, Ws, Wu; @@ -202,13 +202,13 @@ __global__ void jaccard_jw(edge_t e, template int jaccard(vertex_t n, edge_t e, - edge_t const *csrPtr, - vertex_t const *csrInd, - weight_t const *weight_in, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s, - weight_t *weight_j) + edge_t const* csrPtr, + vertex_t const* csrInd, + weight_t const* weight_in, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s, + weight_t* weight_j) { rmm::cuda_stream_view stream_view; dim3 nthreads, nblocks; @@ -258,15 +258,15 @@ int jaccard(vertex_t n, template int jaccard_pairs(vertex_t n, edge_t num_pairs, - edge_t const *csrPtr, - vertex_t const *csrInd, - vertex_t const *first_pair, - vertex_t const *second_pair, - weight_t const *weight_in, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s, - weight_t *weight_j) + edge_t const* csrPtr, + vertex_t const* csrInd, + vertex_t const* first_pair, + vertex_t const* second_pair, + weight_t const* weight_in, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s, + weight_t* weight_j) { dim3 nthreads, nblocks; int y = 4; @@ -316,7 +316,7 @@ int jaccard_pairs(vertex_t n, } // namespace detail template -void jaccard(legacy::GraphCSRView const &graph, WT const *weights, WT *result) +void jaccard(legacy::GraphCSRView const& graph, WT const* weights, WT* result) { CUGRAPH_EXPECTS(result != nullptr, "Invalid input argument: result pointer is NULL"); @@ -348,12 +348,12 @@ void jaccard(legacy::GraphCSRView const &graph, WT const *weights, W } template -void jaccard_list(legacy::GraphCSRView const &graph, - WT const *weights, +void jaccard_list(legacy::GraphCSRView const& graph, + WT const* weights, ET num_pairs, - VT const *first, - VT const *second, - WT *result) + VT const* first, + VT const* second, + WT* result) { CUGRAPH_EXPECTS(result != nullptr, "Invalid input argument: result pointer is NULL"); CUGRAPH_EXPECTS(first != nullptr, "Invalid input argument: first is NULL"); @@ -390,41 +390,43 @@ void jaccard_list(legacy::GraphCSRView const &graph, } } -template void jaccard( - legacy::GraphCSRView const &, float const *, float *); +template void jaccard(legacy::GraphCSRView const&, + float const*, + float*); template void jaccard( - legacy::GraphCSRView const &, double const *, double *); -template void jaccard( - legacy::GraphCSRView const &, float const *, float *); + legacy::GraphCSRView const&, double const*, double*); +template void jaccard(legacy::GraphCSRView const&, + float const*, + float*); template void jaccard( - legacy::GraphCSRView const &, double const *, double *); + legacy::GraphCSRView const&, double const*, double*); template void jaccard_list( - legacy::GraphCSRView const &, - float const *, + legacy::GraphCSRView const&, + float const*, int32_t, - int32_t const *, - int32_t const *, - float *); + int32_t const*, + int32_t const*, + float*); template void jaccard_list( - legacy::GraphCSRView const &, - double const *, + legacy::GraphCSRView const&, + double const*, int32_t, - int32_t const *, - int32_t const *, - double *); + int32_t const*, + int32_t const*, + double*); template void jaccard_list( - legacy::GraphCSRView const &, - float const *, + legacy::GraphCSRView const&, + float const*, int64_t, - int64_t const *, - int64_t const *, - float *); + int64_t const*, + int64_t const*, + float*); template void jaccard_list( - legacy::GraphCSRView const &, - double const *, + legacy::GraphCSRView const&, + double const*, int64_t, - int64_t const *, - int64_t const *, - double *); + int64_t const*, + int64_t const*, + double*); } // namespace cugraph diff --git a/cpp/src/link_prediction/overlap.cu b/cpp/src/link_prediction/overlap.cu index f38c8326ca2..7b7470da7fc 100644 --- a/cpp/src/link_prediction/overlap.cu +++ b/cpp/src/link_prediction/overlap.cu @@ -31,7 +31,7 @@ namespace detail { // TODO: Identical kernel to jaccard_row_sum!! template __global__ void overlap_row_sum( - vertex_t n, edge_t const *csrPtr, vertex_t const *csrInd, weight_t const *v, weight_t *work) + vertex_t n, edge_t const* csrPtr, vertex_t const* csrInd, weight_t const* v, weight_t* work) { vertex_t row; edge_t start, end, length; @@ -56,12 +56,12 @@ __global__ void overlap_row_sum( // TODO: Identical kernel to jaccard_row_sum!! template __global__ void overlap_is(vertex_t n, - edge_t const *csrPtr, - vertex_t const *csrInd, - weight_t const *v, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s) + edge_t const* csrPtr, + vertex_t const* csrInd, + weight_t const* v, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s) { edge_t i, j, Ni, Nj; vertex_t row, col; @@ -121,14 +121,14 @@ __global__ void overlap_is(vertex_t n, // NOTE: NOT the same as jaccard template __global__ void overlap_is_pairs(edge_t num_pairs, - edge_t const *csrPtr, - vertex_t const *csrInd, - vertex_t const *first_pair, - vertex_t const *second_pair, - weight_t const *v, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s) + edge_t const* csrPtr, + vertex_t const* csrInd, + vertex_t const* first_pair, + vertex_t const* second_pair, + weight_t const* v, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s) { edge_t i, idx, Ni, Nj, match; vertex_t row, col, ref, cur, ref_col, cur_col; @@ -185,11 +185,11 @@ __global__ void overlap_is_pairs(edge_t num_pairs, // Overlap weights (*weight) template __global__ void overlap_jw(edge_t e, - edge_t const *csrPtr, - vertex_t const *csrInd, - weight_t *weight_i, - weight_t *weight_s, - weight_t *weight_j) + edge_t const* csrPtr, + vertex_t const* csrInd, + weight_t* weight_i, + weight_t* weight_s, + weight_t* weight_j) { edge_t j; weight_t Wi, Wu; @@ -204,13 +204,13 @@ __global__ void overlap_jw(edge_t e, template int overlap(vertex_t n, edge_t e, - edge_t const *csrPtr, - vertex_t const *csrInd, - weight_t const *weight_in, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s, - weight_t *weight_j) + edge_t const* csrPtr, + vertex_t const* csrInd, + weight_t const* weight_in, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s, + weight_t* weight_j) { dim3 nthreads, nblocks; int y = 4; @@ -259,15 +259,15 @@ int overlap(vertex_t n, template int overlap_pairs(vertex_t n, edge_t num_pairs, - edge_t const *csrPtr, - vertex_t const *csrInd, - vertex_t const *first_pair, - vertex_t const *second_pair, - weight_t const *weight_in, - weight_t *work, - weight_t *weight_i, - weight_t *weight_s, - weight_t *weight_j) + edge_t const* csrPtr, + vertex_t const* csrInd, + vertex_t const* first_pair, + vertex_t const* second_pair, + weight_t const* weight_in, + weight_t* work, + weight_t* weight_i, + weight_t* weight_s, + weight_t* weight_j) { dim3 nthreads, nblocks; int y = 4; @@ -314,7 +314,7 @@ int overlap_pairs(vertex_t n, } // namespace detail template -void overlap(legacy::GraphCSRView const &graph, WT const *weights, WT *result) +void overlap(legacy::GraphCSRView const& graph, WT const* weights, WT* result) { CUGRAPH_EXPECTS(result != nullptr, "Invalid input argument: result pointer is NULL"); @@ -346,12 +346,12 @@ void overlap(legacy::GraphCSRView const &graph, WT const *weights, W } template -void overlap_list(legacy::GraphCSRView const &graph, - WT const *weights, +void overlap_list(legacy::GraphCSRView const& graph, + WT const* weights, ET num_pairs, - VT const *first, - VT const *second, - WT *result) + VT const* first, + VT const* second, + WT* result) { CUGRAPH_EXPECTS(result != nullptr, "Invalid input argument: result pointer is NULL"); CUGRAPH_EXPECTS(first != nullptr, "Invalid input argument: first column is NULL"); @@ -388,41 +388,43 @@ void overlap_list(legacy::GraphCSRView const &graph, } } -template void overlap( - legacy::GraphCSRView const &, float const *, float *); +template void overlap(legacy::GraphCSRView const&, + float const*, + float*); template void overlap( - legacy::GraphCSRView const &, double const *, double *); -template void overlap( - legacy::GraphCSRView const &, float const *, float *); + legacy::GraphCSRView const&, double const*, double*); +template void overlap(legacy::GraphCSRView const&, + float const*, + float*); template void overlap( - legacy::GraphCSRView const &, double const *, double *); + legacy::GraphCSRView const&, double const*, double*); template void overlap_list( - legacy::GraphCSRView const &, - float const *, + legacy::GraphCSRView const&, + float const*, int32_t, - int32_t const *, - int32_t const *, - float *); + int32_t const*, + int32_t const*, + float*); template void overlap_list( - legacy::GraphCSRView const &, - double const *, + legacy::GraphCSRView const&, + double const*, int32_t, - int32_t const *, - int32_t const *, - double *); + int32_t const*, + int32_t const*, + double*); template void overlap_list( - legacy::GraphCSRView const &, - float const *, + legacy::GraphCSRView const&, + float const*, int64_t, - int64_t const *, - int64_t const *, - float *); + int64_t const*, + int64_t const*, + float*); template void overlap_list( - legacy::GraphCSRView const &, - double const *, + legacy::GraphCSRView const&, + double const*, int64_t, - int64_t const *, - int64_t const *, - double *); + int64_t const*, + int64_t const*, + double*); } // namespace cugraph diff --git a/cpp/src/sampling/random_walks.cuh b/cpp/src/sampling/random_walks.cuh index 361726acb56..c67f981ecf5 100644 --- a/cpp/src/sampling/random_walks.cuh +++ b/cpp/src/sampling/random_walks.cuh @@ -250,7 +250,7 @@ struct col_indx_extract_t{*values_} - : thrust::nullopt] __device__(auto indx, auto col_indx) { + : thrust::nullopt] __device__(auto indx, auto col_indx) { auto delta = ptr_d_sizes[indx] - 1; auto v_indx = ptr_d_coalesced_v[indx * max_depth + delta]; auto start_row = row_offsets[v_indx]; diff --git a/cpp/src/sampling/rw_traversals.hpp b/cpp/src/sampling/rw_traversals.hpp index c86f76fcc72..b2ba74e97a2 100644 --- a/cpp/src/sampling/rw_traversals.hpp +++ b/cpp/src/sampling/rw_traversals.hpp @@ -213,11 +213,11 @@ struct horizontal_traversal_t { random_engine_t::generate_random(handle, ptr_d_random, d_random.size(), seed0); - auto const* col_indices = graph.get_matrix_partition_view().get_indices(); - auto const* row_offsets = graph.get_matrix_partition_view().get_offsets(); - auto const* values = graph.get_matrix_partition_view().get_weights() - ? *(graph.get_matrix_partition_view().get_weights()) - : static_cast(nullptr); + auto const* col_indices = graph.get_matrix_partition_view().get_indices(); + auto const* row_offsets = graph.get_matrix_partition_view().get_offsets(); + auto const* values = graph.get_matrix_partition_view().get_weights() + ? *(graph.get_matrix_partition_view().get_weights()) + : static_cast(nullptr); auto* ptr_d_sizes = raw_ptr(d_paths_sz); auto const& d_cached_out_degs = rand_walker.get_out_degs(); diff --git a/cpp/src/structure/graph.cu b/cpp/src/structure/graph.cu index 192234380d9..e3bdd1d5c67 100644 --- a/cpp/src/structure/graph.cu +++ b/cpp/src/structure/graph.cu @@ -25,8 +25,8 @@ namespace { template void degree_from_offsets(vertex_t number_of_vertices, - edge_t const *offsets, - edge_t *degree, + edge_t const* offsets, + edge_t* degree, rmm::cuda_stream_view stream_view) { // Computes out-degree for x = 0 and x = 2 @@ -38,11 +38,11 @@ void degree_from_offsets(vertex_t number_of_vertices, } template -void degree_from_vertex_ids(const raft::handle_t *handle, +void degree_from_vertex_ids(const raft::handle_t* handle, vertex_t number_of_vertices, edge_t number_of_edges, - vertex_t const *indices, - edge_t *degree, + vertex_t const* indices, + edge_t* degree, rmm::cuda_stream_view stream_view) { thrust::for_each(rmm::exec_policy(stream_view), @@ -50,7 +50,7 @@ void degree_from_vertex_ids(const raft::handle_t *handle, thrust::make_counting_iterator(number_of_edges), [indices, degree] __device__(edge_t e) { atomicAdd(degree + indices[e], 1); }); if ((handle != nullptr) && (handle->comms_initialized())) { - auto &comm = handle->get_comms(); + auto& comm = handle->get_comms(); comm.allreduce(degree, degree, number_of_vertices, raft::comms::op_t::SUM, stream_view.value()); } } @@ -61,13 +61,13 @@ namespace cugraph { namespace legacy { template -void GraphViewBase::get_vertex_identifiers(VT *identifiers) const +void GraphViewBase::get_vertex_identifiers(VT* identifiers) const { cugraph::detail::sequence(number_of_vertices, identifiers); } template -void GraphCompressedSparseBaseView::get_source_indices(VT *src_indices) const +void GraphCompressedSparseBaseView::get_source_indices(VT* src_indices) const { CUGRAPH_EXPECTS(offsets != nullptr, "No graph specified"); cugraph::detail::offsets_to_indices( @@ -75,7 +75,7 @@ void GraphCompressedSparseBaseView::get_source_indices(VT *src_indic } template -void GraphCOOView::degree(ET *degree, DegreeDirection direction) const +void GraphCOOView::degree(ET* degree, DegreeDirection direction) const { // // NOTE: We assume offsets/indices are a CSR. If a CSC is passed @@ -112,7 +112,7 @@ void GraphCOOView::degree(ET *degree, DegreeDirection direction) con } template -void GraphCompressedSparseBaseView::degree(ET *degree, DegreeDirection direction) const +void GraphCompressedSparseBaseView::degree(ET* degree, DegreeDirection direction) const { // // NOTE: We assume offsets/indices are a CSR. If a CSC is passed diff --git a/cpp/src/traversal/bfs.cu b/cpp/src/traversal/bfs.cu index b4416b907e5..74a94ba0670 100644 --- a/cpp/src/traversal/bfs.cu +++ b/cpp/src/traversal/bfs.cu @@ -96,7 +96,7 @@ void BFS::setup() // Lets use this int* for the next 3 lines // Its dereferenced value is not initialized - so we dont care about what we // put in it - IndexType *d_nisolated = d_new_frontier_cnt; + IndexType* d_nisolated = d_new_frontier_cnt; cudaMemsetAsync(d_nisolated, 0, sizeof(IndexType), stream); // Computing isolated_bmap @@ -114,10 +114,10 @@ void BFS::setup() } template -void BFS::configure(IndexType *_distances, - IndexType *_predecessors, - double *_sp_counters, - int *_edge_mask) +void BFS::configure(IndexType* _distances, + IndexType* _predecessors, + double* _sp_counters, + int* _edge_mask) { distances = _distances; predecessors = _predecessors; @@ -473,11 +473,11 @@ template class BFS; // NOTE: SP counter increase extremely fast on large graph // It can easily reach 1e40~1e70 on GAP-road.mtx template -void bfs(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - VT *distances, - VT *predecessors, - double *sp_counters, +void bfs(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + VT* distances, + VT* predecessors, + double* sp_counters, const VT start_vertex, bool directed, bool mg_batch) @@ -497,8 +497,8 @@ void bfs(raft::handle_t const &handle, VT number_of_vertices = graph.number_of_vertices; ET number_of_edges = graph.number_of_edges; - const VT *indices_ptr = graph.indices; - const ET *offsets_ptr = graph.offsets; + const VT* indices_ptr = graph.indices; + const ET* offsets_ptr = graph.offsets; int alpha = 15; int beta = 18; @@ -512,66 +512,66 @@ void bfs(raft::handle_t const &handle, // Explicit Instantiation template void bfs( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - uint32_t *distances, - uint32_t *predecessors, - double *sp_counters, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + uint32_t* distances, + uint32_t* predecessors, + double* sp_counters, const uint32_t source_vertex, bool directed, bool mg_batch); // Explicit Instantiation template void bfs( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - uint32_t *distances, - uint32_t *predecessors, - double *sp_counters, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + uint32_t* distances, + uint32_t* predecessors, + double* sp_counters, const uint32_t source_vertex, bool directed, bool mg_batch); // Explicit Instantiation template void bfs( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - int32_t *distances, - int32_t *predecessors, - double *sp_counters, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + int32_t* distances, + int32_t* predecessors, + double* sp_counters, const int32_t source_vertex, bool directed, bool mg_batch); // Explicit Instantiation template void bfs( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - int32_t *distances, - int32_t *predecessors, - double *sp_counters, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + int32_t* distances, + int32_t* predecessors, + double* sp_counters, const int32_t source_vertex, bool directed, bool mg_batch); // Explicit Instantiation template void bfs( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - int64_t *distances, - int64_t *predecessors, - double *sp_counters, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + int64_t* distances, + int64_t* predecessors, + double* sp_counters, const int64_t source_vertex, bool directed, bool mg_batch); // Explicit Instantiation template void bfs( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - int64_t *distances, - int64_t *predecessors, - double *sp_counters, + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + int64_t* distances, + int64_t* predecessors, + double* sp_counters, const int64_t source_vertex, bool directed, bool mg_batch); diff --git a/cpp/src/traversal/bfs.cuh b/cpp/src/traversal/bfs.cuh index 6457665ec09..6bf8e0d0197 100644 --- a/cpp/src/traversal/bfs.cuh +++ b/cpp/src/traversal/bfs.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. * * NVIDIA CORPORATION and its licensors retain all intellectual property * and proprietary rights in and to this software, related documentation @@ -25,8 +25,8 @@ template class BFS { private: IndexType number_of_vertices, number_of_edges; - const IndexType *row_offsets = nullptr; - const IndexType *col_indices = nullptr; + const IndexType* row_offsets = nullptr; + const IndexType* col_indices = nullptr; bool directed; bool deterministic; @@ -36,10 +36,10 @@ class BFS { bool computeDistances; bool computePredecessors; rmm::device_vector distances_vals; - IndexType *distances = nullptr; - IndexType *predecessors = nullptr; - double *sp_counters = nullptr; - int *edge_mask = nullptr; + IndexType* distances = nullptr; + IndexType* predecessors = nullptr; + double* sp_counters = nullptr; + int* edge_mask = nullptr; rmm::device_vector original_frontier; rmm::device_vector visited_bmap; @@ -53,16 +53,16 @@ class BFS { // Working data // For complete description of each, go to bfs.cu IndexType nisolated; - IndexType *frontier = nullptr; - IndexType *new_frontier = nullptr; - IndexType *frontier_vertex_degree = nullptr; - IndexType *exclusive_sum_frontier_vertex_degree = nullptr; - IndexType *unvisited_queue = nullptr; - IndexType *left_unvisited_queue = nullptr; - IndexType *d_new_frontier_cnt = nullptr; - IndexType *d_mu = nullptr; - IndexType *d_unvisited_cnt = nullptr; - IndexType *d_left_unvisited_cnt = nullptr; + IndexType* frontier = nullptr; + IndexType* new_frontier = nullptr; + IndexType* frontier_vertex_degree = nullptr; + IndexType* exclusive_sum_frontier_vertex_degree = nullptr; + IndexType* unvisited_queue = nullptr; + IndexType* left_unvisited_queue = nullptr; + IndexType* d_new_frontier_cnt = nullptr; + IndexType* d_mu = nullptr; + IndexType* d_unvisited_cnt = nullptr; + IndexType* d_left_unvisited_cnt = nullptr; IndexType vertices_bmap_size; @@ -80,8 +80,8 @@ class BFS { BFS(IndexType _number_of_vertices, IndexType _number_of_edges, - const IndexType *_row_offsets, - const IndexType *_col_indices, + const IndexType* _row_offsets, + const IndexType* _col_indices, bool _directed, IndexType _alpha, IndexType _beta, @@ -98,10 +98,10 @@ class BFS { setup(); } - void configure(IndexType *distances, - IndexType *predecessors, - double *sp_counters, - int *edge_mask); + void configure(IndexType* distances, + IndexType* predecessors, + double* sp_counters, + int* edge_mask); void traverse(IndexType source_vertex); }; diff --git a/cpp/src/traversal/bfs_kernels.cuh b/cpp/src/traversal/bfs_kernels.cuh index e55abaa8c1d..4e482b446ba 100644 --- a/cpp/src/traversal/bfs_kernels.cuh +++ b/cpp/src/traversal/bfs_kernels.cuh @@ -40,11 +40,11 @@ namespace bfs_kernels { // visited_bmap_nints = the visited_bmap is made of that number of ints template -__global__ void fill_unvisited_queue_kernel(int *visited_bmap, +__global__ void fill_unvisited_queue_kernel(int* visited_bmap, IndexType visited_bmap_nints, IndexType n, - IndexType *unvisited, - IndexType *unvisited_cnt) + IndexType* unvisited, + IndexType* unvisited_cnt) { typedef cub::BlockScan BlockScan; __shared__ typename BlockScan::TempStorage scan_temp_storage; @@ -118,8 +118,8 @@ __global__ void fill_unvisited_queue_kernel(int *visited_bmap, vec_v.z = v_idx * INT_SIZE + traversal::getNextZeroBit(thread_visited_int); vec_v.w = v_idx * INT_SIZE + traversal::getNextZeroBit(thread_visited_int); - typename traversal::vec_t::vec4 *unvisited_i4 = - reinterpret_cast::vec4 *>( + typename traversal::vec_t::vec4* unvisited_i4 = + reinterpret_cast::vec4*>( &unvisited[current_unvisited_index]); *unvisited_i4 = vec_v; @@ -131,8 +131,8 @@ __global__ void fill_unvisited_queue_kernel(int *visited_bmap, vec_v.x = v_idx * INT_SIZE + traversal::getNextZeroBit(thread_visited_int); vec_v.y = v_idx * INT_SIZE + traversal::getNextZeroBit(thread_visited_int); - typename traversal::vec_t::vec2 *unvisited_i2 = - reinterpret_cast::vec2 *>( + typename traversal::vec_t::vec2* unvisited_i2 = + reinterpret_cast::vec2*>( &unvisited[current_unvisited_index]); *unvisited_i2 = vec_v; @@ -152,11 +152,11 @@ __global__ void fill_unvisited_queue_kernel(int *visited_bmap, // Wrapper template -void fill_unvisited_queue(int *visited_bmap, +void fill_unvisited_queue(int* visited_bmap, IndexType visited_bmap_nints, IndexType n, - IndexType *unvisited, - IndexType *unvisited_cnt, + IndexType* unvisited, + IndexType* unvisited_cnt, cudaStream_t m_stream, bool deterministic) { @@ -181,11 +181,11 @@ void fill_unvisited_queue(int *visited_bmap, // template -__global__ void count_unvisited_edges_kernel(const IndexType *potentially_unvisited, +__global__ void count_unvisited_edges_kernel(const IndexType* potentially_unvisited, const IndexType potentially_unvisited_size, - const int *visited_bmap, - IndexType *degree_vertices, - IndexType *mu) + const int* visited_bmap, + IndexType* degree_vertices, + IndexType* mu) { typedef cub::BlockReduce BlockReduce; __shared__ typename BlockReduce::TempStorage reduce_temp_storage; @@ -214,11 +214,11 @@ __global__ void count_unvisited_edges_kernel(const IndexType *potentially_unvisi // Wrapper template -void count_unvisited_edges(const IndexType *potentially_unvisited, +void count_unvisited_edges(const IndexType* potentially_unvisited, const IndexType potentially_unvisited_size, - const int *visited_bmap, - IndexType *node_degree, - IndexType *mu, + const int* visited_bmap, + IndexType* node_degree, + IndexType* mu, cudaStream_t m_stream) { dim3 grid, block; @@ -246,19 +246,19 @@ void count_unvisited_edges(const IndexType *potentially_unvisited, // template -__global__ void main_bottomup_kernel(const IndexType *unvisited, +__global__ void main_bottomup_kernel(const IndexType* unvisited, const IndexType unvisited_size, - IndexType *left_unvisited, - IndexType *left_unvisited_cnt, - int *visited_bmap, - const IndexType *row_ptr, - const IndexType *col_ind, + IndexType* left_unvisited, + IndexType* left_unvisited_cnt, + int* visited_bmap, + const IndexType* row_ptr, + const IndexType* col_ind, IndexType lvl, - IndexType *new_frontier, - IndexType *new_frontier_cnt, - IndexType *distances, - IndexType *predecessors, - int *edge_mask) + IndexType* new_frontier, + IndexType* new_frontier_cnt, + IndexType* distances, + IndexType* predecessors, + int* edge_mask) { typedef cub::BlockDiscontinuity BlockDiscontinuity; typedef cub::WarpReduce WarpReduce; @@ -487,19 +487,19 @@ __global__ void main_bottomup_kernel(const IndexType *unvisited, } template -void bottom_up_main(IndexType *unvisited, +void bottom_up_main(IndexType* unvisited, IndexType unvisited_size, - IndexType *left_unvisited, - IndexType *d_left_unvisited_idx, - int *visited, - const IndexType *row_ptr, - const IndexType *col_ind, + IndexType* left_unvisited, + IndexType* d_left_unvisited_idx, + int* visited, + const IndexType* row_ptr, + const IndexType* col_ind, IndexType lvl, - IndexType *new_frontier, - IndexType *new_frontier_idx, - IndexType *distances, - IndexType *predecessors, - int *edge_mask, + IndexType* new_frontier, + IndexType* new_frontier_idx, + IndexType* distances, + IndexType* predecessors, + int* edge_mask, cudaStream_t m_stream, bool deterministic) { @@ -531,17 +531,17 @@ void bottom_up_main(IndexType *unvisited, // MAIN_BOTTOMUP_MAX_EDGES && no parent found // template -__global__ void bottom_up_large_degree_kernel(IndexType *left_unvisited, +__global__ void bottom_up_large_degree_kernel(IndexType* left_unvisited, IndexType left_unvisited_size, - int *visited, - const IndexType *row_ptr, - const IndexType *col_ind, + int* visited, + const IndexType* row_ptr, + const IndexType* col_ind, IndexType lvl, - IndexType *new_frontier, - IndexType *new_frontier_cnt, - IndexType *distances, - IndexType *predecessors, - int *edge_mask) + IndexType* new_frontier, + IndexType* new_frontier_cnt, + IndexType* distances, + IndexType* predecessors, + int* edge_mask) { int logical_lane_id = threadIdx.x % BOTTOM_UP_LOGICAL_WARP_SIZE; int logical_warp_id = threadIdx.x / BOTTOM_UP_LOGICAL_WARP_SIZE; @@ -610,17 +610,17 @@ __global__ void bottom_up_large_degree_kernel(IndexType *left_unvisited, } template -void bottom_up_large(IndexType *left_unvisited, +void bottom_up_large(IndexType* left_unvisited, IndexType left_unvisited_size, - int *visited, - const IndexType *row_ptr, - const IndexType *col_ind, + int* visited, + const IndexType* row_ptr, + const IndexType* col_ind, IndexType lvl, - IndexType *new_frontier, - IndexType *new_frontier_idx, - IndexType *distances, - IndexType *predecessors, - int *edge_mask, + IndexType* new_frontier, + IndexType* new_frontier_idx, + IndexType* distances, + IndexType* predecessors, + int* edge_mask, cudaStream_t m_stream, bool deterministic) { @@ -680,24 +680,24 @@ void bottom_up_large(IndexType *left_unvisited, template __global__ void topdown_expand_kernel( - const IndexType *row_ptr, - const IndexType *col_ind, - const IndexType *frontier, + const IndexType* row_ptr, + const IndexType* col_ind, + const IndexType* frontier, const IndexType frontier_size, const IndexType totaldegree, const IndexType max_items_per_thread, const IndexType lvl, - IndexType *new_frontier, - IndexType *new_frontier_cnt, - const IndexType *frontier_degrees_exclusive_sum, - const IndexType *frontier_degrees_exclusive_sum_buckets_offsets, - int *previous_bmap, - int *bmap, - IndexType *distances, - IndexType *predecessors, - double *sp_counters, - const int *edge_mask, - const int *isolated_bmap, + IndexType* new_frontier, + IndexType* new_frontier_cnt, + const IndexType* frontier_degrees_exclusive_sum, + const IndexType* frontier_degrees_exclusive_sum_buckets_offsets, + int* previous_bmap, + int* bmap, + IndexType* distances, + IndexType* predecessors, + double* sp_counters, + const int* edge_mask, + const int* isolated_bmap, bool directed) { // BlockScan @@ -844,7 +844,7 @@ __global__ void topdown_expand_kernel( IndexType local_buf1[TOP_DOWN_BATCH_SIZE]; IndexType local_buf2[TOP_DOWN_BATCH_SIZE]; - IndexType *vec_frontier_degrees_exclusive_sum_index = &local_buf2[0]; + IndexType* vec_frontier_degrees_exclusive_sum_index = &local_buf2[0]; #pragma unroll for (IndexType iv = 0; iv < TOP_DOWN_BATCH_SIZE; ++iv) { @@ -869,7 +869,7 @@ __global__ void topdown_expand_kernel( } } - IndexType *vec_row_ptr_u = &local_buf1[0]; + IndexType* vec_row_ptr_u = &local_buf1[0]; #pragma unroll for (int iv = 0; iv < TOP_DOWN_BATCH_SIZE; ++iv) { IndexType u = vec_u[iv]; @@ -878,7 +878,7 @@ __global__ void topdown_expand_kernel( } // We won't need row_ptr after that, reusing pointer - IndexType *vec_dest_v = vec_row_ptr_u; + IndexType* vec_dest_v = vec_row_ptr_u; #pragma unroll for (int iv = 0; iv < TOP_DOWN_BATCH_SIZE; ++iv) { @@ -901,7 +901,7 @@ __global__ void topdown_expand_kernel( } // We don't need vec_frontier_degrees_exclusive_sum_index anymore - IndexType *vec_v_visited_bmap = vec_frontier_degrees_exclusive_sum_index; + IndexType* vec_v_visited_bmap = vec_frontier_degrees_exclusive_sum_index; // Visited bmap need to contain information about the previous // frontier if we actually process every edge (shortest path counting) @@ -916,7 +916,7 @@ __global__ void topdown_expand_kernel( // From now on we will consider v as a frontier candidate // If for some reason vec_candidate[iv] should be put in the // new_frontier Then set vec_candidate[iv] = -1 - IndexType *vec_frontier_candidate = vec_dest_v; + IndexType* vec_frontier_candidate = vec_dest_v; #pragma unroll for (int iv = 0; iv < TOP_DOWN_BATCH_SIZE; ++iv) { @@ -943,7 +943,7 @@ __global__ void topdown_expand_kernel( if (directed) { // vec_v_visited_bmap is available - IndexType *vec_is_isolated_bmap = vec_v_visited_bmap; + IndexType* vec_is_isolated_bmap = vec_v_visited_bmap; #pragma unroll for (int iv = 0; iv < TOP_DOWN_BATCH_SIZE; ++iv) { @@ -1021,7 +1021,7 @@ __global__ void topdown_expand_kernel( IndexType naccepted_vertices = 0; // We won't need vec_frontier_candidate after that - IndexType *vec_frontier_accepted_vertex = vec_frontier_candidate; + IndexType* vec_frontier_accepted_vertex = vec_frontier_candidate; #pragma unroll for (int iv = 0; iv < TOP_DOWN_BATCH_SIZE; ++iv) { @@ -1094,23 +1094,23 @@ __global__ void topdown_expand_kernel( } template -void frontier_expand(const IndexType *row_ptr, - const IndexType *col_ind, - const IndexType *frontier, +void frontier_expand(const IndexType* row_ptr, + const IndexType* col_ind, + const IndexType* frontier, const IndexType frontier_size, const IndexType totaldegree, const IndexType lvl, - IndexType *new_frontier, - IndexType *new_frontier_cnt, - const IndexType *frontier_degrees_exclusive_sum, - const IndexType *frontier_degrees_exclusive_sum_buckets_offsets, - int *previous_visited_bmap, - int *visited_bmap, - IndexType *distances, - IndexType *predecessors, - double *sp_counters, - const int *edge_mask, - const int *isolated_bmap, + IndexType* new_frontier, + IndexType* new_frontier_cnt, + const IndexType* frontier_degrees_exclusive_sum, + const IndexType* frontier_degrees_exclusive_sum_buckets_offsets, + int* previous_visited_bmap, + int* visited_bmap, + IndexType* distances, + IndexType* predecessors, + double* sp_counters, + const int* edge_mask, + const int* isolated_bmap, bool directed, cudaStream_t m_stream, bool deterministic) diff --git a/cpp/src/traversal/mg/bfs.cuh b/cpp/src/traversal/mg/bfs.cuh index 129c1a554e4..e6c8c3bf700 100644 --- a/cpp/src/traversal/mg/bfs.cuh +++ b/cpp/src/traversal/mg/bfs.cuh @@ -28,12 +28,12 @@ namespace mg { namespace detail { template -void bfs_traverse(raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, +void bfs_traverse(raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, const vertex_t start_vertex, - rmm::device_vector &visited_bmap, - rmm::device_vector &output_frontier_bmap, - operator_t &bfs_op) + rmm::device_vector& visited_bmap, + rmm::device_vector& output_frontier_bmap, + operator_t& bfs_op) { // Frontiers required for BFS rmm::device_vector input_frontier(graph.number_of_vertices); @@ -47,8 +47,8 @@ void bfs_traverse(raft::handle_t const &handle, // Reusing buffers to create isolated bitmap { - rmm::device_vector &local_isolated_ids = input_frontier; - rmm::device_vector &global_isolated_ids = output_frontier; + rmm::device_vector& local_isolated_ids = input_frontier; + rmm::device_vector& global_isolated_ids = output_frontier; detail::create_isolated_bitmap( handle, graph, local_isolated_ids, global_isolated_ids, temp_buffer_len, isolated_bmap); } @@ -110,10 +110,10 @@ void bfs_traverse(raft::handle_t const &handle, } // namespace detail template -void bfs(raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, - vertex_t *distances, - vertex_t *predecessors, +void bfs(raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, + vertex_t* distances, + vertex_t* predecessors, const vertex_t start_vertex) { CUGRAPH_EXPECTS(handle.comms_initialized(), diff --git a/cpp/src/traversal/mg/common_utils.cuh b/cpp/src/traversal/mg/common_utils.cuh index 8ceaf43c827..9a95aba7901 100644 --- a/cpp/src/traversal/mg/common_utils.cuh +++ b/cpp/src/traversal/mg/common_utils.cuh @@ -46,25 +46,25 @@ constexpr inline return_t number_of_words(return_t number_of_bits) template struct isDegreeZero { - edge_t const *offset_; - isDegreeZero(edge_t const *offset) : offset_(offset) {} + edge_t const* offset_; + isDegreeZero(edge_t const* offset) : offset_(offset) {} - __device__ bool operator()(const edge_t &id) const { return (offset_[id + 1] == offset_[id]); } + __device__ bool operator()(const edge_t& id) const { return (offset_[id + 1] == offset_[id]); } }; struct set_nth_bit { - uint32_t *bmap_; - set_nth_bit(uint32_t *bmap) : bmap_(bmap) {} + uint32_t* bmap_; + set_nth_bit(uint32_t* bmap) : bmap_(bmap) {} template - __device__ void operator()(const return_t &id) + __device__ void operator()(const return_t& id) { atomicOr(bmap_ + (id / BitsPWrd), (uint32_t{1} << (id % BitsPWrd))); } }; template -bool is_vertex_isolated(rmm::device_vector &bmap, vertex_t id) +bool is_vertex_isolated(rmm::device_vector& bmap, vertex_t id) { uint32_t word = bmap[id / BitsPWrd]; uint32_t active_bit = static_cast(1) << (id % BitsPWrd); @@ -74,11 +74,11 @@ bool is_vertex_isolated(rmm::device_vector &bmap, vertex_t id) template struct BFSStepNoDist { - uint32_t *output_frontier_; - uint32_t *visited_; - vertex_t *predecessors_; + uint32_t* output_frontier_; + uint32_t* visited_; + vertex_t* predecessors_; - BFSStepNoDist(uint32_t *output_frontier, uint32_t *visited, vertex_t *predecessors) + BFSStepNoDist(uint32_t* output_frontier, uint32_t* visited, vertex_t* predecessors) : output_frontier_(output_frontier), visited_(visited), predecessors_(predecessors) { } @@ -105,13 +105,13 @@ struct BFSStepNoDist { template struct BFSStep { - uint32_t *output_frontier_; - uint32_t *visited_; - vertex_t *predecessors_; - vertex_t *distances_; + uint32_t* output_frontier_; + uint32_t* visited_; + vertex_t* predecessors_; + vertex_t* distances_; vertex_t level_; - BFSStep(uint32_t *output_frontier, uint32_t *visited, vertex_t *predecessors, vertex_t *distances) + BFSStep(uint32_t* output_frontier, uint32_t* visited, vertex_t* predecessors, vertex_t* distances) : output_frontier_(output_frontier), visited_(visited), predecessors_(predecessors), @@ -142,9 +142,9 @@ struct BFSStep { template vertex_t populate_isolated_vertices( - raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, - rmm::device_vector &isolated_vertex_ids) + raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, + rmm::device_vector& isolated_vertex_ids) { bool is_mg = (handle.comms_initialized() && (graph.local_vertices != nullptr) && (graph.local_offsets != nullptr)); @@ -170,11 +170,11 @@ vertex_t populate_isolated_vertices( } template -return_t collect_vectors(raft::handle_t const &handle, - rmm::device_vector &buffer_len, - rmm::device_vector &local, +return_t collect_vectors(raft::handle_t const& handle, + rmm::device_vector& buffer_len, + rmm::device_vector& local, return_t local_count, - rmm::device_vector &global) + rmm::device_vector& global) { CHECK_CUDA(handle.get_stream()); buffer_len.resize(handle.get_comms().get_size()); @@ -206,9 +206,9 @@ return_t collect_vectors(raft::handle_t const &handle, } template -void add_to_bitmap(raft::handle_t const &handle, - rmm::device_vector &bmap, - rmm::device_vector &id, +void add_to_bitmap(raft::handle_t const& handle, + rmm::device_vector& bmap, + rmm::device_vector& id, return_t count) { cudaStream_t stream = handle.get_stream(); @@ -222,12 +222,12 @@ void add_to_bitmap(raft::handle_t const &handle, // For all vertex ids i which are isolated (out degree is 0), set // ith bit of isolated_bmap to 1 template -void create_isolated_bitmap(raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, - rmm::device_vector &local_isolated_ids, - rmm::device_vector &global_isolated_ids, - rmm::device_vector &temp_buffer_len, - rmm::device_vector &isolated_bmap) +void create_isolated_bitmap(raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, + rmm::device_vector& local_isolated_ids, + rmm::device_vector& global_isolated_ids, + rmm::device_vector& temp_buffer_len, + rmm::device_vector& isolated_bmap) { size_t word_count = detail::number_of_words(graph.number_of_vertices); local_isolated_ids.resize(graph.number_of_vertices); @@ -242,8 +242,8 @@ void create_isolated_bitmap(raft::handle_t const &handle, } template -return_t remove_duplicates(raft::handle_t const &handle, - rmm::device_vector &data, +return_t remove_duplicates(raft::handle_t const& handle, + rmm::device_vector& data, return_t data_len) { cudaStream_t stream = handle.get_stream(); @@ -259,13 +259,13 @@ return_t remove_duplicates(raft::handle_t const &handle, // ids. bmap is expected to be of the length // id_end/BitsPWrd and is set to 0 initially template -__global__ void remove_duplicates_kernel(uint32_t *bmap, - return_t *in_id, +__global__ void remove_duplicates_kernel(uint32_t* bmap, + return_t* in_id, return_t id_begin, return_t id_end, return_t count, - return_t *out_id, - return_t *out_count) + return_t* out_id, + return_t* out_count) { return_t tid = blockIdx.x * blockDim.x + threadIdx.x; return_t id; @@ -307,14 +307,14 @@ __global__ void remove_duplicates_kernel(uint32_t *bmap, } template -__global__ void remove_duplicates_kernel(uint32_t *bmap, - uint32_t *isolated_bmap, - return_t *in_id, +__global__ void remove_duplicates_kernel(uint32_t* bmap, + uint32_t* isolated_bmap, + return_t* in_id, return_t id_begin, return_t id_end, return_t count, - return_t *out_id, - return_t *out_count) + return_t* out_id, + return_t* out_count) { return_t tid = blockIdx.x * blockDim.x + threadIdx.x; return_t id; @@ -360,13 +360,13 @@ __global__ void remove_duplicates_kernel(uint32_t *bmap, } template -return_t remove_duplicates(raft::handle_t const &handle, - rmm::device_vector &bmap, - rmm::device_vector &data, +return_t remove_duplicates(raft::handle_t const& handle, + rmm::device_vector& bmap, + rmm::device_vector& data, return_t data_len, return_t data_begin, return_t data_end, - rmm::device_vector &out_data) + rmm::device_vector& out_data) { cudaStream_t stream = handle.get_stream(); @@ -389,13 +389,13 @@ return_t remove_duplicates(raft::handle_t const &handle, template vertex_t preprocess_input_frontier( - raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, - rmm::device_vector &bmap, - rmm::device_vector &isolated_bmap, - rmm::device_vector &input_frontier, + raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, + rmm::device_vector& bmap, + rmm::device_vector& isolated_bmap, + rmm::device_vector& input_frontier, vertex_t input_frontier_len, - rmm::device_vector &output_frontier) + rmm::device_vector& output_frontier) { cudaStream_t stream = handle.get_stream(); @@ -422,12 +422,12 @@ vertex_t preprocess_input_frontier( template vertex_t preprocess_input_frontier( - raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, - rmm::device_vector &bmap, - rmm::device_vector &input_frontier, + raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, + rmm::device_vector& bmap, + rmm::device_vector& input_frontier, vertex_t input_frontier_len, - rmm::device_vector &output_frontier) + rmm::device_vector& output_frontier) { cudaStream_t stream = handle.get_stream(); @@ -452,7 +452,7 @@ vertex_t preprocess_input_frontier( } template -__global__ void fill_kernel(vertex_t *distances, vertex_t count, vertex_t start_vertex) +__global__ void fill_kernel(vertex_t* distances, vertex_t count, vertex_t start_vertex) { vertex_t tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid >= count) { return; } @@ -464,11 +464,11 @@ __global__ void fill_kernel(vertex_t *distances, vertex_t count, vertex_t start_ } template -void fill_max_dist(raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph, +void fill_max_dist(raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph, vertex_t start_vertex, vertex_t global_number_of_vertices, - vertex_t *distances) + vertex_t* distances) { if (distances == nullptr) { return; } vertex_t array_size = global_number_of_vertices; @@ -479,8 +479,8 @@ void fill_max_dist(raft::handle_t const &handle, template vertex_t get_global_vertex_count( - raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph) + raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph) { rmm::device_vector id(1); id[0] = *thrust::max_element(rmm::exec_policy(handle.get_stream())->on(handle.get_stream()), diff --git a/cpp/src/traversal/mg/frontier_expand.cuh b/cpp/src/traversal/mg/frontier_expand.cuh index 4c4d794f067..078ab085724 100644 --- a/cpp/src/traversal/mg/frontier_expand.cuh +++ b/cpp/src/traversal/mg/frontier_expand.cuh @@ -28,8 +28,8 @@ namespace detail { template class FrontierExpand { - raft::handle_t const &handle_; - cugraph::legacy::GraphCSRView const &graph_; + raft::handle_t const& handle_; + cugraph::legacy::GraphCSRView const& graph_; VertexBinner dist_; rmm::device_vector reorganized_vertices_; edge_t vertex_begin_; @@ -37,8 +37,8 @@ class FrontierExpand { rmm::device_vector output_vertex_count_; public: - FrontierExpand(raft::handle_t const &handle, - cugraph::legacy::GraphCSRView const &graph) + FrontierExpand(raft::handle_t const& handle, + cugraph::legacy::GraphCSRView const& graph) : handle_(handle), graph_(graph) { bool is_mg = (handle.comms_initialized() && (graph.local_vertices != nullptr) && @@ -59,9 +59,9 @@ class FrontierExpand { // Return the size of the output_frontier template vertex_t operator()(operator_t op, - rmm::device_vector &input_frontier, + rmm::device_vector& input_frontier, vertex_t input_frontier_len, - rmm::device_vector &output_frontier) + rmm::device_vector& output_frontier) { if (input_frontier_len == 0) { return static_cast(0); } cudaStream_t stream = handle_.get_stream(); diff --git a/cpp/src/traversal/mg/frontier_expand_kernels.cuh b/cpp/src/traversal/mg/frontier_expand_kernels.cuh index 28ba6b19dbc..32b9310f02f 100644 --- a/cpp/src/traversal/mg/frontier_expand_kernels.cuh +++ b/cpp/src/traversal/mg/frontier_expand_kernels.cuh @@ -26,13 +26,13 @@ namespace mg { namespace detail { template -__device__ void write_to_frontier(vertex_t const *thread_frontier, +__device__ void write_to_frontier(vertex_t const* thread_frontier, int thread_frontier_count, - vertex_t *block_frontier, - int *block_frontier_count, - vertex_t *output_frontier, - edge_t *block_write_offset, - edge_t *output_frontier_count) + vertex_t* block_frontier, + int* block_frontier_count, + vertex_t* output_frontier, + edge_t* block_write_offset, + edge_t* output_frontier_count) { // Set frontier count for block to 0 if (threadIdx.x == 0) { *block_frontier_count = 0; } @@ -66,13 +66,13 @@ template -__global__ void block_per_vertex(edge_t const *offsets, - vertex_t const *indices, - vertex_t const *input_frontier, +__global__ void block_per_vertex(edge_t const* offsets, + vertex_t const* indices, + vertex_t const* input_frontier, vertex_t input_frontier_count, vertex_t vertex_begin, - vertex_t *output_frontier, - edge_t *output_frontier_count, + vertex_t* output_frontier, + edge_t* output_frontier_count, operator_t op) { if (blockIdx.x >= input_frontier_count) { return; } @@ -121,13 +121,13 @@ template -__global__ void kernel_per_vertex(edge_t const *offsets, - vertex_t const *indices, - vertex_t const *input_frontier, +__global__ void kernel_per_vertex(edge_t const* offsets, + vertex_t const* indices, + vertex_t const* input_frontier, vertex_t input_frontier_count, vertex_t vertex_begin, - vertex_t *output_frontier, - edge_t *output_frontier_count, + vertex_t* output_frontier, + edge_t* output_frontier_count, operator_t op) { vertex_t current_vertex_index = 0; @@ -171,12 +171,12 @@ __global__ void kernel_per_vertex(edge_t const *offsets, } template -void large_vertex_lb(cugraph::legacy::GraphCSRView const &graph, - DegreeBucket &bucket, +void large_vertex_lb(cugraph::legacy::GraphCSRView const& graph, + DegreeBucket& bucket, operator_t op, vertex_t vertex_begin, - vertex_t *output_vertex_ids, - edge_t *output_vertex_ids_offset, + vertex_t* output_vertex_ids, + edge_t* output_vertex_ids_offset, cudaStream_t stream) { if (bucket.numberOfVertices != 0) { @@ -196,12 +196,12 @@ void large_vertex_lb(cugraph::legacy::GraphCSRView c } template -void medium_vertex_lb(cugraph::legacy::GraphCSRView const &graph, - DegreeBucket &bucket, +void medium_vertex_lb(cugraph::legacy::GraphCSRView const& graph, + DegreeBucket& bucket, operator_t op, vertex_t vertex_begin, - vertex_t *output_vertex_ids, - edge_t *output_vertex_ids_offset, + vertex_t* output_vertex_ids, + edge_t* output_vertex_ids_offset, cudaStream_t stream) { // Vertices with degrees 2^12 <= d < 2^16 are handled by this kernel @@ -223,12 +223,12 @@ void medium_vertex_lb(cugraph::legacy::GraphCSRView } template -void small_vertex_lb(cugraph::legacy::GraphCSRView const &graph, - DegreeBucket &bucket, +void small_vertex_lb(cugraph::legacy::GraphCSRView const& graph, + DegreeBucket& bucket, operator_t op, vertex_t vertex_begin, - vertex_t *output_vertex_ids, - edge_t *output_vertex_ids_offset, + vertex_t* output_vertex_ids, + edge_t* output_vertex_ids_offset, cudaStream_t stream) { int block_count = bucket.numberOfVertices; diff --git a/cpp/src/traversal/mg/vertex_binning_kernels.cuh b/cpp/src/traversal/mg/vertex_binning_kernels.cuh index dbb339fea05..57574965a3a 100644 --- a/cpp/src/traversal/mg/vertex_binning_kernels.cuh +++ b/cpp/src/traversal/mg/vertex_binning_kernels.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ __device__ inline typename std::enable_if<(sizeof(degree_t) == 8), int>::type ce } template -__global__ void simple_fill(return_t *bin0, return_t *bin1, return_t count) +__global__ void simple_fill(return_t* bin0, return_t* bin1, return_t count) { for (return_t i = 0; i < count; i++) { bin0[i] = 0; @@ -49,7 +49,7 @@ __global__ void simple_fill(return_t *bin0, return_t *bin1, return_t count) } template -__global__ void exclusive_scan(return_t *data, return_t *out) +__global__ void exclusive_scan(return_t* data, return_t* out) { constexpr int BinCount = NumberBins; return_t lData[BinCount]; @@ -71,9 +71,9 @@ __global__ void exclusive_scan(return_t *data, return_t *out) // In this function, any id in vertex_ids array is only acceptable as long // as its value is between vertex_begin and vertex_end template -__global__ void count_bin_sizes(edge_t *bins, - edge_t const *offsets, - vertex_t const *vertex_ids, +__global__ void count_bin_sizes(edge_t* bins, + edge_t const* offsets, + vertex_t const* vertex_ids, edge_t const vertex_id_count, vertex_t vertex_begin, vertex_t vertex_end) @@ -81,7 +81,9 @@ __global__ void count_bin_sizes(edge_t *bins, using cugraph::detail::traversal::atomicAdd; constexpr int BinCount = NumberBins; __shared__ edge_t lBin[BinCount]; - for (int i = threadIdx.x; i < BinCount; i += blockDim.x) { lBin[i] = 0; } + for (int i = threadIdx.x; i < BinCount; i += blockDim.x) { + lBin[i] = 0; + } __syncthreads(); for (vertex_t i = threadIdx.x + (blockIdx.x * blockDim.x); i < vertex_id_count; @@ -98,16 +100,18 @@ __global__ void count_bin_sizes(edge_t *bins, } __syncthreads(); - for (int i = threadIdx.x; i < BinCount; i += blockDim.x) { atomicAdd(bins + i, lBin[i]); } + for (int i = threadIdx.x; i < BinCount; i += blockDim.x) { + atomicAdd(bins + i, lBin[i]); + } } // Bin vertices to the appropriate bins by taking into account // the starting offsets calculated by count_bin_sizes template -__global__ void create_vertex_bins(vertex_t *out_vertex_ids, - edge_t *bin_offsets, - edge_t const *offsets, - vertex_t *in_vertex_ids, +__global__ void create_vertex_bins(vertex_t* out_vertex_ids, + edge_t* bin_offsets, + edge_t const* offsets, + vertex_t* in_vertex_ids, edge_t const vertex_id_count, vertex_t vertex_begin, vertex_t vertex_end) @@ -149,12 +153,12 @@ __global__ void create_vertex_bins(vertex_t *out_vertex_ids, } template -void bin_vertices(rmm::device_vector &input_vertex_ids, +void bin_vertices(rmm::device_vector& input_vertex_ids, vertex_t input_vertex_ids_len, - rmm::device_vector &reorganized_vertex_ids, - rmm::device_vector &bin_count_offsets, - rmm::device_vector &bin_count, - edge_t *offsets, + rmm::device_vector& reorganized_vertex_ids, + rmm::device_vector& bin_count_offsets, + rmm::device_vector& bin_count, + edge_t* offsets, vertex_t vertex_begin, vertex_t vertex_end, cudaStream_t stream) diff --git a/cpp/src/traversal/sssp.cu b/cpp/src/traversal/sssp.cu index ac2ab5b2063..61225dd7fd6 100644 --- a/cpp/src/traversal/sssp.cu +++ b/cpp/src/traversal/sssp.cu @@ -49,9 +49,9 @@ void SSSP::setup() iter_buffer_size = sizeof(int) * (edges_bmap_size + vertices_bmap_size) + sizeof(IndexType); iter_buffer.resize(iter_buffer_size, stream); // ith bit of relaxed_edges_bmap <=> ith edge was relaxed - relaxed_edges_bmap = static_cast(iter_buffer.data()); + relaxed_edges_bmap = static_cast(iter_buffer.data()); // ith bit of next_frontier_bmap <=> vertex is active in the next frontier - next_frontier_bmap = static_cast(iter_buffer.data()) + edges_bmap_size; + next_frontier_bmap = static_cast(iter_buffer.data()) + edges_bmap_size; // num vertices in the next frontier d_new_frontier_cnt = next_frontier_bmap + vertices_bmap_size; @@ -73,7 +73,7 @@ void SSSP::setup() exclusive_sum_frontier_vertex_buckets_offsets.resize(bucket_off_size); // Repurpose d_new_frontier_cnt temporarily - IndexType *d_nisolated = d_new_frontier_cnt; + IndexType* d_nisolated = d_new_frontier_cnt; cudaMemsetAsync(d_nisolated, 0, sizeof(IndexType), stream); // Computing isolated_bmap @@ -89,9 +89,9 @@ void SSSP::setup() } template -void SSSP::configure(DistType *_distances, - IndexType *_predecessors, - int *_edge_mask) +void SSSP::configure(DistType* _distances, + IndexType* _predecessors, + int* _edge_mask) { distances = _distances; predecessors = _predecessors; @@ -242,9 +242,9 @@ void SSSP::clean() * @file sssp.cu * --------------------------------------------------------------------------*/ template -void sssp(legacy::GraphCSRView const &graph, - WT *distances, - VT *predecessors, +void sssp(legacy::GraphCSRView const& graph, + WT* distances, + VT* predecessors, const VT source_vertex) { CUGRAPH_EXPECTS(distances || predecessors, "Invalid input argument, both outputs are nullptr"); @@ -257,9 +257,9 @@ void sssp(legacy::GraphCSRView const &graph, int num_vertices = graph.number_of_vertices; int num_edges = graph.number_of_edges; - const ET *offsets_ptr = graph.offsets; - const VT *indices_ptr = graph.indices; - const WT *edge_weights_ptr = nullptr; + const ET* offsets_ptr = graph.offsets; + const VT* indices_ptr = graph.indices; + const WT* edge_weights_ptr = nullptr; // Both if / else branch operate own calls due to // thrust::device_vector lifetime @@ -293,13 +293,13 @@ void sssp(legacy::GraphCSRView const &graph, } // explicit instantiation -template void sssp(legacy::GraphCSRView const &graph, - float *distances, - int *predecessors, +template void sssp(legacy::GraphCSRView const& graph, + float* distances, + int* predecessors, const int source_vertex); -template void sssp(legacy::GraphCSRView const &graph, - double *distances, - int *predecessors, +template void sssp(legacy::GraphCSRView const& graph, + double* distances, + int* predecessors, const int source_vertex); } // namespace cugraph diff --git a/cpp/src/traversal/traversal_common.cuh b/cpp/src/traversal/traversal_common.cuh index 64a21a89b04..ea77173870e 100644 --- a/cpp/src/traversal/traversal_common.cuh +++ b/cpp/src/traversal/traversal_common.cuh @@ -21,7 +21,7 @@ #define MAXBLOCKS 65535 #define WARP_SIZE 32 -#define INT_SIZE 32 +#define INT_SIZE 32 // // Bottom up macros @@ -31,7 +31,7 @@ #define COUNT_UNVISITED_EDGES_DIMX 256 -#define MAIN_BOTTOMUP_DIMX 256 +#define MAIN_BOTTOMUP_DIMX 256 #define MAIN_BOTTOMUP_NWARPS (MAIN_BOTTOMUP_DIMX / WARP_SIZE) #define LARGE_BOTTOMUP_DIMX 256 diff --git a/cpp/src/traversal/tsp.cu b/cpp/src/traversal/tsp.cu index 17183d48f3d..332ccb21834 100644 --- a/cpp/src/traversal/tsp.cu +++ b/cpp/src/traversal/tsp.cu @@ -27,17 +27,17 @@ namespace cugraph { namespace detail { -TSP::TSP(raft::handle_t const &handle, - int const *vtx_ptr, - float const *x_pos, - float const *y_pos, +TSP::TSP(raft::handle_t const& handle, + int const* vtx_ptr, + float const* x_pos, + float const* y_pos, int nodes, int restarts, bool beam_search, int k, int nstart, bool verbose, - int *route) + int* route) : handle_(handle), vtx_ptr_(vtx_ptr), x_pos_(x_pos), @@ -117,11 +117,11 @@ float TSP::compute() h_x_pos.reserve(nodes_ + 1); h_y_pos.reserve(nodes_ + 1); h_route.reserve(nodes_); - std::vector addr_best_x_pos(1); - std::vector addr_best_y_pos(1); - std::vector addr_best_route(1); + std::vector addr_best_x_pos(1); + std::vector addr_best_y_pos(1); + std::vector addr_best_route(1); HighResTimer hr_timer; - auto create_timer = [&hr_timer, this](char const *name) { + auto create_timer = [&hr_timer, this](char const* name) { return VerboseTimer(name, hr_timer, verbose_); }; @@ -213,18 +213,18 @@ void TSP::knn() bool row_major_order = false; rmm::device_uvector input(nodes_ * dim, stream_); - float *input_ptr = input.data(); + float* input_ptr = input.data(); raft::copy(input_ptr, x_pos_, nodes_, stream_); raft::copy(input_ptr + nodes_, y_pos_, nodes_, stream_); rmm::device_uvector search_data(nodes_ * dim, stream_); - float *search_data_ptr = search_data.data(); + float* search_data_ptr = search_data.data(); raft::copy(search_data_ptr, input_ptr, nodes_ * dim, stream_); rmm::device_uvector distances(nodes_ * (k_ + 1), stream_); - float *distances_ptr = distances.data(); + float* distances_ptr = distances.data(); - std::vector input_vec; + std::vector input_vec; std::vector sizes_vec; input_vec.push_back(input_ptr); sizes_vec.push_back(nodes_); @@ -246,17 +246,17 @@ void TSP::knn() } } // namespace detail -float traveling_salesperson(raft::handle_t const &handle, - int const *vtx_ptr, - float const *x_pos, - float const *y_pos, +float traveling_salesperson(raft::handle_t const& handle, + int const* vtx_ptr, + float const* x_pos, + float const* y_pos, int nodes, int restarts, bool beam_search, int k, int nstart, bool verbose, - int *route) + int* route) { RAFT_EXPECTS(route != nullptr, "route should equal the number of nodes"); RAFT_EXPECTS(nodes > 0, "nodes should be strictly positive"); diff --git a/cpp/src/traversal/tsp.hpp b/cpp/src/traversal/tsp.hpp index 8c6948f218c..6073f46ab28 100644 --- a/cpp/src/traversal/tsp.hpp +++ b/cpp/src/traversal/tsp.hpp @@ -29,25 +29,25 @@ namespace cugraph { namespace detail { struct TSPResults { - float **best_x_pos; - float **best_y_pos; - int **best_route; - int *best_cost; + float** best_x_pos; + float** best_y_pos; + int** best_route; + int* best_cost; }; class TSP { public: - TSP(raft::handle_t const &handle, - int const *vtx_ptr, - float const *x_pos, - float const *y_pos, + TSP(raft::handle_t const& handle, + int const* vtx_ptr, + float const* x_pos, + float const* y_pos, int nodes, int restarts, bool beam_search, int k, int nstart, bool verbose, - int *route); + int* route); void setup(); void reset_batch(); @@ -58,7 +58,7 @@ class TSP { private: // Config - raft::handle_t const &handle_; + raft::handle_t const& handle_; cudaStream_t stream_; int max_blocks_; int max_threads_; @@ -69,10 +69,10 @@ class TSP { int best_thread_num_; // TSP - int const *vtx_ptr_; - int *route_; - float const *x_pos_; - float const *y_pos_; + int const* vtx_ptr_; + int* route_; + float const* x_pos_; + float const* y_pos_; int nodes_; int restarts_; bool beam_search_; @@ -84,25 +84,25 @@ class TSP { rmm::device_scalar mylock_scalar_; rmm::device_scalar best_cost_scalar_; - int *mylock_; - int *best_cost_; + int* mylock_; + int* best_cost_; // Vectors rmm::device_uvector neighbors_vec_; rmm::device_uvector work_vec_; - rmm::device_uvector best_x_pos_vec_; - rmm::device_uvector best_y_pos_vec_; - rmm::device_uvector best_route_vec_; + rmm::device_uvector best_x_pos_vec_; + rmm::device_uvector best_y_pos_vec_; + rmm::device_uvector best_route_vec_; - int64_t *neighbors_; - int *work_; - int *work_route_; + int64_t* neighbors_; + int* work_; + int* work_route_; TSPResults results_; }; class VerboseTimer { public: - VerboseTimer(char const *name, HighResTimer &hr_timer, bool verbose) + VerboseTimer(char const* name, HighResTimer& hr_timer, bool verbose) : name_(name), hr_timer_(hr_timer), verbose_(verbose) { if (verbose_) hr_timer_.start(name_); @@ -114,8 +114,8 @@ class VerboseTimer { } private: - const char *name_; - HighResTimer &hr_timer_; + const char* name_; + HighResTimer& hr_timer_; bool verbose_; }; diff --git a/cpp/src/traversal/tsp_solver.hpp b/cpp/src/traversal/tsp_solver.hpp index c7b8cdaaf1d..5fb3ff1d449 100644 --- a/cpp/src/traversal/tsp_solver.hpp +++ b/cpp/src/traversal/tsp_solver.hpp @@ -29,19 +29,19 @@ namespace cugraph { namespace detail { -__global__ void random_init(int *work, - float const *posx, - float const *posy, - int const *vtx_ptr, +__global__ void random_init(int* work, + float const* posx, + float const* posy, + int const* vtx_ptr, int const nstart, int const nodes, int const batch, int const restart_batch) { - int *buf = &work[blockIdx.x * ((4 * nodes + 3 + 31) / 32 * 32)]; - float *px = (float *)(&buf[nodes]); - float *py = &px[nodes + 1]; - int *path = (int *)(&py[nodes + 1]); + int* buf = &work[blockIdx.x * ((4 * nodes + 3 + 31) / 32 * 32)]; + float* px = (float*)(&buf[nodes]); + float* py = &px[nodes + 1]; + int* path = (int*)(&py[nodes + 1]); // Fill values for (int i = threadIdx.x; i <= nodes; i += blockDim.x) { @@ -74,23 +74,24 @@ __global__ void random_init(int *work, } } -__global__ void knn_init(int *work, - float const *posx, - float const *posy, - int const *vtx_ptr, - int64_t const *neighbors, +__global__ void knn_init(int* work, + float const* posx, + float const* posy, + int const* vtx_ptr, + int64_t const* neighbors, int const nstart, int const nodes, int const K, int const batch, int const restart_batch) { - int *buf = &work[blockIdx.x * ((4 * nodes + 3 + 31) / 32 * 32)]; - float *px = (float *)(&buf[nodes]); - float *py = &px[nodes + 1]; - int *path = (int *)(&py[nodes + 1]); + int* buf = &work[blockIdx.x * ((4 * nodes + 3 + 31) / 32 * 32)]; + float* px = (float*)(&buf[nodes]); + float* py = &px[nodes + 1]; + int* path = (int*)(&py[nodes + 1]); - for (int i = threadIdx.x; i < nodes; i += blockDim.x) buf[i] = 0; + for (int i = threadIdx.x; i < nodes; i += blockDim.x) + buf[i] = 0; __syncthreads(); @@ -106,7 +107,8 @@ __global__ void knn_init(int *work, int v = 0; buf[head] = 1; while (progress < nodes - 1) { // beam search as starting point - for (int i = 1; i <= progress; i++) buf[i] = 0; + for (int i = 1; i <= progress; i++) + buf[i] = 0; progress = 0; // reset current location in path and visited array int randjumps = 0; while (progress < nodes - 1) { @@ -130,7 +132,9 @@ __global__ void knn_init(int *work, break; // give up on this traversal, we failed to find a next link randjumps += 1; int nr = (head + 1) % nodes; // jump to next node - while (buf[nr] == 1) { nr = (nr + 1) % nodes; } + while (buf[nr] == 1) { + nr = (nr + 1) % nodes; + } head = nr; progress += 1; buf[head] = 1; @@ -148,7 +152,7 @@ __global__ void knn_init(int *work, } __device__ void two_opt_search( - int *buf, float *px, float *py, int *shbuf, int *minchange, int *mini, int *minj, int const nodes) + int* buf, float* px, float* py, int* shbuf, int* minchange, int* mini, int* minj, int const nodes) { __shared__ float shmem_x[tilesize]; __shared__ float shmem_y[tilesize]; @@ -203,20 +207,20 @@ __device__ void two_opt_search( } __global__ __launch_bounds__(2048, 2) void search_solution(TSPResults results, - int *mylock, - int const *vtx_ptr, + int* mylock, + int const* vtx_ptr, bool beam_search, int const K, int nodes, - float const *posx, - float const *posy, - int *work, + float const* posx, + float const* posy, + int* work, int const nstart) { - int *buf = &work[blockIdx.x * ((4 * nodes + 3 + 31) / 32 * 32)]; - float *px = (float *)(&buf[nodes]); - float *py = &px[nodes + 1]; - int *path = (int *)(&py[nodes + 1]); + int* buf = &work[blockIdx.x * ((4 * nodes + 3 + 31) / 32 * 32)]; + float* px = (float*)(&buf[nodes]); + float* py = &px[nodes + 1]; + int* path = (int*)(&py[nodes + 1]); __shared__ int shbuf[tilesize]; __shared__ int best_change[kswaps]; @@ -339,14 +343,14 @@ __global__ __launch_bounds__(2048, 2) void search_solution(TSPResults results, } while (minchange < 0 && myswaps < 2 * nodes); } -__global__ void get_optimal_tour(TSPResults results, int *mylock, int *work, int const nodes) +__global__ void get_optimal_tour(TSPResults results, int* mylock, int* work, int const nodes) { extern __shared__ int accumulator[]; int climber_id = blockIdx.x; - int *buf = &work[climber_id * ((4 * nodes + 3 + 31) / 32 * 32)]; - float *px = (float *)(&buf[nodes]); - float *py = &px[nodes + 1]; - int *path = (int *)(&py[nodes + 1]); + int* buf = &work[climber_id * ((4 * nodes + 3 + 31) / 32 * 32)]; + float* px = (float*)(&buf[nodes]); + float* py = &px[nodes + 1]; + int* path = (int*)(&py[nodes + 1]); // Now find actual length of the last tour, result of the climb int term = 0; diff --git a/cpp/src/traversal/tsp_utils.hpp b/cpp/src/traversal/tsp_utils.hpp index 2a3445f1c81..48a3e702f09 100644 --- a/cpp/src/traversal/tsp_utils.hpp +++ b/cpp/src/traversal/tsp_utils.hpp @@ -17,7 +17,7 @@ #pragma once #define tilesize 128 -#define kswaps 4 +#define kswaps 4 #include #include @@ -26,7 +26,7 @@ namespace cugraph { namespace detail { -constexpr float euclidean_dist(float *px, float *py, int a, int b) +constexpr float euclidean_dist(float* px, float* py, int a, int b) { return sqrtf((px[a] - px[b]) * (px[a] - px[b]) + (py[a] - py[b]) * (py[a] - py[b])); } @@ -48,7 +48,8 @@ int best_thread_count(int nodes, int max_threads, int sm_count, int warp_size) blocks = (16384 * 2) / smem; if (blocks > sm_count) blocks = sm_count; thr = (threads + warp_size - 1) / warp_size * warp_size; - while (blocks * thr > max_threads_sm) blocks--; + while (blocks * thr > max_threads_sm) + blocks--; perf = threads * blocks; if (perf > best) { best = perf; diff --git a/cpp/src/traversal/two_hop_neighbors.cu b/cpp/src/traversal/two_hop_neighbors.cu index eff91f03127..e1fce911130 100644 --- a/cpp/src/traversal/two_hop_neighbors.cu +++ b/cpp/src/traversal/two_hop_neighbors.cu @@ -33,12 +33,12 @@ namespace cugraph { template std::unique_ptr> get_two_hop_neighbors( - legacy::GraphCSRView const &graph) + legacy::GraphCSRView const& graph) { cudaStream_t stream{nullptr}; rmm::device_vector exsum_degree(graph.number_of_edges + 1); - ET *d_exsum_degree = exsum_degree.data().get(); + ET* d_exsum_degree = exsum_degree.data().get(); // Find the degree of the out vertex of each edge degree_iterator deg_it(graph.offsets); @@ -63,14 +63,14 @@ std::unique_ptr> get_two_hop_neighbors( rmm::device_vector first_pair(output_size); rmm::device_vector second_pair(output_size); - VT *d_first_pair = first_pair.data().get(); - VT *d_second_pair = second_pair.data().get(); + VT* d_first_pair = first_pair.data().get(); + VT* d_second_pair = second_pair.data().get(); // Figure out number of blocks and allocate memory for block bucket offsets ET num_blocks = (output_size + TWO_HOP_BLOCK_SIZE - 1) / TWO_HOP_BLOCK_SIZE; rmm::device_vector block_bucket_offsets(num_blocks + 1); - ET *d_block_bucket_offsets = block_bucket_offsets.data().get(); + ET* d_block_bucket_offsets = block_bucket_offsets.data().get(); // Compute the block bucket offsets dim3 grid, block; @@ -119,9 +119,9 @@ std::unique_ptr> get_two_hop_neighbors( } template std::unique_ptr> get_two_hop_neighbors( - legacy::GraphCSRView const &); + legacy::GraphCSRView const&); template std::unique_ptr> get_two_hop_neighbors( - legacy::GraphCSRView const &); + legacy::GraphCSRView const&); } // namespace cugraph diff --git a/cpp/src/traversal/two_hop_neighbors.cuh b/cpp/src/traversal/two_hop_neighbors.cuh index 87d3b36b861..e830fb4a95f 100644 --- a/cpp/src/traversal/two_hop_neighbors.cuh +++ b/cpp/src/traversal/two_hop_neighbors.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,13 @@ #include -#define MAXBLOCKS 65535 +#define MAXBLOCKS 65535 #define TWO_HOP_BLOCK_SIZE 512 template struct degree_iterator { - edge_t const *offsets; - degree_iterator(edge_t const *_offsets) : offsets(_offsets) {} + edge_t const* offsets; + degree_iterator(edge_t const* _offsets) : offsets(_offsets) {} __host__ __device__ edge_t operator[](edge_t place) { @@ -53,7 +53,7 @@ struct self_loop_flagger { }; template -__device__ edge_t binsearch_maxle(const edge_t *vec, const edge_t val, edge_t low, edge_t high) +__device__ edge_t binsearch_maxle(const edge_t* vec, const edge_t val, edge_t low, edge_t high) { while (true) { if (low == high) return low; // we know it exists @@ -69,8 +69,8 @@ __device__ edge_t binsearch_maxle(const edge_t *vec, const edge_t val, edge_t lo } template -__global__ void compute_bucket_offsets_kernel(const edge_t *frontier_degrees_exclusive_sum, - edge_t *bucket_offsets, +__global__ void compute_bucket_offsets_kernel(const edge_t* frontier_degrees_exclusive_sum, + edge_t* bucket_offsets, const edge_t frontier_size, edge_t total_degree) { @@ -86,15 +86,15 @@ __global__ void compute_bucket_offsets_kernel(const edge_t *frontier_degrees_exc } template -__global__ void scatter_expand_kernel(const edge_t *exsum_degree, - const vertex_t *indices, - const edge_t *offsets, - const edge_t *bucket_offsets, +__global__ void scatter_expand_kernel(const edge_t* exsum_degree, + const vertex_t* indices, + const edge_t* offsets, + const edge_t* bucket_offsets, vertex_t num_verts, edge_t max_item, edge_t max_block, - vertex_t *output_first, - vertex_t *output_second) + vertex_t* output_first, + vertex_t* output_second) { __shared__ edge_t blockRange[2]; for (edge_t bid = blockIdx.x; bid < max_block; bid += gridDim.x) { diff --git a/cpp/src/tree/mst.cu b/cpp/src/tree/mst.cu index 0fae4f2bef7..e6caa629cd1 100644 --- a/cpp/src/tree/mst.cu +++ b/cpp/src/tree/mst.cu @@ -39,9 +39,9 @@ namespace detail { template std::unique_ptr> mst_impl( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - rmm::mr::device_memory_resource *mr) + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + rmm::mr::device_memory_resource* mr) { auto stream = handle.get_stream(); @@ -69,19 +69,19 @@ std::unique_ptr> mst_impl( template std::unique_ptr> minimum_spanning_tree( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - rmm::mr::device_memory_resource *mr) + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + rmm::mr::device_memory_resource* mr) { return detail::mst_impl(handle, graph, mr); } template std::unique_ptr> minimum_spanning_tree( - raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - rmm::mr::device_memory_resource *mr); + raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + rmm::mr::device_memory_resource* mr); template std::unique_ptr> -minimum_spanning_tree(raft::handle_t const &handle, - legacy::GraphCSRView const &graph, - rmm::mr::device_memory_resource *mr); +minimum_spanning_tree(raft::handle_t const& handle, + legacy::GraphCSRView const& graph, + rmm::mr::device_memory_resource* mr); } // namespace cugraph diff --git a/cpp/src/utilities/cython.cu b/cpp/src/utilities/cython.cu index 08402b38c1e..909e3d5b31f 100644 --- a/cpp/src/utilities/cython.cu +++ b/cpp/src/utilities/cython.cu @@ -88,7 +88,7 @@ std::vector compute_edge_counts(raft::handle_t const& handle, auto major_vertices = transposed ? reinterpret_cast(graph_container.dst_vertices) : reinterpret_cast(graph_container.src_vertices); - auto key_first = thrust::make_transform_iterator( + auto key_first = thrust::make_transform_iterator( major_vertices, compute_local_partition_id_t{d_lasts.data(), num_local_partitions}); rmm::device_uvector d_local_partition_ids(num_local_partitions, handle.get_stream()); rmm::device_uvector d_edge_counts(d_local_partition_ids.size(), handle.get_stream()); diff --git a/cpp/src/utilities/graph_utils.cuh b/cpp/src/utilities/graph_utils.cuh index 14275f52b9b..4b7c2baab19 100644 --- a/cpp/src/utilities/graph_utils.cuh +++ b/cpp/src/utilities/graph_utils.cuh @@ -32,12 +32,12 @@ namespace cugraph { namespace detail { //#define DEBUG 1 -#define CUDA_MAX_BLOCKS 65535 +#define CUDA_MAX_BLOCKS 65535 #define CUDA_MAX_KERNEL_THREADS 256 // kernel will launch at most 256 threads per block #define US template -__inline__ __device__ value_t parallel_prefix_sum(count_t n, index_t const *ind, value_t const *w) +__inline__ __device__ value_t parallel_prefix_sum(count_t n, index_t const* ind, value_t const* w) { count_t i, j, mn; value_t v, last; @@ -86,11 +86,11 @@ template struct axpy_functor : public thrust::binary_function { const T a; axpy_functor(T _a) : a(_a) {} - __host__ __device__ T operator()(const T &x, const T &y) const { return a * x + y; } + __host__ __device__ T operator()(const T& x, const T& y) const { return a * x + y; } }; template -void axpy(size_t n, T a, T *x, T *y) +void axpy(size_t n, T a, T* x, T* y) { rmm::cuda_stream_view stream_view; thrust::transform(rmm::exec_policy(stream_view), @@ -105,11 +105,11 @@ void axpy(size_t n, T a, T *x, T *y) // norm template struct square { - __host__ __device__ T operator()(const T &x) const { return x * x; } + __host__ __device__ T operator()(const T& x) const { return x * x; } }; template -T nrm2(size_t n, T *x) +T nrm2(size_t n, T* x) { rmm::cuda_stream_view stream_view; T init = 0; @@ -124,7 +124,7 @@ T nrm2(size_t n, T *x) } template -T nrm1(size_t n, T *x) +T nrm1(size_t n, T* x) { rmm::cuda_stream_view stream_view; T result = thrust::reduce(rmm::exec_policy(stream_view), @@ -135,7 +135,7 @@ T nrm1(size_t n, T *x) } template -void scal(size_t n, T val, T *x) +void scal(size_t n, T val, T* x) { rmm::cuda_stream_view stream_view; thrust::transform(rmm::exec_policy(stream_view), @@ -148,7 +148,7 @@ void scal(size_t n, T val, T *x) } template -void addv(size_t n, T val, T *x) +void addv(size_t n, T val, T* x) { rmm::cuda_stream_view stream_view; thrust::transform(rmm::exec_policy(stream_view), @@ -161,7 +161,7 @@ void addv(size_t n, T val, T *x) } template -void fill(size_t n, T *x, T value) +void fill(size_t n, T* x, T value) { rmm::cuda_stream_view stream_view; thrust::fill(rmm::exec_policy(stream_view), @@ -172,7 +172,7 @@ void fill(size_t n, T *x, T value) } template -void scatter(size_t n, T *src, T *dst, M *map) +void scatter(size_t n, T* src, T* dst, M* map) { rmm::cuda_stream_view stream_view; thrust::scatter(rmm::exec_policy(stream_view), @@ -184,7 +184,7 @@ void scatter(size_t n, T *src, T *dst, M *map) } template -void printv(size_t n, T *vec, int offset) +void printv(size_t n, T* vec, int offset) { thrust::device_ptr dev_ptr(vec); std::cout.precision(15); @@ -199,7 +199,7 @@ void printv(size_t n, T *vec, int offset) } template -void copy(size_t n, T *x, T *res) +void copy(size_t n, T* x, T* res) { thrust::device_ptr dev_ptr(x); thrust::device_ptr res_ptr(res); @@ -217,11 +217,11 @@ template struct dangling_functor : public thrust::unary_function { const T val; dangling_functor(T _val) : val(_val) {} - __host__ __device__ T operator()(const T &x) const { return val + x; } + __host__ __device__ T operator()(const T& x) const { return val + x; } }; template -void update_dangling_nodes(size_t n, T *dangling_nodes, T damping_factor) +void update_dangling_nodes(size_t n, T* dangling_nodes, T damping_factor) { rmm::cuda_stream_view stream_view; thrust::transform_if(rmm::exec_policy(stream_view), @@ -237,15 +237,15 @@ void update_dangling_nodes(size_t n, T *dangling_nodes, T damping_factor) template __global__ void degree_coo(const IndexType n, const IndexType e, - const IndexType *ind, - ValueType *degree) + const IndexType* ind, + ValueType* degree) { for (int i = threadIdx.x + blockIdx.x * blockDim.x; i < e; i += gridDim.x * blockDim.x) atomicAdd(°ree[ind[i]], (ValueType)1.0); } template -__global__ void flag_leafs_kernel(const size_t n, const IndexType *degree, ValueType *bookmark) +__global__ void flag_leafs_kernel(const size_t n, const IndexType* degree, ValueType* bookmark) { for (auto i = threadIdx.x + blockIdx.x * blockDim.x; i < n; i += gridDim.x * blockDim.x) if (degree[i] == 0) bookmark[i] = 1.0; @@ -254,19 +254,19 @@ __global__ void flag_leafs_kernel(const size_t n, const IndexType *degree, Value template __global__ void degree_offsets(const IndexType n, const IndexType e, - const IndexType *ind, - ValueType *degree) + const IndexType* ind, + ValueType* degree) { for (int i = threadIdx.x + blockIdx.x * blockDim.x; i < n; i += gridDim.x * blockDim.x) degree[i] += ind[i + 1] - ind[i]; } template -__global__ void type_convert(FromType *array, int n) +__global__ void type_convert(FromType* array, int n) { for (int i = threadIdx.x + blockIdx.x * blockDim.x; i < n; i += gridDim.x * blockDim.x) { ToType val = array[i]; - ToType *vals = (ToType *)array; + ToType* vals = (ToType*)array; vals[i] = val; } } @@ -274,10 +274,10 @@ __global__ void type_convert(FromType *array, int n) template __global__ void equi_prob3(const IndexType n, const IndexType e, - const IndexType *csrPtr, - const IndexType *csrInd, - ValueType *val, - IndexType *degree) + const IndexType* csrPtr, + const IndexType* csrInd, + ValueType* val, + IndexType* degree) { int j, row, col; for (row = threadIdx.z + blockIdx.z * blockDim.z; row < n; row += gridDim.z * blockDim.z) { @@ -293,10 +293,10 @@ __global__ void equi_prob3(const IndexType n, template __global__ void equi_prob2(const IndexType n, const IndexType e, - const IndexType *csrPtr, - const IndexType *csrInd, - ValueType *val, - IndexType *degree) + const IndexType* csrPtr, + const IndexType* csrInd, + ValueType* val, + IndexType* degree) { int row = blockIdx.x * blockDim.x + threadIdx.x; if (row < n) { @@ -314,10 +314,10 @@ __global__ void equi_prob2(const IndexType n, template void HT_matrix_csc_coo(const IndexType n, const IndexType e, - const IndexType *csrPtr, - const IndexType *csrInd, - ValueType *val, - ValueType *bookmark) + const IndexType* csrPtr, + const IndexType* csrInd, + ValueType* val, + ValueType* bookmark) { rmm::cuda_stream_view stream_view; rmm::device_uvector degree(n, stream_view); @@ -360,7 +360,7 @@ void HT_matrix_csc_coo(const IndexType n, } template -__global__ void offsets_to_indices_kernel(const offsets_t *offsets, index_t v, index_t *indices) +__global__ void offsets_to_indices_kernel(const offsets_t* offsets, index_t v, index_t* indices) { auto tid{threadIdx.x}; auto ctaStart{blockIdx.x}; @@ -377,7 +377,7 @@ __global__ void offsets_to_indices_kernel(const offsets_t *offsets, index_t v, i } template -void offsets_to_indices(const offsets_t *offsets, index_t v, index_t *indices) +void offsets_to_indices(const offsets_t* offsets, index_t v, index_t* indices) { cudaStream_t stream{nullptr}; index_t nthreads = min(v, (index_t)CUDA_MAX_KERNEL_THREADS); @@ -387,7 +387,7 @@ void offsets_to_indices(const offsets_t *offsets, index_t v, index_t *indices) } template -void sequence(IndexType n, IndexType *vec, IndexType init = 0) +void sequence(IndexType n, IndexType* vec, IndexType init = 0) { thrust::sequence( thrust::device, thrust::device_pointer_cast(vec), thrust::device_pointer_cast(vec + n), init); @@ -395,7 +395,7 @@ void sequence(IndexType n, IndexType *vec, IndexType init = 0) } template -bool has_negative_val(DistType *arr, size_t n) +bool has_negative_val(DistType* arr, size_t n) { // custom kernel with boolean bitwise reduce may be // faster. diff --git a/cpp/src/utilities/high_res_timer.hpp b/cpp/src/utilities/high_res_timer.hpp index 807496c8f86..cf265991f21 100644 --- a/cpp/src/utilities/high_res_timer.hpp +++ b/cpp/src/utilities/high_res_timer.hpp @@ -54,7 +54,7 @@ class HighResTimer { it->second.second += stop_time.tv_sec * 1000000000 + stop_time.tv_nsec; } - double get_average_runtime(std::string const &label) + double get_average_runtime(std::string const& label) { auto it = timers.find(label); if (it != timers.end()) { @@ -70,7 +70,7 @@ class HighResTimer { // // Add display functions... specific label or entire structure // - void display(std::ostream &os) + void display(std::ostream& os) { os << "Timer Results (in ms):" << std::endl; for (auto it = timers.begin(); it != timers.end(); ++it) { @@ -80,7 +80,7 @@ class HighResTimer { } } - void display(std::ostream &os, std::string label) + void display(std::ostream& os, std::string label) { auto it = timers.find(label); os << it->first << " called " << it->second.first @@ -88,7 +88,7 @@ class HighResTimer { << std::endl; } - void display_and_clear(std::ostream &os) + void display_and_clear(std::ostream& os) { os << "Timer Results (in ms):" << std::endl; for (auto it = timers.begin(); it != timers.end(); ++it) { diff --git a/cpp/src/utilities/path_retrieval.cu b/cpp/src/utilities/path_retrieval.cu index 2d862f659e5..765cccc1916 100644 --- a/cpp/src/utilities/path_retrieval.cu +++ b/cpp/src/utilities/path_retrieval.cu @@ -26,11 +26,11 @@ namespace cugraph { namespace detail { template -__global__ void get_traversed_cost_kernel(vertex_t const *vertices, - vertex_t const *preds, - vertex_t const *vtx_map, - weight_t const *info_weights, - weight_t *out, +__global__ void get_traversed_cost_kernel(vertex_t const* vertices, + vertex_t const* preds, + vertex_t const* vtx_map, + weight_t const* info_weights, + weight_t* out, vertex_t stop_vertex, vertex_t num_vertices) { @@ -48,11 +48,11 @@ __global__ void get_traversed_cost_kernel(vertex_t const *vertices, } template -void get_traversed_cost_impl(raft::handle_t const &handle, - vertex_t const *vertices, - vertex_t const *preds, - weight_t const *info_weights, - weight_t *out, +void get_traversed_cost_impl(raft::handle_t const& handle, + vertex_t const* vertices, + vertex_t const* preds, + weight_t const* info_weights, + weight_t* out, vertex_t stop_vertex, vertex_t num_vertices) { @@ -70,8 +70,8 @@ void get_traversed_cost_impl(raft::handle_t const &handle, rmm::device_uvector vtx_map_v(num_vertices, stream); rmm::device_uvector vtx_keys_v(num_vertices, stream); - vertex_t *vtx_map = vtx_map_v.data(); - vertex_t *vtx_keys = vtx_keys_v.data(); + vertex_t* vtx_map = vtx_map_v.data(); + vertex_t* vtx_keys = vtx_keys_v.data(); raft::copy(vtx_keys, vertices, num_vertices, stream); thrust::sequence(rmm::exec_policy(stream)->on(stream), vtx_map, vtx_map + num_vertices); @@ -85,11 +85,11 @@ void get_traversed_cost_impl(raft::handle_t const &handle, } // namespace detail template -void get_traversed_cost(raft::handle_t const &handle, - vertex_t const *vertices, - vertex_t const *preds, - weight_t const *info_weights, - weight_t *out, +void get_traversed_cost(raft::handle_t const& handle, + vertex_t const* vertices, + vertex_t const* preds, + weight_t const* info_weights, + weight_t* out, vertex_t stop_vertex, vertex_t num_vertices) { @@ -99,35 +99,35 @@ void get_traversed_cost(raft::handle_t const &handle, handle, vertices, preds, info_weights, out, stop_vertex, num_vertices); } -template void get_traversed_cost(raft::handle_t const &handle, - int32_t const *vertices, - int32_t const *preds, - float const *info_weights, - float *out, +template void get_traversed_cost(raft::handle_t const& handle, + int32_t const* vertices, + int32_t const* preds, + float const* info_weights, + float* out, int32_t stop_vertex, int32_t num_vertices); -template void get_traversed_cost(raft::handle_t const &handle, - int32_t const *vertices, - int32_t const *preds, - double const *info_weights, - double *out, +template void get_traversed_cost(raft::handle_t const& handle, + int32_t const* vertices, + int32_t const* preds, + double const* info_weights, + double* out, int32_t stop_vertex, int32_t num_vertices); -template void get_traversed_cost(raft::handle_t const &handle, - int64_t const *vertices, - int64_t const *preds, - float const *info_weights, - float *out, +template void get_traversed_cost(raft::handle_t const& handle, + int64_t const* vertices, + int64_t const* preds, + float const* info_weights, + float* out, int64_t stop_vertex, int64_t num_vertices); -template void get_traversed_cost(raft::handle_t const &handle, - int64_t const *vertices, - int64_t const *preds, - double const *info_weights, - double *out, +template void get_traversed_cost(raft::handle_t const& handle, + int64_t const* vertices, + int64_t const* preds, + double const* info_weights, + double* out, int64_t stop_vertex, int64_t num_vertices); } // namespace cugraph diff --git a/cpp/src/utilities/spmv_1D.cu b/cpp/src/utilities/spmv_1D.cu index 8a7378e69d3..b4db219fb89 100644 --- a/cpp/src/utilities/spmv_1D.cu +++ b/cpp/src/utilities/spmv_1D.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ namespace cugraph { namespace mg { template -MGcsrmv::MGcsrmv(raft::handle_t const &handle, - vertex_t *local_vertices, - vertex_t *part_off, - edge_t *off, - vertex_t *ind, - weight_t *val, - weight_t *x) +MGcsrmv::MGcsrmv(raft::handle_t const& handle, + vertex_t* local_vertices, + vertex_t* part_off, + edge_t* off, + vertex_t* ind, + weight_t* val, + weight_t* x) : handle_(handle), local_vertices_(local_vertices), part_off_(part_off), @@ -49,7 +49,7 @@ MGcsrmv::~MGcsrmv() } template -void MGcsrmv::run(weight_t *x) +void MGcsrmv::run(weight_t* x) { using namespace raft::matrix; @@ -72,7 +72,7 @@ void MGcsrmv::run(weight_t *x) auto stream = handle_.get_stream(); - auto const &comm{handle_.get_comms()}; // local + auto const& comm{handle_.get_comms()}; // local std::vector recvbuf(comm.get_size()); std::vector displs(comm.get_size()); diff --git a/cpp/tests/centrality/betweenness_centrality_test.cu b/cpp/tests/centrality/betweenness_centrality_test.cu index c3883d9694f..a171b0010d1 100644 --- a/cpp/tests/centrality/betweenness_centrality_test.cu +++ b/cpp/tests/centrality/betweenness_centrality_test.cu @@ -50,68 +50,80 @@ // C++ Reference Implementation // ============================================================================ template -void ref_accumulation(result_t *result, +void ref_accumulation(result_t* result, vertex_t const number_of_vertices, - std::stack &S, - std::vector> &pred, - std::vector &sigmas, - std::vector &deltas, + std::stack& S, + std::vector>& pred, + std::vector& sigmas, + std::vector& deltas, vertex_t source) { - for (vertex_t v = 0; v < number_of_vertices; ++v) { deltas[v] = 0; } + for (vertex_t v = 0; v < number_of_vertices; ++v) { + deltas[v] = 0; + } while (!S.empty()) { vertex_t w = S.top(); S.pop(); - for (vertex_t v : pred[w]) { deltas[v] += (sigmas[v] / sigmas[w]) * (1.0 + deltas[w]); } + for (vertex_t v : pred[w]) { + deltas[v] += (sigmas[v] / sigmas[w]) * (1.0 + deltas[w]); + } if (w != source) { result[w] += deltas[w]; } } } template -void ref_endpoints_accumulation(result_t *result, +void ref_endpoints_accumulation(result_t* result, vertex_t const number_of_vertices, - std::stack &S, - std::vector> &pred, - std::vector &sigmas, - std::vector &deltas, + std::stack& S, + std::vector>& pred, + std::vector& sigmas, + std::vector& deltas, vertex_t source) { result[source] += S.size() - 1; - for (vertex_t v = 0; v < number_of_vertices; ++v) { deltas[v] = 0; } + for (vertex_t v = 0; v < number_of_vertices; ++v) { + deltas[v] = 0; + } while (!S.empty()) { vertex_t w = S.top(); S.pop(); - for (vertex_t v : pred[w]) { deltas[v] += (sigmas[v] / sigmas[w]) * (1.0 + deltas[w]); } + for (vertex_t v : pred[w]) { + deltas[v] += (sigmas[v] / sigmas[w]) * (1.0 + deltas[w]); + } if (w != source) { result[w] += deltas[w] + 1; } } } template -void ref_edge_accumulation(result_t *result, +void ref_edge_accumulation(result_t* result, vertex_t const number_of_vertices, - std::stack &S, - std::vector> &pred, - std::vector &sigmas, - std::vector &deltas, + std::stack& S, + std::vector>& pred, + std::vector& sigmas, + std::vector& deltas, vertex_t source) { - for (vertex_t v = 0; v < number_of_vertices; ++v) { deltas[v] = 0; } + for (vertex_t v = 0; v < number_of_vertices; ++v) { + deltas[v] = 0; + } while (!S.empty()) { vertex_t w = S.top(); S.pop(); - for (vertex_t v : pred[w]) { deltas[v] += (sigmas[v] / sigmas[w]) * (1.0 + deltas[w]); } + for (vertex_t v : pred[w]) { + deltas[v] += (sigmas[v] / sigmas[w]) * (1.0 + deltas[w]); + } if (w != source) { result[w] += deltas[w]; } } } // Algorithm 1: Shortest-path vertex betweenness, (Brandes, 2001) template -void reference_betweenness_centrality_impl(vertex_t *indices, - edge_t *offsets, +void reference_betweenness_centrality_impl(vertex_t* indices, + edge_t* offsets, vertex_t const number_of_vertices, - result_t *result, + result_t* result, bool endpoints, - vertex_t const *sources, + vertex_t const* sources, vertex_t const number_of_sources) { std::queue Q; @@ -159,7 +171,7 @@ void reference_betweenness_centrality_impl(vertex_t *indices, } template -void reference_rescale(result_t *result, +void reference_rescale(result_t* result, bool directed, bool normalize, bool endpoints, @@ -190,25 +202,27 @@ void reference_rescale(result_t *result, rescale_factor *= (casted_number_of_vertices / casted_number_of_sources); } } - for (auto idx = 0; idx < number_of_vertices; ++idx) { result[idx] *= rescale_factor; } + for (auto idx = 0; idx < number_of_vertices; ++idx) { + result[idx] *= rescale_factor; + } } template void reference_betweenness_centrality( - cugraph::legacy::GraphCSRView const &graph, - result_t *result, + cugraph::legacy::GraphCSRView const& graph, + result_t* result, bool normalize, bool endpoints, // This is not yet implemented vertex_t const number_of_sources, - vertex_t const *sources) + vertex_t const* sources) { vertex_t number_of_vertices = graph.number_of_vertices; edge_t number_of_edges = graph.number_of_edges; thrust::host_vector h_indices(number_of_edges); thrust::host_vector h_offsets(number_of_vertices + 1); - thrust::device_ptr d_indices((vertex_t *)&graph.indices[0]); - thrust::device_ptr d_offsets((edge_t *)&graph.offsets[0]); + thrust::device_ptr d_indices((vertex_t*)&graph.indices[0]); + thrust::device_ptr d_offsets((edge_t*)&graph.offsets[0]); thrust::copy(d_indices, d_indices + number_of_edges, h_indices.begin()); thrust::copy(d_offsets, d_offsets + (number_of_vertices + 1), h_offsets.begin()); @@ -249,7 +263,7 @@ template void reference_betweenness_centrality( // Compare while allowing relatie error of epsilon // zero_threshold indicates when we should drop comparison for small numbers template -bool compare_close(const T &a, const T &b, const precision_t epsilon, precision_t zero_threshold) +bool compare_close(const T& a, const T& b, const precision_t epsilon, precision_t zero_threshold) { return ((zero_threshold > a && zero_threshold > b)) || (a >= b * (1.0 - epsilon)) && (a <= b * (1.0 + epsilon)); @@ -265,12 +279,12 @@ typedef struct BC_Usecase_t { std::string config_; // Path to graph file std::string file_path_; // Complete path to graph using dataset_root_dir int number_of_sources_; // Starting point from the traversal - BC_Usecase_t(const std::string &config, int number_of_sources) + BC_Usecase_t(const std::string& config, int number_of_sources) : config_(config), number_of_sources_(number_of_sources) { // assume relative paths are relative to RAPIDS_DATASET_ROOT_DIR // FIXME: Use platform independent stuff from c++14/17 on compiler update - const std::string &rapidsDatasetRootDir = cugraph::test::get_rapids_dataset_root_dir(); + const std::string& rapidsDatasetRootDir = cugraph::test::get_rapids_dataset_root_dir(); if ((config_ != "") && (config_[0] != '/')) { file_path_ = rapidsDatasetRootDir + "/" + config_; } else { @@ -301,7 +315,7 @@ class Tests_BC : public ::testing::TestWithParam { typename result_t, bool normalize, bool endpoints> - void run_current_test(const BC_Usecase &configuration) + void run_current_test(const BC_Usecase& configuration) { // Step 1: Construction of the graph based on configuration bool is_directed = false; @@ -324,7 +338,7 @@ class Tests_BC : public ::testing::TestWithParam { std::vector sources(configuration.number_of_sources_); thrust::sequence(thrust::host, sources.begin(), sources.end(), 0); - vertex_t *sources_ptr = nullptr; + vertex_t* sources_ptr = nullptr; if (configuration.number_of_sources_ > 0) { sources_ptr = sources.data(); } reference_betweenness_centrality( @@ -339,7 +353,7 @@ class Tests_BC : public ::testing::TestWithParam { d_result.data().get(), normalize, endpoints, - static_cast(nullptr), + static_cast(nullptr), configuration.number_of_sources_, sources_ptr); cudaDeviceSynchronize(); diff --git a/cpp/tests/centrality/edge_betweenness_centrality_test.cu b/cpp/tests/centrality/edge_betweenness_centrality_test.cu index 5f832475b3b..67fdb22f953 100644 --- a/cpp/tests/centrality/edge_betweenness_centrality_test.cu +++ b/cpp/tests/centrality/edge_betweenness_centrality_test.cu @@ -53,8 +53,8 @@ template edge_t get_edge_index_from_source_and_destination(vertex_t source_vertex, vertex_t destination_vertex, - vertex_t const *indices, - edge_t const *offsets) + vertex_t const* indices, + edge_t const* offsets) { edge_t index = -1; edge_t first_edge_idx = offsets[source_vertex]; @@ -65,17 +65,19 @@ edge_t get_edge_index_from_source_and_destination(vertex_t source_vertex, } template -void ref_accumulation(result_t *result, - vertex_t const *indices, - edge_t const *offsets, +void ref_accumulation(result_t* result, + vertex_t const* indices, + edge_t const* offsets, vertex_t const number_of_vertices, - std::stack &S, - std::vector> &pred, - std::vector &sigmas, - std::vector &deltas, + std::stack& S, + std::vector>& pred, + std::vector& sigmas, + std::vector& deltas, vertex_t source) { - for (vertex_t v = 0; v < number_of_vertices; ++v) { deltas[v] = 0; } + for (vertex_t v = 0; v < number_of_vertices; ++v) { + deltas[v] = 0; + } while (!S.empty()) { vertex_t w = S.top(); S.pop(); @@ -93,11 +95,11 @@ void ref_accumulation(result_t *result, // Algorithm 1: Shortest-path vertex betweenness, (Brandes, 2001) template -void reference_edge_betweenness_centrality_impl(vertex_t *indices, - edge_t *offsets, +void reference_edge_betweenness_centrality_impl(vertex_t* indices, + edge_t* offsets, vertex_t const number_of_vertices, - result_t *result, - vertex_t const *sources, + result_t* result, + vertex_t const* sources, vertex_t const number_of_sources) { std::queue Q; @@ -135,7 +137,7 @@ void reference_edge_betweenness_centrality_impl(vertex_t *indices, } template -void reference_rescale(result_t *result, +void reference_rescale(result_t* result, bool directed, bool normalize, vertex_t const number_of_vertices, @@ -150,24 +152,26 @@ void reference_rescale(result_t *result, } else { if (!directed) { rescale_factor /= static_cast(2); } } - for (auto idx = 0; idx < number_of_edges; ++idx) { result[idx] *= rescale_factor; } + for (auto idx = 0; idx < number_of_edges; ++idx) { + result[idx] *= rescale_factor; + } } template void reference_edge_betweenness_centrality( - cugraph::legacy::GraphCSRView const &graph, - result_t *result, + cugraph::legacy::GraphCSRView const& graph, + result_t* result, bool normalize, vertex_t const number_of_sources, - vertex_t const *sources) + vertex_t const* sources) { vertex_t number_of_vertices = graph.number_of_vertices; edge_t number_of_edges = graph.number_of_edges; thrust::host_vector h_indices(number_of_edges); thrust::host_vector h_offsets(number_of_vertices + 1); - thrust::device_ptr d_indices((vertex_t *)&graph.indices[0]); - thrust::device_ptr d_offsets((edge_t *)&graph.offsets[0]); + thrust::device_ptr d_indices((vertex_t*)&graph.indices[0]); + thrust::device_ptr d_offsets((edge_t*)&graph.offsets[0]); thrust::copy(d_indices, d_indices + number_of_edges, h_indices.begin()); thrust::copy(d_offsets, d_offsets + (number_of_vertices + 1), h_offsets.begin()); @@ -186,7 +190,7 @@ void reference_edge_betweenness_centrality( // Compare while allowing relatie error of epsilon // zero_threshold indicates when we should drop comparison for small numbers template -bool compare_close(const T &a, const T &b, const precision_t epsilon, precision_t zero_threshold) +bool compare_close(const T& a, const T& b, const precision_t epsilon, precision_t zero_threshold) { return ((zero_threshold > a && zero_threshold > b)) || (a >= b * (1.0 - epsilon)) && (a <= b * (1.0 + epsilon)); @@ -202,12 +206,12 @@ typedef struct EdgeBC_Usecase_t { std::string config_; // Path to graph file std::string file_path_; // Complete path to graph using dataset_root_dir int number_of_sources_; // Starting point from the traversal - EdgeBC_Usecase_t(const std::string &config, int number_of_sources) + EdgeBC_Usecase_t(const std::string& config, int number_of_sources) : config_(config), number_of_sources_(number_of_sources) { // assume relative paths are relative to RAPIDS_DATASET_ROOT_DIR // FIXME: Use platform independent stuff from c++14/17 on compiler update - const std::string &rapidsDatasetRootDir = cugraph::test::get_rapids_dataset_root_dir(); + const std::string& rapidsDatasetRootDir = cugraph::test::get_rapids_dataset_root_dir(); if ((config_ != "") && (config_[0] != '/')) { file_path_ = rapidsDatasetRootDir + "/" + config_; } else { @@ -237,7 +241,7 @@ class Tests_EdgeBC : public ::testing::TestWithParam { typename weight_t, typename result_t, bool normalize> - void run_current_test(const EdgeBC_Usecase &configuration) + void run_current_test(const EdgeBC_Usecase& configuration) { // Step 1: Construction of the graph based on configuration bool is_directed = false; @@ -260,7 +264,7 @@ class Tests_EdgeBC : public ::testing::TestWithParam { std::vector sources(configuration.number_of_sources_); thrust::sequence(thrust::host, sources.begin(), sources.end(), 0); - vertex_t *sources_ptr = nullptr; + vertex_t* sources_ptr = nullptr; if (configuration.number_of_sources_ > 0) { sources_ptr = sources.data(); } reference_edge_betweenness_centrality( @@ -274,7 +278,7 @@ class Tests_EdgeBC : public ::testing::TestWithParam { G, d_result.data().get(), normalize, - static_cast(nullptr), + static_cast(nullptr), configuration.number_of_sources_, sources_ptr); CUDA_TRY(cudaMemcpy(result.data(), diff --git a/cpp/tests/centrality/katz_centrality_test.cu b/cpp/tests/centrality/katz_centrality_test.cu index e4951dd9098..ee2df5347fc 100644 --- a/cpp/tests/centrality/katz_centrality_test.cu +++ b/cpp/tests/centrality/katz_centrality_test.cu @@ -35,7 +35,9 @@ std::vector getGoldenTopKIds(std::ifstream& fs_result, int k = 10) std::vector vec; int val; int count = 0; - while (fs_result >> val && ((count++) < k)) { vec.push_back(val); } + while (fs_result >> val && ((count++) < k)) { + vec.push_back(val); + } vec.resize(k); return vec; } diff --git a/cpp/tests/community/ecg_test.cpp b/cpp/tests/community/ecg_test.cpp index 15c2fb118c9..f174d882937 100644 --- a/cpp/tests/community/ecg_test.cpp +++ b/cpp/tests/community/ecg_test.cpp @@ -143,7 +143,9 @@ TEST(ecg, dolphin) ASSERT_EQ((min >= 0), 1); std::set cluster_ids; - for (auto c : cluster_id) { cluster_ids.insert(c); } + for (auto c : cluster_id) { + cluster_ids.insert(c); + } ASSERT_EQ(cluster_ids.size(), size_t(max + 1)); diff --git a/cpp/tests/community/mg_louvain_helper.cu b/cpp/tests/community/mg_louvain_helper.cu index e5b99c5cbdd..b5347778b4c 100644 --- a/cpp/tests/community/mg_louvain_helper.cu +++ b/cpp/tests/community/mg_louvain_helper.cu @@ -32,10 +32,10 @@ namespace cugraph { namespace test { template -void single_gpu_renumber_edgelist_given_number_map(raft::handle_t const &handle, - rmm::device_uvector &edgelist_rows_v, - rmm::device_uvector &edgelist_cols_v, - rmm::device_uvector &renumber_map_gathered_v) +void single_gpu_renumber_edgelist_given_number_map(raft::handle_t const& handle, + rmm::device_uvector& edgelist_rows_v, + rmm::device_uvector& edgelist_cols_v, + rmm::device_uvector& renumber_map_gathered_v) { rmm::device_uvector index_v(renumber_map_gathered_v.size(), handle.get_stream()); @@ -63,9 +63,9 @@ template std::tuple, rmm::device_uvector, std::optional>> -compressed_sparse_to_edgelist(edge_t const *compressed_sparse_offsets, - vertex_t const *compressed_sparse_indices, - std::optional compressed_sparse_weights, +compressed_sparse_to_edgelist(edge_t const* compressed_sparse_offsets, + vertex_t const* compressed_sparse_indices, + std::optional compressed_sparse_weights, vertex_t major_first, vertex_t major_last, cudaStream_t stream) @@ -112,9 +112,9 @@ compressed_sparse_to_edgelist(edge_t const *compressed_sparse_offsets, template void sort_and_coarsen_edgelist( - rmm::device_uvector &edgelist_major_vertices /* [INOUT] */, - rmm::device_uvector &edgelist_minor_vertices /* [INOUT] */, - std::optional> &edgelist_weights /* [INOUT] */, + rmm::device_uvector& edgelist_major_vertices /* [INOUT] */, + rmm::device_uvector& edgelist_minor_vertices /* [INOUT] */, + std::optional>& edgelist_weights /* [INOUT] */, cudaStream_t stream) { auto pair_first = thrust::make_zip_iterator( @@ -170,11 +170,11 @@ std::tuple, rmm::device_uvector, std::optional>> compressed_sparse_to_relabeled_and_sorted_and_coarsened_edgelist( - edge_t const *compressed_sparse_offsets, - vertex_t const *compressed_sparse_indices, - std::optional compressed_sparse_weights, - vertex_t const *p_major_labels, - vertex_t const *p_minor_labels, + edge_t const* compressed_sparse_offsets, + vertex_t const* compressed_sparse_indices, + std::optional compressed_sparse_weights, + vertex_t const* p_major_labels, + vertex_t const* p_minor_labels, vertex_t major_first, vertex_t major_last, vertex_t minor_first, @@ -217,10 +217,10 @@ compressed_sparse_to_relabeled_and_sorted_and_coarsened_edgelist( template std::unique_ptr> coarsen_graph( - raft::handle_t const &handle, - cugraph::experimental::graph_view_t const - &graph_view, - vertex_t const *labels) + raft::handle_t const& handle, + cugraph::experimental::graph_view_t const& + graph_view, + vertex_t const* labels) { auto [coarsened_edgelist_major_vertices, coarsened_edgelist_minor_vertices, @@ -238,14 +238,13 @@ coarsen_graph( handle.get_stream()); cugraph::experimental::edgelist_t edgelist{}; - edgelist.p_src_vertices = store_transposed ? coarsened_edgelist_minor_vertices.data() - : coarsened_edgelist_major_vertices.data(); - edgelist.p_dst_vertices = store_transposed ? coarsened_edgelist_major_vertices.data() - : coarsened_edgelist_minor_vertices.data(); - edgelist.p_edge_weights = - coarsened_edgelist_weights - ? std::optional{(*coarsened_edgelist_weights).data()} - : std::nullopt; + edgelist.p_src_vertices = store_transposed ? coarsened_edgelist_minor_vertices.data() + : coarsened_edgelist_major_vertices.data(); + edgelist.p_dst_vertices = store_transposed ? coarsened_edgelist_major_vertices.data() + : coarsened_edgelist_minor_vertices.data(); + edgelist.p_edge_weights = coarsened_edgelist_weights + ? std::optional{(*coarsened_edgelist_weights).data()} + : std::nullopt; edgelist.number_of_edges = static_cast(coarsened_edgelist_major_vertices.size()); vertex_t new_number_of_vertices = @@ -267,16 +266,16 @@ coarsen_graph( // explicit instantiation template void single_gpu_renumber_edgelist_given_number_map( - raft::handle_t const &handle, - rmm::device_uvector &d_edgelist_rows, - rmm::device_uvector &d_edgelist_cols, - rmm::device_uvector &d_renumber_map_gathered_v); + raft::handle_t const& handle, + rmm::device_uvector& d_edgelist_rows, + rmm::device_uvector& d_edgelist_cols, + rmm::device_uvector& d_renumber_map_gathered_v); template std::unique_ptr> coarsen_graph( - raft::handle_t const &handle, - cugraph::experimental::graph_view_t const &graph_view, - int32_t const *labels); + raft::handle_t const& handle, + cugraph::experimental::graph_view_t const& graph_view, + int32_t const* labels); } // namespace test } // namespace cugraph diff --git a/cpp/tests/community/mg_louvain_helper.hpp b/cpp/tests/community/mg_louvain_helper.hpp index 5ed710b7417..7e03f435724 100644 --- a/cpp/tests/community/mg_louvain_helper.hpp +++ b/cpp/tests/community/mg_louvain_helper.hpp @@ -25,29 +25,29 @@ namespace cugraph { namespace test { template -bool compare_renumbered_vectors(raft::handle_t const &handle, - std::vector const &v1, - std::vector const &v2); +bool compare_renumbered_vectors(raft::handle_t const& handle, + std::vector const& v1, + std::vector const& v2); template -bool compare_renumbered_vectors(raft::handle_t const &handle, - rmm::device_uvector const &v1, - rmm::device_uvector const &v2); +bool compare_renumbered_vectors(raft::handle_t const& handle, + rmm::device_uvector const& v1, + rmm::device_uvector const& v2); template void single_gpu_renumber_edgelist_given_number_map( - raft::handle_t const &handle, - rmm::device_uvector &d_edgelist_rows, - rmm::device_uvector &d_edgelist_cols, - rmm::device_uvector &d_renumber_map_gathered_v); + raft::handle_t const& handle, + rmm::device_uvector& d_edgelist_rows, + rmm::device_uvector& d_edgelist_cols, + rmm::device_uvector& d_renumber_map_gathered_v); template std::unique_ptr> coarsen_graph( - raft::handle_t const &handle, - cugraph::experimental::graph_view_t const - &graph_view, - vertex_t const *labels); + raft::handle_t const& handle, + cugraph::experimental::graph_view_t const& + graph_view, + vertex_t const* labels); } // namespace test } // namespace cugraph diff --git a/cpp/tests/community/mg_louvain_test.cpp b/cpp/tests/community/mg_louvain_test.cpp index 971685d7537..1f7276fa116 100644 --- a/cpp/tests/community/mg_louvain_test.cpp +++ b/cpp/tests/community/mg_louvain_test.cpp @@ -183,7 +183,9 @@ class Louvain_MG_Testfixture : public ::testing::TestWithParam auto const comm_rank = comm.get_rank(); auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { --row_comm_size; } + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } cugraph::partition_2d::subcomm_factory_t subcomm_factory(handle, row_comm_size); diff --git a/cpp/tests/components/mg_weakly_connected_components_test.cpp b/cpp/tests/components/mg_weakly_connected_components_test.cpp index 9285b3ed668..11e3f803b38 100644 --- a/cpp/tests/components/mg_weakly_connected_components_test.cpp +++ b/cpp/tests/components/mg_weakly_connected_components_test.cpp @@ -75,7 +75,9 @@ class Tests_MGWeaklyConnectedComponents auto const comm_rank = comm.get_rank(); auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { --row_comm_size; } + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } cugraph::partition_2d::subcomm_factory_t subcomm_factory(handle, row_comm_size); diff --git a/cpp/tests/components/scc_test.cu b/cpp/tests/components/scc_test.cu index 5448cf79cce..eaf6daf2d29 100644 --- a/cpp/tests/components/scc_test.cu +++ b/cpp/tests/components/scc_test.cu @@ -115,7 +115,8 @@ struct Tests_Strongly_CC : ::testing::TestWithParam { } std::cout << "#iterations:\n"; - for (auto&& count : strongly_cc_counts) std::cout << count << std::endl; + for (auto&& count : strongly_cc_counts) + std::cout << count << std::endl; } } virtual void SetUp() {} diff --git a/cpp/tests/experimental/mg_bfs_test.cpp b/cpp/tests/experimental/mg_bfs_test.cpp index 75d4d4ce6a3..5257c728ce4 100644 --- a/cpp/tests/experimental/mg_bfs_test.cpp +++ b/cpp/tests/experimental/mg_bfs_test.cpp @@ -74,7 +74,9 @@ class Tests_MGBFS : public ::testing::TestWithParam(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { --row_comm_size; } + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } cugraph::partition_2d::subcomm_factory_t subcomm_factory(handle, row_comm_size); diff --git a/cpp/tests/experimental/mg_katz_centrality_test.cpp b/cpp/tests/experimental/mg_katz_centrality_test.cpp index d0120e3a2e8..9071701324e 100644 --- a/cpp/tests/experimental/mg_katz_centrality_test.cpp +++ b/cpp/tests/experimental/mg_katz_centrality_test.cpp @@ -57,8 +57,8 @@ class Tests_MGKatzCentrality // Compare the results of running Katz Centrality on multiple GPUs to that of a single-GPU run template - void run_current_test(KatzCentrality_Usecase const &katz_usecase, - input_usecase_t const &input_usecase) + void run_current_test(KatzCentrality_Usecase const& katz_usecase, + input_usecase_t const& input_usecase) { // 1. initialize handle @@ -66,12 +66,14 @@ class Tests_MGKatzCentrality HighResClock hr_clock{}; raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - auto &comm = handle.get_comms(); + auto& comm = handle.get_comms(); auto const comm_size = comm.get_size(); auto const comm_rank = comm.get_rank(); auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { --row_comm_size; } + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } cugraph::partition_2d::subcomm_factory_t subcomm_factory(handle, row_comm_size); @@ -118,7 +120,7 @@ class Tests_MGKatzCentrality cugraph::experimental::katz_centrality(handle, mg_graph_view, - static_cast(nullptr), + static_cast(nullptr), d_mg_katz_centralities.data(), alpha, beta, @@ -173,7 +175,7 @@ class Tests_MGKatzCentrality cugraph::experimental::katz_centrality( handle, sg_graph_view, - static_cast(nullptr), + static_cast(nullptr), d_sg_katz_centralities.data(), alpha, beta, diff --git a/cpp/tests/experimental/mg_sssp_test.cpp b/cpp/tests/experimental/mg_sssp_test.cpp index efc40bd6b97..ce2556bed00 100644 --- a/cpp/tests/experimental/mg_sssp_test.cpp +++ b/cpp/tests/experimental/mg_sssp_test.cpp @@ -71,7 +71,9 @@ class Tests_MGSSSP : public ::testing::TestWithParam(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { --row_comm_size; } + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } cugraph::partition_2d::subcomm_factory_t subcomm_factory(handle, row_comm_size); diff --git a/cpp/tests/generators/erdos_renyi_test.cpp b/cpp/tests/generators/erdos_renyi_test.cpp index c91a9af7c41..3606ce2ddef 100644 --- a/cpp/tests/generators/erdos_renyi_test.cpp +++ b/cpp/tests/generators/erdos_renyi_test.cpp @@ -28,7 +28,7 @@ struct GenerateErdosRenyiTest : public ::testing::Test { }; template -void test_symmetric(std::vector &h_src_v, std::vector &h_dst_v) +void test_symmetric(std::vector& h_src_v, std::vector& h_dst_v) { std::vector reverse_src_v(h_src_v.size()); std::vector reverse_dst_v(h_dst_v.size()); diff --git a/cpp/tests/layout/force_atlas2_test.cu b/cpp/tests/layout/force_atlas2_test.cu index 1a259418bc7..e736f2d2db5 100644 --- a/cpp/tests/layout/force_atlas2_test.cu +++ b/cpp/tests/layout/force_atlas2_test.cu @@ -215,7 +215,8 @@ class Tests_Force_Atlas2 : public ::testing::TestWithParam // Transpose the data std::vector> C_contiguous_embedding(m, std::vector(2)); for (int i = 0; i < m; i++) { - for (int j = 0; j < 2; j++) C_contiguous_embedding[i][j] = h_pos[j * m + i]; + for (int j = 0; j < 2; j++) + C_contiguous_embedding[i][j] = h_pos[j * m + i]; } // Test trustworthiness diff --git a/cpp/tests/layout/knn.h b/cpp/tests/layout/knn.h index 07d07528769..26666794896 100644 --- a/cpp/tests/layout/knn.h +++ b/cpp/tests/layout/knn.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,8 @@ double sq_euclid_dist(const point& x, const point& y) double total = 0; auto i = x.attributes.begin(); auto j = y.attributes.begin(); - for (; i != x.attributes.end() && j != y.attributes.end(); ++i, ++j) total += pow(*i - *j, 2); + for (; i != x.attributes.end() && j != y.attributes.end(); ++i, ++j) + total += pow(*i - *j, 2); return total; } @@ -63,6 +64,7 @@ std::vector knn_classify(std::list& dataframe, const point& c, const auto count = 0; auto j = distances.begin(); ++j; - for (; j != distances.end() && count < k; ++j, ++count) res.push_back(j->index); + for (; j != distances.end() && count < k; ++j, ++count) + res.push_back(j->index); return res; } diff --git a/cpp/tests/layout/trust_worthiness.h b/cpp/tests/layout/trust_worthiness.h index 40c9782a76e..5a112ea3c6b 100644 --- a/cpp/tests/layout/trust_worthiness.h +++ b/cpp/tests/layout/trust_worthiness.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,8 @@ double euclidian_dist(const std::vector& x, const std::vector& y) double total = 0; auto i = x.begin(); auto j = y.begin(); - for (; i != x.end() && j != y.end(); ++i, ++j) total += pow(*i, 2) - 2 * *i * *j + pow(*j, 2); + for (; i != x.end() && j != y.end(); ++i, ++j) + total += pow(*i, 2) - 2 * *i * *j + pow(*j, 2); return sqrt(total); } @@ -62,7 +63,8 @@ std::vector argsort(Iter begin, Iter end, Compare comp) return comp(*prev.second, *next.second); }); - for (auto i : pairList) ret.push_back(i.first); + for (auto i : pairList) + ret.push_back(i.first); return ret; } @@ -109,7 +111,8 @@ double compute_rank(const std::vector>& ind_X, ranks[j] = idx; } } - for (auto& val : ranks) val -= k; + for (auto& val : ranks) + val -= k; for (const auto& val : ranks) if (val > 0) rank += val; @@ -122,7 +125,9 @@ void print_matrix(const std::vector>& matrix) { for (size_t i = 0; i < matrix.size(); ++i) { std::cout << "[ "; - for (size_t j = 0; j < matrix[i].size(); ++j) { std::cout << matrix[i][j] << ' '; } + for (size_t j = 0; j < matrix[i].size(); ++j) { + std::cout << matrix[i][j] << ' '; + } std::cout << "]\n"; } } diff --git a/cpp/tests/linear_assignment/hungarian_test.cu b/cpp/tests/linear_assignment/hungarian_test.cu index 26496e95271..f806a217a8f 100644 --- a/cpp/tests/linear_assignment/hungarian_test.cu +++ b/cpp/tests/linear_assignment/hungarian_test.cu @@ -26,14 +26,14 @@ #include #include -__global__ void setup_generator(curandState *state) +__global__ void setup_generator(curandState* state) { int id = threadIdx.x + blockIdx.x * blockDim.x; curand_init(43, id, 0, &state[id]); } template -__global__ void generate_random(curandState *state, int n, T *data, int32_t upper_bound) +__global__ void generate_random(curandState* state, int n, T* data, int32_t upper_bound) { int first = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; diff --git a/cpp/tests/pagerank/mg_pagerank_test.cpp b/cpp/tests/pagerank/mg_pagerank_test.cpp index 27d9bd1cbd1..fca889c3299 100644 --- a/cpp/tests/pagerank/mg_pagerank_test.cpp +++ b/cpp/tests/pagerank/mg_pagerank_test.cpp @@ -74,7 +74,9 @@ class Tests_MGPageRank auto const comm_rank = comm.get_rank(); auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { --row_comm_size; } + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } cugraph::partition_2d::subcomm_factory_t subcomm_factory(handle, row_comm_size); diff --git a/cpp/tests/sampling/random_walks_profiling.cu b/cpp/tests/sampling/random_walks_profiling.cu index 6049230e21a..595086a570e 100644 --- a/cpp/tests/sampling/random_walks_profiling.cu +++ b/cpp/tests/sampling/random_walks_profiling.cu @@ -181,7 +181,9 @@ void run(RandomWalks_Usecase const& configuration, traversal_id_t trv_id) // FIXME: the num_paths vector might be better specified via the // configuration input instead of hardcoding here. std::vector v_np{1, 10, 100}; - for (auto&& num_paths : v_np) { output_random_walks_time(graph_view, num_paths, trv_id); } + for (auto&& num_paths : v_np) { + output_random_walks_time(graph_view, num_paths, trv_id); + } } /** diff --git a/cpp/tests/traversal/bfs_ref.h b/cpp/tests/traversal/bfs_ref.h index a32b2f99787..5efdce818e7 100644 --- a/cpp/tests/traversal/bfs_ref.h +++ b/cpp/tests/traversal/bfs_ref.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include template -void populate_neighbors(VT *indices, ET *offsets, VT w, std::vector &neighbors) +void populate_neighbors(VT* indices, ET* offsets, VT w, std::vector& neighbors) { ET edge_start = offsets[w]; ET edge_end = offsets[w + 1]; @@ -31,14 +31,14 @@ void populate_neighbors(VT *indices, ET *offsets, VT w, std::vector &neighbo // This implements the BFS based on (Brandes, 2001) for shortest path counting template -void ref_bfs(VT *indices, - ET *offsets, +void ref_bfs(VT* indices, + ET* offsets, VT const number_of_vertices, - std::queue &Q, - std::stack &S, - std::vector &dist, - std::vector> &pred, - std::vector &sigmas, + std::queue& Q, + std::stack& S, + std::vector& dist, + std::vector>& pred, + std::vector& sigmas, VT source) { std::vector neighbors; diff --git a/cpp/tests/traversal/bfs_test.cu b/cpp/tests/traversal/bfs_test.cu index 03ca1ec9455..b0da605a0a0 100644 --- a/cpp/tests/traversal/bfs_test.cu +++ b/cpp/tests/traversal/bfs_test.cu @@ -46,7 +46,7 @@ // C++ Reference Implementation // ============================================================================ template -bool compare_close(const T &a, const T &b, const precision_t epsilon, precision_t zero_threshold) +bool compare_close(const T& a, const T& b, const precision_t epsilon, precision_t zero_threshold) { return ((zero_threshold > a && zero_threshold > b)) || (a >= b * (1.0 - epsilon)) && (a <= b * (1.0 + epsilon)); @@ -59,9 +59,9 @@ typedef struct BFS_Usecase_t { std::string config_; // Path to graph file std::string file_path_; // Complete path to graph using dataset_root_dir int source_; // Starting point from the traversal - BFS_Usecase_t(const std::string &config, int source) : config_(config), source_(source) + BFS_Usecase_t(const std::string& config, int source) : config_(config), source_(source) { - const std::string &rapidsDatasetRootDir = cugraph::test::get_rapids_dataset_root_dir(); + const std::string& rapidsDatasetRootDir = cugraph::test::get_rapids_dataset_root_dir(); if ((config_ != "") && (config_[0] != '/')) { file_path_ = rapidsDatasetRootDir + "/" + config_; } else { @@ -86,7 +86,7 @@ class Tests_BFS : public ::testing::TestWithParam { // WT edge weight data type // return_sp_counter should BFS return shortest path countner template - void run_current_test(const BFS_Usecase &configuration) + void run_current_test(const BFS_Usecase& configuration) { // Step 1: Construction of the graph based on configuration VT number_of_vertices; diff --git a/cpp/tests/utilities/base_fixture.hpp b/cpp/tests/utilities/base_fixture.hpp index 3121d3074d4..75570b2c467 100644 --- a/cpp/tests/utilities/base_fixture.hpp +++ b/cpp/tests/utilities/base_fixture.hpp @@ -46,14 +46,14 @@ namespace test { * ``` **/ class BaseFixture : public ::testing::Test { - rmm::mr::device_memory_resource *_mr{rmm::mr::get_current_device_resource()}; + rmm::mr::device_memory_resource* _mr{rmm::mr::get_current_device_resource()}; public: /** * @brief Returns pointer to `device_memory_resource` that should be used for all tests inheriting *from this fixture **/ - rmm::mr::device_memory_resource *mr() { return _mr; } + rmm::mr::device_memory_resource* mr() { return _mr; } }; /// MR factory functions @@ -90,7 +90,7 @@ inline auto make_binning() * @return Memory resource instance */ inline std::shared_ptr create_memory_resource( - std::string const &allocation_mode) + std::string const& allocation_mode) { if (allocation_mode == "binning") return make_binning(); if (allocation_mode == "cuda") return make_cuda(); @@ -110,7 +110,7 @@ inline std::shared_ptr create_memory_resource( * * @return Parsing results in the form of cxxopts::ParseResult */ -inline auto parse_test_options(int argc, char **argv) +inline auto parse_test_options(int argc, char** argv) { try { cxxopts::Options options(argv[0], " - cuGraph tests command line options"); @@ -118,7 +118,7 @@ inline auto parse_test_options(int argc, char **argv) "rmm_mode", "RMM allocation mode", cxxopts::value()->default_value("pool")); return options.parse(argc, argv); - } catch (const cxxopts::OptionException &e) { + } catch (const cxxopts::OptionException& e) { CUGRAPH_FAIL("Error parsing command line options"); } } @@ -133,7 +133,7 @@ inline auto parse_test_options(int argc, char **argv) * creating the default memory resource. */ #define CUGRAPH_TEST_PROGRAM_MAIN() \ - int main(int argc, char **argv) \ + int main(int argc, char** argv) \ { \ ::testing::InitGoogleTest(&argc, argv); \ auto const cmd_opts = parse_test_options(argc, argv); \ @@ -144,7 +144,7 @@ inline auto parse_test_options(int argc, char **argv) } #define CUGRAPH_MG_TEST_PROGRAM_MAIN() \ - int main(int argc, char **argv) \ + int main(int argc, char** argv) \ { \ MPI_TRY(MPI_Init(&argc, &argv)); \ int comm_rank{}; \ diff --git a/cpp/tests/utilities/cxxopts.hpp b/cpp/tests/utilities/cxxopts.hpp index 9a0b6e500d6..5aa77723a1f 100644 --- a/cpp/tests/utilities/cxxopts.hpp +++ b/cpp/tests/utilities/cxxopts.hpp @@ -17,6 +17,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* + * Copyright (c) 2021, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef CXXOPTS_HPP_INCLUDED #define CXXOPTS_HPP_INCLUDED @@ -89,7 +105,9 @@ inline String& stringAppend(String& s, String a) { return s.append(std::move(a)) inline String& stringAppend(String& s, int n, UChar32 c) { - for (int i = 0; i != n; ++i) { s.append(c); } + for (int i = 0; i != n; ++i) { + s.append(c); + } return s; } @@ -1449,7 +1467,9 @@ inline void Options::generate_all_groups_help(String& result) const std::vector all_groups; all_groups.reserve(m_help.size()); - for (auto& group : m_help) { all_groups.push_back(group.first); } + for (auto& group : m_help) { + all_groups.push_back(group.first); + } generate_group_help(result, all_groups); } @@ -1494,4 +1514,4 @@ inline const HelpGroupDetails& Options::group_help(const std::string& group) con } // namespace cxxopts -#endif // CXXOPTS_HPP_INCLUDED \ No newline at end of file +#endif // CXXOPTS_HPP_INCLUDED diff --git a/cpp/tests/utilities/device_comm_wrapper.cu b/cpp/tests/utilities/device_comm_wrapper.cu index 2d66e05c59f..2fee7719e36 100644 --- a/cpp/tests/utilities/device_comm_wrapper.cu +++ b/cpp/tests/utilities/device_comm_wrapper.cu @@ -26,7 +26,7 @@ namespace cugraph { namespace test { template -rmm::device_uvector device_gatherv(raft::handle_t const &handle, T const *d_input, size_t size) +rmm::device_uvector device_gatherv(raft::handle_t const& handle, T const* d_input, size_t size) { bool is_root = handle.get_comms().get_rank() == int{0}; auto rx_sizes = cugraph::experimental::host_scalar_gather( @@ -52,20 +52,20 @@ rmm::device_uvector device_gatherv(raft::handle_t const &handle, T const *d_i // explicit instantiation -template rmm::device_uvector device_gatherv(raft::handle_t const &handle, - int32_t const *d_input, +template rmm::device_uvector device_gatherv(raft::handle_t const& handle, + int32_t const* d_input, size_t size); -template rmm::device_uvector device_gatherv(raft::handle_t const &handle, - int64_t const *d_input, +template rmm::device_uvector device_gatherv(raft::handle_t const& handle, + int64_t const* d_input, size_t size); -template rmm::device_uvector device_gatherv(raft::handle_t const &handle, - float const *d_input, +template rmm::device_uvector device_gatherv(raft::handle_t const& handle, + float const* d_input, size_t size); -template rmm::device_uvector device_gatherv(raft::handle_t const &handle, - double const *d_input, +template rmm::device_uvector device_gatherv(raft::handle_t const& handle, + double const* d_input, size_t size); } // namespace test diff --git a/cpp/tests/utilities/device_comm_wrapper.hpp b/cpp/tests/utilities/device_comm_wrapper.hpp index f56f24248d6..55145edd71b 100644 --- a/cpp/tests/utilities/device_comm_wrapper.hpp +++ b/cpp/tests/utilities/device_comm_wrapper.hpp @@ -23,7 +23,7 @@ namespace cugraph { namespace test { template -rmm::device_uvector device_gatherv(raft::handle_t const &handle, T const *d_input, size_t size); +rmm::device_uvector device_gatherv(raft::handle_t const& handle, T const* d_input, size_t size); } // namespace test } // namespace cugraph