Skip to content

Commit

Permalink
Merge pull request #947 from afender/opg_csr_pagerank
Browse files Browse the repository at this point in the history
[REVIEW] OPG pagerank (CUDA)
  • Loading branch information
BradReesWork authored Jun 23, 2020
2 parents 9f71b90 + f9671c7 commit bc48a35
Show file tree
Hide file tree
Showing 16 changed files with 452 additions and 292 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## New Features
- PR #937 Add wrapper for gunrock HITS algorithm
- PR #939 Updated Notebooks to include new features and benchmarks
- PR #944 opg pagerank dask
- PR #944 OPG pagerank (dask)
- PR #947 OPG pagerank (CUDA)

## Improvements
- PR #898 Add Edge Betweenness Centrality, and endpoints to BC
Expand Down
14 changes: 2 additions & 12 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags")
option(BUILD_TESTS "Configure CMake to build tests"
ON)

option(BUILD_MPI "Build with MPI" OFF)
if (BUILD_MPI)
find_package(MPI REQUIRED)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
endif(BUILD_MPI)
###################################################################################################
# - cmake modules ---------------------------------------------------------------------------------

Expand Down Expand Up @@ -305,8 +298,10 @@ add_library(cugraph SHARED
src/db/db_parser_integration_test.cu
src/db/db_operators.cu
src/utilities/cusparse_helper.cu
src/utilities/spmv_1D.cu
src/structure/graph.cu
src/link_analysis/pagerank.cu
src/link_analysis/pagerank_1D.cu
src/link_analysis/gunrock_hits.cpp
src/traversal/bfs.cu
src/traversal/sssp.cu
Expand Down Expand Up @@ -346,10 +341,6 @@ add_library(cugraph SHARED
add_dependencies(cugraph cugunrock)
add_dependencies(cugraph raft)

if (BUILD_MPI)
add_compile_definitions(ENABLE_OPG=1)
endif (BUILD_MPI)

###################################################################################################
# - include paths ---------------------------------------------------------------------------------
target_include_directories(cugraph
Expand All @@ -367,7 +358,6 @@ target_include_directories(cugraph
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CUGUNROCK_DIR}/include"
"${NCCL_INCLUDE_DIRS}"
"${MPI_CXX_INCLUDE_PATH}"
"${RAFT_DIR}/cpp/include"
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include"
Expand Down
58 changes: 31 additions & 27 deletions cpp/include/algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace cugraph {
* when the tolerance descreases and/or alpha increases toward the limiting value of 1.
* The user is free to use default values or to provide inputs for the initial guess,
* tolerance and maximum number of iterations.
*
* @throws cugraph::logic_error with a custom message when an error
occurs.
Expand All @@ -38,7 +39,9 @@ namespace cugraph {
32-bit)
* @tparam WT Type of edge weights. Supported value : float or double.
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] handle Library handle (RAFT). If a communicator is set in the handle,
the multi GPU version will be selected.
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
information as a transposed adjacency list (CSC). Edge weights are not used for this algorithm.
* @param[in] alpha The damping factor alpha represents the probability to follow
an outgoing edge, standard value is 0.85. Thus, 1.0-alpha is the probability to “teleport” to a
Expand All @@ -48,29 +51,30 @@ namespace cugraph {
* @param[in] pagerank Array of size V. Should contain the initial guess if
has_guess=true. In this case the initial guess cannot be the vector of 0s. Memory is provided and
owned by the caller.
* @param[in] personalization_subset_size (optional) The number of vertices for to personalize.
Initialized to 0 by default.
* @param[in] personalization_subset (optional) Array of size personalization_subset_size containing
vertices for running personalized pagerank. Initialized to nullptr by default. Memory is provided
and owned by the caller.
* @param[in] personalization_values (optional) Array of size personalization_subset_size containing
values associated with personalization_subset vertices. Initialized to nullptr by default. Memory
is provided and owned by the caller.
* @param[in] tolerance Set the tolerance the approximation, this parameter should be a
small magnitude value.
* @param[in] personalization_subset_size (optional) Supported on single-GPU, on the roadmap for
Multi-GPU. The number of vertices for to personalize. Initialized to 0 by default.
* @param[in] personalization_subset (optional) Supported on single-GPU, on the roadmap for
Multi-GPU..= Array of size personalization_subset_size containing vertices for running personalized
pagerank. Initialized to nullptr by default. Memory is provided and owned by the caller.
* @param[in] personalization_values (optional) Supported on single-GPU, on the roadmap for
Multi-GPU. Array of size personalization_subset_size containing values associated with
personalization_subset vertices. Initialized to nullptr by default. Memory is provided and owned by
the caller.
* @param[in] tolerance Supported on single-GPU. Set the tolerance the approximation,
this parameter should be a small magnitude value.
* The lower the tolerance the better the approximation. If this
value is 0.0f, cuGRAPH will use the default value which is 1.0E-5.
value is 0.0f, cuGraph will use the default value which is 1.0E-5.
* Setting too small a tolerance can lead to non-convergence due
to numerical roundoff. Usually values between 0.01 and 0.00001 are acceptable.
* @param[in] max_iter (optional) The maximum number of iterations before an answer is
returned. This can be used to limit the execution time and do an early exit before the solver
reaches the convergence tolerance.
* If this value is lower or equal to 0 cuGRAPH will use the
* If this value is lower or equal to 0 cuGraph will use the
default value, which is 500.
* @param[in] has_guess (optional) This parameter is used to notify cuGRAPH if it
should use a user-provided initial guess. False means the user does not have a guess, in this case
cuGRAPH will use a uniform vector set to 1/V.
* If the value is True, cuGRAPH will read the pagerank parameter
* @param[in] has_guess (optional) Supported on single-GPU. This parameter is used to
notify cuGraph if it should use a user-provided initial guess. False means the user does not have a
guess, in this case cuGraph will use a uniform vector set to 1/V.
* If the value is True, cuGraph will read the pagerank parameter
and use this as an initial guess.
* @param[out] *pagerank The PageRank : pagerank[i] is the PageRank of vertex i. Memory
remains provided and owned by the caller.
Expand Down Expand Up @@ -204,7 +208,7 @@ void overlap_list(experimental::GraphCSRView<VT, ET, WT> const &graph,
* @tparam WT Type of edge weights. Supported values : float or
* double.
*
* @param[in] graph cuGRAPH graph descriptor, should contain the
* @param[in] graph cuGraph graph descriptor, should contain the
* connectivity information as a COO. Graph is considered undirected. Edge weights are used for this
* algorithm and set to 1 by default.
* @param[out] pos Device array (2, n) containing x-axis and y-axis
Expand Down Expand Up @@ -279,7 +283,7 @@ void force_atlas2(experimental::GraphCOOView<VT, ET, WT> &graph,
* @tparam result_t Type of computed result. Supported values : float or double
* (double only supported in default implementation)
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a CSR
* @param[out] result Device array of centrality scores
* @param[in] normalized If true, return normalized scores, if false return unnormalized
Expand Down Expand Up @@ -321,7 +325,7 @@ void betweenness_centrality(experimental::GraphCSRView<VT, ET, WT> const &graph,
* @tparam result_t Type of computed result. Supported values : float or double
* (double only supported in default implementation)
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a CSR
* @param[out] result Device array of centrality scores
* @param[in] normalized If true, return normalized scores, if false return unnormalized
Expand Down Expand Up @@ -371,7 +375,7 @@ enum class cugraph_cc_t {
* @tparam ET Type of edge identifiers. Supported value : int (signed, 32-bit)
* @tparam WT Type of edge weights. Supported values : float or double.
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a CSR
* @param[in] connectivity_type STRONG or WEAK
* @param[out] labels Device array of component labels (labels[i] indicates the label
Expand Down Expand Up @@ -399,7 +403,7 @@ void connected_components(experimental::GraphCSRView<VT, ET, WT> const &graph,
* 32-bit)
* @tparam WT Type of edge weights. Supported values : float or double.
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a COO
* @param[in] k The order of the truss
* @param[in] mr Memory resource used to allocate the returned graph
Expand All @@ -425,7 +429,7 @@ std::unique_ptr<experimental::GraphCOO<VT, ET, WT>> k_truss_subgraph(
* @tparam WT Type of edge weights. Supported values : float or double.
* @tparam result_t Type of computed result. Supported values : float
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a CSR
* @param[out] result Device array of centrality scores
* @param[in] alpha Attenuation factor with a default value of 0.1. Alpha is set to
Expand Down Expand Up @@ -456,7 +460,7 @@ void katz_centrality(experimental::GraphCSRView<VT, ET, WT> const &graph,
/**
* @brief Compute the Core Number for the nodes of the graph G
*
* @param[in] graph cuGRAPH graph descriptor with a valid edgeList or adjList
* @param[in] graph cuGraph graph descriptor with a valid edgeList or adjList
* @param[out] core_number Populated by the core number of every vertex in the graph
*
* @throws cugraph::logic_error when an error occurs.
Expand All @@ -476,7 +480,7 @@ void core_number(experimental::GraphCSRView<VT, ET, WT> const &graph, VT *core_n
* 32-bit)
* @tparam WT Type of edge weights. Supported values : float or double.
*
* @param[in] graph cuGRAPH graph in coordinate format
* @param[in] graph cuGraph graph in coordinate format
* @param[in] k Order of the core. This value must not be negative.
* @param[in] vertex_id User specified vertex identifiers for which core number values
* are supplied
Expand Down Expand Up @@ -527,7 +531,7 @@ std::unique_ptr<cugraph::experimental::GraphCOO<VT, ET, WT>> get_two_hop_neighbo
* 32-bit)
* @tparam WT Type of edge weights. Supported values : float or double.
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a CSR
*
* @param[out] distances If set to a valid pointer, array of size V populated by distance
Expand Down Expand Up @@ -560,7 +564,7 @@ void sssp(experimental::GraphCSRView<VT, ET, WT> const &graph,
* 32-bit)
* @tparam WT Type of edge weights. Supported values : int (signed, 32-bit)
*
* @param[in] graph cuGRAPH graph descriptor, should contain the connectivity
* @param[in] graph cuGraph graph descriptor, should contain the connectivity
* information as a CSR
*
* @param[out] distances If set to a valid pointer, this is populated by distance of
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace cugraph {
* @tparam ET type of edge index
* @tparam WT type of the edge weight
*
* @param[in] graph cuGRAPH graph in coordinate format
* @param[in] graph cuGraph graph in coordinate format
* @param[in] mr Memory resource used to allocate the returned graph
*
* @return Unique pointer to generate Compressed Sparse Row graph
Expand Down
1 change: 1 addition & 0 deletions cpp/include/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
#pragma once
#include <unistd.h>
#include <cstddef>
#include <cstdint>
#include <iostream>
Expand Down
37 changes: 21 additions & 16 deletions cpp/src/link_analysis/pagerank.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <utilities/error.hpp>

#include <graph.hpp>
#include "pagerank_1D.cuh"
#include "utilities/graph_utils.cuh"

namespace cugraph {
Expand Down Expand Up @@ -352,23 +353,27 @@ void pagerank(raft::handle_t const &handle,
bool has_guess)
{
CUGRAPH_EXPECTS(pagerank != nullptr, "Invalid API parameter: Pagerank array should be of size V");

// Multi-GPU
if (handle.comms_initialized()) {
std::cout << "\nINSIDE CPP\n";
auto &comm = handle.get_comms();
std::cout << comm.get_rank() << "\n";
std::cout << comm.get_size() << "\n";
return;
}
return detail::pagerank_impl<VT, ET, WT>(graph,
pagerank,
personalization_subset_size,
personalization_subset,
personalization_values,
alpha,
tolerance,
max_iter,
has_guess);
CUGRAPH_EXPECTS(personalization_subset == nullptr,
"Invalid API parameter: Multi-GPU Pagerank does not support Personalized "
"variant currently, please use the single GPU version for this feature. The "
"multi-GPU support is comming.");
CUGRAPH_EXPECTS(has_guess == false,
"Invalid API parameter: Multi-GPU Pagerank does not guess, please use the "
"single GPU version for this feature");
CUGRAPH_EXPECTS(max_iter > 0, "The number of iteration must be positive");
return cugraph::opg::pagerank<VT, ET, WT>(handle, graph, pagerank, alpha, max_iter);
} else // Single GPU
return detail::pagerank_impl<VT, ET, WT>(graph,
pagerank,
personalization_subset_size,
personalization_subset,
personalization_values,
alpha,
tolerance,
max_iter,
has_guess);
}

// explicit instantiation
Expand Down
Loading

0 comments on commit bc48a35

Please sign in to comment.