From: jzhou Date: Tue, 18 Nov 2008 23:20:44 +0000 (+0000) Subject: Fix bugs in scheduling simulator. Also add -robustroot setting in Tests/dotest script X-Git-Tag: buildscript^7~30 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=62a2e5377a6d5d303ff6a927cfbc35f7f14f6453;p=IRC.git Fix bugs in scheduling simulator. Also add -robustroot setting in Tests/dotest script --- diff --git a/Robust/src/Analysis/Scheduling/CoreSimulator.java b/Robust/src/Analysis/Scheduling/CoreSimulator.java index 0bc4543b..38b3a0d1 100644 --- a/Robust/src/Analysis/Scheduling/CoreSimulator.java +++ b/Robust/src/Analysis/Scheduling/CoreSimulator.java @@ -166,6 +166,17 @@ public class CoreSimulator { } allycores = null; } + // check if need to transfer to other cores + Queue targetcores = this.getTargetCores(obj.getCurrentFS()); + if(targetcores != null) { + if(transObjs == null) { + transObjs = new Vector(); + } + if(!transObjs.contains(obj)) { + transObjs.add(obj); + } + remove = true; + } for(int j = 0; j < this.tasks.size(); j++) { this.tasks.elementAt(j).refreshPara(obj, remove); } diff --git a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java index 94b887ec..89e8f827 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java +++ b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java @@ -213,7 +213,9 @@ public class ScheduleAnalysis { } toVisit = null; - SchedulingUtil.printScheduleGraph("scheduling_ori.dot", this.scheduleNodes); + if(this.state.PRINTSCHEDULING) { + SchedulingUtil.printScheduleGraph("scheduling_ori.dot", this.scheduleNodes); + } } public void scheduleAnalysis() { @@ -384,7 +386,9 @@ public class ScheduleAnalysis { fe2ses = null; sn2fes = null; - SchedulingUtil.printScheduleGraph("scheduling_extend.dot", this.scheduleNodes); + if(this.state.PRINTSCHEDULING) { + SchedulingUtil.printScheduleGraph("scheduling_extend.dot", this.scheduleNodes); + } } private void handleScheduleEdge(ScheduleEdge se, boolean merge) { @@ -746,8 +750,10 @@ public class ScheduleAnalysis { // Enough cores, no need to combine any ScheduleNode this.scheduleGraphs.addElement(this.scheduleNodes); int gid = 1; - String path = "scheduling_" + gid + ".dot"; - SchedulingUtil.printScheduleGraph(path, this.scheduleNodes); + if(this.state.PRINTSCHEDULING) { + String path = "scheduling_" + gid + ".dot"; + SchedulingUtil.printScheduleGraph(path, this.scheduleNodes); + } } else { // Go through all the Scheudle Nodes, organize them in order of their cid Vector> sNodeVecs = new Vector>(); @@ -1052,8 +1058,10 @@ public class ScheduleAnalysis { sn2hash = null; sn2sn = null; - String path = "scheduling_" + gid + ".dot"; - SchedulingUtil.printScheduleGraph(path, result); + if(this.state.PRINTSCHEDULING) { + String path = "scheduling_" + gid + ".dot"; + SchedulingUtil.printScheduleGraph(path, result); + } return result; } diff --git a/Robust/src/Analysis/Scheduling/ScheduleSimulator.java b/Robust/src/Analysis/Scheduling/ScheduleSimulator.java index 49c063df..d5db4149 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleSimulator.java +++ b/Robust/src/Analysis/Scheduling/ScheduleSimulator.java @@ -303,7 +303,7 @@ public class ScheduleSimulator { // this obj will reside on this core cs.addObject(tobj); } else { - Integer targetCore = cores.peek(); + Integer targetCore = cores.poll(); if(targetCore == coreNum) { // this obj will reside on this core cs.addObject(tobj); @@ -315,8 +315,9 @@ public class ScheduleSimulator { tmpqueue.add(new ObjectInfo(tobj)); tmpqueue = null; } - cores = null; + cores.add(targetCore); } + cores = null; // check if this object becoming shared or not Vector allycores = cs.getAllyCores(tobj.getCurrentFS()); if(allycores != null) { @@ -380,8 +381,10 @@ public class ScheduleSimulator { finishTasks = null; } - SchedulingUtil.printSimulationResult("SimulatorResult_" + this.invoketime + ".dot", this.processTime, - this.coreNum, this.checkpoints); + if(this.state.PRINTSCHEDULESIM) { + SchedulingUtil.printSimulationResult("SimulatorResult_" + this.invoketime + ".dot", this.processTime, + this.coreNum, this.checkpoints); + } System.out.println("Simulate scheduling #" + this.invoketime + ": "); System.out.println("\tTotal execution time is: " + this.processTime); System.out.println("\tUtility of cores: "); diff --git a/Robust/src/Analysis/Scheduling/TaskSimulator.java b/Robust/src/Analysis/Scheduling/TaskSimulator.java index 6e5c6eb4..f8dfc927 100644 --- a/Robust/src/Analysis/Scheduling/TaskSimulator.java +++ b/Robust/src/Analysis/Scheduling/TaskSimulator.java @@ -213,11 +213,26 @@ public class TaskSimulator { if(tpara.isShared()) { if(tpara.isHold()) { // shared object held by other tasks - finishTime = 800; // TODO currenly assume the effort on requesting locks are only 1 - this.currentRun.setFinishTime(finishTime); + finishTime = 800; // TODO currenly assume the effort on requesting locks are only 800 + /*this.currentRun.setFinishTime(finishTime); this.currentRun.setExetype(1); paraQueues.elementAt(i).poll(); paraQueues.elementAt(i).add(tpara); + for(int j = 0; j < i; ++j) { + tpara = this.paraQueues.elementAt(j).poll(); + if(tpara.isShared() && tpara.isHold()) { + tpara.setHold(false); + } + this.paraQueues.elementAt(j).add(tpara); + }*/ + // remove it instead + this.currentRun.setFinishTime(finishTime); + this.currentRun.setExetype(2); + paraQueues.elementAt(i).poll(); + // remove this object from the remaining parameter queues + for(int j = i + 1; j < paraQueues.size(); j++) { + paraQueues.elementAt(j).remove(tpara); + } for(int j = 0; j < i; ++j) { tpara = this.paraQueues.elementAt(j).poll(); if(tpara.isShared() && tpara.isHold()) { @@ -228,7 +243,7 @@ public class TaskSimulator { return; } else if (tpara.getVersion() != this.objVersionTbl.get(tpara)) { // shared object has been updated and no longer fitted to this task - finishTime = 800; // TODO currenly assume the effort on requesting locks are only 1 + finishTime = 800; // TODO currenly assume the effort on requesting locks are only 800 this.currentRun.setFinishTime(finishTime); this.currentRun.setExetype(2); paraQueues.elementAt(i).poll(); diff --git a/Robust/src/Analysis/TaskStateAnalysis/FEdge.java b/Robust/src/Analysis/TaskStateAnalysis/FEdge.java index c998d70c..c81d8546 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FEdge.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FEdge.java @@ -206,6 +206,10 @@ public class FEdge extends Edge { public int getInvokeNumGap() { return this.expInvokeNum - this.invokeNum; } + + public int getInvokeNumGapByObj(int byObj) { + return this.expInvokeNum - (this.invokeNum/byObj); + } public void setExpInvokeNum(int expInvokeNum) { this.expInvokeNum = expInvokeNum; diff --git a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java index 2fb5b671..58bd822f 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java @@ -33,6 +33,7 @@ public class FlagState extends GraphNode implements Cloneable { private int executeTime; private int visited4time; private int invokeNum; + private int byObj; // for building multicore codes private int andmask; private int checkmask; @@ -54,6 +55,7 @@ public class FlagState extends GraphNode implements Cloneable { this.executeTime = -1; this.visited4time = -1; this.invokeNum = 0; + this.byObj = 0; this.andmask = 0; this.checkmask = 0; this.setmask = false; @@ -283,13 +285,16 @@ public class FlagState extends GraphNode implements Cloneable { FlagState fs=(FlagState)o; if (fs.cd!=cd) return false; + if(fs.byObj != this.byObj) { + return false; + } return (fs.flagstate.equals(flagstate) & fs.tags.equals(tags)); } return false; } public int hashCode() { - return cd.hashCode()^flagstate.hashCode()^tags.hashCode(); + return cd.hashCode()^flagstate.hashCode()^tags.hashCode()^byObj; } public String getLabel() { @@ -422,6 +427,7 @@ public class FlagState extends GraphNode implements Cloneable { for(int i = 0; i < this.inedges.size(); i++) { o.inedges.addElement(this.inedges.elementAt(i)); } + o.byObj = this.byObj; return o; } @@ -435,7 +441,11 @@ public class FlagState extends GraphNode implements Cloneable { // refresh all the expInvokeNum of each edge for(int i = 0; i < this.edges.size(); i++) { next = (FEdge) this.edges.elementAt(i); - next.setExpInvokeNum((int)(Math.ceil(this.invokeNum * next.getProbability() / 100))); + if(this.byObj == 0) { + next.setExpInvokeNum((int)(Math.ceil(this.invokeNum * next.getProbability() / 100))); + } else { + next.setExpInvokeNum((int)(Math.ceil(((this.invokeNum - 1) / this.byObj + 1) * next.getProbability() / 100))); + } } // find the one with the biggest gap between its actual invoke time and the expected invoke time @@ -446,7 +456,7 @@ public class FlagState extends GraphNode implements Cloneable { boolean isbackedge = true; for(int i = 0; i < this.edges.size(); i++) { next = ((FEdge) this.edges.elementAt(i)); - int temp = next.getInvokeNumGap(); + int temp = (this.byObj == 0) ? next.getInvokeNumGap() : next.getInvokeNumGapByObj(this.byObj); boolean exchange = false; if((temp > gap) && (next.getTask().equals(td))) { exchange = true; @@ -473,6 +483,14 @@ public class FlagState extends GraphNode implements Cloneable { return next; } + public int getByObj() { + return byObj; + } + + public void setByObj(int byObj) { + this.byObj = byObj; + } + /*public Vector getAllys() { return allys; } diff --git a/Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFADemo.java b/Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFADemo.java index fdc07bc5..7c923d05 100644 --- a/Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFADemo.java +++ b/Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFADemo.java @@ -88,26 +88,28 @@ public class PSFADemo { Cell toadd = (Cell)(g.m_neighCells.get(key)); int toaddnp = toadd.m_numPars; for(int j = 0; j < toaddnp; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); + if(np < cell.m_p.length) { + if(cell.m_p[np] == null) { + cell.m_p[np] = new Vec3(); + cell.m_hv[np] = new Vec3(); + cell.m_v[np] = new Vec3(); + cell.m_a[np] = new Vec3(); + } + cell.m_p[np].m_x = toadd.m_p[j].m_x; + cell.m_p[np].m_y = toadd.m_p[j].m_y; + cell.m_p[np].m_z = toadd.m_p[j].m_z; + cell.m_hv[np].m_x = toadd.m_hv[j].m_x; + cell.m_hv[np].m_y = toadd.m_hv[j].m_y; + cell.m_hv[np].m_z = toadd.m_hv[j].m_z; + cell.m_v[np].m_x = toadd.m_v[j].m_x; + cell.m_v[np].m_y = toadd.m_v[j].m_y; + cell.m_v[np].m_z = toadd.m_v[j].m_z; + cell.m_a[np].m_x = toadd.m_a[j].m_x; + cell.m_a[np].m_y = toadd.m_a[j].m_y; + cell.m_a[np].m_z = toadd.m_a[j].m_z; + cell.m_density[np] = toadd.m_density[j]; + np++; } - cell.m_p[np].m_x = toadd.m_p[j].m_x; - cell.m_p[np].m_y = toadd.m_p[j].m_y; - cell.m_p[np].m_z = toadd.m_p[j].m_z; - cell.m_hv[np].m_x = toadd.m_hv[j].m_x; - cell.m_hv[np].m_y = toadd.m_hv[j].m_y; - cell.m_hv[np].m_z = toadd.m_hv[j].m_z; - cell.m_v[np].m_x = toadd.m_v[j].m_x; - cell.m_v[np].m_y = toadd.m_v[j].m_y; - cell.m_v[np].m_z = toadd.m_v[j].m_z; - cell.m_a[np].m_x = toadd.m_a[j].m_x; - cell.m_a[np].m_y = toadd.m_a[j].m_y; - cell.m_a[np].m_z = toadd.m_a[j].m_z; - cell.m_density[np] = toadd.m_density[j]; - np++; } cell.m_numPars += toaddnp; visited.put(key, key); @@ -126,26 +128,28 @@ public class PSFADemo { Cell toadd = g.m_cells[ix][iy][iz]; int toaddnp = toadd.m_numPars; for(int j = 0; j < toaddnp; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); + if(np < cell.m_p.length) { + if(cell.m_p[np] == null) { + cell.m_p[np] = new Vec3(); + cell.m_hv[np] = new Vec3(); + cell.m_v[np] = new Vec3(); + cell.m_a[np] = new Vec3(); + } + cell.m_p[np].m_x = toadd.m_p[j].m_x; + cell.m_p[np].m_y = toadd.m_p[j].m_y; + cell.m_p[np].m_z = toadd.m_p[j].m_z; + cell.m_hv[np].m_x = toadd.m_hv[j].m_x; + cell.m_hv[np].m_y = toadd.m_hv[j].m_y; + cell.m_hv[np].m_z = toadd.m_hv[j].m_z; + cell.m_v[np].m_x = toadd.m_v[j].m_x; + cell.m_v[np].m_y = toadd.m_v[j].m_y; + cell.m_v[np].m_z = toadd.m_v[j].m_z; + cell.m_a[np].m_x = toadd.m_a[j].m_x; + cell.m_a[np].m_y = toadd.m_a[j].m_y; + cell.m_a[np].m_z = toadd.m_a[j].m_z; + cell.m_density[np] = toadd.m_density[j]; + np++; } - cell.m_p[np].m_x = toadd.m_p[j].m_x; - cell.m_p[np].m_y = toadd.m_p[j].m_y; - cell.m_p[np].m_z = toadd.m_p[j].m_z; - cell.m_hv[np].m_x = toadd.m_hv[j].m_x; - cell.m_hv[np].m_y = toadd.m_hv[j].m_y; - cell.m_hv[np].m_z = toadd.m_hv[j].m_z; - cell.m_v[np].m_x = toadd.m_v[j].m_x; - cell.m_v[np].m_y = toadd.m_v[j].m_y; - cell.m_v[np].m_z = toadd.m_v[j].m_z; - cell.m_a[np].m_x = toadd.m_a[j].m_x; - cell.m_a[np].m_y = toadd.m_a[j].m_y; - cell.m_a[np].m_z = toadd.m_a[j].m_z; - cell.m_density[np] = toadd.m_density[j]; - np++; } cell.m_numPars += toaddnp; visited.put(index, index); @@ -171,26 +175,28 @@ public class PSFADemo { Cell toadd = g.m_cells[ix][iy][iz]; int toaddnp = toadd.m_numPars; for(int j = 0; j < toaddnp; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); + if(np < cell.m_p.length) { + if(cell.m_p[np] == null) { + cell.m_p[np] = new Vec3(); + cell.m_hv[np] = new Vec3(); + cell.m_v[np] = new Vec3(); + cell.m_a[np] = new Vec3(); + } + cell.m_p[np].m_x = toadd.m_p[j].m_x; + cell.m_p[np].m_y = toadd.m_p[j].m_y; + cell.m_p[np].m_z = toadd.m_p[j].m_z; + cell.m_hv[np].m_x = toadd.m_hv[j].m_x; + cell.m_hv[np].m_y = toadd.m_hv[j].m_y; + cell.m_hv[np].m_z = toadd.m_hv[j].m_z; + cell.m_v[np].m_x = toadd.m_v[j].m_x; + cell.m_v[np].m_y = toadd.m_v[j].m_y; + cell.m_v[np].m_z = toadd.m_v[j].m_z; + cell.m_a[np].m_x = toadd.m_a[j].m_x; + cell.m_a[np].m_y = toadd.m_a[j].m_y; + cell.m_a[np].m_z = toadd.m_a[j].m_z; + cell.m_density[np] = toadd.m_density[j]; + np++; } - cell.m_p[np].m_x = toadd.m_p[j].m_x; - cell.m_p[np].m_y = toadd.m_p[j].m_y; - cell.m_p[np].m_z = toadd.m_p[j].m_z; - cell.m_hv[np].m_x = toadd.m_hv[j].m_x; - cell.m_hv[np].m_y = toadd.m_hv[j].m_y; - cell.m_hv[np].m_z = toadd.m_hv[j].m_z; - cell.m_v[np].m_x = toadd.m_v[j].m_x; - cell.m_v[np].m_y = toadd.m_v[j].m_y; - cell.m_v[np].m_z = toadd.m_v[j].m_z; - cell.m_a[np].m_x = toadd.m_a[j].m_x; - cell.m_a[np].m_y = toadd.m_a[j].m_y; - cell.m_a[np].m_z = toadd.m_a[j].m_z; - cell.m_density[np] = toadd.m_density[j]; - np++; } cell.m_numPars += toaddnp; visited.put(index, index); @@ -218,26 +224,28 @@ public class PSFADemo { cell.m_numPars = 0; int np = 0; for(int j = 0; j < toflushnp; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); + if(np < cell.m_p.length) { + if(cell.m_p[np] == null) { + cell.m_p[np] = new Vec3(); + cell.m_hv[np] = new Vec3(); + cell.m_v[np] = new Vec3(); + cell.m_a[np] = new Vec3(); + } + cell.m_p[np].m_x = toflush.m_p[j].m_x; + cell.m_p[np].m_y = toflush.m_p[j].m_y; + cell.m_p[np].m_z = toflush.m_p[j].m_z; + cell.m_hv[np].m_x = toflush.m_hv[j].m_x; + cell.m_hv[np].m_y = toflush.m_hv[j].m_y; + cell.m_hv[np].m_z = toflush.m_hv[j].m_z; + cell.m_v[np].m_x = toflush.m_v[j].m_x; + cell.m_v[np].m_y = toflush.m_v[j].m_y; + cell.m_v[np].m_z = toflush.m_v[j].m_z; + cell.m_a[np].m_x = toflush.m_a[j].m_x; + cell.m_a[np].m_y = toflush.m_a[j].m_y; + cell.m_a[np].m_z = toflush.m_a[j].m_z; + cell.m_density[np] = toflush.m_density[j]; + np++; } - cell.m_p[np].m_x = toflush.m_p[j].m_x; - cell.m_p[np].m_y = toflush.m_p[j].m_y; - cell.m_p[np].m_z = toflush.m_p[j].m_z; - cell.m_hv[np].m_x = toflush.m_hv[j].m_x; - cell.m_hv[np].m_y = toflush.m_hv[j].m_y; - cell.m_hv[np].m_z = toflush.m_hv[j].m_z; - cell.m_v[np].m_x = toflush.m_v[j].m_x; - cell.m_v[np].m_y = toflush.m_v[j].m_y; - cell.m_v[np].m_z = toflush.m_v[j].m_z; - cell.m_a[np].m_x = toflush.m_a[j].m_x; - cell.m_a[np].m_y = toflush.m_a[j].m_y; - cell.m_a[np].m_z = toflush.m_a[j].m_z; - cell.m_density[np] = toflush.m_density[j]; - np++; } cell.m_numPars += toflushnp; visited.put(key, key); @@ -258,26 +266,28 @@ public class PSFADemo { cell.m_numPars = 0; int np = 0; for(int j = 0; j < toflushnp; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); + if(np < cell.m_p.length) { + if(cell.m_p[np] == null) { + cell.m_p[np] = new Vec3(); + cell.m_hv[np] = new Vec3(); + cell.m_v[np] = new Vec3(); + cell.m_a[np] = new Vec3(); + } + cell.m_p[np].m_x = toflush.m_p[j].m_x; + cell.m_p[np].m_y = toflush.m_p[j].m_y; + cell.m_p[np].m_z = toflush.m_p[j].m_z; + cell.m_hv[np].m_x = toflush.m_hv[j].m_x; + cell.m_hv[np].m_y = toflush.m_hv[j].m_y; + cell.m_hv[np].m_z = toflush.m_hv[j].m_z; + cell.m_v[np].m_x = toflush.m_v[j].m_x; + cell.m_v[np].m_y = toflush.m_v[j].m_y; + cell.m_v[np].m_z = toflush.m_v[j].m_z; + cell.m_a[np].m_x = toflush.m_a[j].m_x; + cell.m_a[np].m_y = toflush.m_a[j].m_y; + cell.m_a[np].m_z = toflush.m_a[j].m_z; + cell.m_density[np] = toflush.m_density[j]; + np++; } - cell.m_p[np].m_x = toflush.m_p[j].m_x; - cell.m_p[np].m_y = toflush.m_p[j].m_y; - cell.m_p[np].m_z = toflush.m_p[j].m_z; - cell.m_hv[np].m_x = toflush.m_hv[j].m_x; - cell.m_hv[np].m_y = toflush.m_hv[j].m_y; - cell.m_hv[np].m_z = toflush.m_hv[j].m_z; - cell.m_v[np].m_x = toflush.m_v[j].m_x; - cell.m_v[np].m_y = toflush.m_v[j].m_y; - cell.m_v[np].m_z = toflush.m_v[j].m_z; - cell.m_a[np].m_x = toflush.m_a[j].m_x; - cell.m_a[np].m_y = toflush.m_a[j].m_y; - cell.m_a[np].m_z = toflush.m_a[j].m_z; - cell.m_density[np] = toflush.m_density[j]; - np++; } cell.m_numPars += toflushnp; visited.put(index, index); @@ -304,26 +314,28 @@ public class PSFADemo { cell.m_numPars = 0; int np = 0; for(int j = 0; j < toflushnp; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); + if(np < cell.m_p.length) { + if(cell.m_p[np] == null) { + cell.m_p[np] = new Vec3(); + cell.m_hv[np] = new Vec3(); + cell.m_v[np] = new Vec3(); + cell.m_a[np] = new Vec3(); + } + cell.m_p[np].m_x = toflush.m_p[j].m_x; + cell.m_p[np].m_y = toflush.m_p[j].m_y; + cell.m_p[np].m_z = toflush.m_p[j].m_z; + cell.m_hv[np].m_x = toflush.m_hv[j].m_x; + cell.m_hv[np].m_y = toflush.m_hv[j].m_y; + cell.m_hv[np].m_z = toflush.m_hv[j].m_z; + cell.m_v[np].m_x = toflush.m_v[j].m_x; + cell.m_v[np].m_y = toflush.m_v[j].m_y; + cell.m_v[np].m_z = toflush.m_v[j].m_z; + cell.m_a[np].m_x = toflush.m_a[j].m_x; + cell.m_a[np].m_y = toflush.m_a[j].m_y; + cell.m_a[np].m_z = toflush.m_a[j].m_z; + cell.m_density[np] = toflush.m_density[j]; + np++; } - cell.m_p[np].m_x = toflush.m_p[j].m_x; - cell.m_p[np].m_y = toflush.m_p[j].m_y; - cell.m_p[np].m_z = toflush.m_p[j].m_z; - cell.m_hv[np].m_x = toflush.m_hv[j].m_x; - cell.m_hv[np].m_y = toflush.m_hv[j].m_y; - cell.m_hv[np].m_z = toflush.m_hv[j].m_z; - cell.m_v[np].m_x = toflush.m_v[j].m_x; - cell.m_v[np].m_y = toflush.m_v[j].m_y; - cell.m_v[np].m_z = toflush.m_v[j].m_z; - cell.m_a[np].m_x = toflush.m_a[j].m_x; - cell.m_a[np].m_y = toflush.m_a[j].m_y; - cell.m_a[np].m_z = toflush.m_a[j].m_z; - cell.m_density[np] = toflush.m_density[j]; - np++; } cell.m_numPars += toflushnp; visited.put(index, index); @@ -546,12 +558,6 @@ public class PSFADemo { int np = cell.m_numPars; Cell toadd = (Cell)(g.m_neighCells.get(key)); for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_v[j].m_x += toadd.m_v[j].m_x - cell.m_a[j].m_x; cell.m_v[j].m_y += toadd.m_v[j].m_y - cell.m_a[j].m_y; cell.m_v[j].m_z += toadd.m_v[j].m_z - cell.m_a[j].m_z; @@ -571,12 +577,6 @@ public class PSFADemo { int np = cell.m_numPars; Cell toadd = g.m_cells[ix][iy][iz]; for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_v[j].m_x = toadd.m_v[j].m_x - cell.m_a[j].m_x; cell.m_v[j].m_y = toadd.m_v[j].m_y - @@ -606,12 +606,6 @@ public class PSFADemo { int np = cell.m_numPars; Cell toadd = g.m_cells[ix][iy][iz]; for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_v[j].m_x = toadd.m_v[j].m_x - cell.m_a[j].m_x; cell.m_v[j].m_y = toadd.m_v[j].m_y - @@ -636,12 +630,6 @@ public class PSFADemo { Cell cell = (Cell)it_values.next(); int np = cell.m_numPars; for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_a[j].m_x += cell.m_v[j].m_x; cell.m_a[j].m_y += cell.m_v[j].m_y; cell.m_a[j].m_z += cell.m_v[j].m_z; @@ -661,12 +649,6 @@ public class PSFADemo { Cell cell = (Cell)(g.m_neighCells.get(key)); int np = cell.m_numPars; for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_a[j].m_x = toflush.m_a[j].m_x; cell.m_a[j].m_y = toflush.m_a[j].m_y; cell.m_a[j].m_z = toflush.m_a[j].m_z; @@ -687,12 +669,6 @@ public class PSFADemo { Cell cell = g.m_cells[ix][iy][iz]; int np = cell.m_numPars; for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_a[j].m_x = toflush.m_a[j].m_x; cell.m_a[j].m_y = toflush.m_a[j].m_y; cell.m_a[j].m_z = toflush.m_a[j].m_z; @@ -719,12 +695,6 @@ public class PSFADemo { Cell cell = g.m_cells[ix][iy][iz]; int np = cell.m_numPars; for(int j = 0; j < np; ++j) { - if(cell.m_p[np] == null) { - cell.m_p[np] = new Vec3(); - cell.m_hv[np] = new Vec3(); - cell.m_v[np] = new Vec3(); - cell.m_a[np] = new Vec3(); - } cell.m_a[j].m_x = toflush.m_a[j].m_x; cell.m_a[j].m_y = toflush.m_a[j].m_y; cell.m_a[j].m_z = toflush.m_a[j].m_z; diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 157fe003..89322492 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -67,6 +67,8 @@ public class State { public boolean INSTRUCTIONFAILURE=false; public static double TRUEPROB=0.8; public static boolean PRINTFLAT=false; + public static boolean PRINTSCHEDULING=false; + public static boolean PRINTSCHEDULESIM=false; public int CORENUM = 1; public String structfile; public String main; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 01ed2f6b..c63ed8df 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -75,6 +75,10 @@ public class Main { state.TRUEPROB=Double.parseDouble(args[++i]); } else if (option.equals("-printflat")) State.PRINTFLAT=true; + else if (option.equals("-printscheduling")) + State.PRINTSCHEDULING=true; + else if (option.equals("-printschedulesim")) + State.PRINTSCHEDULESIM=true; else if (option.equals("-struct")) state.structfile=args[++i]; else if (option.equals("-conscheck")) @@ -147,6 +151,18 @@ public class Main { System.out.println("-ownwritedots -- write ownership graphs; can be all results or just final results"); System.out.println("-ownaliasfile -- write a text file showing all detected aliases in program tasks"); System.out.println("-optional -- enable optional arguments"); + System.out.println("-scheduling do task scheduling" ); + System.out.println("-multicore generate multi-core version binary"); + System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1"); + System.out.println("-raw generate raw version binary (should be used together with -multicore)"); + System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)"); + System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)"); + System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)"); + System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)"); + System.out.println("-threadsimulate generate multi-thread simulate version binary"); + System.out.println("-rawuseio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version"); + System.out.println("-printscheduling -- print out scheduling graphs"); + System.out.println("-printschedulesim -- print out scheduling simulation result graphs"); System.out.println("-webinterface -- enable web interface"); System.out.println("-help -- print out help"); System.exit(0); @@ -312,10 +328,22 @@ public class Main { while(inint.startsWith(" ")) { inint = inint.substring(1); } - tmpinindex = inint.indexOf(';'); + tmpinindex = inint.indexOf(','); + if(tmpinindex == -1) { + break; + } int numofexits = Integer.parseInt(inint.substring(0, tmpinindex)); TaskInfo tinfo = new TaskInfo(numofexits); inint = inint.substring(tmpinindex + 1); + while(inint.startsWith(" ")) { + inint = inint.substring(1); + } + tmpinindex = inint.indexOf(';'); + int byObj = Integer.parseInt(inint.substring(0, tmpinindex)); + if(byObj != -1) { + tinfo.m_byObj = byObj; + } + inint = inint.substring(tmpinindex + 1); while(inint.startsWith(" ")) { inint = inint.substring(1); } @@ -403,16 +431,20 @@ public class Main { int total = 100; for(int j = 0; j < numEdges; j++) { FEdge pfe = fev.elementAt(j); - tint = taskinfos.get(td.getSymbol()).m_exetime[pfe.getTaskExitIndex()]; + TaskInfo taskinfo = taskinfos.get(td.getSymbol()); + tint = taskinfo.m_exetime[pfe.getTaskExitIndex()]; pfe.setExeTime(tint); - double idouble = taskinfos.get(td.getSymbol()).m_probability[pfe.getTaskExitIndex()]; + double idouble = taskinfo.m_probability[pfe.getTaskExitIndex()]; pfe.setProbability(idouble); int newRate = 0; - if((taskinfos.get(td.getSymbol()).m_newobjinfo.elementAt(pfe.getTaskExitIndex()) != null) - && (taskinfos.get(td.getSymbol()).m_newobjinfo.elementAt(pfe.getTaskExitIndex()).containsKey(cd.getSymbol()))) { - newRate = taskinfos.get(td.getSymbol()).m_newobjinfo.elementAt(pfe.getTaskExitIndex()).get(cd.getSymbol()); + if((taskinfo.m_newobjinfo.elementAt(pfe.getTaskExitIndex()) != null) + && (taskinfo.m_newobjinfo.elementAt(pfe.getTaskExitIndex()).containsKey(cd.getSymbol()))) { + newRate = taskinfo.m_newobjinfo.elementAt(pfe.getTaskExitIndex()).get(cd.getSymbol()); } pfe.addNewObjInfo(cd, newRate, idouble); + if(taskinfo.m_byObj != -1) { + ((FlagState)pfe.getSource()).setByObj(taskinfo.m_byObj); + } } fev = null; } @@ -426,10 +458,14 @@ public class Main { int total = 100; while(it_edges.hasNext()) { FEdge edge = (FEdge)it_edges.next(); - tint = taskinfos.get(edge.getTask().getSymbol()).m_exetime[edge.getTaskExitIndex()]; + TaskInfo taskinfo = taskinfos.get(edge.getTask().getSymbol()); + tint = taskinfo.m_exetime[edge.getTaskExitIndex()]; edge.setExeTime(tint); - double idouble = taskinfos.get(edge.getTask().getSymbol()).m_probability[edge.getTaskExitIndex()]; + double idouble = taskinfo.m_probability[edge.getTaskExitIndex()]; edge.setProbability(idouble); + if(taskinfo.m_byObj != -1) { + ((FlagState)edge.getSource()).setByObj(taskinfo.m_byObj); + } } } } @@ -478,7 +514,8 @@ public class Main { (cdname.equals("MDRunner")) || (cdname.equals("Stage")) || (cdname.equals("AppDemoRunner")) || - (cdname.equals("FilterBankAtom"))) { + (cdname.equals("FilterBankAtom")) || + (cdname.equals("Grid"))) { newRate = 16; } else if(cdname.equals("SentenceParser")) { newRate = 4; @@ -554,7 +591,7 @@ public class Main { // Create a new output stream for the standard output. PrintStream stdout = null; try { - stdout = new PrintStream(new FileOutputStream("SimulatorResult.out")); + stdout = new PrintStream(new FileOutputStream("/scratch/SimulatorResult.out")); } catch (Exception e) { // Sigh. Couldn't open the file. System.out.println("Redirect: Unable to open output file!"); @@ -590,63 +627,55 @@ public class Main { //simulate these schedulings ScheduleSimulator scheduleSimulator = new ScheduleSimulator(scheduleAnalysis.getCoreNum(), state, ta); - Iterator it_scheduling = scheduleAnalysis.getSchedulingsIter(); - int index = 0; + Vector> schedulings = scheduleAnalysis.getSchedulings(); Vector selectedScheduling = new Vector(); int processTime = Integer.MAX_VALUE; - while(it_scheduling.hasNext()) { - Vector scheduling = (Vector)it_scheduling.next(); - scheduleSimulator.setScheduling(scheduling); - int tmpTime = scheduleSimulator.process(); - if(tmpTime < processTime) { - selectedScheduling.clear(); - selectedScheduling.add(index); - processTime = tmpTime; - } else if(tmpTime == processTime) { - selectedScheduling.add(index); - } - scheduling = null; - index++; + if(schedulings.size() > 1500) { + int index = 0; + int upperbound = schedulings.size(); + long seed = 0; + java.util.Random r = new java.util.Random(seed); + for(int ii = 0; ii < 1500; ii++) { + index = (int)((Math.abs((double)r.nextInt() / (double)Integer.MAX_VALUE)) * upperbound); + System.out.println("Scheduling index:" + index); + //System.err.println("Scheduling index:" + index); + Vector scheduling = schedulings.elementAt(index); + scheduleSimulator.setScheduling(scheduling); + int tmpTime = scheduleSimulator.process(); + if(tmpTime < processTime) { + selectedScheduling.clear(); + selectedScheduling.add(index); + processTime = tmpTime; + } else if(tmpTime == processTime) { + selectedScheduling.add(index); + } + scheduling = null; + } + } else { + Iterator it_scheduling = scheduleAnalysis.getSchedulingsIter(); + int index = 0; + while(it_scheduling.hasNext()) { + Vector scheduling = (Vector)it_scheduling.next(); + scheduleSimulator.setScheduling(scheduling); + int tmpTime = scheduleSimulator.process(); + if(tmpTime < processTime) { + selectedScheduling.clear(); + selectedScheduling.add(index); + processTime = tmpTime; + } else if(tmpTime == processTime) { + selectedScheduling.add(index); + } + scheduling = null; + index++; + } } + System.out.print("Selected schedulings with least exectution time " + processTime + ": \n\t"); for(int i = 0; i < selectedScheduling.size(); i++) { System.out.print((selectedScheduling.elementAt(i) + 1) + ", "); } System.out.println(); - /*ScheduleSimulator scheduleSimulator = new ScheduleSimulator(4, state, ta); - Vector scheduling = new Vector(); - for(int i = 0; i < 4; i++) { - Schedule schedule = new Schedule(i); - scheduling.add(schedule); - } - Iterator it_tasks = state.getTaskSymbolTable().getAllDescriptorsIterator(); - while(it_tasks.hasNext()) { - TaskDescriptor td = (TaskDescriptor)it_tasks.next(); - if(td.getSymbol().equals("t10")) { - scheduling.elementAt(1).addTask(td); - } else { - scheduling.elementAt(0).addTask(td); - } - } - ClassDescriptor cd = (ClassDescriptor)state.getClassSymbolTable().get("E"); - scheduling.elementAt(0).addTargetCore(cd, 1); - scheduleSimulator.setScheduling(scheduling); - scheduleSimulator.process(); - - Vector scheduling1 = new Vector(); - for(int i = 0; i < 4; i++) { - Schedule schedule = new Schedule(i); - scheduling1.add(schedule); - } - Iterator it_tasks1 = state.getTaskSymbolTable().getAllDescriptorsIterator(); - while(it_tasks1.hasNext()) { - TaskDescriptor td = (TaskDescriptor)it_tasks1.next(); - scheduling1.elementAt(0).addTask(td); - } - scheduleSimulator.setScheduling(scheduling1); - scheduleSimulator.process();*/ - // Close the streams. try { stdout.close(); @@ -736,6 +765,7 @@ public class Main { public int[] m_exetime; public double[] m_probability; public Vector> m_newobjinfo; + public int m_byObj; public TaskInfo(int numofexits) { this.m_numofexits = numofexits; @@ -745,6 +775,7 @@ public class Main { for(int i = 0; i < this.m_numofexits; i++) { this.m_newobjinfo.add(null); } + this.m_byObj = -1; } } } diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index aef2a45a..237a1eb8 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -3985,6 +3985,7 @@ parameterpresent: #ifdef RAWDEBUG raw_test_pass_reg(x); #endif + raw_test_pass_reg(x); raw_test_done(0xa009); #else exit(-1); diff --git a/Robust/src/Tests/dotest b/Robust/src/Tests/dotest index 3681a920..20ed204c 100755 --- a/Robust/src/Tests/dotest +++ b/Robust/src/Tests/dotest @@ -4,8 +4,10 @@ ARG2=$2 shift shift +dir=`pwd` + echo Doing Test $ARG1 -../buildscript -mainclass $ARG1 $ARG2 -o $ARG1 &>/dev/null +../buildscript -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1 &>/dev/null $ARG1.bin $@ &> output/$ARG1.output diff output/$ARG1.output output/$ARG1.output.goal rm $ARG1.bin diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 332b24d5..c5b34f54 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -24,6 +24,8 @@ echo "-rawconfig config raw simulator as 4xn (should be used together with -raw) echo "-rawpath print out execute path information for raw version (should be used together with -raw)" echo "-useprofile use profiling data for scheduling (should be used together with -raw)" echo -threadsimulate generate multi-thread simulate version binary +echo -printscheduling print out scheduling graphs +echo -printschedulesim print out scheduling simulator result graphs echo -optional enable optional echo -debug generate debug symbols echo -prefetch do prefetch analysis