/** * KMetis Algorithm */ void partition(MetisGraph* metisGraph, int nparts) { int coarsenTo = (int) max(metisGraph->getNumNodes() / (40 * intlog2(nparts)), 20 * (nparts)); int maxVertexWeight = (int) (1.5 * ((metisGraph->getNumNodes()) / (double) coarsenTo)); Coarsener coarsener(false, coarsenTo, maxVertexWeight); Galois::StatTimer T; T.start(); Galois::Timer t; t.start(); MetisGraph* mcg = coarsener.coarsen(metisGraph); t.stop(); cout<<"coarsening time: " << t.get() << " ms"<<endl; float* totalPartitionWeights = new float[nparts]; std::fill_n(totalPartitionWeights, nparts, 1 / (float) nparts); maxVertexWeight = (int) (1.5 * ((mcg->getNumNodes()) / COARSEN_FRACTION)); PMetis pmetis(20, maxVertexWeight); Galois::Timer init_part_t; init_part_t.start(); pmetis.mlevelRecursiveBisection(mcg, nparts, totalPartitionWeights, 0, 0); init_part_t.stop(); cout << "initial partition time: "<< init_part_t.get() << " ms"<<endl; Galois::Timer refine_t; std::fill_n(totalPartitionWeights, nparts, 1 / (float) nparts); refine_t.start(); refineKWay(mcg, metisGraph, totalPartitionWeights, (float) 1.03, nparts); refine_t.stop(); cout << "refine time: " << refine_t.get() << " ms"<<endl; delete[] totalPartitionWeights; T.stop(); }
int main(int argc, char** argv) { Galois::StatManager M; bool serial = false; LonestarStart(argc, argv, name, desc, url); initializeGraph(filename, sourceId, sinkId, &app); if (relabelInt == 0) { app.global_relabel_interval = app.graph.size() * ALPHA + app.graph.sizeEdges() / 3; } else { app.global_relabel_interval = relabelInt; } std::cout << "number of nodes: " << app.graph.size() << "\n"; std::cout << "global relabel interval: " << app.global_relabel_interval << "\n"; std::cout << "serial execution: " << (serial ? "yes" : "no") << "\n"; Galois::StatTimer T; T.start(); run(); T.stop(); std::cout << "Flow is " << app.graph.getData(app.sink).excess << "\n"; if (!skipVerify) { Config orig; initializeGraph(filename, sourceId, sinkId, &orig); verify(orig); std::cout << "(Partially) Verified\n"; } return 0; }
void run() { typedef typename Algo::Graph Graph; Algo algo; Graph graph; algo.readGraph(graph, filename, transposeGraphName); Galois::preAlloc(numThreads + (2*graph.size() * sizeof(typename Graph::node_data_type)) / Galois::Runtime::MM::hugePageSize); Galois::reportPageAlloc("MeminfoPre"); Galois::StatTimer T; auto eamp = -amp;///tolerance; std::cout << "Running " << algo.name() << " version\n"; std::cout << "tolerance: " << tolerance << "\n"; std::cout << "effective amp: " << eamp << "\n"; T.start(); Galois::do_all_local(graph, [&graph] (typename Graph::GraphNode n) { graph.getData(n).init(); }); algo(graph, tolerance, eamp); T.stop(); Galois::reportPageAlloc("MeminfoPost"); if (!skipVerify) { algo.verify(graph, tolerance); printTop(graph, 10, algo.name().c_str(), numThreads); } }
void run() { typedef typename Algo::Graph Graph; typedef typename Graph::GraphNode GNode; Algo algo; Graph graph; GNode source; initialize(algo, graph, source); Galois::preAlloc(numThreads + (3*graph.size() * sizeof(typename Graph::node_data_type)) / Galois::Runtime::MM::pageSize); Galois::reportPageAlloc("MeminfoPre"); Galois::StatTimer T; std::cout << "Running " << algo.name() << " version\n"; T.start(); Galois::do_all_local(graph, typename Algo::Initialize(graph)); algo(graph, source); T.stop(); Galois::reportPageAlloc("MeminfoPost"); if (!skipVerify) { int count = 0; for (typename Graph::iterator ii = graph.begin(), ei = graph.end(); ii != ei && count < 10; ++ii, ++count) { std::cout << count << ": " << std::setiosflags(std::ios::fixed) << std::setprecision(6) << graph.getData(*ii).dependencies << "\n"; } } }
void run() { Algo algo; Galois::StatTimer T; T.start(); algo(); T.stop(); }
void runPPR() { typedef typename Algo::Graph Graph; Algo algo; Graph graph; algo.readGraph(graph, filename, transposeGraphName); std::cout << "Read " << std::distance(graph.begin(), graph.end()) << " Nodes\n"; Galois::preAlloc(numThreads + (graph.size() * sizeof(typename Graph::node_data_type)) / Galois::Runtime::MM::hugePageSize); Galois::reportPageAlloc("MeminfoPre"); unsigned numSeeds = 2; Galois::StatTimer Tt; Tt.start(); auto seeds = findPPRSeeds(graph, numSeeds); Tt.stop(); std::cout << "Find " << numSeeds << " seeds (found " << seeds.size() << ") in " << Tt.get() << "ms\n"; std::map<typename Graph::GraphNode, std::deque<unsigned> > clusters; unsigned counter = 0; for (auto seed : seeds) { Galois::StatTimer T1, T2, T3; std::cout << "Running " << algo.name() << " version\n"; T1.start(); Galois::do_all_local(graph, [&graph] (typename Graph::GraphNode n) { graph.getData(n).init(); }); T1.stop(); T2.start(); algo(graph, seed); T2.stop(); T3.start(); auto c = algo.cluster_from_sweep(graph); T3.stop(); std::cout << T1.get() << " " << T2.get() << " " << T3.get() << "\n"; std::cout << seed << " : " << c.size() << "\n"; // for (auto n : c) // std::cout << n << " "; // std::cout << "\n"; for (auto n : c) clusters[n].push_back(counter); ++counter; Galois::reportPageAlloc("MeminfoPost"); } for (auto np : clusters) { std::cout << np.first << ": "; for (auto n : np.second) std::cout << n << " "; std::cout << "\n"; } }
void run(const AlgoTy& algo, GNode source) { Galois::preAlloc(numThreads + (3 * graph.size() * sizeof(SNode)) / GaloisRuntime::MM::pageSize); Galois::Statistic("MeminfoPre", GaloisRuntime::MM::pageAllocInfo()); Galois::StatTimer T; std::cout << "Running " << algo.name() << " version\n"; T.start(); algo(source); T.stop(); Galois::Statistic("MeminfoPost", GaloisRuntime::MM::pageAllocInfo()); }
int main(int argc, char **argv){ char *filename; bool output = false; if(argc > 2){ filename = argv[1]; number_of_threads = atoi(argv[2]); }else{ std::cout << "You need to give filename and number of threads to run on" << std::endl; } if(argc > 3){ output = true; } graph.structureFromFile(filename); std::cout << "in main graph loaded" << std::endl; //Initialize the component ids of the nodes with the node number for (Graph::iterator ii = graph.begin(), ei = graph.end(); ii != ei; ++ii) { Graph::GraphNode src = *ii; graph.getData(src, Galois::NONE).dist = src; } Galois::preAlloc((16 + (graph.size() * sizeof(SNode) * 2) / GaloisRuntime::MM::pageSize)*8); Galois::Statistic("MeminfoPre", GaloisRuntime::MM::pageAllocInfo()); Galois::StatTimer T; T.start(); GNode gn1; gettimeofday(&start, NULL); AsyncAlgo a; a(gn1); gettimeofday(&end, NULL); T.stop(); Galois::Statistic("MeminfoPost", GaloisRuntime::MM::pageAllocInfo()); if(output) print_componentIds(); std::cout << "Time taken by parallel galois chunked fifo implementation on " << graph.size() << " nodes is " << (((end.tv_sec - start.tv_sec) * 1000000u + end.tv_usec - start.tv_usec) / 1.e6) << std::endl; return 0; }
void runBodyParallel(const GNode src[NUM], int n) { using namespace GaloisRuntime::WorkList; typedef dChunkedLIFO<16> dChunk; typedef ChunkedLIFO<16> Chunk; typedef OrderedByIntegerMetric<UpdateRequestIndexer,dChunk> OBIM; Galois::StatTimer T; UpdateRequest one[NUM]; for (int i = 0; i < n; ++i) one[i] = UpdateRequest(src[i], 0, i); T.start(); Galois::for_each<OBIM>(&one[0], &one[n], process()); T.stop(); }
int main(int argc, char** argv) { Galois::StatManager statManager; LonestarStart(argc, argv, name, desc, url); graph.structureFromFile(filename); unsigned int id = 0; for (Graph::iterator gb = graph.begin(), ge = graph.end(); gb != ge; ++gb, ++id) { graph.getData(*gb).vertexId = graph.getData(*gb).component = id; } Galois::StatTimer T; T.start(); switch (algo) { case serial: SerialAlgo()(); break; default: GaloisAlgo()(); break; } T.stop(); cout<<"Time Spent "<<T.get()<<" ms "<<endl; return 0; }
//End body of for-each. /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// EdgeDataType runBodyParallel() { using namespace Galois::WorkList; typedef dChunkedFIFO<64> dChunk; typedef ChunkedFIFO<64> Chunk; typedef OrderedByIntegerMetric<Indexer, dChunk> OBIM; #if BORUVKA_DEBUG std::cout<<"Graph size "<<graph.size()<<std::endl; #endif #if COMPILE_STATISICS BORUVKA_SAMPLE_FREQUENCY = graph.size()/200;//200 samples should be sufficient. #endif for (size_t i = 0; i < MSTWeight.size(); i++){ *MSTWeight.getRemote(i) = 0; } cout << "Starting loop body\n"; Galois::StatTimer T; T.start(); #ifdef GALOIS_USE_EXP Exp::PriAuto<64, Indexer, OBIM, seq_less, seq_gt>::for_each(graph.begin(), graph.end(), process()); #else // Galois::for_each<dChunk>(graph.begin(), graph.end(), process()); Galois::for_each<OBIM>(graph.begin(), graph.end(), process()); #endif T.stop(); EdgeDataType res = 0; for (size_t i = 0; i < MSTWeight.size(); i++) { #if BORUVKA_DEBUG std::cout<<"MST +=" << *MSTWeight.getRemote(i)<<std::endl; #endif res += *MSTWeight.getRemote(i); } // std::cout << "MST Weight is " << res <<std::endl; return res; }
int main(int argc, char **argv) { if(argc != 4) { std::cout<<"No enough arugments\n"; exit(0); } double alpha = 0.15; int maxIter = 50; int n_threads; std::string meta_file, data_file; n_threads = atoi(argv[1]); meta_file = argv[2]; data_file = argv[3]; int row, col, size; //reading the meta file std::ifstream fmeta(meta_file.c_str()); fmeta >> row >> col >> size; double *R = new double[col]; for(int i=0; i<col; i++) { R[i] = (double)1/col; } double *Y = new double[col](); double *pM = new double[col](); //create a sparse matrix pr_spMatrix spA(n_threads, data_file); spA.getpM(pM, alpha); spA.initNodes(R, Y); spA.initEdges(pM); spA.initV(alpha, col); //--------timing-------------------- Galois::StatTimer T; T.start(); for(size_t i=0; i<maxIter; i++) { spA.pagerank_multiply(); } T.stop(); int maxTop = 10; spA.getR(R); int* idx = new int[col]; sort_idx(R, idx, col); for(int i=0; i<maxTop; i++) { printf("rank: %d | %d | %0.15f\n", i+1, idx[i], R[idx[i]]); } printf("total running time: %f seconds\n", double(T.get())/1000); delete[] idx; delete[] pM; delete[] Y; delete[] R; }
int main(int argc, char** argv) { Galois::StatManager statManager; LonestarStart(argc, argv, name, desc, url); graph = new Graph(); { Mesh m; m.read(graph, filename.c_str(), detAlgo == nondet); Verifier v; if (!skipVerify && !v.verify(graph)) { std::cerr << "bad input mesh\n"; assert(0 && "Refinement failed"); abort(); } } std::cout << "configuration: " << std::distance(graph->begin(), graph->end()) << " total triangles, " << std::count_if(graph->begin(), graph->end(), is_bad(graph)) << " bad triangles\n"; Galois::Statistic("MeminfoPre1", GaloisRuntime::MM::pageAllocInfo()); Galois::preAlloc(15 * numThreads + GaloisRuntime::MM::pageAllocInfo() * 10); Galois::Statistic("MeminfoPre2", GaloisRuntime::MM::pageAllocInfo()); Galois::StatTimer T; T.start(); if (detAlgo == nondet) Galois::do_all_local(*graph, Preprocess()); else std::for_each(graph->begin(), graph->end(), Preprocess()); Galois::Statistic("MeminfoMid", GaloisRuntime::MM::pageAllocInfo()); Galois::StatTimer Trefine("refine"); Trefine.start(); using namespace GaloisRuntime::WorkList; typedef LocalQueues<dChunkedLIFO<256>, ChunkedLIFO<256> > BQ; typedef ChunkedAdaptor<false,32> CA; switch (detAlgo) { case nondet: Galois::for_each_local<CA>(wl, Process<>()); break; case detBase: Galois::for_each_det(wl.begin(), wl.end(), Process<>()); break; case detPrefix: Galois::for_each_det(wl.begin(), wl.end(), Process<detPrefix>(), Process<>()); break; case detDisjoint: Galois::for_each_det(wl.begin(), wl.end(), Process<detDisjoint>()); break; default: std::cerr << "Unknown algorithm" << detAlgo << "\n"; abort(); } Trefine.stop(); T.stop(); Galois::Statistic("MeminfoPost", GaloisRuntime::MM::pageAllocInfo()); if (!skipVerify) { int size = Galois::ParallelSTL::count_if(graph->begin(), graph->end(), is_bad(graph)); if (size != 0) { std::cerr << size << " bad triangles remaining.\n"; assert(0 && "Refinement failed"); abort(); } Verifier v; if (!v.verify(graph)) { std::cerr << "Refinement failed.\n"; assert(0 && "Refinement failed"); abort(); } std::cout << "Refinement OK\n"; } return 0; }
int main(int argc, char** argv) { Galois::StatManager M; LonestarStart(argc, argv, name, desc, url); Graph g; G = &g; G->structureFromFile(filename.c_str()); NumNodes = G->size(); #if SHARE_SINGLE_BC std::vector<cache_line_storage<BCrecord> > cb(NumNodes); CB = &cb; #else Galois::GVectorElementAccumulator<std::vector<double> > cb; CB = &cb; #endif initGraphData(); int iterations = NumNodes; if (iterLimit) iterations = iterLimit; boost::filter_iterator<HasOut,Graph::iterator> begin = boost::make_filter_iterator(HasOut(G), g.begin(), g.end()), end = boost::make_filter_iterator(HasOut(G), g.end(), g.end()); iterations = std::min((int) std::distance(begin, end), iterations); std::cout << "NumNodes: " << NumNodes << " Iterations: " << iterations << "\n"; end = begin; std::advance(end, iterations); std::vector<GNode> tmp; std::copy(begin, end, std::back_inserter(tmp)); typedef GaloisRuntime::WorkList::dChunkedLIFO<1> WL; Galois::StatTimer T; T.start(); Galois::for_each<WL>(tmp.begin(), tmp.end(), process()); T.stop(); if (forceVerify || !skipVerify) { verify(); } else { // print bc value for first 10 nodes #if SHARE_SINGLE_BC #else const std::vector<double>& bcv = CB->reduce(); #endif for (int i=0; i<10; ++i) #if SHARE_SINGLE_BC std::cout << i << ": " << setiosflags(std::ios::fixed) << std::setprecision(6) << (*CB)[i].data.bc << "\n"; #else std::cout << i << ": " << setiosflags(std::ios::fixed) << std::setprecision(6) << bcv[i] << "\n"; #endif #if SHOULD_PRODUCE_CERTIFICATE printBCcertificate(); #endif } std::cerr << "Application done...\n"; Galois::StatTimer tt("cleanup"); tt.start(); cleanupData(); tt.stop(); return 0; }