Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
  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;
  }
Exemplo n.º 3
0
 void operator()(GNode src, Galois::UserContext<GNode>& ctx) {
   for (Graph::edge_iterator ii = graph.edge_begin(src, Galois::ALL),
       ei = graph.edge_end(src, Galois::ALL); ii != ei; ++ii) {
     GNode dst = graph.getEdgeDst(ii);
     Node& ddata = graph.getData(dst, Galois::NONE);
     if (ddata.component == root)
       continue;
     ddata.component = root;
     mst.push(std::make_pair(src, dst));
     ctx.push(dst);
   }
 }
Exemplo n.º 4
0
 void operator()(const GNode& src) const {
   Node& sdata = graph.getData(src, Galois::NONE);
   for (Graph::edge_iterator ii = graph.edge_begin(src, Galois::NONE),
       ei = graph.edge_end(src, Galois::NONE); ii != ei; ++ii) {
     GNode dst = graph.getEdgeDst(ii);
     Node& ddata = graph.getData(dst, Galois::NONE);
     if (sdata.merge(&ddata)) {
       mst.push(std::make_pair(src, dst));
     } else {
       emptyMerges += 1;
     }
   }
 }
Exemplo n.º 5
0
void run() {
  typedef Galois::WorkList::dChunkedFIFO<16> Chunk;
  typedef Galois::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) {
          Galois::for_each_local<OBIM>(initial, Process<nondet>(counter), "Discharge");
        } else {
          Galois::for_each_local(initial, 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;
    }
  }
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
 void operator()(GNode item) const {
   if (graph->getData(item, Galois::NONE).isBad())
     wl.push(item);
 }