62 #include <boost/bind.hpp> 
   63 #include <boost/function.hpp> 
   74 #include <boost/interprocess/managed_heap_memory.hpp> 
   82     std::cerr << 
"Usage: -i <string> -s <int>\n" 
   83          << 
" -i <string>   - input graph base filename (required)\n" 
   84          << 
" -s <int>      - Source vertex of BFS (Default is 0)\n" 
   85          << 
" -h            - print help and exit\n\n";
 
   89 void parse_cmd_line(
int argc, 
char** argv, std::string& input_filename, uint64_t& source_vertex) {
 
   91     std::cout << 
"CMD line:";
 
   92     for (
int i=0; i<argc; ++i) {
 
   93       std::cout << 
" " << argv[i];
 
   95     std::cout << std::endl;
 
   98   bool found_input_filename = 
false;
 
  102   bool prn_help = 
false;
 
  103   while ((c = getopt(argc, argv, 
"i:s:h ")) != -1) {
 
  109          source_vertex = atoll(optarg);
 
  112          found_input_filename = 
true;
 
  113          input_filename = optarg;
 
  116          std::cerr << 
"Unrecognized option: "<<c<<
", ignore."<<std::endl;
 
  121    if (prn_help || !found_input_filename) {
 
  127 int main(
int argc, 
char** argv) {
 
  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)
environment * havoqgt_env()
mapped_type::segment_manager segment_manager_type
segment_manager_type * get_segment_manager()
old_environment & get_environment()
uint64_t local_id() const 
int main(int argc, char **argv)
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)