Ejemplo n.º 1
0
void const_graph_visitort::const_graph_explore(event_grapht& egraph, unsigned next,
  unsigned end, std::list<unsigned>& old_path)
{
  if(next == end) {
    /* inserts all the pos collected from old_path in edges */
    std::list<unsigned>::const_iterator it=old_path.begin();
    std::list<unsigned>::const_iterator next_it=it;
    ++next_it;
    for(;next_it!=old_path.end() && it!=old_path.end(); ++it, ++next_it)
    {
      /* it should be a po_s, and not a po_s^+ */
      assert(egraph.has_po_edge(*it,*next_it));
      fence_inserter.add_edge(edget(*it,*next_it));
    }
  }
  else if(egraph.po_out(next).size()==0) {
    /* this path is not connecting a to b => return */
  }
  else {
    for(graph<abstract_eventt>::edgest::const_iterator
      next_it=egraph.po_out(next).begin();
      next_it!=egraph.po_out(next).end();
      ++next_it)
    {
      if(visited_nodes.find(next_it->first)!=visited_nodes.end())
        continue;
      visited_nodes.insert(next_it->first);

      old_path.push_back/*front*/(next_it->first);
      const_graph_explore(egraph, next_it->first, end, old_path);
      old_path.pop_back/*front*/();
    }
  }
}
Ejemplo n.º 2
0
void const_graph_visitort::graph_explore_AC(
  event_grapht &egraph,
  event_idt next,
  std::list<event_idt> &old_path,
  std::set<unsigned> &edges,
  bool porw)
{
  /* TODO: restricts to C_1 U ... U C_n */
  assert(old_path.size() > 0);

  fence_inserter.instrumenter.message.debug() << "(AC) explore "
    << old_path.front() << " --...--> " << next << messaget::eom;

  if(visited_nodes.find(next)!=visited_nodes.end())
     return;
  visited_nodes.insert(next);

  /* if all the incoming pos were already visited, add */
  bool no_other_pos = true;
  for(wmm_grapht::edgest::const_iterator it=
    egraph.po_in(next).begin();
    it!=egraph.po_in(next).end();
    ++it)
    if(visited_nodes.find(it->first)==visited_nodes.end())
    {
      no_other_pos = false;
      break;
    }

  if(egraph.po_in(next).empty() || no_other_pos)
  {
    /* inserts all the pos collected from old_path in edges */
    std::list<event_idt>::const_iterator it=old_path.begin();
    std::list<event_idt>::const_iterator next_it=it;
    ++next_it;
    for( ; next_it!=old_path.end() && it!=old_path.end(); ++it, ++next_it)
    {
      const abstract_eventt &e1=egraph[*next_it];
      const abstract_eventt &e2=egraph[*it];
      if(!porw ||
         (e1.operation==abstract_eventt::operationt::Read &&
          e2.operation==abstract_eventt::operationt::Write))
        edges.insert(fence_inserter.add_edge(edget(*next_it, *it)));
    }
    assert(it!=old_path.end());
  }
  else
  {
    for(wmm_grapht::edgest::const_iterator
      next_it=egraph.po_in(next).begin();
      next_it!=egraph.po_in(next).end();
      ++next_it)
    {
      old_path.push_back/*front*/(next_it->first);
      graph_explore_AC(egraph, next_it->first, old_path, edges);
      old_path.pop_back/*front*/();
    }
  }
}
Ejemplo n.º 3
0
void const_graph_visitort::const_graph_explore_AC(
  event_grapht &egraph,
  event_idt next,
  std::list<event_idt> &old_path)
{
  /* TODO: restricts to C_1 U ... U C_n */
  assert(old_path.size() > 0);

  if(visited_nodes.find(next)!=visited_nodes.end())
     return;
  visited_nodes.insert(next);

  /* if all the incoming pos were already visited, add */
  bool no_other_pos = true;
  for(wmm_grapht::edgest::const_iterator it=
    egraph.po_in(next).begin();
    it!=egraph.po_in(next).end();
    ++it)
    if(visited_nodes.find(it->first)==visited_nodes.end())
    {
      no_other_pos = false;
      break;
    }

  /* if beginning of the thread */
  if(egraph.po_in(next).empty() || no_other_pos)
  {
    /* inserts all the pos collected from old_path in edges */
    std::list<event_idt>::const_iterator it=old_path.begin();
    std::list<event_idt>::const_iterator next_it=it;
    ++next_it;
    for( ; next_it!=old_path.end() && it!=old_path.end(); ++it, ++next_it)
    {
      const abstract_eventt &e1=egraph[*next_it];
      const abstract_eventt &e2=egraph[*it];
      if(e1.operation==abstract_eventt::operationt::Read &&
         e2.operation==abstract_eventt::operationt::Write)
        fence_inserter.add_edge(edget(*next_it, *it));
    }
    // NEW
    assert(it!=old_path.end());
  }
  else
  {
    for(wmm_grapht::edgest::const_iterator
      next_it=egraph.po_in(next).begin();
      next_it!=egraph.po_in(next).end();
      ++next_it)
    {
      old_path.push_back/*front*/(next_it->first);
      const_graph_explore_AC(egraph, next_it->first, old_path);
      old_path.pop_back/*front*/();
    }
  }
}