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*/(); } } }
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*/(); } } }