Skip to content

Commit

Permalink
Fix bug in SplitMiner: the DFG can be disconnected after detectParall…
Browse files Browse the repository at this point in the history
…elism() method (try Sepsis log, using group as event classifier - selector).
  • Loading branch information
brucenguyen1 committed Jul 29, 2019
1 parent 80eab77 commit aca6245
Showing 1 changed file with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class DirectlyFollowGraphPlus {
protected Set<DFGEdge> loopsL2;
protected Map<Integer, HashSet<Integer>> parallelisms;
protected Set<DFGEdge> bestEdges;
private Set<DFGEdge> untouchableEdges;

protected double percentileFrequencyThreshold;
protected double parallelismsThreshold;
Expand Down Expand Up @@ -172,6 +173,8 @@ public void buildDFGP() {
System.out.println("DFGP - settings > " + percentileFrequencyThreshold + " : " + parallelismsThreshold + " : " + filterType.toString());

buildDirectlyFollowsGraph(); //first method to execute
bestEdgesOnMaxCapacitiesForConnectedness(); //run if there may be the chance to have a disconnected graph

detectLoops(); //depends on buildDirectlyFollowsGraph()
detectParallelisms(); //depends on detectLoops()

Expand Down Expand Up @@ -652,7 +655,11 @@ protected void addEdge(DFGEdge e) {
private boolean removeEdge(DFGEdge e, boolean safe) {
int src = e.getSourceCode();
int tgt = e.getTargetCode();
if( safe && ((incomings.get(tgt).size() == 1) || (outgoings.get(src).size() == 1)) ) return false;
if( (incomings.get(tgt).size() == 1) || (outgoings.get(src).size() == 1) ) return false;
if( safe && untouchableEdges.contains(e) ) {
System.out.println("DEBUG - this edge ensures connectedness! not removable!");
return false;
}
incomings.get(tgt).remove(e);
outgoings.get(src).remove(e);
dfgp.get(src).remove(tgt);
Expand Down Expand Up @@ -738,4 +745,87 @@ public void printParallelisms() {
System.out.println();
}
}

// EXPERIMENTAL

private void bestEdgesOnMaxCapacitiesForConnectedness() {
int src, tgt, cap, maxCap;
DFGEdge bp, bs;

LinkedList<Integer> toVisit = new LinkedList<>();
Set<Integer> unvisited = new HashSet<>();

HashMap<Integer, DFGEdge> bestPredecessorFromSource = new HashMap<>();
HashMap<Integer, DFGEdge> bestSuccessorToSink = new HashMap<>();

Map<Integer, Integer> maxCapacitiesFromSource = new HashMap<>();
Map<Integer, Integer> maxCapacitiesToSink = new HashMap<>();

for( int n : nodes.keySet() ) {
maxCapacitiesFromSource.put(n, 0);
maxCapacitiesToSink.put(n, 0);
}

maxCapacitiesFromSource.put(startcode, Integer.MAX_VALUE);
maxCapacitiesToSink.put(endcode, Integer.MAX_VALUE);

// forward exploration
toVisit.add(startcode);
unvisited.addAll(nodes.keySet());
unvisited.remove(startcode);

while( !toVisit.isEmpty() ) {
src = toVisit.removeFirst();
cap = maxCapacitiesFromSource.get(src);
for( DFGEdge oe : outgoings.get(src) ) {
tgt = oe.getTargetCode();
maxCap = (cap > oe.getFrequency() ? oe.getFrequency() : cap);
if( (maxCap > maxCapacitiesFromSource.get(tgt)) ) { //|| ((maxCap == maxCapacitiesFromSource.get(tgt)) && (bestPredecessorFromSource.get(tgt).getFrequency() < oe.getFrequency())) ) {
maxCapacitiesFromSource.put(tgt, maxCap);
bestPredecessorFromSource.put(tgt, oe);
if( !toVisit.contains(tgt) ) unvisited.add(tgt);
}
if( unvisited.contains(tgt) ) {
toVisit.addLast(tgt);
unvisited.remove(tgt);
}
}
}


// backward exploration
toVisit.add(endcode);
unvisited.clear();
unvisited.addAll(nodes.keySet());
unvisited.remove(endcode);

while( !toVisit.isEmpty() ) {
tgt = toVisit.removeFirst();
cap = maxCapacitiesToSink.get(tgt);
for( DFGEdge ie : incomings.get(tgt) ) {
src = ie.getSourceCode();
maxCap = (cap > ie.getFrequency() ? ie.getFrequency() : cap);
if( (maxCap > maxCapacitiesToSink.get(src)) ) { //|| ((maxCap == maxCapacitiesToSink.get(src)) && (bestSuccessorToSink.get(src).getFrequency() < ie.getFrequency())) ) {
maxCapacitiesToSink.put(src, maxCap);
bestSuccessorToSink.put(src, ie);
if( !toVisit.contains(src) ) unvisited.add(src);
}
if( unvisited.contains(src) ) {
toVisit.addLast(src);
unvisited.remove(src);
}
}
}

untouchableEdges = new HashSet<>();
for( int n : nodes.keySet() ) {
untouchableEdges.add(bestPredecessorFromSource.get(n));
untouchableEdges.add(bestSuccessorToSink.get(n));
}
untouchableEdges.remove(null);

// for( int n : nodes.keySet() ) {
// System.out.println("DEBUG - " + n + " : [" + maxCapacitiesFromSource.get(n) + "][" + maxCapacitiesToSink.get(n) + "]");
// }
}
}

0 comments on commit aca6245

Please sign in to comment.