131 int mpi_rank(0), mpi_size(0);
135 CHK_MPI(MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank));
136 CHK_MPI(MPI_Comm_size(MPI_COMM_WORLD, &mpi_size));
140 std::cout <<
"MPI initialized with " << mpi_size <<
" ranks." << std::endl;
144 MPI_Barrier(MPI_COMM_WORLD);
147 std::string graph_input;
148 uint64_t source_vertex = 0;
152 MPI_Barrier(MPI_COMM_WORLD);
157 find<graph_type>(
"graph_obj").first;
158 assert(graph !=
nullptr);
160 MPI_Barrier(MPI_COMM_WORLD);
162 std::cout <<
"Graph Loaded Ready." << std::endl;
165 MPI_Barrier(MPI_COMM_WORLD);
173 MPI_Barrier(MPI_COMM_WORLD);
175 std::cout <<
"BFS data allocated. Starting BFS from vertex " << source_vertex << std::endl;
181 uint64_t isource = source_vertex;
183 uint64_t global_degree(0);
185 uint64_t local_degree = 0;
186 source = graph->label_to_locator(isource);
190 if (uint32_t(mpi_rank) == source.
owner()) {
191 local_degree = graph->degree(source);
193 global_degree =
mpi_all_reduce(local_degree, std::greater<uint64_t>(),
195 if(global_degree == 0) ++isource;
196 }
while (global_degree == 0);
197 if (uint32_t(mpi_rank) == source.
owner()) {
198 if(isource != source_vertex) {
199 std::cout <<
"Vertex " << source_vertex <<
" has a degree of 0. New source vertex = " << isource << std::endl;
201 std::cout <<
"Starting vertex = " << isource << std::endl;
203 std::cout <<
"delegate? = " << source.
is_delegate() << std::endl;
204 std::cout <<
"local_id = " << source.
local_id() << std::endl;
205 std::cout <<
"degree = " << graph->degree(source) << std::endl;
208 bfs_level_data.reset(128);
210 MPI_Barrier(MPI_COMM_WORLD);
211 double time_start = MPI_Wtime();
214 MPI_Barrier(MPI_COMM_WORLD);
215 double time_end = MPI_Wtime();
217 uint64_t visited_total(0);
218 for (uint64_t level = 0; level < 15; ++level) {
219 uint64_t local_count(0);
221 for (vitr = graph->vertices_begin();
222 vitr != graph->vertices_end();
224 if (bfs_level_data[*vitr] == level) {
231 for (citr = graph->controller_begin();
232 citr != graph->controller_end();
234 if (bfs_level_data[*citr] == level) {
240 std::plus<uint64_t>(), MPI_COMM_WORLD);
241 visited_total += global_count;
242 if (mpi_rank == 0 && global_count > 0) {
243 std::cout <<
"Level " << level <<
": " << global_count << std::endl;
245 if (global_count == 0) {
251 if (visited_total > 1) {
253 <<
"Visited total = " << visited_total << std::endl
254 <<
"BFS Time = " << time_end - time_start << std::endl;
255 time += time_end - time_start;
260 std::cout <<
"Count BFS = " << count << std::endl;
261 std::cout <<
"AVERAGE BFS = " << time / double(count) << std::endl;
hmpi::delegate_partitioned_graph< segment_manager_t > graph_type
bip::vector< vertex_locator, SegmentAllocator< vertex_locator > >::const_iterator controller_iterator
T mpi_all_reduce(T in_d, Op in_op, MPI_Comm mpi_comm)
mapped_type::segment_manager segment_manager_type
segment_manager_type * get_segment_manager()
old_environment & get_environment()
uint64_t local_id() const
void breadth_first_search(TGraph *g, LevelData &level_data, ParentData &parent_data, typename TGraph::vertex_locator s)
void parse_cmd_line(int argc, char **argv, std::string &input_filename, uint64_t &source_vertex)
havoqgt::distributed_db::segment_manager_type segment_manager_t
void havoqgt_init(int *argc, char ***argv)