Skip to content

Commit

Permalink
Update C++ MG PageRank test (#1419)
Browse files Browse the repository at this point in the history
- [x] Add tests using graphs with isolated vertices
- [x] Add personalized PageRank tests
- [x] Test code refactoring
- [x] Create libcugraphtestutil.a

This PR fixes FIXMEs added in #1361 to address #1136

Authors:
  - Seunghwa Kang (@seunghwak)

Approvers:
  - Rick Ratzel (@rlratzel)
  - Andrei Schaffer (@aschaffer)
  - Brad Rees (@BradReesWork)

URL: #1419
  • Loading branch information
seunghwak authored Mar 1, 2021
1 parent ca89594 commit 0adc558
Show file tree
Hide file tree
Showing 24 changed files with 1,337 additions and 1,157 deletions.
8 changes: 4 additions & 4 deletions cpp/include/algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,9 @@ void sssp(raft::handle_t const &handle,
template <typename vertex_t, typename edge_t, typename weight_t, typename result_t, bool multi_gpu>
void pagerank(raft::handle_t const &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,
weight_t const *adj_matrix_row_out_weight_sums,
vertex_t const *personalization_vertices,
result_t const *personalization_values,
vertex_t personalization_vector_size,
result_t *pageranks,
result_t alpha,
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void pagerank(raft::handle_t const &handle,
template <typename vertex_t, typename edge_t, typename weight_t, typename result_t, bool multi_gpu>
void katz_centrality(raft::handle_t const &handle,
graph_view_t<vertex_t, edge_t, weight_t, true, multi_gpu> const &graph_view,
result_t *betas,
result_t const *betas,
result_t *katz_centralities,
result_t alpha,
result_t beta,
Expand Down
8 changes: 8 additions & 0 deletions cpp/include/experimental/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class graph_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enab
static constexpr bool is_adj_matrix_transposed = store_transposed;
static constexpr bool is_multi_gpu = multi_gpu;

graph_t(raft::handle_t const &handle) : detail::graph_base_t<vertex_t, edge_t, weight_t>() {}

graph_t(raft::handle_t const &handle,
std::vector<edgelist_t<vertex_t, edge_t, weight_t>> const &edgelists,
partition_t<vertex_t> const &partition,
Expand Down Expand Up @@ -123,6 +125,12 @@ class graph_t<vertex_t, edge_t, weight_t, store_transposed, multi_gpu, std::enab
static constexpr bool is_adj_matrix_transposed = store_transposed;
static constexpr bool is_multi_gpu = multi_gpu;

graph_t(raft::handle_t const &handle)
: detail::graph_base_t<vertex_t, edge_t, weight_t>(),
offsets_(0, handle.get_stream()),
indices_(0, handle.get_stream()),
weights_(0, handle.get_stream()){};

graph_t(raft::handle_t const &handle,
edgelist_t<vertex_t, edge_t, weight_t> const &edgelist,
vertex_t number_of_vertices,
Expand Down
4 changes: 4 additions & 0 deletions cpp/include/experimental/graph_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ namespace experimental {
template <typename vertex_t>
class partition_t {
public:
partition_t() = default;

partition_t(std::vector<vertex_t> const& vertex_partition_offsets,
bool hypergraph_partitioned,
int row_comm_size,
Expand Down Expand Up @@ -247,6 +249,8 @@ size_t constexpr num_segments_per_vertex_partition{3};
template <typename vertex_t, typename edge_t, typename weight_t>
class graph_base_t {
public:
graph_base_t() = default;

graph_base_t(raft::handle_t const& handle,
vertex_t number_of_vertices,
edge_t number_of_edges,
Expand Down
28 changes: 14 additions & 14 deletions cpp/src/experimental/katz_centrality.cu
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace detail {
template <typename GraphViewType, typename result_t>
void katz_centrality(raft::handle_t const &handle,
GraphViewType const &pull_graph_view,
result_t *betas,
result_t const *betas,
result_t *katz_centralities,
result_t alpha,
result_t beta, // relevant only if betas == nullptr
Expand Down Expand Up @@ -173,7 +173,7 @@ void katz_centrality(raft::handle_t const &handle,
template <typename vertex_t, typename edge_t, typename weight_t, typename result_t, bool multi_gpu>
void katz_centrality(raft::handle_t const &handle,
graph_view_t<vertex_t, edge_t, weight_t, true, multi_gpu> const &graph_view,
result_t *betas,
result_t const *betas,
result_t *katz_centralities,
result_t alpha,
result_t beta, // relevant only if beta == nullptr
Expand All @@ -200,7 +200,7 @@ void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int32_t, float, true, true> const &graph_view,
float *betas,
float const *betas,
float *katz_centralities,
float alpha,
float beta,
Expand All @@ -212,7 +212,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int32_t, double, true, true> const &graph_view,
double *betas,
double const *betas,
double *katz_centralities,
double alpha,
double beta,
Expand All @@ -224,7 +224,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int64_t, float, true, true> const &graph_view,
float *betas,
float const *betas,
float *katz_centralities,
float alpha,
float beta,
Expand All @@ -236,7 +236,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int64_t, double, true, true> const &graph_view,
double *betas,
double const *betas,
double *katz_centralities,
double alpha,
double beta,
Expand All @@ -248,7 +248,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int64_t, int64_t, float, true, true> const &graph_view,
float *betas,
float const *betas,
float *katz_centralities,
float alpha,
float beta,
Expand All @@ -260,7 +260,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int64_t, int64_t, double, true, true> const &graph_view,
double *betas,
double const *betas,
double *katz_centralities,
double alpha,
double beta,
Expand All @@ -272,7 +272,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int32_t, float, true, false> const &graph_view,
float *betas,
float const *betas,
float *katz_centralities,
float alpha,
float beta,
Expand All @@ -284,7 +284,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int32_t, double, true, false> const &graph_view,
double *betas,
double const *betas,
double *katz_centralities,
double alpha,
double beta,
Expand All @@ -296,7 +296,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int64_t, float, true, false> const &graph_view,
float *betas,
float const *betas,
float *katz_centralities,
float alpha,
float beta,
Expand All @@ -308,7 +308,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int32_t, int64_t, double, true, false> const &graph_view,
double *betas,
double const *betas,
double *katz_centralities,
double alpha,
double beta,
Expand All @@ -320,7 +320,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int64_t, int64_t, float, true, false> const &graph_view,
float *betas,
float const *betas,
float *katz_centralities,
float alpha,
float beta,
Expand All @@ -332,7 +332,7 @@ template void katz_centrality(raft::handle_t const &handle,

template void katz_centrality(raft::handle_t const &handle,
graph_view_t<int64_t, int64_t, double, true, false> const &graph_view,
double *betas,
double const *betas,
double *katz_centralities,
double alpha,
double beta,
Expand Down
84 changes: 42 additions & 42 deletions cpp/src/experimental/pagerank.cu
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ namespace detail {
template <typename GraphViewType, typename result_t>
void pagerank(raft::handle_t const& handle,
GraphViewType const& pull_graph_view,
typename GraphViewType::weight_type* precomputed_vertex_out_weight_sums,
typename GraphViewType::vertex_type* personalization_vertices,
result_t* personalization_values,
typename GraphViewType::weight_type const* precomputed_vertex_out_weight_sums,
typename GraphViewType::vertex_type const* personalization_vertices,
result_t const* personalization_values,
typename GraphViewType::vertex_type personalization_vector_size,
result_t* pageranks,
result_t alpha,
Expand Down Expand Up @@ -279,9 +279,9 @@ void pagerank(raft::handle_t const& handle,
template <typename vertex_t, typename edge_t, typename weight_t, typename result_t, bool multi_gpu>
void pagerank(raft::handle_t const& handle,
graph_view_t<vertex_t, edge_t, weight_t, true, multi_gpu> const& graph_view,
weight_t* precomputed_vertex_out_weight_sums,
vertex_t* personalization_vertices,
result_t* personalization_values,
weight_t const* precomputed_vertex_out_weight_sums,
vertex_t const* personalization_vertices,
result_t const* personalization_values,
vertex_t personalization_vector_size,
result_t* pageranks,
result_t alpha,
Expand All @@ -308,9 +308,9 @@ void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, float, true, true> const& graph_view,
float* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
float* personalization_values,
float const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
float const* personalization_values,
int32_t personalization_vector_size,
float* pageranks,
float alpha,
Expand All @@ -321,9 +321,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, double, true, true> const& graph_view,
double* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
double* personalization_values,
double const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
double const* personalization_values,
int32_t personalization_vector_size,
double* pageranks,
double alpha,
Expand All @@ -334,9 +334,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, float, true, true> const& graph_view,
float* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
float* personalization_values,
float const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
float const* personalization_values,
int32_t personalization_vector_size,
float* pageranks,
float alpha,
Expand All @@ -347,9 +347,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, double, true, true> const& graph_view,
double* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
double* personalization_values,
double const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
double const* personalization_values,
int32_t personalization_vector_size,
double* pageranks,
double alpha,
Expand All @@ -360,9 +360,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, float, true, true> const& graph_view,
float* precomputed_vertex_out_weight_sums,
int64_t* personalization_vertices,
float* personalization_values,
float const* precomputed_vertex_out_weight_sums,
int64_t const* personalization_vertices,
float const* personalization_values,
int64_t personalization_vector_size,
float* pageranks,
float alpha,
Expand All @@ -373,9 +373,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, double, true, true> const& graph_view,
double* precomputed_vertex_out_weight_sums,
int64_t* personalization_vertices,
double* personalization_values,
double const* precomputed_vertex_out_weight_sums,
int64_t const* personalization_vertices,
double const* personalization_values,
int64_t personalization_vector_size,
double* pageranks,
double alpha,
Expand All @@ -386,9 +386,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, float, true, false> const& graph_view,
float* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
float* personalization_values,
float const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
float const* personalization_values,
int32_t personalization_vector_size,
float* pageranks,
float alpha,
Expand All @@ -399,9 +399,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, double, true, false> const& graph_view,
double* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
double* personalization_values,
double const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
double const* personalization_values,
int32_t personalization_vector_size,
double* pageranks,
double alpha,
Expand All @@ -412,9 +412,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, float, true, false> const& graph_view,
float* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
float* personalization_values,
float const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
float const* personalization_values,
int32_t personalization_vector_size,
float* pageranks,
float alpha,
Expand All @@ -425,9 +425,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, double, true, false> const& graph_view,
double* precomputed_vertex_out_weight_sums,
int32_t* personalization_vertices,
double* personalization_values,
double const* precomputed_vertex_out_weight_sums,
int32_t const* personalization_vertices,
double const* personalization_values,
int32_t personalization_vector_size,
double* pageranks,
double alpha,
Expand All @@ -438,9 +438,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, float, true, false> const& graph_view,
float* precomputed_vertex_out_weight_sums,
int64_t* personalization_vertices,
float* personalization_values,
float const* precomputed_vertex_out_weight_sums,
int64_t const* personalization_vertices,
float const* personalization_values,
int64_t personalization_vector_size,
float* pageranks,
float alpha,
Expand All @@ -451,9 +451,9 @@ template void pagerank(raft::handle_t const& handle,

template void pagerank(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, double, true, false> const& graph_view,
double* precomputed_vertex_out_weight_sums,
int64_t* personalization_vertices,
double* personalization_values,
double const* precomputed_vertex_out_weight_sums,
int64_t const* personalization_vertices,
double const* personalization_values,
int64_t personalization_vector_size,
double* pageranks,
double alpha,
Expand Down
Loading

0 comments on commit 0adc558

Please sign in to comment.