bool verify() { if (Galois::ParallelSTL::find_if(graph.begin(), graph.end(), is_bad_graph()) == graph.end()) { if (Galois::ParallelSTL::find_if(mst.begin(), mst.end(), is_bad_mst()) == mst.end()) { CheckAcyclic c; return c(); } } return false; }
void run() { typedef GaloisRuntime::WorkList::dChunkedFIFO<16> Chunk; typedef GaloisRuntime::WorkList::OrderedByIntegerMetric<Indexer,Chunk> OBIM; Galois::InsertBag<GNode> initial; initializePreflow(initial); while (initial.begin() != initial.end()) { Galois::StatTimer T_discharge("DischargeTime"); T_discharge.start(); Counter counter; switch (detAlgo) { case nondet: if (useHLOrder) { #ifdef GALOIS_USE_EXP Exp::PriAuto<16, Indexer, OBIM, GLess, GGreater>::for_each(initial.begin(), initial.end(), Process<nondet>(counter), "Discharge"); #else Galois::for_each<OBIM>(initial.begin(), initial.end(), Process<nondet>(counter), "Discharge"); #endif } else { Galois::for_each(initial.begin(), initial.end(), Process<nondet>(counter), "Discharge"); } break; case detBase: Galois::for_each_det(initial.begin(), initial.end(), Process<detBase>(counter), "Discharge"); break; case detDisjoint: Galois::for_each_det(initial.begin(), initial.end(), Process<detDisjoint>(counter), "Discharge"); break; default: std::cerr << "Unknown algorithm" << detAlgo << "\n"; abort(); } T_discharge.stop(); if (app.should_global_relabel) { Galois::StatTimer T_global_relabel("GlobalRelabelTime"); T_global_relabel.start(); initial.clear(); globalRelabel(initial); app.should_global_relabel = false; std::cout << " Flow after global relabel: " << app.graph.getData(app.sink).excess << "\n"; T_global_relabel.stop(); } else { break; } } }
bool operator()() { Accum a; accum = &a; Galois::do_all_local(graph, *this); unsigned numRoots = a.roots.reduce(); unsigned numEdges = std::distance(mst.begin(), mst.end()); if (graph.size() - numRoots != numEdges) { std::cerr << "Generated graph is not a forest. " << "Expected " << graph.size() - numRoots << " edges but " << "found " << numEdges << "\n"; return false; } std::cout << "Num trees: " << numRoots << "\n"; std::cout << "Tree edges: " << numEdges << "\n"; return true; }
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; }