]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph_parallel/test/distributed_rmat_pagerank.cpp
1 // Copyright (C) 2006 The Trustees of Indiana University.
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // Authors: Brian Barrett
11 #include <boost/graph/use_mpi.hpp>
12 #include <boost/config.hpp>
13 #include <boost/throw_exception.hpp>
14 #include <boost/graph/distributed/adjacency_list.hpp>
15 #include <boost/graph/distributed/compressed_sparse_row_graph.hpp>
16 #include <boost/property_map/parallel/distributed_property_map.hpp>
17 #include <boost/graph/distributed/mpi_process_group.hpp>
18 #include <boost/graph/distributed/concepts.hpp>
19 #include <boost/graph/distributed/page_rank.hpp>
20 #include <boost/graph/rmat_graph_generator.hpp>
21 #include <boost/random/linear_congruential.hpp>
22 #include <boost/graph/graphviz.hpp>
23 #include <boost/property_map/vector_property_map.hpp>
29 #ifdef BOOST_NO_EXCEPTIONS
31 boost::throw_exception(std::exception
const& ex
)
33 std::cout
<< ex
.what() << std::endl
;
38 using namespace boost
;
39 using boost::graph::distributed::mpi_process_group
;
41 typedef double time_type
;
43 inline time_type
get_time()
48 std::string
print_time(time_type t
)
50 std::ostringstream out
;
51 out
<< std::setiosflags(std::ios::fixed
) << std::setprecision(2) << t
;
56 test_filtered_rmat_pagerank(int n
, int m
, double a
, double b
, double c
, double d
, int iters
)
59 std::size_t id
= process_id(pg
);
61 if (id
== 0) printf("INFO: Params: n=%d, m=%d, a=%f, b=%f, c=%f, d=%f, iters=%d.\n",
62 n
, m
, a
, b
, c
, d
, iters
);
64 typedef parallel::variant_distribution
<mpi_process_group
> Distribution
;
65 Distribution distrib
= parallel::block(pg
, n
);
67 typedef adjacency_list
<vecS
,
68 distributedS
<mpi_process_group
, vecS
>,
69 bidirectionalS
> Graph
;
71 typedef scalable_rmat_iterator
<mpi_process_group
, Distribution
, rand48
, Graph
>
74 if (id
== 0) printf("INFO: Generating graph.\n");
77 Graph
g(RMATIter(pg
, distrib
, gen
, n
, m
, a
, b
, c
, d
, true),
78 RMATIter(), n
, pg
, distrib
);
82 if (id
== 0) printf("INFO: Starting PageRank.\n");
84 std::vector
<double> ranks(num_vertices(g
));
86 time_type start
= get_time();
87 page_rank(g
, make_iterator_property_map(ranks
.begin(), get(boost::vertex_index
, g
)),
88 graph::n_iterations(iters
), 0.85, n
);
89 time_type end
= get_time();
91 if (process_id(g
.process_group()) == 0) {
92 std::cout
<< "INFO: Test Complete. time = " <<
93 print_time(end
- start
) << "s." << std::endl
;
94 printf("RESULT: %d %d %d %f %f %f %f %f\n",
95 num_processes(pg
), n
, m
, a
, b
, c
, d
, end
- start
);
101 main(int argc
, char* argv
[])
103 mpi::environment
env(argc
, argv
);
106 test_filtered_rmat_pagerank(40, 200, 0.58, 0.19, 0.19, 0.04, 10);
108 test_filtered_rmat_pagerank(atoi(argv
[1]), atoi(argv
[2]), atof(argv
[3]),
109 atof(argv
[4]), atof(argv
[5]), atof(argv
[6]),