Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Pattern accelerator based implementation of PageRank, Katz Centrality, BFS, & SSSP #838

Merged
merged 182 commits into from Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 178 commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
73ace81
draft pattern accelerator API for the pagerank pattern
seunghwak Apr 22, 2020
5c93240
implement pagerank using the pattern accelerator API
seunghwak Apr 22, 2020
8a66ec5
implement katz centrality using the pattern accelerator API
seunghwak Apr 22, 2020
388b93c
add handle to the pattern accelerator API
seunghwak Apr 22, 2020
d725d74
fix minor issues in pagerank & katz_centrality
seunghwak Apr 22, 2020
6c50c25
add a pattern to support BFS
seunghwak Apr 23, 2020
3faffba
draft implementation of BFS using pattern accelerator APIs
seunghwak Apr 23, 2020
71052b6
move non-public APIs to the detail namespace
seunghwak Apr 23, 2020
52d09fe
minor tweak to bfs
seunghwak Apr 24, 2020
5e053c8
initial draft of sssp using pattern accelerator
seunghwak Apr 24, 2020
aa86d6a
merge e_op and e_pred_op and add reduce_op for bfs & sssp patterns
seunghwak Apr 27, 2020
692a9fc
tweaking patterns for BFS & SSSP for better accelerator implementation
seunghwak Apr 27, 2020
2a7624b
raise abstraction level for vertex queue
seunghwak Apr 28, 2020
2350282
direction optimized to direction optimizing in BFS
seunghwak Apr 30, 2020
c788f1a
Merge branch 'branch-0.14' of https://github.com/rapidsai/cugraph int…
seunghwak May 6, 2020
f8034c4
Merge branch 'branch-0.14' of https://github.com/rapidsai/cugraph int…
seunghwak May 6, 2020
700bd7b
update comments, class & function names, and several additional API c…
seunghwak May 6, 2020
dcbac12
add FIXME comments to remove opg as a template parameter from graph a…
seunghwak May 6, 2020
366829d
rename frontier to better reflect that it is a froniter on adjacency …
seunghwak May 6, 2020
d38f85c
updated pattern accelerator API for better expressiblity and to enabl…
seunghwak May 6, 2020
68759a6
remove template parameter bool opg from graph analytics
seunghwak May 6, 2020
b3e4ac7
remove unnecessary code
seunghwak May 6, 2020
e54a415
.cuh to .cu and explicit instantiation for templated graph analytics …
seunghwak May 6, 2020
2c8d8e4
Merge branch 'branch-0.14' of https://github.com/rapidsai/cugraph int…
seunghwak May 7, 2020
c03125c
"split patterns.hpp to three files"
seunghwak May 8, 2020
f8c656a
"add aliases vertex_type, edge_type, weight_type to Graph classes (to…
seunghwak May 8, 2020
5e30a30
"add invalid_vertex_id and invalid_edge_id"
seunghwak May 8, 2020
9f4517f
"add traits.hpp (initially supporting is_csr and is_csc)"
seunghwak May 8, 2020
99c1053
"fix typos"
seunghwak May 8, 2020
3c62765
add bfs.cu to CMakeLists.txt
seunghwak May 10, 2020
1bd5b1c
misc. fixes
seunghwak May 10, 2020
ac37967
fix several compile errors
seunghwak May 10, 2020
c45cf20
resolve merge conflicts
seunghwak May 10, 2020
f5427af
add graph_device_view class
seunghwak May 13, 2020
2198294
add is_opg to graph classes
seunghwak May 13, 2020
bccdb7b
add a frontier queue class for pattern accelerators
seunghwak May 19, 2020
338347a
fix bfs compile errors with pattern accelrator API
seunghwak May 19, 2020
1ba9a7b
initail commit of two level pattern accelrators
seunghwak May 19, 2020
e5589ce
fix frontier queue compile errors
seunghwak May 19, 2020
381c347
few tweaks
seunghwak May 19, 2020
695420d
initial commit of reduce_op.cuh
seunghwak May 19, 2020
ff2afa1
improve AdjMatrixRowFrontier implementation
seunghwak May 21, 2020
e8e1ef1
first full implementation of two level patterns for BFS & SSSP
seunghwak May 21, 2020
381dca2
first full ipmlementation of BFS using a pattern accelerator
seunghwak May 21, 2020
36b462b
update copyright year and add min to reduce_op
seunghwak May 21, 2020
9156460
add sssp to CMakeLists.txt
seunghwak May 21, 2020
7fbbc42
spilt two_levels_patterns.cuh to one file per pattern
seunghwak May 21, 2020
2121f77
thrust::raw_pointer_cast to data().get() following cuDF's convention
seunghwak May 21, 2020
b8a4776
resolve merge conflicts
seunghwak May 21, 2020
85d016b
Merge branch 'branch-0.14' of github.com:rapidsai/cugraph into fea_pa…
seunghwak May 21, 2020
0a5d130
move pattern accelerator related files to the patterns directory
seunghwak May 26, 2020
4d24b92
add edge_utils.cuh
seunghwak May 27, 2020
f5d525d
add transform_reduce_e pattern accelerator implmentation
seunghwak May 27, 2020
11a2007
add utility functions
seunghwak May 27, 2020
1950f28
update bfs with pattern accelerator implementation
seunghwak May 27, 2020
9ae143c
update sssp with pattern accelerator implementation
seunghwak May 27, 2020
d2f6e13
update graph_device_view
seunghwak May 27, 2020
2f6641f
update queue implementation
seunghwak May 27, 2020
d297bdb
update expand_and_transform_if_e pattern implementation
seunghwak May 27, 2020
c193f0e
placeholder
seunghwak May 27, 2020
bd286d3
fix merge error
seunghwak May 27, 2020
0ba8667
move implemented patterns out from one_level_patterns.cuh
seunghwak May 27, 2020
86a776c
Merge branch 'branch-0.14' of github.com:rapidsai/cugraph into fea_pa…
seunghwak May 27, 2020
c3976fc
Merge remote-tracking branch 'upstream/branch-0.15' into fea_pattern_acc
seunghwak May 27, 2020
0f381b7
fix a conceptual bug (row in graph adjacency matrix is always source,…
seunghwak May 31, 2020
9579a15
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jun 1, 2020
f231c39
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jun 4, 2020
3dc28f5
temporary commit to switch a branch
seunghwak Jun 4, 2020
fcb196a
resolve merge conflicts
seunghwak Jun 12, 2020
1204ceb
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jun 12, 2020
3e6d5b0
minor fixes on include statements
seunghwak Jun 15, 2020
5a26721
add experimental BFS to the test suites
seunghwak Jun 15, 2020
6fe3d65
use the real raft handle than the temporary placeholder
seunghwak Jun 15, 2020
fc884ff
add experimental BFS test
seunghwak Jun 16, 2020
bfcd60e
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jun 16, 2020
6b94916
several bug fixes
seunghwak Jun 16, 2020
1e920b7
run clang-format
seunghwak Jun 16, 2020
d81ebae
GraphType graph => GraphType const& graph_device_view in pattern acce…
seunghwak Jun 18, 2020
e5c2f97
now BFS passes C++ tests
seunghwak Jun 18, 2020
99cdc88
add depth_limit to the reference BFS implementation
seunghwak Jun 18, 2020
80de8f6
run clang-format
seunghwak Jun 19, 2020
73398e0
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jun 19, 2020
431aff0
remove dead code
seunghwak Jun 19, 2020
b7dcc7a
fix to work with new RAFT based error handling mechanism
seunghwak Jun 19, 2020
edc881d
minor code restructuring
seunghwak Jun 21, 2020
a079267
apply cutoff
seunghwak Jun 21, 2020
5ac706e
add SSSP test
seunghwak Jun 22, 2020
8402be7
cosmetic updates to BFS test
seunghwak Jun 22, 2020
3ef196e
SSSP bug fixes
seunghwak Jun 23, 2020
e7bc89f
SSSP code restructuring
seunghwak Jun 23, 2020
b81d939
update template bfs & sssp functions to take pointers for distances a…
seunghwak Jun 23, 2020
e16287d
now SSSP passes C++ tests
seunghwak Jun 23, 2020
20ec6df
add fixme comments
seunghwak Jun 23, 2020
bf3c375
temporary commit to change branch
seunghwak Jun 24, 2020
d16aed0
bug fix in graph_device_view.cuh
seunghwak Jun 25, 2020
f7d2c90
compile error fix in bfs_test.cpp
seunghwak Jun 26, 2020
40c7fa9
add declarations for PageRank and Katz in algorithms.hpp
seunghwak Jun 26, 2020
a9fbae4
bug fix in is_column_major
seunghwak Jun 26, 2020
0dc414b
fix namings
seunghwak Jun 29, 2020
c5f36d6
implement patter accelerator APIs for PageRank and Katz Centrality
seunghwak Jun 30, 2020
b097f55
remove unused file
seunghwak Jun 30, 2020
34e7e48
resolve merge conflicts
seunghwak Jun 30, 2020
d1132fc
bug fix
seunghwak Jun 30, 2020
8730a73
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jun 30, 2020
f68a36d
modify reference BFS & SSSP to take pointers instead of iterators
seunghwak Jun 30, 2020
da72479
resolve merge conflicts
seunghwak Jul 1, 2020
1e993ed
compute adj_matrix_out_weights_sums if not provided (nullptr) in Page…
seunghwak Jul 1, 2020
b907b92
rename ..._v..._e to ..._v..._nbr
seunghwak Jul 1, 2020
395a4c7
add utilities for atomic_add (better move this to RAFT)
seunghwak Jul 1, 2020
5af4caa
update experimental SSSP test
seunghwak Jul 1, 2020
5451bad
bug fix in copy_v_transform_reduce_in|out_nbr
seunghwak Jul 2, 2020
2f553a8
reorder pattern accelerator API input parameters
seunghwak Jul 6, 2020
485de07
tweak pattern accelerator API
seunghwak Jul 6, 2020
b0efe45
add PageRank tests with the pattern accelerator API
seunghwak Jul 6, 2020
fb5442c
tweak katz centrality with the pattern accelerator
seunghwak Jul 8, 2020
03e996c
minor tweak for PageRank test code
seunghwak Jul 8, 2020
4540237
add katz centrality test
seunghwak Jul 8, 2020
c2d50ca
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jul 8, 2020
fd85e21
remove experimental:: from graph classes
seunghwak Jul 8, 2020
b1727ce
style fix (use T{} instead of static_cast<T> for constant values
seunghwak Jul 8, 2020
f8778e9
minor style fix
seunghwak Jul 8, 2020
89b4135
count_if_adj_matrix_row to any_of_adj_matrix_row (adj_matrix_row valu…
seunghwak Jul 8, 2020
a4ca603
AdjMatrixRowFrontier -> VertexFrontier
seunghwak Jul 9, 2020
b570bc8
break update_frontier_v_push_if_out_nbr to two functions (the second …
seunghwak Jul 9, 2020
2ac249e
add pure_function flag to reduce_op (if this is defined and set to tr…
seunghwak Jul 9, 2020
ff44015
add documentation for experimental bfs, sssp, pagerank, and katz_cent…
seunghwak Jul 10, 2020
7210b81
add documentation
seunghwak Jul 14, 2020
847f9b0
rename opg to multi-GPU
seunghwak Jul 14, 2020
c6ed3bd
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Jul 14, 2020
58a280a
resolve merge conflicts
seunghwak Jul 23, 2020
6026d1f
change get_number_of_edges return type from vertex_type to edge_type
seunghwak Aug 8, 2020
6855c25
fix merge conflicts
seunghwak Aug 11, 2020
733defc
fix compile errors
seunghwak Aug 11, 2020
ed35cf7
move the pattern accelerator API out from the detail namespace (this …
seunghwak Aug 11, 2020
f4e46ab
thrust::cuda::par.on(handle.get_stream()) to rmm::exec_policy(handle.…
seunghwak Aug 11, 2020
86ee0dd
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Aug 13, 2020
e2bcae6
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Aug 13, 2020
4782bd0
Merge branch 'branch-0.15' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Aug 13, 2020
be3bea4
fix typo in comments
seunghwak Aug 14, 2020
335ed80
escape code from exp_graph.hpp to graph_device_view.cuh
seunghwak Aug 18, 2020
d0fa8b3
resolve merge conflicts
seunghwak Aug 31, 2020
f54a996
partially update tests to work with the new graph class (more updates…
seunghwak Sep 1, 2020
fdc36c3
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 2, 2020
391994c
temp commit to change branch
seunghwak Sep 2, 2020
b5c6a2f
update tests to use the new graph class
seunghwak Sep 3, 2020
18130af
update algorithm public interface to work with the new graph class
seunghwak Sep 3, 2020
87259a4
update any_of_adj_matrix_row to support MG
seunghwak Sep 4, 2020
e5a34d7
temporary commit for branch change
seunghwak Sep 4, 2020
7b47e1a
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 4, 2020
268aa12
update to work with the new graph class
seunghwak Sep 10, 2020
9f88c70
resolve merge conflicts
seunghwak Sep 10, 2020
68c91d5
fix compile errors
seunghwak Sep 10, 2020
6fc0847
clang-format
seunghwak Sep 10, 2020
9639cb1
replace graph_device_view.cuh with vertex_partition_device.cuh & matr…
seunghwak Sep 10, 2020
9ed3d5a
undo changes in include/graph.hpp, this file is no longer relevant to…
seunghwak Sep 10, 2020
06402f9
additionally undo changes in include/graph.hpp, this file is no longe…
seunghwak Sep 10, 2020
bf20884
remove unnecessary comments
seunghwak Sep 10, 2020
5e34dde
remove unnecessary template parameters
seunghwak Sep 10, 2020
51a24e5
add copy_to_adj_matrix_col
seunghwak Sep 16, 2020
a025538
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 16, 2020
0d5b0a1
replace for loops with thrust algorithms and few minor cosmetic fixes
seunghwak Sep 16, 2020
45cd340
break unnecessary loop carried dependendy
seunghwak Sep 16, 2020
5a9c6ca
bug fix
seunghwak Sep 16, 2020
d3434be
bug fix (previously used plus_thrust_tuple where plus_edge_op_result …
seunghwak Sep 16, 2020
d808c2b
fix erreneous comments
seunghwak Sep 16, 2020
2cfbb93
clang-format
seunghwak Sep 16, 2020
cb54bd5
fixed a bug (copy_v_transform_reduce_nbr worked with only raw pointer…
seunghwak Sep 18, 2020
0854f62
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 18, 2020
9e1484d
update change log
seunghwak Sep 18, 2020
274ea2a
clang-format
seunghwak Sep 18, 2020
6c37b0d
remove cuda.cuh (this is replaced by raft)
seunghwak Sep 18, 2020
b568443
clang-format
seunghwak Sep 18, 2020
8339cb7
clang-format
seunghwak Sep 18, 2020
9aaf731
update raft tag
seunghwak Sep 18, 2020
cfefe63
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 18, 2020
b3f502b
remove unecessary code
seunghwak Sep 19, 2020
ff0b2bf
update sG interface of graph_view.hpp to mirror MG interface
seunghwak Sep 19, 2020
3165637
replace comm_p_row_key & comm_p_col_key with key_naming_t().row_name(…
seunghwak Sep 19, 2020
72c5cbe
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 23, 2020
54227cf
fixed confusing variable names
seunghwak Sep 24, 2020
1132074
Merge branch 'branch-0.16' of github.com:rapidsai/cugraph into fea_pa…
seunghwak Sep 24, 2020
c50f85c
resolve merge conflicts
seunghwak Sep 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## New Features
- PR #1098 Add new graph classes to support 2D partitioning
- PR #1124 Sub-communicator initialization for 2D partitioning support
- PR #838 Add pattern accelerator API functions and pattern accelerator API based implementations of PageRank, Katz Centrality, BFS, and SSSP

## Improvements
- PR 1081 MNMG Renumbering - sort partitions by degree
Expand Down
4 changes: 4 additions & 0 deletions cpp/CMakeLists.txt
Expand Up @@ -337,6 +337,10 @@ add_library(cugraph SHARED
src/centrality/betweenness_centrality.cu
src/experimental/graph.cu
src/experimental/graph_view.cu
src/experimental/bfs.cu
src/experimental/sssp.cu
src/experimental/pagerank.cu
src/experimental/katz_centrality.cu
)

#
Expand Down
175 changes: 175 additions & 0 deletions cpp/include/algorithms.hpp
Expand Up @@ -15,6 +15,7 @@
*/
#pragma once

#include <experimental/graph_view.hpp>
#include <graph.hpp>
#include <internals.hpp>
#include <raft/handle.hpp>
Expand Down Expand Up @@ -936,4 +937,178 @@ void hits(GraphCSRView<VT, ET, WT> const &graph,

} // namespace gunrock

namespace experimental {

/**
* @brief Run breadth-first search to find the distances (and predecessors) from the source
* vertex.
*
* This function computes the distances (minimum number of hops to reach the vertex) from the source
* vertex. If @p predecessors is not `nullptr`, this function calculates the predecessor of each
* vertex (parent vertex in the breadth-first search tree) as well.
*
* @throws cugraph::logic_error on erroneous input arguments.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param distances Pointer to the output distance array.
* @param predecessors Pointer to the output predecessor array or `nullptr`.
* @param source_vertex Source vertex to start breadth-first search (root vertex of the breath-first
* search tree).
* @param direction_optimizing If set to true, this algorithm switches between the push based
* breadth-first search and pull based breadth-first search depending on the size of the
* breadth-first search frontier (currently unsupported). This option is valid only for symmetric
* input graphs.
* @param depth_limit Sets the maximum number of breadth-first search iterations. Any vertices
* farther than @p depth_limit hops from @p source_vertex will be marked as unreachable.
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`).
*/
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
void bfs(raft::handle_t &handle,
graph_view_t<vertex_t, edge_t, weight_t, false, multi_gpu> const &graph_view,
vertex_t *distances,
vertex_t *predecessors,
vertex_t source_vertex,
bool direction_optimizing = false,
vertex_t depth_limit = std::numeric_limits<vertex_t>::max(),
bool do_expensive_check = false);

/**
* @brief Run single-source shortest-path to compute the minimum distances (and predecessors) from
* the source vertex.
*
* This function computes the distances (minimum edge weight sums) from the source vertex. If @p
* predecessors is not `nullptr`, this function calculates the predecessor of each vertex in the
* shortest-path as well. Graph edge weights should be non-negative.
*
* @throws cugraph::logic_error on erroneous input arguments.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param distances Pointer to the output distance array.
* @param predecessors Pointer to the output predecessor array or `nullptr`.
* @param source_vertex Source vertex to start single-source shortest-path.
* @param cutoff Single-source shortest-path terminates if no more vertices are reachable within the
* distance of @p cutoff. Any vertex farther than @p cutoff will be marked as unreachable.
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`).
*/
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
void sssp(raft::handle_t &handle,
graph_view_t<vertex_t, edge_t, weight_t, false, multi_gpu> const &graph_view,
weight_t *distances,
vertex_t *predecessors,
vertex_t source_vertex,
weight_t cutoff = std::numeric_limits<weight_t>::max(),
bool do_expensive_check = false);

/**
* @brief Compute PageRank scores.
*
* This function computes general (if @p personalization_vertices is `nullptr`) or personalized (if
* @p personalization_vertices is not `nullptr`.) PageRank scores.
*
* @throws cugraph::logic_error on erroneous input arguments or if fails to converge before @p
* max_iterations.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @tparam result_t Type of PageRank scores.
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param adj_matrix_row_out_weight_sums Pointer to an array storing sums of out-going edge weights
* for the vertices in the rows of the graph adjacency matrix (for re-use) or `nullptr`. If
* `nullptr`, these values are freshly computed. Computing these values outsid this function reduces
* the number of memoray allocations/deallocations and computing if a user repeatedly computes
* PageRank scores using the same graph with different personalization vectors.
* @param personalization_vertices Pointer to an array storing personalization vertex identifiers
* (compute personalized PageRank) or `nullptr` (compute general PageRank).
* @param personalization_values Pointer to an array storing personalization values for the vertices
* in the personalization set. Relevant only if @p personalization_vertices is not `nullptr`.
* @param personalization_vector_size Size of the personalization set. If @personalization_vertices
* is not `nullptr`, the sizes of the arrays pointed by @p personalization_vertices and @p
* personalization_values should be @p personalization_vector_size.
* @param pageranks Pointer to the output PageRank score array.
* @param alpha PageRank damping factor.
* @param epsilon Error tolerance to check convergence. Convergence is assumed if the sum of the
* differences in PageRank values between two consecutive iterations is less than the number of
* vertices in the graph multiplied by @p epsilon.
* @param max_iterations Maximum number of PageRank iterations.
* @param has_initial_guess If set to `true`, values in the PageRank output array (pointed by @p
* pageranks) is used as initial PageRank values. If false, initial PageRank values are set to 1.0
* divided by the number of vertices in the graph.
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`).
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename result_t, bool multi_gpu>
void pagerank(raft::handle_t &handle,
graph_view_t<vertex_t, edge_t, weight_t, true, multi_gpu> const &graph_view,
weight_t *adj_matrix_row_out_weight_sums,
vertex_t *personalization_vertices,
result_t *personalization_values,
vertex_t personalization_vector_size,
result_t *pageranks,
result_t alpha,
result_t epsilon,
size_t max_iterations = 500,
bool has_initial_guess = false,
bool do_expensive_check = false);

/**
* @brief Compute Katz Centrality scores.
*
* This function computes Katz Centrality scores.
*
* @throws cugraph::logic_error on erroneous input arguments or if fails to converge before @p
* max_iterations.
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @tparam result_t Type of Katz Centrality scores.
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param betas Pointer to an array holding the values to be added to each vertex's new Katz
* Centrality score in every iteration or `nullptr`. If set to `nullptr`, constant @p beta is used
* instead.
* @param katz_centralities Pointer to the output Katz Centrality score array.
* @param alpha Katz Centrality attenuation factor. This should be smaller than the inverse of the
* maximum eigenvalue of the adjacency matrix of @p graph.
* @param beta Constant value to be added to each vertex's new Katz Centrality score in every
* iteration. Relevant only when @p betas is `nullptr`.
* @param epsilon Error tolerance to check convergence. Convergence is assuemd if the sum of the
* differences in Katz Centrality values between two consecutive iterations is less than the number
* of vertices in the graph multiplied by @p epsilon.
* @param max_iterations Maximum number of Katz Centrality iterations.
* @param has_initial_guess If set to `true`, values in the Katz Centrality output array (pointed by
* @p katz_centralities) is used as initial Katz Centrality values. If false, zeros are used as
* initial Katz Centrality values.
* @param normalize If set to `true`, final Katz Centrality scores are normalized (the L2-norm of
* the returned Katz Centrality score array is 1.0) before returning.
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`).
*/
template <typename vertex_t, typename edge_t, typename weight_t, typename result_t, bool multi_gpu>
void katz_centrality(raft::handle_t &handle,
graph_view_t<vertex_t, edge_t, weight_t, true, multi_gpu> const &graph_view,
result_t *betas,
result_t *katz_centralities,
result_t alpha,
result_t beta,
result_t epsilon,
size_t max_iterations = 500,
bool has_initial_guess = false,
bool normalize = false,
bool do_expensive_check = false);

} // namespace experimental

} // namespace cugraph
15 changes: 8 additions & 7 deletions cpp/include/experimental/detail/graph_utils.cuh
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include <experimental/graph_view.hpp>
#include <partition_manager.hpp>

#include <rmm/thrust_rmm_allocator.h>
#include <raft/handle.hpp>
Expand All @@ -39,10 +40,10 @@ rmm::device_uvector<edge_t> compute_major_degree(
std::vector<edge_t const *> const &adj_matrix_partition_offsets,
partition_t<vertex_t> const &partition)
{
auto &comm_p_row = handle.get_subcomm(comm_p_row_key);
auto &comm_p_row = handle.get_subcomm(cugraph::partition_2d::key_naming_t().row_name());
auto const comm_p_row_rank = comm_p_row.get_rank();
auto const comm_p_row_size = comm_p_row.get_size();
auto &comm_p_col = handle.get_subcomm(comm_p_col_key);
auto &comm_p_col = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name());
auto const comm_p_col_rank = comm_p_col.get_rank();
auto const comm_p_col_size = comm_p_col.get_size();

Expand Down Expand Up @@ -74,11 +75,11 @@ rmm::device_uvector<edge_t> compute_major_degree(
vertex_t major_first{};
vertex_t major_last{};
std::tie(major_first, major_last) = partition.get_vertex_partition_range(vertex_partition_idx);
auto p_offsets = partition.is_hypergraph_partitioned()
? adj_matrix_partition_offsets[i]
: adj_matrix_partition_offsets[0] +
(major_first - partition.get_vertex_partition_range_first(
comm_p_col_size * comm_p_row_rank));
auto p_offsets =
partition.is_hypergraph_partitioned()
? adj_matrix_partition_offsets[i]
: adj_matrix_partition_offsets[0] +
(major_first - partition.get_vertex_partition_first(comm_p_col_size * comm_p_row_rank));
thrust::transform(rmm::exec_policy(handle.get_stream())->on(handle.get_stream()),
thrust::make_counting_iterator(vertex_t{0}),
thrust::make_counting_iterator(major_last - major_first),
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/experimental/graph.hpp
Expand Up @@ -72,8 +72,7 @@ class graph_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enab

vertex_t get_number_of_local_vertices() const
{
return partition_.get_vertex_partition_range_last() -
partition_.get_vertex_partition_range_first();
return partition_.get_vertex_partition_last() - partition_.get_vertex_partition_first();
}

graph_view_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu> view()
Expand Down