// Create a new output stream for the stcriticalPathandard output.
PrintStream stdout = null;
try {
+ if(!state.BAMBOOCOMPILETIME) {
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!");
//origOut.println ("Test output via 'origOut' reference.");
// Set the System out and err streams to use our replacements.
- System.setOut(stdout);
+ if(!state.BAMBOOCOMPILETIME) {
+ System.setOut(stdout);
+ }
Vector<Schedule> scheduling = null;
Vector<ScheduleNode> schedulinggraph = null;
int threshold = this.scheduleThreshold;
// simulate the generated schedulings and try to optimize it
do {
+ if(!state.BAMBOOCOMPILETIME) {
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++) {
selectedSchedulings.elementAt(0));
selectedSimExeGraph_bk = selectedSimExeGraphs.elementAt(0);
+ if(!state.BAMBOOCOMPILETIME) {
System.out.print("end of: #" + tryindex + " (bestexetime: "
+ bestexetime + ")\n");
System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ }
tryindex++;
threshold = this.scheduleThreshold;
} else if(tmpexetime == bestexetime) {
+ if(!state.BAMBOOCOMPILETIME) {
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) {
+ threshold += 10;
+ if((threshold > 40) ||
+ ((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 10)) {
break;
}
} else {
+ if(!state.BAMBOOCOMPILETIME) {
System.out.print("end of: #" + tryindex + " (bestexetime: "
+ bestexetime + ")\n");
System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ }
tryindex++;
if(threshold == this.scheduleThreshold) {
if(scheduleGraphs != null) {
selectedSimExeGraphs.addElement(selectedSimExeGraph_bk);
}
threshold += 10;
- if((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 1) {
+ if( (threshold > 40) ||
+ ((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 1)) {
break;
}
- //break;
+ break;
}
- //if(tooptimize) {
+ if(tooptimize) {
// try to optimize the best one scheduling
//do {
newscheduleGraphs = optimizeScheduling(scheduleGraphs,
scheduleGraphs.removeElementAt(selectedSchedulings.elementAt(0));
selectedSimExeGraphs.removeElementAt(0);
}
- /*} else {
+ } else {
break;
- }*/
+ }
}while(newscheduleGraphs != null); // TODO: could it possibly lead to endless loop?
if(scheduleGraphs != null) {
td2maincd.clear();
td2maincd = null;
+ if(!state.BAMBOOCOMPILETIME) {
System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ }
System.out.print("selected bestexetime: " + bestexetime + "\n");
+ if(!state.BAMBOOCOMPILETIME) {
String path = this.state.outputdir + "scheduling_selected.dot";
SchedulingUtil.printScheduleGraph(path, schedulinggraph);
+ }
// Close the streams.
try {
+ if(!state.BAMBOOCOMPILETIME) {
stdout.close();
stdout = null;
System.setOut(origOut);
+ }
} catch (Exception e) {
origOut.println("Redirect: Unable to close files!");
}
}
// flush the dependences and earliest start time
+ if(!state.BAMBOOCOMPILETIME) {
it_cores = tooptimize.keySet().iterator();
while(it_cores.hasNext()) {
int corenum = it_cores.next();
left -= ops.size();
}
ops = null;
+ }
} else {
// there are spare cores, try to reorganize the tasks to the spare
// cores
CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine);
Random rand = new Random();
while ((left > 0) && (cGen.nextGen())) {
- //while ((left > 0) && (cGen.randomGen())) {
+ //while ((left > 0) && (cGen.randomGenE())) {
if(Math.abs(rand.nextInt()) % 100 > this.generateThreshold) {
Vector<Vector<CombinationUtil.Combine>> combine = cGen.getCombine();
Vector<ScheduleNode> sNodes =
int gid = 1;
boolean isBig = Math.pow(this.coreNum, reduceNum) > 1000;
Random rand = new Random();
- if(false) {
+ if(isBig && state.BAMBOOCOMPILETIME) {
CombinationUtil.RootsGenerator rGen =
CombinationUtil.allocateRootsGenerator(sNodeVecs,
this.coreNum);
- while((!isBig || (gid <= this.scheduleThreshold)) && (rGen.nextGen())) {
+ while((gid <= this.scheduleThreshold) && (rGen.nextGen())) {
// first get the chosen rootNodes
Vector<Vector<ScheduleNode>> rootNodes = rGen.getRootNodes();
Vector<Vector<ScheduleNode>> nodes2combine = rGen.getNode2Combine();
CombinationUtil.CombineGenerator cGen =
CombinationUtil.allocateCombineGenerator(rootNodes,
nodes2combine);
- while((!isBig || (gid <= this.scheduleThreshold)) && (cGen.randomGenE())) {
+ while((gid <= this.scheduleThreshold) && (cGen.randomGenE())) {
boolean implement = true;
/*if(isBig) {
implement = Math.abs(rand.nextInt()) % 100 > generateThreshold;
CombinationUtil.allocateRandomGenerator(sNodeVecs,
this.coreNum);
// random genenration
- while((!isBig || (gid <= this.scheduleThreshold)) && (rGen.nextGen())) {
+ while((gid <= this.scheduleThreshold) && (rGen.nextGen())) {
Vector<Vector<ScheduleNode>> mapping = rGen.getMapping();
boolean implement = true;
if(isBig) {
while(it_scheduling.hasNext()) {
Vector<Schedule> scheduling =
(Vector<Schedule>)it_scheduling.next();
+ if(!state.BAMBOOCOMPILETIME) {
System.out.println("Scheduling index:" + scheduling.elementAt(0).getGid());
+ }
this.setScheduling(scheduling);
Vector<SimExecutionNode> simexegraph = new Vector<SimExecutionNode>();
Vector<CheckPoint> checkpoints = new Vector<CheckPoint>();
it_scheduling = null;
//}
+ if(!state.BAMBOOCOMPILETIME) {
System.out.print("Selected schedulings with least exectution time " + processTime + ": \n\t");
for(int i = 0; i < selectedScheduling.size(); i++) {
int gid = schedulings.elementAt(selectedScheduling.elementAt(i)).elementAt(0).getGid();
System.out.print(gid + ", ");
}
System.out.println();
+ }
return processTime;
}
this.coreNum,
checkpoints);
}
+ if(!state.BAMBOOCOMPILETIME) {
System.out.println("Simulate scheduling #" + gid + ": ");
System.out.println("\tTotal execution time is: " + this.processTime);
System.out.println("\tUtility of cores: ");
for(int j = 0; j < this.cores.size(); j++) {
System.out.println("\t\tcore" + j + ": " + getUtility(j) + "%");
}
+ }
return this.processTime;
}
public boolean FLATIRGRAPHTASKS=false;
public boolean FLATIRGRAPHUSERMETHODS=false;
public boolean FLATIRGRAPHLIBMETHODS=false;
- public boolean MULTICORE=false;
- public boolean MULTICOREGC=false;
public boolean OWNERSHIP=false;
public int OWNERSHIPALLOCDEPTH=3;
public boolean OWNERSHIPWRITEDOTS=false;
public boolean DISJOINTSNAPSTOPAFTER=false;
public boolean OPTIONAL=false;
- public boolean ARRAYBOUNDARYCHECK=true;
- public boolean RAW=false;
public boolean ARRAYPAD=false;
- public boolean SCHEDULING=false;
- public boolean USEPROFILE=false;
- public String profilename = null;
public boolean THREAD=false;
public boolean CONSCHECK=false;
public boolean INSTRUCTIONFAILURE=false;
public boolean METHODEFFECTS=false;
public static double TRUEPROB=0.8;
public static boolean PRINTFLAT=false;
- public static boolean PRINTSCHEDULING=false;
- public static boolean PRINTSCHEDULESIM=false;
- public static boolean PRINTCRITICALPATH=false;
+
//DSM options
public boolean DSM=false;
public boolean DSMTASK=false;
public boolean DELAYCOMP=false;
public boolean DUALVIEW=false;
public boolean HYBRID=false;
- //Other options
+
+ // Bamboo options
+ public boolean MULTICORE=false;
+ public boolean MULTICOREGC=false;
+ public boolean BAMBOOCOMPILETIME = false;
+ public boolean ARRAYBOUNDARYCHECK=true;
+ public boolean RAW=false;
+ public boolean SCHEDULING=false;
+ public boolean USEPROFILE=false;
+ public static boolean PRINTSCHEDULING=false;
+ public static boolean PRINTSCHEDULESIM=false;
+ public static boolean PRINTCRITICALPATH=false;
public int CORENUM = 1;
public int CORENUM4GC = 0;
+ public String profilename = null;
+ public String outputdir = "/scratch/";
+ //Other options
public String structfile;
public String main;
- public String outputdir = "/scratch/";
public boolean INLINEATOMIC=false;
public int inlineatomicdepth;
public HashSet selfloops;
} else if (option.equals("-flatirlibmethods")) {
state.FLATIRGRAPH=true;
state.FLATIRGRAPHLIBMETHODS=true;
+ } else if (option.equals("-bamboocompiletime")) {
+ state.BAMBOOCOMPILETIME = true;
} else if (option.equals("-multicore"))
state.MULTICORE=true;
else if (option.equals("-multicoregc"))
if(isDistributeInfo) {
mcImplSynthesis.distribution(isDisAll, startnum);
} else {
- //double timeStartAnalysis = (double) System.nanoTime();
+ double timeStartAnalysis = (double) System.nanoTime();
mcImplSynthesis.setScheduleThreshold(20);
mcImplSynthesis.setProbThreshold(0);
mcImplSynthesis.setGenerateThreshold(30);
Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
- //double timeEndAnalysis = (double) System.nanoTime();
- //double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
- //System.err.println("The analysis took" + dt + "sec.");
- //System.exit(0);
+ double timeEndAnalysis = (double) System.nanoTime();
+ if(state.BAMBOOCOMPILETIME) {
+ double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
+ System.err.println("The analysis took" + dt + "sec.");
+ System.exit(0);
+ }
// generate multicore codes
if(state.MULTICORE) {