private boolean sorted = false;
private boolean clone = false;
- private int transTime;
+ private long transTime;
/** Class constructor
* @param cd ClassDescriptor
this.transTime = 0;
}
- public int getTransTime() {
+ public long getTransTime() {
return this.transTime;
}
- public void setTransTime(int transTime) {
+ public void setTransTime(long transTime) {
this.transTime = transTime;
}
public int hashCode() {
return cd.hashCode()^uid^cid^Boolean.toString(sorted).hashCode()^
- Boolean.toString(clone).hashCode()^transTime^flagStates.hashCode();
+ Boolean.toString(clone).hashCode()^(int)transTime^flagStates.hashCode();
}
public String getLabel() {
Hashtable<FlagState, Vector<Integer>> allyCSimulator;
Hashtable<FlagState, FlagState> targetFState;
int coreNum;
- int activeTime;
+ long activeTime;
public CoreSimulator(RuntimeSchedule schedule,
int coreNum) {
this.targetFState = targetFState;
}
- public int getActiveTime() {
+ public long getActiveTime() {
return activeTime;
}
Vector<Integer> allycores = this.getAllyCores(obj.getCurrentFS());
if(allycores != null) {
obj.setShared(true);
- for(int k = 0; k < allycores.size(); ++k) {
+ //for(int k = 0; k < allycores.size(); ++k) {
//Integer allyCore = allycores.elementAt(k);
if(transObjs == null) {
transObjs = new Vector<ObjectSimulator>();
transObjs.add(obj);
}
remove = false;
- }
+ //}
allycores = null;
}
// check if need to transfer to other cores
return transObjs;
}
- public void updateTask(int time) {
+ public void updateTask(long time) {
this.activeTime += time;
this.rtask.updateFinishTime(time);
}
it_tasks = null;
int tryindex = 1;
- int bestexetime = Integer.MAX_VALUE;
+ long bestexetime = Long.MAX_VALUE;
Random rand = new Random();
// simulate the generated schedulings and try to optimize it
do {
selectedSimExeGraphs.elementAt(i).clear();
}
selectedSimExeGraphs.clear();
- int tmpexetime = this.scheduleSimulator.simulate(schedulings,
+ long tmpexetime = this.scheduleSimulator.simulate(schedulings,
selectedSchedulings,
selectedSimExeGraphs);
boolean remove = false;
System.setOut(stdout);
if(false) {
- this.scheduleAnalysis.setScheduleThreshold(100000);
+ // Generate all possible schedulings
+ this.scheduleAnalysis.setScheduleThreshold(Integer.MAX_VALUE);
this.scheduleAnalysis.schedule(-1);
Vector<Vector<ScheduleNode>> totestscheduleGraphs =
selectedSimExeGraphs.elementAt(i).clear();
}
selectedSimExeGraphs.clear();
- int tmpexetime = this.scheduleSimulator.simulate(schedulings,
+ long tmpexetime = this.scheduleSimulator.simulate(schedulings,
selectedSchedulings,
selectedSimExeGraphs);
output.println(((float)tmpexetime/1000000));
}
+
} else {
// generate multiple schedulings
this.scheduleThreshold = 20;
new Vector<Vector<ScheduleNode>>();
newscheduleGraphs.add(totestscheduleGraphs.elementAt(ii));
int tryindex = 1;
- int bestexetime = Integer.MAX_VALUE;
+ long bestexetime = Long.MAX_VALUE;
int gid = 1;
Vector<Schedule> scheduling = null;
Vector<ScheduleNode> schedulinggraph = null;
tmpgraph.clear();
}
selectedSimExeGraphs.clear();
- int tmpexetime = this.scheduleSimulator.simulate(schedulings,
+ long tmpexetime = this.scheduleSimulator.simulate(schedulings,
selectedSchedulings,
selectedSimExeGraphs);
if(isfirst) {
// TODO: currently only get one critical path. It's possible that there are
// multiple critical paths and some of them can not be optimized while others
// can. Need to fix up for this situation.
- private int getCriticalPath(SimExecutionNode senode,
- Vector<SimExecutionEdge> criticalPath) {
+ private long getCriticalPath(SimExecutionNode senode,
+ Vector<SimExecutionEdge> criticalPath) {
Vector<SimExecutionEdge> edges = (Vector<SimExecutionEdge>)senode.getEdgeVector();
if((edges == null) || (edges.size() == 0)) {
edges = null;
}
Vector<SimExecutionEdge> subcriticalpath = new Vector<SimExecutionEdge>();
SimExecutionEdge edge = edges.elementAt(0);
- int sum = edge.getWeight() + getCriticalPath((SimExecutionNode)edge.getTarget(),
+ long sum = edge.getWeight() + getCriticalPath((SimExecutionNode)edge.getTarget(),
subcriticalpath);
criticalPath.clear();
criticalPath.add(edge);
for(int i = 1; i < edges.size(); i++) {
edge = edges.elementAt(i);
subcriticalpath.clear();
- int tmpsum = edge.getWeight()
+ long tmpsum = edge.getWeight()
+ getCriticalPath((SimExecutionNode)edge.getTarget(),
subcriticalpath);
if(tmpsum > sum) {
Vector<SimExecutionEdge> predicates = seedge.getPredicates();
if(predicates != null) {
// have predicates
- int starttime = 0;
+ long starttime = 0;
// check the latest finish time of all the predicates
for(int j = 0; j < predicates.size(); j++) {
SimExecutionEdge predicate = predicates.elementAt(j);
- int tmptime = predicate.getBestStartPoint() + predicate.getWeight();
+ long tmptime = predicate.getBestStartPoint() + predicate.getWeight();
if(tmptime > starttime) {
starttime = tmptime;
seedge.setLastpredicateEdge(predicate);
seedge.setBestStartPoint(starttime);
} else if(seedge.getSource().getInedgeVector().size() > 0) {
// should have only one in edge
- int starttime = ((SimExecutionNode)seedge.getSource()).getTimepoint();
+ long starttime = ((SimExecutionNode)seedge.getSource()).getTimepoint();
seedge.setBestStartPoint(starttime);
} else {
// no predicates
// first check all seedges whose real start point is late than predicted
// earliest start time and group them
- int opcheckpoint = Integer.MAX_VALUE;
+ long opcheckpoint = Long.MAX_VALUE;
Vector<Integer> sparecores = null;
// group according to core index
- Hashtable<Integer, Hashtable<Integer, Vector<SimExecutionEdge>>> toselects =
- new Hashtable<Integer, Hashtable<Integer, Vector<SimExecutionEdge>>>();
+ Hashtable<Long, Hashtable<Integer, Vector<SimExecutionEdge>>> toselects =
+ new Hashtable<Long, Hashtable<Integer, Vector<SimExecutionEdge>>>();
Random rand = new Random();
for(int i = 0; i < criticalPath.size(); i++) {
SimExecutionEdge seedge = criticalPath.elementAt(i);
- int starttime = seedge.getBestStartPoint();
+ long starttime = seedge.getBestStartPoint();
if(starttime < ((SimExecutionNode)seedge.getSource()).getTimepoint()) {
// no restrictions due to data dependencies
// have potential to be parallelled and start execution earlier
// Randomly choose the tasks to optimize(previously only
// consider the tasks with smallest best start time)
- Vector<Integer> keys = new Vector<Integer>(toselects.keySet());
+ Vector<Long> keys = new Vector<Long>(toselects.keySet());
do{
int length = keys.size();
if(length == 0) {
return optimizeschedulegraphs;
}
int tochoose = Math.abs(rand.nextInt()) % length;
- opcheckpoint = (keys.elementAt(tochoose)).intValue();
+ opcheckpoint = (keys.elementAt(tochoose)).longValue();
keys.removeElementAt(tochoose);
Hashtable<Integer, Vector<SimExecutionEdge>> tooptimize =
toselects.get(opcheckpoint);
SimExecutionEdge seedge = tooptimize.values().iterator().next().elementAt(0);
SimExecutionNode lastpredicatenode = seedge.getLastpredicateNode();
SimExecutionEdge lastpredicateedge = seedge.getLastpredicateEdge();
- int timepoint = lastpredicatenode.getTimepoint();
+ long timepoint = lastpredicatenode.getTimepoint();
if(lastpredicateedge.getTd() == null) {
// transfer edge
timepoint += lastpredicateedge.getWeight();
CombinationUtil.CombineGenerator cGen =
CombinationUtil.allocateCombineGenerator(rootNodes,
nodes2combine);
- while((gid <= this.scheduleThreshold) && cGen.nextGen()) {
+ while((gid <= this.scheduleThreshold) && cGen.nextGen()) {
if(Math.abs(rand.nextInt()) % 100 > generateThreshold) {
Vector<Vector<CombinationUtil.Combine>> combine = cGen.getCombine();
Vector<ScheduleNode> sNodes =
private ClassNode targetCNode;
private double probability;
- private int transTime;
+ private long transTime;
private long listExeTime;
private FEdge fedge;
if(ScheduleEdge.NEWEDGE == this.type) {
completeLabel += ":" + Integer.toString(this.newRate);
}
- completeLabel += ":(" + Double.toString(this.probability) + "%)" + ":[" + Integer.toString(this.transTime) + "]";
+ completeLabel += ":(" + Double.toString(this.probability) + "%)" + ":[" + Long.toString(this.transTime) + "]";
return completeLabel;
}
public int hashCode() {
int hashcode = gid^uid^label.hashCode()^target.hashCode()^source.hashCode()^fstate.hashCode()^
sourceCNode.hashCode()^targetCNode.hashCode()^newRate^(int)probability^
- type^transTime^(int)listExeTime;
+ type^(int)transTime^(int)listExeTime;
if(targetFState != null) {
hashcode ^= targetFState.hashCode();
}
this.newRate = nr;
}
- public int getTransTime() {
+ public long getTransTime() {
return this.transTime;
}
- public void setTransTime(int transTime) {
+ public void setTransTime(long transTime) {
this.transTime = transTime;
}
private Vector<Schedule> scheduling;
private Vector<CoreSimulator> cores;
private Vector<TaskSimulator> tasks;
- private int processTime;
+ private long processTime;
private int invoketime;
State state;
applyScheduling();
}
- public int simulate(Vector<Vector<Schedule>> schedulings,
+ public long simulate(Vector<Vector<Schedule>> schedulings,
Vector<Integer> selectedScheduling,
Vector<Vector<SimExecutionEdge>> selectedSimExeGraphs) {
- int processTime = Integer.MAX_VALUE;
+ long processTime = Long.MAX_VALUE;
/*if(schedulings.size() > 1500) {
int index = 0;
int upperbound = schedulings.size();
this.setScheduling(scheduling);
Vector<SimExecutionEdge> simexegraph = new Vector<SimExecutionEdge>();
Vector<CheckPoint> checkpoints = new Vector<CheckPoint>();
- int tmpTime = process(checkpoints, simexegraph);
+ long tmpTime = process(checkpoints, simexegraph);
if(tmpTime < processTime) {
selectedScheduling.clear();
selectedScheduling.add(index);
}
public int getUtility(int index) {
- return (this.cores.elementAt(index).getActiveTime() * 100) / this.processTime;
+ return (int)(this.cores.elementAt(index).getActiveTime() * 100) / (int)this.processTime;
}
public Vector<Schedule> getScheduling() {
return tasks;
}
- public int process(Vector<CheckPoint> checkpoints,
- Vector<SimExecutionEdge> simexegraph) {
+ public long process(Vector<CheckPoint> checkpoints,
+ Vector<SimExecutionEdge> simexegraph) {
assert(this.scheduling != null);
this.invoketime++;
Hashtable<SimExecutionNode, Action> senode2action =
new Hashtable<SimExecutionNode, Action>();
SimExecutionNode[] lastseNodes = new SimExecutionNode[this.cores.size()];
- Hashtable<Action, Integer> action2exetime =
- new Hashtable<Action, Integer>();
+ Hashtable<Action, Long> action2exetime =
+ new Hashtable<Action, Long>();
Hashtable<TransTaskSimulator, SimExecutionNode> tttask2senode =
new Hashtable<TransTaskSimulator, SimExecutionNode>();
- Hashtable<Integer, Integer> obj2transtime =
- new Hashtable<Integer, Integer>();
+ Hashtable<Integer, Long> obj2transtime =
+ new Hashtable<Integer, Long>();
Hashtable<Integer, SimExecutionEdge> obj2lastseedge =
new Hashtable<Integer, SimExecutionEdge>();
SimExecutionNode seNode = new SimExecutionNode(coreid, this.processTime);
seNode.setSpareCores(cp.getSpareCores());
senode2action.put(seNode, action);
- action2exetime.put(action, -1);
+ action2exetime.put(action, (long)-1);
lastseNodes[coreid] = seNode;
}
}
// for each task in todo queue, decide the execution path of this time
// according to statistic information
- int finishTime = Integer.MAX_VALUE;
+ long finishTime = Long.MAX_VALUE;
Vector<TaskSimulator> finishTasks = new Vector<TaskSimulator>();
for(i = 0; i < this.tasks.size(); i++) {
TaskSimulator task = this.tasks.elementAt(i);
task.process();
- int tempTime = task.getCurrentRun().getFinishTime();
+ long tempTime = task.getCurrentRun().getFinishTime();
if(tempTime < finishTime) {
finishTime = tempTime;
finishTasks.clear();
// create edges between previous senode on this core to this node
if(lastsenode != null) {
Action tmpaction = senode2action.get(lastsenode);
- int weight = tmpaction != null? action2exetime.get(tmpaction) : 0; // TODO ????
+ long weight = tmpaction != null? action2exetime.get(tmpaction) : 0; // TODO ????
SimExecutionEdge seEdge = new SimExecutionEdge(seNode,
lastsenode.getCoreNum(),
tmpaction != null? tmpaction.getTd():null,
if(lastedge.getCoreNum() != seEdge.getCoreNum()) {
// the obj is transferred from another core
// create an seEdge for this transfer
- int transweight = obj2transtime.get(tparam);
+ long transweight = obj2transtime.get(tparam);
SimExecutionEdge transseEdge = new SimExecutionEdge((SimExecutionNode)seEdge.getSource(),
lastedge.getCoreNum(),
null, // TODO: not sure if this is enough
Vector<SimExecutionEdge> simexegraph,
Hashtable<SimExecutionNode, Action> senode2action,
SimExecutionNode[] lastseNodes,
- Hashtable<Action, Integer> action2exetime,
+ Hashtable<Action, Long> action2exetime,
Hashtable<TransTaskSimulator, SimExecutionNode> tttask2senode,
- Hashtable<Integer, Integer> obj2transtime) {
+ Hashtable<Integer, Long> obj2transtime) {
TransTaskSimulator tmptask = (TransTaskSimulator)task;
// add ADDOBJ task to targetCore
int targetCoreNum = tmptask.getTargetCoreNum();
SimExecutionNode seNode = new SimExecutionNode(targetCoreNum, this.processTime);
seNode.setSpareCores(cp.getSpareCores());
senode2action.put(seNode, action);
- action2exetime.put(action, -1);
+ action2exetime.put(action, (long)-1);
SimExecutionNode lastsenode = lastseNodes[targetCoreNum];
// create edges between previous senode on this core to this node
0,
null);
} else {
- int weight = action2exetime.get(tmpaction);
+ long weight = action2exetime.get(tmpaction);
seEdge = new SimExecutionEdge(seNode,
lastsenode.getCoreNum(),
tmpaction.getTd(),
Vector<TransTaskSimulator> tttasks,
Hashtable<SimExecutionNode, Action> senode2action,
SimExecutionNode[] lastseNodes,
- Hashtable<Action, Integer> action2exetime) {
+ Hashtable<Action, Long> action2exetime) {
Vector<ObjectSimulator> totransObjs = new Vector<ObjectSimulator>();
CoreSimulator cs = task.getCs();
int corenum = cs.getCoreNum();
Vector<Integer> allycores = cs.getAllyCores(nobj.getCurrentFS());
if(allycores != null) {
nobj.setShared(true);
- for(int k = 0; k < allycores.size(); ++k) {
+ // TODO, temporarily send to at most 2 cores
+ int numtosend = allycores.size() > 2 ? 2 : allycores.size();
+ for(int k = 0; k < numtosend; ++k) {
Integer allyCore = allycores.elementAt(k);
if(allyCore == corenum) {
cs.addObject(nobj);
Vector<Integer> allycores = cs.getAllyCores(tobj.getCurrentFS());
if(allycores != null) {
tobj.setShared(true);
- for(int k = 0; k < allycores.size(); ++k) {
+ // TODO, temporarily send to at most 2 cores
+ int numtosend = allycores.size() > 2 ? 2 : allycores.size();
+ for(int k = 0; k < numtosend; ++k) {
Integer allyCore = allycores.elementAt(k);
if(allyCore == corenum) {
cs.addObject(tobj);
Vector<SimExecutionEdge> simexegraph,
Hashtable<SimExecutionNode, Action> senode2action,
SimExecutionNode[] lastseNodes,
- Hashtable<Action, Integer> action2exetime,
+ Hashtable<Action, Long> action2exetime,
Hashtable<TransTaskSimulator, SimExecutionNode> tttask2senode,
- Hashtable<Integer, Integer> obj2transtime,
+ Hashtable<Integer, Long> obj2transtime,
Hashtable<Integer, SimExecutionEdge> obj2lastseedge) {
TaskSimulator newTask = cs.process();
int corenum = cs.getCoreNum();
SimExecutionNode seNode = new SimExecutionNode(corenum, this.processTime);
seNode.setSpareCores(cp.getSpareCores());
senode2action.put(seNode, action);
- action2exetime.put(action, -1);
+ action2exetime.put(action, (long)-1);
SimExecutionNode lastsenode = lastseNodes[corenum];
// create edges between previous senode on this core to this node
if(lastsenode != null) {
Action tmpaction = senode2action.get(lastsenode);
- int weight = tmpaction != null? action2exetime.get(tmpaction):0;
+ long weight = tmpaction != null? action2exetime.get(tmpaction):0;
seEdge = new SimExecutionEdge(seNode,
lastsenode.getCoreNum(),
tmpaction!= null?tmpaction.getTd():null,
// create edges between previous senode on this core to this node
if(lastsenode != null) {
Action tmpaction = senode2action.get(lastsenode);
- int weight = action2exetime.get(tmpaction);
+ long weight = action2exetime.get(tmpaction);
seEdge = new SimExecutionEdge(seNode,
lastsenode.getCoreNum(),
tmpaction.getTd(),
if(lastedge.getCoreNum() != seEdge.getCoreNum()) {
// the obj is transferred from another core
// create an seEdge for this transfer
- int weight = obj2transtime.get(tparam);
+ long weight = obj2transtime.get(tparam);
SimExecutionEdge transseEdge = new SimExecutionEdge((SimExecutionNode)seEdge.getSource(),
lastedge.getCoreNum(),
null, // TODO: not sure if this is enough
CheckPoint cp,
Hashtable<SimExecutionNode, Action> senode2action,
SimExecutionNode[] lastseNodes,
- Hashtable<Action, Integer> action2exetime,
+ Hashtable<Action, Long> action2exetime,
int type) {
Action action = new Action(cs.getCoreNum(),
type,
}
public class CheckPoint {
- private int timepoint;
+ private long timepoint;
private Vector<Action> actions;
private Vector<Integer> spareCores;
- public CheckPoint(int timepoint,
+ public CheckPoint(long timepoint,
int corenum) {
super();
this.timepoint = timepoint;
}
}
- public int getTimepoint() {
+ public long getTimepoint() {
return timepoint;
}
}
}
-}
\ No newline at end of file
+}
}
public static void printSimulationResult(String path,
- int time,
+ long time,
int coreNum,
Vector<CheckPoint> checkpoints) {
try {
}
output.print("\t");
output.print("\t");
- int prev = Integer.parseInt(timeNodes.elementAt(0));
- int next = 0;
- int max = 0;
- int max2 = 0;
+ long prev = Long.parseLong(timeNodes.elementAt(0));
+ long next = 0;
+ long max = 0;
+ long max2 = 0;
for(j = 1; j < timeNodes.size(); j++) {
- next = Integer.parseInt(timeNodes.elementAt(j));
- int delta = next - prev;
+ next = Long.parseLong(timeNodes.elementAt(j));
+ long delta = next - prev;
if(max < delta) {
max2 = max;
max = delta;
max2 = max/100;
}
output.println("\"Time\"->" + timeNodes.elementAt(0) + "[style=invis];");
- prev = Integer.parseInt(timeNodes.elementAt(0));
+ prev = Long.parseLong(timeNodes.elementAt(0));
next = 0;
for(j = 1; j < timeNodes.size(); j++) {
- next = Integer.parseInt(timeNodes.elementAt(j));
+ next = Long.parseLong(timeNodes.elementAt(j));
if(next - prev > max2) {
do {
output.print(prev + "->");
private int coreNum;
private TaskDescriptor td;
private Vector<Integer> taskparams;
- private int weight;
+ private long weight;
- private int bestStartPoint;
+ private long bestStartPoint;
private SimExecutionNode lastpredicatenode;
private SimExecutionEdge lastpredicateedge;
private Vector<SimExecutionEdge> predicates;
public SimExecutionEdge(SimExecutionNode target,
int corenum,
TaskDescriptor td,
- int weight,
+ long weight,
Vector<Integer> taskparams) {
super(target);
this.eid = SimExecutionEdge.nodeID++;
this.isFixedTime = true;
}
- public int getBestStartPoint() {
+ public long getBestStartPoint() {
if(this.bestStartPoint == -1) {
if(this.predicates.size() > 0) {
// have predicates
- int starttime = 0;
+ long starttime = 0;
// check the latest finish time of all the predicates
for(int j = 0; j < this.predicates.size(); j++) {
SimExecutionEdge predicate = this.predicates.elementAt(j);
- int tmptime = predicate.getBestStartPoint() + predicate.getWeight();
+ long tmptime = predicate.getBestStartPoint() + predicate.getWeight();
if(tmptime > starttime) {
starttime = tmptime;
this.lastpredicateedge = predicate;
return bestStartPoint;
}
- public void setBestStartPoint(int bestStartPoint) {
+ public void setBestStartPoint(long bestStartPoint) {
this.bestStartPoint = bestStartPoint;
}
return td;
}
- public int getWeight() {
+ public long getWeight() {
return weight;
}
private static int nodeID=0;
private int coreNum;
- private int timepoint;
+ private long timepoint;
public Vector<Integer> spareCores;
public SimExecutionNode(int corenum,
- int timepoint) {
+ long timepoint) {
this.nid = SimExecutionNode.nodeID++;
this.coreNum = corenum;
this.timepoint = timepoint;
return nid;
}
- public int getTimepoint() {
+ public long getTimepoint() {
return timepoint;
}
boolean finish;
public class ExeResult {
- int finishTime;
+ long finishTime;
Vector<ObjectSimulator> newObjs;
int exetype; // 0--normal executing
// 1--abort due to fail on grabbing locks
newObjs = null;
}
- public int getFinishTime() {
+ public long getFinishTime() {
return finishTime;
}
- public void setFinishTime(int finishTime) {
+ public void setFinishTime(long finishTime) {
this.finishTime = finishTime;
}
this.currentRun.init();
}
- int finishTime = 0;
+ long finishTime = 0;
// According to runtime statistic information, decide the execution path of this task this time.
// Mainly following things:
// 1.the result, i.e. the result FlagState reached by each parameter.
this.currentRun.setExetype(0);
}
- public void updateFinishTime(int time) {
+ public void updateFinishTime(long time) {
this.currentRun.setFinishTime(this.currentRun.finishTime - time);
finish = false;
}
cp ../tmpbuilddirectory/*.c ./
cp ../tmpbuilddirectory/*.h ./
+make
+
else #!RAWFLAG && !TILERAFLAG
cd $CURDIR
FILES="$FILES $ROBUSTROOT/Runtime/localobjects.c"
fi
-if $MLP
+if $MLPFLAG
then
FILES="$FILES $ROBUSTROOT/Runtime/mlp_runtime.c"
FILES="$FILES $ROBUSTROOT/Runtime/psemaphore.c"