int main(int argc, char *argv[]) { rtc_clock wall_clock; desc.add_options() ("help,h", "Produce help message") ("algorithm,a", boost::program_options::value<std::string>()->default_value("quick_sort"), "Sort algorithm: quick_sort (default), counting_sort") ("source,i", boost::program_options::value<std::string>()->required(), "Name of the input to sort (need input.ini)"); try { boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); boost::program_options::notify(vm); } catch (boost::program_options::error &e) { if (vm.count("help") || argc == 1) { std::cerr << desc << "\n"; } std::cerr << "Error:" << e.what() << std::endl; std::cerr << "Try: " << argv[0] << " --help" << std::endl; exit(-1); } init_graph_desc(vm["source"].as<std::string>()); unsigned char *stream; unsigned long items, record_size; std::stringstream fname; fname << pt.get<std::string>("graph.name"); items = pt.get < unsigned long > ("graph.edges"); int fd_edges = open(fname.str().c_str(), O_RDONLY | O_LARGEFILE); if (fd_edges == -1) { BOOST_LOG_TRIVIAL(fatal) << "Unable to open edges file " << fname.str() << ":" << strerror(errno); exit(-1); } if (pt.get < unsigned long > ("graph.type") == 1) { record_size = format::type1::format_utils::split_size_bytes(); stream = (unsigned char *) map_anon_memory(items * record_size, true, "Sort buffer"); read_from_file(fd_edges, stream, items * record_size); close(fd_edges); } else { BOOST_LOG_TRIVIAL(fatal) << "Unknown file type"; exit(-1); } if (vm["algorithm"].as<std::string>() == "quick_sort") { wall_clock.start(); qsort(stream, items, record_size, compare<format::type1::format_utils>); wall_clock.stop(); } else if (vm["algorithm"].as<std::string>() == "counting_sort") { wall_clock.start(); unsigned long keys = pt.get < unsigned long > ("graph.vertices"); counting_sort<format::type1::format_utils> (stream, (unsigned char *) map_anon_memory(items * record_size, true, "Output buffer"), items, (unsigned long *) map_anon_memory(keys * sizeof(unsigned long), true, "Index"), keys); wall_clock.stop(); } else { BOOST_LOG_TRIVIAL(fatal) << "Don't know how to do " << vm["algorithm"].as<std::string>(); exit(-1); } wall_clock.print("TIME WALL "); return 0; }
int main(int argc, const char* argv[]) { /* Parse the cmd line */ setup_options(argc, argv); BOOST_LOG_TRIVIAL(info) << "STARTUP"; BOOST_LOG_TRIVIAL(info) << "CORE::GRAPH " << vm["graph"].as<std::string>(); BOOST_LOG_TRIVIAL(info) << "CORE::ALGORITHM " << vm["benchmark"].as<std::string>(); /* Read in key graph information */ init_graph_desc(vm["graph"].as<std::string>()); unsigned long blocked_memory = vm["blocked_memory"].as<unsigned long>(); if(blocked_memory > 0) { BOOST_LOG_TRIVIAL(info) << clock::timestamp() << " Blocking memory amount " << blocked_memory; (void)map_anon_memory(blocked_memory, true, "Blockmem"); BOOST_LOG_TRIVIAL(info) << clock::timestamp() << " Done blocking memory"; } /* Only certain combinations of algorithms and formats * are supported. This is encoded below. * Algorithms that require the edge value cannot use format type2 */ if(false); ADD_SG_ALGORITHM(bfs, algorithm::sg_simple::bfs, 1, false); ADD_SG_ALGORITHM(bfs, algorithm::sg_simple::bfs, 2, false); ADD_SGASYNC_ALGORITHM(bfs_async, algorithm::sg_simple::bfs_async, 1, false); ADD_SGASYNC_ALGORITHM(bfs_async, algorithm::sg_simple::bfs_async, 2, false); ADD_SG_ALGORITHM(bfs_forest, algorithm::sg_simple::bfs_forest, 1, false); ADD_SG_ALGORITHM(bfs_forest, algorithm::sg_simple::bfs_forest, 2, false); ADD_SG_ALGORITHM(degree_cnt, algorithm::sg_simple::degree_cnt, 1, false); ADD_SG_ALGORITHM(degree_cnt, algorithm::sg_simple::degree_cnt, 2, false); ADD_SG_ALGORITHM(conductance, algorithm::sg_simple::conductance, 1, false); ADD_SG_ALGORITHM(conductance, algorithm::sg_simple::conductance, 2, false); ADD_SG_ALGORITHM(range_check, algorithm::sg_simple::range_check, 1, false); ADD_SG_ALGORITHM(range_check, algorithm::sg_simple::range_check, 2, false); ADD_ALGORITHM(reverse, algorithm::reverse::reverse, 1, false); ADD_ALGORITHM(reverse, algorithm::reverse::reverse, 2, false); ADD_SG_ALGORITHM(spmv, algorithm::sg_simple::spmv, 1, false); ADD_SG_ALGORITHM(sssp, algorithm::sg_simple::sssp, 1, false); ADD_SG_ALGORITHM(sssp_forest, algorithm::sg_simple::sssp_forest, 1, false); ADD_SG_ALGORITHM(cc, algorithm::sg_simple::cc, 1, false); ADD_SG_ALGORITHM(cc, algorithm::sg_simple::cc, 2, false); ADD_ALGORITHM(cc_online, algorithm::cc_online_ns::cc_online, 1, false); ADD_ALGORITHM(cc_online, algorithm::cc_online_ns::cc_online, 2, false); // Uncomment for ALS //ADD_SG_ALGORITHM(als, algorithm::sg_simple::als_factorization, 1, false); //ADD_SGASYNC_ALGORITHM(als_async, algorithm::sg_simple::als_async_factorization, 1, false); // ADD_SG_ALGORITHM(checkbip, algorithm::sg_simple::check_if_bipartite, 1, false); ADD_SG_ALGORITHM(mis, algorithm::sg_simple::mis, 1, false); ADD_SG_ALGORITHM(mis, algorithm::sg_simple::mis, 2, false); ADD_SG_ALGORITHM(pagerank, algorithm::sg_simple::pagerank, 1, false); ADD_SG_ALGORITHM(pagerank, algorithm::sg_simple::pagerank, 2, false); ADD_SG_ALGORITHM(pagerank_ddf, algorithm::sg_simple::pagerank_ddf, 1, false); ADD_SG_ALGORITHM(pagerank_ddf, algorithm::sg_simple::pagerank_ddf, 2, false); ADD_ALGORITHM(belief_propagation, algorithm::belief_prop::standard::belief_propagation, 1, false); ADD_ALGORITHM(belief_propagation_graphchi, algorithm::belief_prop::graphchi::belief_propagation_graphchi, 1, false); ADD_ALGORITHM(belief_propagation_graphchi, algorithm::belief_prop::graphchi::belief_propagation_graphchi, 2, false); ADD_ALGORITHM(mcst, algorithm::mcst::mcst, 1, false); ADD_SG_ALGORITHM(hyperanf, algorithm::sg_simple::hyperanf, 1, false); ADD_SG_ALGORITHM(hyperanf, algorithm::sg_simple::hyperanf, 2, false); ADD_ALGORITHM(scc, algorithm::scc::scc, 1, false); ADD_ALGORITHM(scc, algorithm::scc::scc, 2, false); ADD_ALGORITHM(triangle_counting, algorithm::triangle_counting::triangle_counting, 1, false); ADD_ALGORITHM(triangle_counting, algorithm::triangle_counting::triangle_counting, 2, false); ADD_ALGORITHM(bc, algorithm::bc::bc, 1, false); else {