From: jzhou Date: Mon, 2 Mar 2009 02:06:14 +0000 (+0000) Subject: add codes for generating distribution data for new search algorithm X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=8ab277adf1821eb760e4e904ae2b74941414ebfa;p=IRC.git add codes for generating distribution data for new search algorithm --- diff --git a/Robust/src/Analysis/Scheduling/CombinationUtil.java b/Robust/src/Analysis/Scheduling/CombinationUtil.java index 4356cbfa..be8f5667 100644 --- a/Robust/src/Analysis/Scheduling/CombinationUtil.java +++ b/Robust/src/Analysis/Scheduling/CombinationUtil.java @@ -38,6 +38,15 @@ public class CombinationUtil { this.node2Combine = null; this.rootNodes = null; } + + public void clear() { + this.sNodeVecs = null; + this.node2Combine.clear(); + this.node2Combine = null; + this.rootNodes.clear(); + this.rootNodes = null; + this.rootNum = 0; + } public boolean nextGen() { boolean trial = false; @@ -215,6 +224,17 @@ public class CombinationUtil { this.lastchoices = null; this.first4choice = false; } + + public void clear() { + this.rootNodes = null; + this.rootNStates.clear(); + this.rootNStates = null; + this.node2Combine = null; + this.combine.clear(); + this.combine = null; + this.lastchoices = null; + this.first4choice = false; + } public Vector> getCombine() { return combine; diff --git a/Robust/src/Analysis/Scheduling/MCImplSynthesis.java b/Robust/src/Analysis/Scheduling/MCImplSynthesis.java index 1bcb2879..983af365 100644 --- a/Robust/src/Analysis/Scheduling/MCImplSynthesis.java +++ b/Robust/src/Analysis/Scheduling/MCImplSynthesis.java @@ -1,7 +1,9 @@ package Analysis.Scheduling; +import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; +import java.io.PrintWriter; import java.util.Hashtable; import java.util.Iterator; import java.util.Random; @@ -27,6 +29,9 @@ public class MCImplSynthesis { int coreNum; int scheduleThreshold; int probThreshold; + int generateThreshold; + + //Random rand; public MCImplSynthesis(State state, TaskAnalysis ta, @@ -37,12 +42,14 @@ public class MCImplSynthesis { this.ownershipAnalysis = oa; this.scheduleAnalysis = new ScheduleAnalysis(state, ta); - scheduleAnalysis.setCoreNum(this.coreNum); + this.scheduleAnalysis.setCoreNum(this.coreNum); this.scheduleSimulator = new ScheduleSimulator(this.coreNum, state, ta); this.scheduleThreshold = 1000; this.probThreshold = 0; + this.generateThreshold = 30; + //this.rand = new Random(); } public int getCoreNum() { @@ -65,6 +72,14 @@ public class MCImplSynthesis { this.probThreshold = probThreshold; } + public int getGenerateThreshold() { + return generateThreshold; + } + + public void setGenerateThreshold(int generateThreshold) { + this.generateThreshold = generateThreshold; + } + public Vector synthesis() { // Print stuff to the original output and error streams. // The stuff printed through the 'origOut' and 'origErr' references @@ -107,7 +122,10 @@ public class MCImplSynthesis { // generate multiple schedulings this.scheduleAnalysis.setScheduleThreshold(this.scheduleThreshold); - this.scheduleAnalysis.schedule(); + this.scheduleAnalysis.schedule(this.generateThreshold); + if(this.generateThreshold > 5) { + this.generateThreshold = 5; + } Vector> scheduleGraphs = null; Vector> newscheduleGraphs = @@ -126,6 +144,7 @@ public class MCImplSynthesis { multiparamtds.addElement(td); } } + it_tasks = null; int tryindex = 1; int bestexetime = Integer.MAX_VALUE; @@ -135,6 +154,18 @@ public class MCImplSynthesis { System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); System.out.print("Simulate and optimize round: #" + tryindex + ": \n"); gid += newscheduleGraphs.size(); + if(scheduleGraphs != null) { + for(int i = 0; i < scheduleGraphs.size(); i++) { + Vector tmpgraph = scheduleGraphs.elementAt(i); + for(int j = 0; j < tmpgraph.size(); j++) { + tmpgraph.elementAt(j).getEdgeVector().clear(); + tmpgraph.elementAt(j).getInedgeVector().clear(); + } + tmpgraph.clear(); + tmpgraph = null; + } + scheduleGraphs.clear(); + } scheduleGraphs = newscheduleGraphs; schedulings.clear(); // get scheduling layouts from schedule graphs @@ -143,16 +174,29 @@ public class MCImplSynthesis { Vector tmpscheduling = generateScheduling(scheduleGraph, multiparamtds); schedulings.add(tmpscheduling); + scheduleGraph = null; + tmpscheduling = null; } selectedSchedulings.clear(); + for(int i = 0; i < selectedSimExeGraphs.size(); i++) { + selectedSimExeGraphs.elementAt(i).clear(); + } selectedSimExeGraphs.clear(); int tmpexetime = this.scheduleSimulator.simulate(schedulings, selectedSchedulings, selectedSimExeGraphs); if(tmpexetime < bestexetime) { bestexetime = tmpexetime; + if(scheduling != null) { + scheduling.clear(); + for(int j = 0; j < schedulinggraph.size(); j++) { + schedulinggraph.elementAt(j).getEdgeVector().clear(); + schedulinggraph.elementAt(j).getInedgeVector().clear(); + } + schedulinggraph.clear(); + } scheduling = schedulings.elementAt(selectedSchedulings.elementAt(0)); - schedulinggraph = newscheduleGraphs.elementAt(selectedSchedulings.elementAt(0)); + schedulinggraph = scheduleGraphs.elementAt(selectedSchedulings.elementAt(0)); System.out.print("end of: #" + tryindex + " (bestexetime: " + bestexetime + ")\n"); System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); tryindex++; @@ -173,28 +217,275 @@ public class MCImplSynthesis { selectedSimExeGraphs, gid, this.scheduleThreshold); + if(tmpexetime < bestexetime) { + scheduleGraphs.remove(selectedSchedulings.elementAt(0)); + } }while(newscheduleGraphs != null); // TODO: could it possibly lead to endless loop? + if(scheduleGraphs != null) { + scheduleGraphs.clear(); + } scheduleGraphs = null; newscheduleGraphs = null; + schedulings.clear(); schedulings = null; + selectedSchedulings.clear(); selectedSchedulings = null; + for(int i = 0; i < selectedSimExeGraphs.size(); i++) { + selectedSimExeGraphs.elementAt(i).clear(); + } + selectedSimExeGraphs.clear(); selectedSimExeGraphs = null; + multiparamtds.clear(); multiparamtds = null; - + + System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + System.out.print("selected bestexetime: " + bestexetime + "\n"); String path = this.state.outputdir + "scheduling_selected.dot"; SchedulingUtil.printScheduleGraph(path, schedulinggraph); // Close the streams. try { stdout.close(); + stdout = null; System.setOut(origOut); } catch (Exception e) { origOut.println("Redirect: Unable to close files!"); } + + schedulinggraph.clear(); + schedulinggraph = null; return scheduling; } + + // for test + // get the distribution info of new search algorithm + public void distribution() { + // Print stuff to the original output and error streams. + // The stuff printed through the 'origOut' and 'origErr' references + // should go to the console on most systems while the messages + // printed through the 'System.out' and 'System.err' will end up in + // the files we created for them. + //origOut.println ("\nRedirect: Round #2"); + //System.out.println ("Test output via 'SimulatorResult.out'."); + //origOut.println ("Test output via 'origOut' reference."); + + // Save the current standard input, output, and error streams + // for later restoration. + PrintStream origOut = System.out; + + // Create a new output stream for the standard output. + PrintStream stdout = null; + try { + stdout = new PrintStream( + new FileOutputStream(this.state.outputdir + "SimulatorResult_" + + this.coreNum + ".out")); + } catch (Exception e) { + // Sigh. Couldn't open the file. + System.out.println("Redirect: Unable to open output file!"); + System.exit(1); + } + + // Print stuff to the original output and error streams. + // On most systems all of this will end up on your console when you + // run this application. + //origOut.println ("\nRedirect: Round #1"); + //System.out.println ("Test output via 'System.out'."); + //origOut.println ("Test output via 'origOut' reference."); + + // Set the System out and err streams to use our replacements. + System.setOut(stdout); + + // generate multiple schedulings + this.scheduleAnalysis.setScheduleThreshold(1000); + this.scheduleAnalysis.schedule(20); + this.generateThreshold = 5; + this.probThreshold = 0; + + Vector> scheduleGraphs = null; + Vector> totestscheduleGraphs = + this.scheduleAnalysis.getScheduleGraphs(); + Vector> schedulings = new Vector>(); + Vector selectedSchedulings = new Vector(); + Vector> selectedSimExeGraphs = + new Vector>(); + + // check all multi-parameter tasks + Vector multiparamtds = new Vector(); + Iterator it_tasks = this.state.getTaskSymbolTable().getDescriptorsIterator(); + while(it_tasks.hasNext()) { + TaskDescriptor td = (TaskDescriptor)it_tasks.next(); + if(td.numParameters() > 1) { + multiparamtds.addElement(td); + } + } + it_tasks = null; + + File file=new File(this.state.outputdir + "distributeinfo_s_" + this.coreNum + ".out"); + FileOutputStream dotstream = null; + File file2=new File(this.state.outputdir + "distributeinfo_o_" + this.coreNum + ".out"); + FileOutputStream dotstream2 = null; + try { + dotstream = new FileOutputStream(file,false); + dotstream2 = new FileOutputStream(file2,false); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + PrintWriter output = new java.io.PrintWriter(dotstream, true); + PrintWriter output2 = new java.io.PrintWriter(dotstream2, true); + output.println("start time(1,000,000 cycles): " + totestscheduleGraphs.size()); + output2.println("optimized time(1,000,000 cycles): " + totestscheduleGraphs.size()); + for(int ii = 0; ii < 1/*totestscheduleGraphs.size()*/; ii++) { + Vector> newscheduleGraphs = + new Vector>(); + newscheduleGraphs.add(totestscheduleGraphs.elementAt(ii)); + int tryindex = 1; + int bestexetime = Integer.MAX_VALUE; + int gid = 1; + Vector scheduling = null; + Vector schedulinggraph = null; + boolean isfirst = true; + Random rand = new Random(); + // simulate the generated schedulings and try to optimize it + System.out.print("=========================================================\n"); + System.out.print("# " + ii + ": \n"); + do { + System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + System.out.print("Simulate and optimize round: #" + tryindex + ": \n"); + gid += newscheduleGraphs.size(); + if(scheduleGraphs != null) { + for(int i = 0; i < scheduleGraphs.size(); i++) { + Vector tmpgraph = scheduleGraphs.elementAt(i); + for(int j = 0; j < tmpgraph.size(); j++) { + ScheduleNode snode = tmpgraph.elementAt(j); + snode.getEdgeVector().clear(); + snode.getInedgeVector().clear(); + snode.getScheduleEdges().clear(); + snode.getClassNodes().clear(); + } + tmpgraph.clear(); + tmpgraph = null; + } + scheduleGraphs.clear(); + } + scheduleGraphs = newscheduleGraphs; + schedulings.clear(); + // get scheduling layouts from schedule graphs + for(int i = 0; i < scheduleGraphs.size(); i++) { + Vector scheduleGraph = scheduleGraphs.elementAt(i); + Vector tmpscheduling = + generateScheduling(scheduleGraph, multiparamtds); + schedulings.add(tmpscheduling); + scheduleGraph = null; + tmpscheduling = null; + } + selectedSchedulings.clear(); + for(int i = 0; i < selectedSimExeGraphs.size(); i++) { + selectedSimExeGraphs.elementAt(i).clear(); + } + selectedSimExeGraphs.clear(); + int tmpexetime = this.scheduleSimulator.simulate(schedulings, + selectedSchedulings, + selectedSimExeGraphs); + if(isfirst) { + output.println(((float)tmpexetime/1000000)); + isfirst = false; + } + if(tmpexetime < bestexetime) { + bestexetime = tmpexetime; + if(scheduling != null) { + scheduling.clear(); + for(int j = 0; j < schedulinggraph.size(); j++) { + ScheduleNode snode = schedulinggraph.elementAt(j); + snode.getEdgeVector().clear(); + snode.getInedgeVector().clear(); + snode.getScheduleEdges().clear(); + snode.getClassNodes().clear(); + } + schedulinggraph.clear(); + } + scheduling = schedulings.elementAt(selectedSchedulings.elementAt(0)); + schedulinggraph = scheduleGraphs.elementAt(selectedSchedulings.elementAt(0)); + tryindex++; + System.out.print("end of: #" + tryindex + " (bestexetime: " + bestexetime + ")\n"); + System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + } else if(tmpexetime == bestexetime) { + System.out.print("end of: #" + tryindex + " (bestexetime: " + bestexetime + ")\n"); + System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + tryindex++; + if((Math.abs(rand.nextInt()) % 100) < this.probThreshold) { + break; + } + } else { + break; + } + + // try to optimize theschedulings best one scheduling + newscheduleGraphs = optimizeScheduling(scheduleGraphs, + selectedSchedulings, + selectedSimExeGraphs, + gid, + this.scheduleThreshold); + if(tmpexetime < bestexetime) { + scheduleGraphs.remove(selectedSchedulings.elementAt(0)); + } + }while(newscheduleGraphs != null); // TODO: could it possibly lead to endless loop? + + scheduleGraphs.clear(); + scheduleGraphs = null; + scheduling = null; + schedulinggraph = null; + if(newscheduleGraphs != null) { + newscheduleGraphs.clear(); + } + newscheduleGraphs = null; + totestscheduleGraphs.elementAt(ii).clear(); + for(int i = 0; i < schedulings.size(); i++) { + schedulings.elementAt(i).clear(); + } + schedulings.clear(); + selectedSchedulings.clear(); + for(int i = 0; i < selectedSimExeGraphs.size(); i++) { + selectedSimExeGraphs.elementAt(i).clear(); + } + selectedSimExeGraphs.clear(); + + output2.println(((float)bestexetime/1000000)); + System.out.print("=========================================================\n"); + } + + if(scheduleGraphs != null) { + scheduleGraphs.clear(); + } + scheduleGraphs = null; + totestscheduleGraphs = null; + for(int i = 0; i < schedulings.size(); i++) { + schedulings.elementAt(i).clear(); + } + schedulings.clear(); + schedulings = null; + selectedSchedulings.clear(); + selectedSchedulings = null; + selectedSimExeGraphs.clear(); + selectedSimExeGraphs = null; + multiparamtds.clear(); + multiparamtds = null; + + // Close the streams. + try { + output.close(); + stdout.close(); + output = null; + stdout = null; + System.setOut(origOut); + } catch (Exception e) { + origOut.println("Redirect: Unable to close files!"); + } + + return; + } private Vector> optimizeScheduling(Vector> scheduleGraphs, Vector selectedScheduleGraphs, @@ -258,7 +549,7 @@ public class MCImplSynthesis { for(int i = 0; i < criticalPath.size(); i++) { SimExecutionEdge seedge = criticalPath.elementAt(i); Vector predicates = seedge.getPredicates(); - if(predicates.size() > 0) { + if(predicates != null) { // have predicates int starttime = 0; // check the latest finish time of all the predicates @@ -486,7 +777,9 @@ public class MCImplSynthesis { (SimExecutionNode)tmpseedge.getTarget(); if(tmpsenode.getTimepoint() > timepoint) { // update the predicate info - edge.getPredicates().remove(lastpredicateedge); + if(edge.getPredicates() != null) { + edge.getPredicates().remove(lastpredicateedge); + } edge.addPredicate(criticalPath.elementAt(index)); break; } @@ -615,27 +908,33 @@ public class MCImplSynthesis { CombinationUtil.CombineGenerator cGen = CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine); + Random rand = new Random(); while ((left > 0) && (cGen.nextGen())) { - Vector> combine = cGen.getCombine(); - Vector sNodes = SchedulingUtil.generateScheduleGraph(this.state, - newscheduleGraph, - scheduleEdges, - rootNodes, - combine, - lgid++); - if(optimizeschedulegraphs == null) { - optimizeschedulegraphs = new Vector>(); + if(Math.abs(rand.nextInt()) % 100 > this.generateThreshold) { + Vector> combine = cGen.getCombine(); + Vector sNodes = SchedulingUtil.generateScheduleGraph(this.state, + newscheduleGraph, + scheduleEdges, + rootNodes, + combine, + lgid++); + if(optimizeschedulegraphs == null) { + optimizeschedulegraphs = new Vector>(); + } + optimizeschedulegraphs.add(sNodes); + combine = null; + sNodes = null; + left--; } - optimizeschedulegraphs.add(sNodes); - combine = null; - sNodes = null; - left--; } + cGen.clear(); rootNodes = null; nodes2combine = null; newscheduleGraph = null; scheduleEdges.clear(); scheduleEdges = null; + roots = null; + tocombines = null; return optimizeschedulegraphs; } @@ -721,6 +1020,7 @@ public class MCImplSynthesis { setstartupcore = true; } } + it_edges = null; } it_flags = null; } diff --git a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java index 9471e651..2ec42225 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java +++ b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java @@ -66,7 +66,7 @@ public class ScheduleAnalysis { return scheduleEdges; } - public void schedule() { + public void schedule(int generateThreshold) { try { Vector toBreakDown = new Vector(); ScheduleNode startupNode = null; @@ -81,7 +81,8 @@ public class ScheduleAnalysis { // as possible CFSTGTransform(); // mappint to real multi-core processor - coreMapping(); + coreMapping(generateThreshold); + toBreakDown = null; } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -139,6 +140,7 @@ public class ScheduleAnalysis { } } } + it_rootnodes = null; } Iterator it_flags = this.taskanalysis.getFlagStates(cd).iterator(); while(it_flags.hasNext()) { @@ -155,10 +157,13 @@ public class ScheduleAnalysis { ((FlagState)edge.getSource()).setByObj(taskinfo.m_byObj); } } + it_edges = null; } + it_flags = null; } } taskinfos = null; + it_classes = null; } else { randomProfileSetting(); } @@ -187,13 +192,16 @@ public class ScheduleAnalysis { edge.setisbackedge(true); } } + it_edges = null; } + it_fs = null; } } } fss = null; } } + it_classes = null; } private void readProfileInfo(java.util.Hashtable taskinfos) { @@ -308,6 +316,9 @@ public class ScheduleAnalysis { taskinfos.put(inname, tinfo); inindex = profiledata.indexOf('\n'); } + inStream.close(); + inStream = null; + b = null; } catch(Exception e) { e.printStackTrace(); } @@ -318,12 +329,14 @@ public class ScheduleAnalysis { // Randomly set the newRate and probability of FEdges java.util.Random r=new java.util.Random(); int tint = 0; - for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) { + Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); + for(; it_classes.hasNext();) { ClassDescriptor cd=(ClassDescriptor) it_classes.next(); if(cd.hasFlags()) { Vector rootnodes=this.taskanalysis.getRootNodes(cd); if(rootnodes!=null) { - for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();) { + Iterator it_rootnodes=rootnodes.iterator(); + for(; it_rootnodes.hasNext();) { FlagState root=(FlagState)it_rootnodes.next(); Vector allocatingTasks = root.getAllocatingTasks(); if(allocatingTasks != null) { @@ -374,6 +387,7 @@ public class ScheduleAnalysis { } } } + it_rootnodes = null; } Iterator it_flags = this.taskanalysis.getFlagStates(cd).iterator(); @@ -413,9 +427,12 @@ public class ScheduleAnalysis { total -= tint; } } + it_edges = null; } + it_flags = null; } } + it_classes = null; } private ScheduleNode buildCFSTG(Vector toBreakDown) { @@ -446,9 +463,11 @@ public class ScheduleAnalysis { cNode.setTransTime(45); } } + rootnodes = null; fStates = null; sFStates = null; } + it_classes = null; ScheduleNode startupNode = null; // For each ClassNode create a ScheduleNode containing it @@ -538,7 +557,6 @@ public class ScheduleAnalysis { for(i = 0; i < toBreakDown.size(); i++ ) { cloneSNodeList(toBreakDown.elementAt(i), false); } - toBreakDown = null; } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -576,6 +594,7 @@ public class ScheduleAnalysis { while(it_edge.hasNext()) { toVisit.add((ScheduleNode)((ScheduleEdge)it_edge.next()).getTarget()); } + it_edge = null; } } toVisit = null; @@ -748,6 +767,7 @@ public class ScheduleAnalysis { ses = null; } keys = null; + it_keys = null; } fe2ses.clear(); sn2fes.clear(); @@ -931,6 +951,7 @@ public class ScheduleAnalysis { toClone = null; clone = null; qcn2cn = null; + cn2cn.clear(); cn2cn = null; origins = null; sn2sn = null; @@ -988,6 +1009,7 @@ public class ScheduleAnalysis { sfss.removeElement(temp); } } + it_edges = null; } sfss = null; Vector sFStates = FlagState.DFS.topology(fStates, null); @@ -1021,6 +1043,7 @@ public class ScheduleAnalysis { toiterate.add(temp); } } + it_inedges = null; } toiterate = null; @@ -1063,6 +1086,7 @@ public class ScheduleAnalysis { } } } + it_isEdges = null; oldSNode.getScheduleEdges().removeAll(toremove); toremove.clear(); // redirect ScheudleEdges out of this subtree to the new ScheduleNode @@ -1080,6 +1104,7 @@ public class ScheduleAnalysis { } } } + it_sEdges = null; se.getSource().getEdgeVector().removeAll(toremove); toremove = null; rCNodes = null; @@ -1115,7 +1140,7 @@ public class ScheduleAnalysis { // TODO: restrict the number of generated scheduling according to the setted // scheduleThreshold - private void coreMapping() throws Exception { + private void coreMapping(int generateThreshold) throws Exception { if(this.coreNum == -1) { throw new Exception("Error: un-initialized coreNum when doing scheduling."); } @@ -1148,6 +1173,7 @@ public class ScheduleAnalysis { this.coreNum); int gid = 1; + Random rand = new Random(); while((gid <= this.scheduleThreshold) && (rGen.nextGen())) { // first get the chosen rootNodes Vector> rootNodes = rGen.getRootNodes(); @@ -1157,20 +1183,25 @@ public class ScheduleAnalysis { CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine); while((gid <= this.scheduleThreshold) && cGen.nextGen()) { - Vector> combine = cGen.getCombine(); - Vector sNodes = SchedulingUtil.generateScheduleGraph(this.state, - this.scheduleNodes, - this.scheduleEdges, - rootNodes, - combine, - gid++); - this.scheduleGraphs.add(sNodes); - combine = null; - sNodes = null; + if(Math.abs(rand.nextInt()) % 100 > generateThreshold) { + Vector> combine = cGen.getCombine(); + Vector sNodes = + SchedulingUtil.generateScheduleGraph(this.state, + this.scheduleNodes, + this.scheduleEdges, + rootNodes, + combine, + gid++); + this.scheduleGraphs.add(sNodes); + combine = null; + sNodes = null; + } } + cGen.clear(); rootNodes = null; nodes2combine = null; } + rGen.clear(); sNodeVecs = null; } } diff --git a/Robust/src/Analysis/Scheduling/ScheduleNode.java b/Robust/src/Analysis/Scheduling/ScheduleNode.java index b8d993bb..2c2d2c24 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleNode.java +++ b/Robust/src/Analysis/Scheduling/ScheduleNode.java @@ -134,6 +134,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { for(int i = 0; i < mergedcids.size(); i++) { this.hashcid = this.hashcid * 31 + mergedcids.elementAt(i); } + mergedcids = null; } public int getExeTime() { @@ -332,6 +333,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { toiterate.add(temp); } } + it_inedges = null; } toiterate = null; @@ -354,6 +356,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { } this.edges.addElement(tse); } + it_edges = null; targetSEdges = null; @@ -378,6 +381,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { tse.setSource(this); this.edges.addElement(tse); } + it_edges = null; // As all tasks inside one ScheduleNode are executed sequentially, // simply add the execution time of all the ClassNodes inside one ScheduleNode. @@ -424,6 +428,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { tse.setTarget(this); this.inedges.addElement(tse); } + it_edges = null; // As all tasks inside one ScheduleNode are executed sequentially, // simply add the execution time of all the ClassNodes inside one ScheduleNode. @@ -456,6 +461,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { } } } + it_innersEdges = null; this.scheduleEdges.removeAll(toremove); for(int i = 0; i < toremove.size(); i++) { ScheduleEdge tse = toremove.elementAt(i); @@ -479,6 +485,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { sNode.addEdge(tse); } } + it_exsEdges = null; // redirect inedges whose target is this Classnode to new ScheduleNode Iterator it_insEdges = this.inedges(); while(it_insEdges.hasNext()) { @@ -488,6 +495,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { tse.setTarget(sNode); } } + it_insEdges = null; this.inedges.removeAll(toremove); toremove.clear(); toremove = null; diff --git a/Robust/src/Analysis/Scheduling/ScheduleSimulator.java b/Robust/src/Analysis/Scheduling/ScheduleSimulator.java index e8b7565e..754d2356 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleSimulator.java +++ b/Robust/src/Analysis/Scheduling/ScheduleSimulator.java @@ -113,7 +113,9 @@ public class ScheduleSimulator { selectedSimExeGraphs.add(simexegraph); } scheduling = null; + checkpoints.clear(); checkpoints = null; + simexegraph = null; index++; } it_scheduling = null; @@ -665,6 +667,7 @@ public class ScheduleSimulator { tmpentry = null; nobjs = null; } + it_entries = null; transObjQueues = null; return totransObjs; @@ -891,14 +894,16 @@ public class ScheduleSimulator { this.type = type; this.td = ts.getTd(); Vector> paraQueues = ts.getParaQueues(); - this.taskparams = new Vector(); - if((this.type != TASKABORT) && (this.type != TASKREMOVE)) { + if(this.type == TASKSTART) { + this.taskparams = new Vector(); for(int i = 0; i < paraQueues.size(); i++) { ObjectSimulator tpara = paraQueues.elementAt(i).peek(); this.taskparams.add(tpara.getOid()); } - paraQueues = null; + } else { + this.taskparams = null; } + paraQueues = null; if(this.type == TFWITHOBJ) { this.nObjs = new Hashtable(); } else { diff --git a/Robust/src/Analysis/Scheduling/SchedulingUtil.java b/Robust/src/Analysis/Scheduling/SchedulingUtil.java index 2728af34..8197cdd2 100644 --- a/Robust/src/Analysis/Scheduling/SchedulingUtil.java +++ b/Robust/src/Analysis/Scheduling/SchedulingUtil.java @@ -283,6 +283,7 @@ public class SchedulingUtil { output.println("\t\tlabel=\"" + gn.getTextLabel() + "\";"); Iterator it_cnodes = gn.getClassNodesIterator(); traverseCNodes(output, it_cnodes); + it_cnodes = null; //Draw the internal 'new' edges Iterator it_edges =gn.getScheduleEdgesIterator(); while(it_edges.hasNext()) { @@ -316,6 +317,7 @@ public class SchedulingUtil { } } output.println("\t}\n"); + it_edges = null; //Draw 'new' edges of this ScheduleNode while(edges.hasNext()) { ScheduleEdge se = (ScheduleEdge)edges.next(); @@ -342,7 +344,9 @@ public class SchedulingUtil { output.println(se.getTargetFState().getLabel() + " [label=\"" + se.getLabel() + "\", color=red, style=dashed];"); } } + edges = null; } + it = null; } private static void traverseCNodes(PrintWriter output, @@ -399,7 +403,8 @@ public class SchedulingUtil { Edge edge = (Edge) edges.next(); GraphNode node = edge.getTarget(); if (nodes.contains(node)) { - for(Iterator nodeit=nonmerge(node, nodes).iterator(); nodeit.hasNext();) { + Iterator nodeit=nonmerge(node, nodes).iterator(); + for(; nodeit.hasNext();) { GraphNode node2=(GraphNode)nodeit.next(); String edgelabel = ""; String edgedotnodeparams=""; @@ -425,12 +430,19 @@ public class SchedulingUtil { NewObjInfo noi = hashtable.get(cd); edgelabel += ":{ class " + cd.getSymbol() + " | " + noi.getNewRate() + " | (" + noi.getProbability() + "%) }"; } + keys = null; + it_keys = null; } output.println("\t" + gn.getLabel() + " -> " + node2.getLabel() + " [" + "label=\"" + edgelabel + "\"" + edgedotnodeparams + "];"); } + nodeit = null; } } + edges = null; } + cycleset = null; + namers = null; + it = null; } private static Set nonmerge(GraphNode gn, @@ -451,8 +463,10 @@ public class SchedulingUtil { if (!newset.contains(node)&&nodes.contains(node)) toprocess.add(node); } + edges = null; } } + toprocess = null; return newset; } @@ -598,7 +612,9 @@ public class SchedulingUtil { } else { tmpLabel.append(";"); } + entry = null; } + it_entry = null; if(!(lastTaskNodes[cNum].equals("first"))) { if (!(lastTaskNodes[cNum].equals(tmpTaskNode))) { output.print("\t"); @@ -834,6 +850,7 @@ public class SchedulingUtil { } output.println("}"); output.close(); + nodes = null; } catch (Exception e) { e.printStackTrace(); System.exit(-1); diff --git a/Robust/src/Analysis/Scheduling/SimExecutionEdge.java b/Robust/src/Analysis/Scheduling/SimExecutionEdge.java index 533a5b05..4f0a5014 100644 --- a/Robust/src/Analysis/Scheduling/SimExecutionEdge.java +++ b/Robust/src/Analysis/Scheduling/SimExecutionEdge.java @@ -35,7 +35,7 @@ public class SimExecutionEdge extends Edge { this.bestStartPoint = -1; this.lastpredicatenode = null; this.lastpredicateedge = null; - this.predicates = new Vector(); + this.predicates = null; this.isFixedTime = true; } @@ -77,6 +77,9 @@ public class SimExecutionEdge extends Edge { } public void addPredicate(SimExecutionEdge predicate) { + if(this.predicates == null) { + this.predicates = new Vector(); + } if(!this.predicates.contains(predicate)) { this.predicates.add(predicate); } diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index db364b58..6a6f6a52 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -55,7 +55,8 @@ public class Main { Vector sourcefiles=new Vector(); state.classpath.add("."); - String outputdir = null; + String outputdir = null; + boolean isDistributeInfo = false; for(int i=0; i scheduling = mcImplSynthesis.synthesis(); - - // generate multicore codes - if(state.MULTICORE) { - BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, - bf.getMap(), - tu, - sa, - scheduling, - mcImplSynthesis.getCoreNum(), - pa); - bcm.setOwnershipAnalysis(oa); - bcm.buildCode(); + if(isDistributeInfo) { + mcImplSynthesis.distribution(); + } else { + mcImplSynthesis.setScheduleThreshold(50); + mcImplSynthesis.setProbThreshold(0); + mcImplSynthesis.setGenerateThreshold(30); + Vector scheduling = mcImplSynthesis.synthesis(); + + // generate multicore codes + if(state.MULTICORE) { + BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, + bf.getMap(), + tu, + sa, + scheduling, + mcImplSynthesis.getCoreNum(), + pa); + bcm.setOwnershipAnalysis(oa); + bcm.buildCode(); + } + scheduling.clear(); + scheduling = null; } - scheduling = null; } }