From 60b14680cd7d7f2022e9505d7e85d00b914d19fa Mon Sep 17 00:00:00 2001 From: jzhou Date: Sun, 15 Nov 2009 02:53:36 +0000 Subject: [PATCH] bug fix in scheduling --- .../Analysis/Scheduling/MCImplSynthesis.java | 89 ++++++++++++++++--- .../Analysis/Scheduling/ScheduleAnalysis.java | 48 ++++++---- .../src/Analysis/Scheduling/ScheduleNode.java | 17 +++- .../Scheduling/ScheduleSimulator.java | 49 +++++++++- .../Analysis/Scheduling/SchedulingUtil.java | 66 ++++++++------ .../Analysis/Scheduling/SimExecutionEdge.java | 2 +- .../Analysis/Scheduling/TaskSimulator.java | 16 ++++ .../src/Analysis/TaskStateAnalysis/FEdge.java | 15 +++- .../Analysis/TaskStateAnalysis/FlagState.java | 7 +- Robust/src/Runtime/multicoreruntime.h | 2 +- Robust/src/Runtime/multicoretask.c | 18 ++-- Robust/src/Runtime/socket.c | 6 +- Robust/src/buildscript | 4 +- 13 files changed, 260 insertions(+), 79 deletions(-) diff --git a/Robust/src/Analysis/Scheduling/MCImplSynthesis.java b/Robust/src/Analysis/Scheduling/MCImplSynthesis.java index 544f29cd..93252182 100644 --- a/Robust/src/Analysis/Scheduling/MCImplSynthesis.java +++ b/Robust/src/Analysis/Scheduling/MCImplSynthesis.java @@ -140,6 +140,7 @@ public class MCImplSynthesis { if(this.generateThreshold > 5) { this.generateThreshold = 5; } + this.scheduleSimulator.init(); Vector> scheduleGraphs = null; Vector> newscheduleGraphs = @@ -150,10 +151,12 @@ public class MCImplSynthesis { Vector selectedSchedulings = new Vector(); Vector selectedSimExeGraphs = new Vector(); + SimExecutionNode selectedSimExeGraph_bk = null; int tryindex = 1; long bestexetime = Long.MAX_VALUE; Random rand = new Random(); + int threshold = this.scheduleThreshold; // simulate the generated schedulings and try to optimize it do { System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); @@ -204,35 +207,79 @@ public class MCImplSynthesis { snode.getClassNodes().clear(); } schedulinggraph.clear(); + selectedSimExeGraph_bk = null; } scheduling = schedulings.elementAt(selectedSchedulings.elementAt(0)); schedulinggraph = scheduleGraphs.elementAt( selectedSchedulings.elementAt(0)); + selectedSimExeGraph_bk = selectedSimExeGraphs.elementAt(0); + System.out.print("end of: #" + tryindex + " (bestexetime: " + bestexetime + ")\n"); System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); tryindex++; + threshold = this.scheduleThreshold; } else if(tmpexetime == bestexetime) { System.out.print("end of: #" + tryindex + " (bestexetime: " + bestexetime + ")\n"); System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); tryindex++; + threshold = this.scheduleThreshold; if((Math.abs(rand.nextInt()) % 100) < this.probThreshold) { break; } } else { - break; + System.out.print("end of: #" + tryindex + " (bestexetime: " + + bestexetime + ")\n"); + System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + tryindex++; + if(threshold == this.scheduleThreshold) { + if(scheduleGraphs != null) { + scheduleGraphs.clear(); + } + scheduleGraphs.addElement(schedulinggraph); + if(selectedSchedulings != null) { + selectedSchedulings.clear(); + } + selectedSchedulings.addElement(Integer.valueOf(0)); + if(selectedSimExeGraphs != null) { + selectedSimExeGraphs.clear(); + } + selectedSimExeGraphs.addElement(selectedSimExeGraph_bk); + } + threshold += 10; + if((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 1) { + break; + } + //break; } //if(tooptimize) { // try to optimize the best one scheduling + //do { newscheduleGraphs = optimizeScheduling(scheduleGraphs, selectedSchedulings, selectedSimExeGraphs, gid, - this.scheduleThreshold); + threshold); + /*if(newscheduleGraphs != null) { + if(this.generateThreshold < 30) { + this.generateThreshold = 30; + } + break; + } else { + threshold += 10; + if(this.generateThreshold > 0) { + this.generateThreshold -= 3; + } + if((Math.abs(rand.nextInt()) % 10000) < this.probThreshold + 1) { + break; + } + } + }while(true);*/ if(remove) { scheduleGraphs.removeElementAt(selectedSchedulings.elementAt(0)); + selectedSimExeGraphs.removeElementAt(0); } /*} else { break; @@ -330,6 +377,7 @@ public class MCImplSynthesis { // Generate all possible schedulings this.scheduleAnalysis.setScheduleThreshold(Integer.MAX_VALUE); this.scheduleAnalysis.schedule(-1, multiparamtds); + this.scheduleSimulator.init(); Vector> totestscheduleGraphs = this.scheduleAnalysis.getScheduleGraphs(); @@ -600,6 +648,10 @@ public class MCImplSynthesis { selectedScheduleGraphs.elementAt(i)); SimExecutionNode startnode = selectedSimExeGraphs.elementAt(i); Vector criticalPath = analyzeCriticalPath(startnode); + // for Test + if(this.state.PRINTCRITICALPATH) { + System.err.println("gid: " + lgid + " endpoint: " + startnode.getTimepoint()); + } Vector> tmposchedulegraphs = optimizeCriticalPath(schedulegraph, criticalPath, @@ -618,7 +670,7 @@ public class MCImplSynthesis { tmposchedulegraphs = null; break; } - } + } schedulegraph = null; criticalPath = null; tmposchedulegraphs = null; @@ -651,7 +703,7 @@ public class MCImplSynthesis { (Iterator)snode.inedges(); while(it_iedges.hasNext()) { SimExecutionEdge sedge = it_iedges.next(); - if(sedge.getWeight() != 0) { + //if(sedge.getWeight() != 0) { SimExecutionNode tsnode = (SimExecutionNode)(sedge.getSource()); if(tsnode.getTimepoint() + sedge.getWeight() == snode.getTimepoint()) { nsnode = tsnode; @@ -659,7 +711,7 @@ public class MCImplSynthesis { sum += sedge.getWeight(); break; } - } + //} } it_iedges = null; snode = nsnode; @@ -731,14 +783,17 @@ public class MCImplSynthesis { for(int i = 0; i < criticalPath.size(); i++) { SimExecutionEdge seedge = criticalPath.elementAt(i); long starttime = seedge.getBestStartPoint(); - if(starttime < ((SimExecutionNode)seedge.getSource()).getTimepoint()) { + if((starttime < ((SimExecutionNode)seedge.getSource()).getTimepoint()) + && (seedge.getTd() != null)){ + // Note: must be a task related edge, can not be an object transfer edge // no restrictions due to data dependencies // have potential to be parallelled and start execution earlier seedge.setFixedTime(false); // consider to optimize it only when its predicates can NOT // be optimized, otherwise first considering optimize its predicates - SimExecutionEdge lastpredicateedge = seedge.getLastpredicateEdge(); - if(lastpredicateedge.isFixedTime()) { + //SimExecutionEdge lastpredicateedge = seedge.getLastpredicateEdge(); + // TODO + //if(lastpredicateedge.isFixedTime()) { int corenum = seedge.getCoreNum(); if(!toselects.containsKey(starttime)) { toselects.put(starttime, @@ -749,7 +804,7 @@ public class MCImplSynthesis { new Vector()); } toselects.get(starttime).get(corenum).add(seedge); - } + //} } } @@ -985,8 +1040,9 @@ public class MCImplSynthesis { } } it_cnodes = null; + // split the node - ScheduleNode splitnode = snode.spliteClassNode(tosplit); + ScheduleNode splitnode = snode.spliteClassNode(tosplit); newscheduleGraph.add(splitnode); tocombines.add(splitnode); tosplit = null; @@ -1011,8 +1067,14 @@ public class MCImplSynthesis { Vector> rootNodes = SchedulingUtil.rangeScheduleNodes(roots); + if(rootNodes == null) { + return optimizeschedulegraphs; + } Vector> nodes2combine = SchedulingUtil.rangeScheduleNodes(tocombines); + if(nodes2combine == null) { + return optimizeschedulegraphs; + } CombinationUtil.CombineGenerator cGen = CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine); @@ -1039,6 +1101,13 @@ public class MCImplSynthesis { cGen.clear(); rootNodes = null; nodes2combine = null; + for(int j = 0; j < newscheduleGraph.size(); j++) { + ScheduleNode snode = newscheduleGraph.elementAt(j); + snode.getEdgeVector().clear(); + snode.getInedgeVector().clear(); + snode.getScheduleEdges().clear(); + snode.getClassNodes().clear(); + } newscheduleGraph = null; scheduleEdges.clear(); scheduleEdges = null; diff --git a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java index 181296f3..0a4e6cc5 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java +++ b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java @@ -44,7 +44,7 @@ public class ScheduleAnalysis { this.scheduleGraphs = null; this.td2maincd = null; } - + public void setTransThreshold(int tt) { this.transThreshold = tt; } @@ -158,6 +158,11 @@ public class ScheduleAnalysis { if(taskinfo.m_byObj != -1) { ((FlagState)pfe.getSource()).setByObj(taskinfo.m_byObj); } + // TODO for test + /*System.err.println("task " + td.getSymbol() + " exit# " + + pfe.getTaskExitIndex() + " exetime: " + pfe.getExeTime() + + " prob: " + pfe.getProbability() + "% newobj: " + + pfe.getNewObjInfoHashtable().size());*/ } fev = null; } @@ -184,6 +189,10 @@ public class ScheduleAnalysis { if(taskinfo.m_byObj != -1) { ((FlagState)edge.getSource()).setByObj(taskinfo.m_byObj); } + // TODO for test + /*System.err.println("task " + edge.getTask().getSymbol() + " exit# " + + edge.getTaskExitIndex() + " exetime: " + edge.getExeTime() + + " prob: " + edge.getProbability());*/ } it_edges = null; } @@ -659,20 +668,23 @@ public class ScheduleAnalysis { } } - private void handleDescenSEs(Vector ses) { - ScheduleEdge tempse = ses.elementAt(0); - long temptime = tempse.getListExeTime(); - // find out the ScheduleEdge with least exeTime - for(int k = 1; k < ses.size(); k++) { - long ttemp = ses.elementAt(k).getListExeTime(); - if(ttemp < temptime) { - tempse = ses.elementAt(k); - temptime = ttemp; - } // if(ttemp < temptime) - } // for(int k = 1; k < ses.size(); k++) - // handle the tempse - handleScheduleEdge(tempse, true); - ses.removeElement(tempse); + private void handleDescenSEs(Vector ses, + boolean isflag) { + if(isflag) { + ScheduleEdge tempse = ses.elementAt(0); + long temptime = tempse.getListExeTime(); + // find out the ScheduleEdge with least exeTime + for(int k = 1; k < ses.size(); k++) { + long ttemp = ses.elementAt(k).getListExeTime(); + if(ttemp < temptime) { + tempse = ses.elementAt(k); + temptime = ttemp; + } // if(ttemp < temptime) + } // for(int k = 1; k < ses.size(); k++) + // handle the tempse + handleScheduleEdge(tempse, true); + ses.removeElement(tempse); + } // handle other ScheduleEdges for(int k = 0; k < ses.size(); k++) { handleScheduleEdge(ses.elementAt(k), false); @@ -751,7 +763,8 @@ public class ScheduleAnalysis { for(int j = 0; j < fes.size(); j++) { FEdge tempfe = fes.elementAt(j); Vector ses = fe2ses.get(tempfe); - this.handleDescenSEs(ses); + boolean isflag = !(preSNode.edges().hasNext()); + this.handleDescenSEs(ses, isflag); ses = null; fe2ses.remove(tempfe); } // for(int j = 0; j < fes.size(); j++) @@ -796,7 +809,8 @@ public class ScheduleAnalysis { while(it_keys.hasNext()) { FEdge tempfe = (FEdge)it_keys.next(); Vector ses = fe2ses.get(tempfe); - this.handleDescenSEs(ses); + boolean isflag = !(tempfe.getTarget().edges().hasNext()); + this.handleDescenSEs(ses, isflag); ses = null; } keys = null; diff --git a/Robust/src/Analysis/Scheduling/ScheduleNode.java b/Robust/src/Analysis/Scheduling/ScheduleNode.java index 060d7da1..031e74ed 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleNode.java +++ b/Robust/src/Analysis/Scheduling/ScheduleNode.java @@ -440,6 +440,9 @@ public class ScheduleNode extends GraphNode implements Cloneable { public ScheduleNode spliteClassNode(ClassNode cd) { ScheduleNode sNode = new ScheduleNode(cd, this.gid); + // clean all inedges and edges + sNode.edges.clear(); + sNode.inedges.clear(); this.classNodes.remove(cd); cd.setScheduleNode(sNode); @@ -449,7 +452,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { e.printStackTrace(); } - // redirct all corresponding internal ScheduleEdge to the new snode + // redirect all corresponding internal ScheduleEdge to the new snode Iterator it_innersEdges = this.scheduleEdges.iterator(); Vector toremove = new Vector(); if(it_innersEdges != null) { @@ -476,15 +479,22 @@ public class ScheduleNode extends GraphNode implements Cloneable { } } toremove.clear(); + // redirect external ScheudleEdges out of this cd to the new ScheduleNode Iterator it_exsEdges = this.edges(); while(it_exsEdges.hasNext()) { ScheduleEdge tse = (ScheduleEdge)it_exsEdges.next(); if(tse.getSourceCNode().equals(cd)) { - this.removeEdge(tse); - sNode.addEdge(tse); + toremove.add(tse); + //this.removeEdge(tse); + //sNode.addEdge(tse); + tse.setSource(sNode); + sNode.edges.addElement(tse); } } + this.edges.removeAll(toremove); + toremove.clear(); + it_exsEdges = null; // redirect inedges whose target is this Classnode to new ScheduleNode Iterator it_insEdges = this.inedges(); @@ -493,6 +503,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { if(tse.getTargetCNode().equals(cd)) { toremove.add(tse); tse.setTarget(sNode); + sNode.inedges.addElement(tse); } } it_insEdges = null; diff --git a/Robust/src/Analysis/Scheduling/ScheduleSimulator.java b/Robust/src/Analysis/Scheduling/ScheduleSimulator.java index 48b82a09..2459b5f5 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleSimulator.java +++ b/Robust/src/Analysis/Scheduling/ScheduleSimulator.java @@ -6,9 +6,11 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; +import java.util.Set; import java.util.Vector; import java.util.Map.Entry; +import Analysis.TaskStateAnalysis.FEdge; import Analysis.TaskStateAnalysis.FlagState; import Analysis.TaskStateAnalysis.TaskAnalysis; import IR.ClassDescriptor; @@ -23,6 +25,9 @@ public class ScheduleSimulator { private Vector tasks; private long processTime; private int invoketime; + + private Vector fstates; + private Vector fedges; State state; TaskAnalysis taskanalysis; @@ -38,6 +43,8 @@ public class ScheduleSimulator { this.invoketime = 0; this.state = state; this.taskanalysis = taskanalysis; + this.fstates = new Vector(); + this.fedges = new Vector(); } public ScheduleSimulator(int corenum, @@ -56,9 +63,34 @@ public class ScheduleSimulator { this.invoketime = 0; this.state = state; this.taskanalysis = taskanalysis; + this.fstates = new Vector(); + this.fedges = new Vector(); applyScheduling(); } + public void init() { + // gather all the flag states and fedges together + Iterator it_classes = this.state.getClassSymbolTable().getDescriptorsIterator(); + while(it_classes.hasNext()) { + ClassDescriptor cd = (ClassDescriptor) it_classes.next(); + Iterator it_fStates = this.taskanalysis.getFlagStates(cd).iterator(); + + while(it_fStates.hasNext()) { + FlagState fs = it_fStates.next(); + if(!this.fstates.contains(fs)) { + this.fstates.addElement(fs); + } + Iterator it_fe = (Iterator)fs.edges(); + while(it_fe.hasNext()) { + FEdge next = it_fe.next(); + if(!this.fedges.contains(next)) { + this.fedges.addElement(next); + } + } + } + } + } + public long simulate(Vector> schedulings, Vector selectedScheduling, Vector selectedSimExeGraphs) { @@ -206,6 +238,18 @@ public class ScheduleSimulator { public Vector getTasks() { return tasks; } + + private void init4Simulation() { +// TODO for test + /*System.err.println("======Init for Sim # " + + this.scheduling.elementAt(0).getGid() + "======");*/ + for(int i = 0; i < this.fstates.size(); i++) { + this.fstates.elementAt(i).init4Simulate(); + } + for(int i = 0; i < this.fedges.size(); i++) { + this.fedges.elementAt(i).init4Simulate(); + } + } public long process(Vector checkpoints, Vector simexegraph) { @@ -214,6 +258,9 @@ public class ScheduleSimulator { this.invoketime++; this.processTime = 0; + // initialization + this.init4Simulation(); + // helper structures for building SimExecutionGraph Hashtable senode2action = new Hashtable(); @@ -427,7 +474,7 @@ public class ScheduleSimulator { int gid = this.scheduling.elementAt(0).getGid(); if(this.state.PRINTSCHEDULESIM) { - SchedulingUtil.printSimulationResult(this.state.outputdir + "SimulatorResult_" + gid + ".dot", + SchedulingUtil.printSimulationResult(this.state.outputdir + "SimGraph/" + "SimulatorResult_" + gid + ".dot", this.processTime, this.coreNum, checkpoints); diff --git a/Robust/src/Analysis/Scheduling/SchedulingUtil.java b/Robust/src/Analysis/Scheduling/SchedulingUtil.java index a20dc748..3df8d890 100644 --- a/Robust/src/Analysis/Scheduling/SchedulingUtil.java +++ b/Robust/src/Analysis/Scheduling/SchedulingUtil.java @@ -165,40 +165,47 @@ public class SchedulingUtil { } // Organize the scheduleNodes in order of their cid - public static Vector> rangeScheduleNodes(Vector scheduleNodes) { - Vector> sNodeVecs = new Vector>(); - - for(int i = 0; i < scheduleNodes.size(); i++) { - ScheduleNode tmpn = scheduleNodes.elementAt(i); - int tmpcid = tmpn.getCid(); - int index = 0; - for(index = 0; index < sNodeVecs.size(); index++) { - if(sNodeVecs.elementAt(index).elementAt(0).getCid() > tmpcid) { - // find the place to insert - sNodeVecs.add(sNodeVecs.lastElement()); - for(int j = sNodeVecs.size() - 2; j > index; j--) { - sNodeVecs.setElementAt(sNodeVecs.elementAt(j - 1), j); - } - sNodeVecs.setElementAt(new Vector(), index); - } else if(sNodeVecs.elementAt(index).elementAt(0).getCid() == tmpcid) { - break; - } - } - if(index == sNodeVecs.size()) { - sNodeVecs.add(new Vector()); - } - - /*int index = tmpcid; + public static Vector> + rangeScheduleNodes(Vector scheduleNodes) { + try{ + Vector> sNodeVecs = new Vector>(); + + for(int i = 0; i < scheduleNodes.size(); i++) { + ScheduleNode tmpn = scheduleNodes.elementAt(i); + int tmpcid = tmpn.getCid(); + int index = 0; + for(index = 0; index < sNodeVecs.size(); index++) { + if(sNodeVecs.elementAt(index).elementAt(0).getCid() > tmpcid) { + // find the place to insert + sNodeVecs.add(sNodeVecs.lastElement()); + for(int j = sNodeVecs.size() - 2; j > index; j--) { + sNodeVecs.setElementAt(sNodeVecs.elementAt(j - 1), j); + } + sNodeVecs.setElementAt(new Vector(), index); + } else if(sNodeVecs.elementAt(index).elementAt(0).getCid() == tmpcid) { + break; + } + } + if(index == sNodeVecs.size()) { + sNodeVecs.add(new Vector()); + } + + /*int index = tmpcid; while(sNodeVecs.size() <= index) { sNodeVecs.add(null); } if(sNodeVecs.elementAt(index) == null) { sNodeVecs.setElementAt(new Vector(), index); }*/ - sNodeVecs.elementAt(index).add(tmpn); - } - - return sNodeVecs; + sNodeVecs.elementAt(index).add(tmpn); + } + + return sNodeVecs; + } catch(Error e) { + System.err.println("Error in rangeScheduleNodes"); + e.printStackTrace(); + return null; + } } /*public static int maxDivisor(int l, int r) { @@ -839,17 +846,20 @@ public class SchedulingUtil { label = startnode.getCoreNum() + ":" + startnode.getTimepoint(); output.println("\t" + startnode.getLabel() + " [label=\"" + label + "\" ];"); + nodes.addElement(startnode); } if(!nodes.contains(endnode)) { label = endnode.getCoreNum() + ":" + endnode.getTimepoint(); output.println("\t" + endnode.getLabel() + " [label=\"" + label + "\" ];"); + nodes.addElement(endnode); } output.println("\t" + startnode.getLabel() + " -> " + endnode.getLabel() + " [" + "label=\"" + seedge.getLabel() + "\"];"); } output.println("}"); output.close(); + nodes.clear(); nodes = null; } catch (Exception e) { e.printStackTrace(); diff --git a/Robust/src/Analysis/Scheduling/SimExecutionEdge.java b/Robust/src/Analysis/Scheduling/SimExecutionEdge.java index a8edc42b..8d070015 100644 --- a/Robust/src/Analysis/Scheduling/SimExecutionEdge.java +++ b/Robust/src/Analysis/Scheduling/SimExecutionEdge.java @@ -41,7 +41,7 @@ public class SimExecutionEdge extends Edge { public long getBestStartPoint() { if(this.bestStartPoint == -1) { - if(this.predicates.size() > 0) { + if((this.predicates != null) && (this.predicates.size() > 0)) { // have predicates long starttime = 0; // check the latest finish time of all the predicates diff --git a/Robust/src/Analysis/Scheduling/TaskSimulator.java b/Robust/src/Analysis/Scheduling/TaskSimulator.java index 9e1044f8..94347641 100644 --- a/Robust/src/Analysis/Scheduling/TaskSimulator.java +++ b/Robust/src/Analysis/Scheduling/TaskSimulator.java @@ -287,12 +287,23 @@ public class TaskSimulator { paraQueues.elementAt(j).remove(tpara); } } + long ftime = 0; for(int i = 0; i < paraQueues.size(); i++) { ObjectSimulator tpara = paraQueues.elementAt(i).peek(); FlagState tfstate = tpara.getCurrentFS(); FEdge toexecute = tfstate.process(td); finishTime += toexecute.getExeTime(); + // TODO for test + if(ftime == 0) { + ftime = toexecute.getExeTime(); + } else if(ftime != toexecute.getExeTime()) { + //System.err.println("error for simulation: " + td.getSymbol()); + } + // TODO for test + /*if(td.getSymbol().equals("addIYLM")) { + System.err.println("# " + i + " time: " + toexecute.getExeTime()); + }*/ if((toexecute.getNewObjInfoHashtable() != null) && (toexecute.getNewObjInfoHashtable().size() > 0)) { // have new objects @@ -314,6 +325,11 @@ public class TaskSimulator { tpara.increaseVersion(); } finishTime /= paraQueues.size(); +// TODO for test + /*if(td.getSymbol().equals("addIYLM")) { + System.err.println("total time: " + finishTime); + System.err.println("====="); + }*/ this.currentRun.setFinishTime(finishTime); this.currentRun.setExetype(0); } diff --git a/Robust/src/Analysis/TaskStateAnalysis/FEdge.java b/Robust/src/Analysis/TaskStateAnalysis/FEdge.java index 751574c7..71d4a45b 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FEdge.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FEdge.java @@ -155,7 +155,9 @@ public class FEdge extends Edge { e.source.equals(source) && e.td==td&& e.parameterindex==parameterindex && - e.executeTime == executeTime) { + e.executeTime == executeTime && + e.m_taskexitindex == m_taskexitindex && + e.m_isbackedge == m_isbackedge) { if(this.newObjInfos != null) { if(e.newObjInfos == null) { return false; @@ -194,6 +196,17 @@ public class FEdge extends Edge { } this.newObjInfos.put(cd, new NewObjInfo(newRate, probability)); } + + public void init4Simulate() { + this.invokeNum = 0; + this.expInvokeNum = 0; + if(this.newObjInfos != null) { + Iterator it_nobjs = this.newObjInfos.values().iterator(); + while(it_nobjs.hasNext()) { + it_nobjs.next().invokeNum = 0; + } + } + } public void process() { this.invokeNum++; diff --git a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java index 0270fd5e..80353b03 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java @@ -438,6 +438,9 @@ public class FlagState extends GraphNode implements Cloneable { public FEdge process(TaskDescriptor td) { FEdge next = null; this.invokeNum++; + if(td.getSymbol().equals("addIYLM")) { + next = null; + } // refresh all the expInvokeNum of each edge for(int i = 0; i < this.edges.size(); i++) { next = (FEdge) this.edges.elementAt(i); @@ -448,8 +451,8 @@ public class FlagState extends GraphNode implements Cloneable { } } - // find the one with the biggest gap between its actual invoke time and the expected invoke time - // and associated with task td + // find the one with the biggest gap between its actual invoke time and + // the expected invoke time and associated with task td int index = 0; int gap = 0; double prob = 0; diff --git a/Robust/src/Runtime/multicoreruntime.h b/Robust/src/Runtime/multicoreruntime.h index 7610b519..220b6d8a 100644 --- a/Robust/src/Runtime/multicoreruntime.h +++ b/Robust/src/Runtime/multicoreruntime.h @@ -221,7 +221,7 @@ struct Queue * totransobjqueue; // queue to hold objs to be transferred #define BAMBOO_PAGE_SIZE (64 * 64) #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE) #else -#define BAMBOO_NUM_PAGES (1024 * 512 * 4) +#define BAMBOO_NUM_PAGES (1024 * 1024 * 3.5) #define BAMBOO_PAGE_SIZE (4096) #define BAMBOO_SMEM_SIZE (16 * BAMBOO_PAGE_SIZE) #endif diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index 6447caf5..75a5f47c 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -1342,10 +1342,9 @@ void * smemalloc(int coren, int size, int * allocsize) { void * mem = NULL; - int isize = size+(BAMBOO_CACHE_LINE_SIZE); - int toallocate = ((size+(BAMBOO_CACHE_LINE_SIZE))>(BAMBOO_SMEM_SIZE)) ? - (size+(BAMBOO_CACHE_LINE_SIZE)):(BAMBOO_SMEM_SIZE); #ifdef MULTICORE_GC + int isize = size+(BAMBOO_CACHE_LINE_SIZE); + int toallocate = (isize>(BAMBOO_SMEM_SIZE)) ? (isize):(BAMBOO_SMEM_SIZE); // go through free mem list for suitable chunks int tofindb = 0; struct freeMemItem * freemem = findFreeMemChunk(coren, isize, &tofindb); @@ -1387,8 +1386,9 @@ void * smemalloc(int coren, } } else { #else - mem = mspace_calloc(bamboo_free_msp, 1, isize); - *allocsize = isize; + int toallocate = (size>(BAMBOO_SMEM_SIZE)) ? (size):(BAMBOO_SMEM_SIZE); + mem = mspace_calloc(bamboo_free_msp, 1, toallocate); + *allocsize = toallocate; if(mem == NULL) { #endif // no enough shared global memory @@ -1856,16 +1856,14 @@ msg: bamboo_smem_size = 0; bamboo_cur_msp = 0; } else { +#ifdef MULTICORE_GC // fill header to store the size of this mem block (*((int*)msgdata[1])) = msgdata[2]; bamboo_smem_size = msgdata[2] - BAMBOO_CACHE_LINE_SIZE; -#ifdef MULTICORE_GC bamboo_cur_msp = msgdata[1] + BAMBOO_CACHE_LINE_SIZE; #else - bamboo_cur_msp = - create_mspace_with_base((void*)(msgdata[1]+BAMBOO_CACHE_LINE_SIZE), - msgdata[2]-BAMBOO_CACHE_LINE_SIZE, - 0); + bamboo_smem_size = msgdata[2]; + bamboo_cur_msp =(void*)(msgdata[1]); #endif } smemflag = true; diff --git a/Robust/src/Runtime/socket.c b/Robust/src/Runtime/socket.c index 7c079ac0..e9e73d45 100644 --- a/Robust/src/Runtime/socket.c +++ b/Robust/src/Runtime/socket.c @@ -180,10 +180,10 @@ struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct A } return arraybytearray; -#endif - } - else + } else { return NULL; + } +#endif } diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 7526510f..8b15dd91 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -487,7 +487,7 @@ fi if $MULTICOREFLAG then -if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx2500m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \ +if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx1500m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \ $ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/ \ -dir $BUILDDIR $JAVAOPTS $SRCFILES then exit $? @@ -626,7 +626,7 @@ cd $TILERADIR make clean rm ./* -export TILERACFLAGS="-DTASK -DMULTICORE -DCLOSE_PRINT" +export TILERACFLAGS="-DTASK -DMULTICORE -DCLOSE_PRINT -DTILERA" if $CACHEFLUSHFLAG then # print path -- 2.34.1