From 26e34ba8a99342157bdde0097e76d948c1659f58 Mon Sep 17 00:00:00 2001 From: Laxman Dhulipala Date: Mon, 9 Dec 2024 18:01:10 +0000 Subject: [PATCH] PR: for directed graphs. --- benchmarks/PageRank/PageRank.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/benchmarks/PageRank/PageRank.h b/benchmarks/PageRank/PageRank.h index 884eea9d..6e9dc327 100644 --- a/benchmarks/PageRank/PageRank.h +++ b/benchmarks/PageRank/PageRank.h @@ -113,7 +113,7 @@ struct PR_Vertex_Reset { template sequence PageRank_edgeMap(Graph& G, double eps = 0.000001, - size_t max_iters = 100) { + size_t max_iters = 100, gbbs::flags flags = 0) { const uintE n = G.n; const double damping = 0.85; @@ -140,27 +140,31 @@ sequence PageRank_edgeMap(Graph& G, double eps = 0.000001, // SpMV edgeMap(G, Frontier, PR_F(p_curr.begin(), p_next.begin(), G), 0, - no_output); + no_output | flags); vertexMap(Frontier, PR_Vertex_F(p_curr.begin(), p_next.begin(), damping, n, dangling_sum, one_over_n)); - // Check convergence: compute L1-norm between p_curr and p_next + // Check convergence: compute L1-norm between p_curr and p_next. auto differences = parlay::delayed_seq( n, [&](size_t i) { return fabs(p_curr[i] - p_next[i]); }); double L1_norm = parlay::reduce(differences); - if (L1_norm < eps) break; + + // Swap p_curr and p_next. The final vector returned will be p_curr. + std::swap(p_curr, p_next); + if (L1_norm < eps) { + break; + } gbbs_debug(std::cout << "L1_norm = " << L1_norm << std::endl;); // Reset p_curr - parallel_for(0, n, [&](size_t i) { p_curr[i] = static_cast(0); }); - std::swap(p_curr, p_next); + parallel_for(0, n, [&](size_t i) { p_next[i] = static_cast(0); }); gbbs_debug(t.stop(); t.next("iteration time");); } - auto max_pr = parlay::reduce_max(p_next); + auto max_pr = parlay::reduce_max(p_curr); std::cout << "max_pr = " << max_pr << std::endl; - return p_next; + return p_curr; } template @@ -227,7 +231,7 @@ sequence PageRank(Graph& G, double eps = 0.000001, timer tt; tt.start(); EM.template edgeMapReduce_dense( - Frontier, cond_f, map_f, reduce_f, apply_f, 0.0, no_output); + Frontier, cond_f, map_f, reduce_f, apply_f, 0.0, no_output | in_edges); tt.stop(); tt.next("em time");