From: jzhou Date: Tue, 15 Apr 2008 17:48:01 +0000 (+0000) Subject: add codes for generating multi-core version binary. Also add options -multicore ... X-Git-Tag: preEdgeChange~159 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=90387876e887ae7dc034e2ddfb6a3df0fb7dc281;p=IRC.git add codes for generating multi-core version binary. Also add options -multicore & -raw into the buildscript --- diff --git a/Robust/src/Analysis/Scheduling/Schedule.java b/Robust/src/Analysis/Scheduling/Schedule.java index 90c058eb..38d7339a 100644 --- a/Robust/src/Analysis/Scheduling/Schedule.java +++ b/Robust/src/Analysis/Scheduling/Schedule.java @@ -57,7 +57,10 @@ public class Schedule { if(!this.targetCores.containsKey(fstate)) { this.targetCores.put(fstate, new LinkedList()); } - this.targetCores.get(fstate).add(targetCore); + //if(!this.targetCores.get(fstate).contains(targetCore)) { + this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items, + // which reflects probabilities. + //} } public void addTargetCore(FlagState fstate, Integer targetCore, FlagState tfstate) { @@ -67,11 +70,15 @@ public class Schedule { if(!this.targetCores.containsKey(fstate)) { this.targetCores.put(fstate, new LinkedList()); } - this.targetCores.get(fstate).add(targetCore); + //if(!this.targetCores.get(fstate).contains(targetCore)) { + this.targetCores.get(fstate).add(targetCore); + //} if(this.targetFState == null) { this.targetFState = new Hashtable(); } - this.targetFState.put(fstate, tfstate); + //if(!this.targetFState.containsKey(fstate)) { + this.targetFState.put(fstate, tfstate); + //} } public Vector getTasks() { diff --git a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java index 1ca15645..a44cbab6 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java +++ b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java @@ -565,8 +565,7 @@ public class ScheduleAnalysis { toiterate = null; // create a 'trans' ScheudleEdge between this new ScheduleNode and se's source ScheduleNode - ScheduleEdge sEdge = new ScheduleEdge(sNode, "transmit", (FlagState)fe.getTarget(), false, 0);//new ScheduleEdge(sNode, "transmit", cNode.getClassDescriptor(), false, 0); - sEdge.setTargetFState(fs); + ScheduleEdge sEdge = new ScheduleEdge(sNode, "transmit", fs, false, 0);//new ScheduleEdge(sNode, "transmit", cNode.getClassDescriptor(), false, 0); sEdge.setFEdge(fe); sEdge.setSourceCNode(sCNode); sEdge.setTargetCNode(cNode); @@ -830,12 +829,23 @@ public class ScheduleAnalysis { for(int i = 0; i < toMerge.size(); i++) { ScheduleEdge sEdge = toMerge.elementAt(i); // merge this edge - ((ScheduleNode)sEdge.getSource()).mergeSEdge(sEdge); + if(sEdge.getIsNew()) { + ((ScheduleNode)sEdge.getSource()).mergeSEdge(sEdge); + } else { + try { + ((ScheduleNode)sEdge.getSource()).mergeTransEdge(sEdge); + } catch(Exception e) { + e.printStackTrace(); + System.exit(-1); + } + } result.removeElement(sEdge.getTarget()); - // As se has been changed into an internal edge inside a ScheduleNode, - // change the source and target of se from original ScheduleNodes into ClassNodes. - sEdge.setTarget(sEdge.getTargetCNode()); - sEdge.setSource(sEdge.getSourceCNode()); + if(sEdge.getIsNew()) { + // As se has been changed into an internal edge inside a ScheduleNode, + // change the source and target of se from original ScheduleNodes into ClassNodes. + sEdge.setTarget(sEdge.getTargetCNode()); + sEdge.setSource(sEdge.getSourceCNode()); + } } toMerge = null; diff --git a/Robust/src/Analysis/Scheduling/ScheduleNode.java b/Robust/src/Analysis/Scheduling/ScheduleNode.java index 88c8214c..e1fbaa7e 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleNode.java +++ b/Robust/src/Analysis/Scheduling/ScheduleNode.java @@ -2,6 +2,8 @@ package Analysis.Scheduling; import java.util.*; +import Analysis.TaskStateAnalysis.FEdge; +import Analysis.TaskStateAnalysis.FlagState; import Util.GraphNode; /** This class holds flag transition diagram(s) can be put on one core. @@ -241,7 +243,8 @@ public class ScheduleNode extends GraphNode implements Cloneable{ this.executionTime += ((ScheduleNode)se.getTarget()).getExeTime(); } - public void mergeSNode(ScheduleNode sn) throws Exception { + public void mergeTransEdge(ScheduleEdge se) throws Exception { + ScheduleNode sn = (ScheduleNode)se.getTarget(); Vector targetCNodes = (Vector)sn.getClassNodes(); Vector targetSEdges = (Vector)sn.getScheduleEdges(); @@ -261,8 +264,9 @@ public class ScheduleNode extends GraphNode implements Cloneable{ } } targetCNodes = null; - targetSEdges = null; + sn.removeInedge(se); + this.removeEdge(se); Iterator it_edges = sn.edges(); while(it_edges.hasNext()) { ScheduleEdge tse = (ScheduleEdge)it_edges.next(); @@ -270,6 +274,47 @@ public class ScheduleNode extends GraphNode implements Cloneable{ this.edges.addElement(tse); } + // merge the split ClassNode of same class + FlagState sfs = se.getFstate(); + FlagState tfs = se.getTargetFState(); + ClassNode scn = se.getSourceCNode(); + ClassNode tcn = se.getTargetCNode(); + sfs.getEdgeVector().addAll(tfs.getEdgeVector()); + // merge the subtree whose root is nfs from the whole flag transition tree + Vector sfss = scn.getFlagStates(); + sfss.addAll(tcn.getFlagStates()); + sfss.removeElement(tfs); + classNodes.removeElement(tcn); + + // flush the exeTime of fs and its ancestors + sfs.setExeTime(0); + Queue toiterate = new LinkedList(); + toiterate.add(sfs); + while(!toiterate.isEmpty()) { + FlagState tmpfs = toiterate.poll(); + int ttime = tmpfs.getExeTime(); + Iterator it_inedges = tmpfs.inedges(); + while(it_inedges.hasNext()) { + FEdge fEdge = (FEdge)it_inedges.next(); + FlagState temp = (FlagState)fEdge.getSource(); + int time = fEdge.getExeTime() + ttime; + if(temp.getExeTime() > time) { + temp.setExeTime(time); + toiterate.add(temp); + } + } + } + toiterate = null; + + // redirct internal ScheduleEdge from tcn to scn + for(int i = 0; i < targetSEdges.size(); ++i) { + ScheduleEdge tmpse = targetSEdges.elementAt(i); + if(tmpse.getSourceCNode().equals(tcn)) { + tmpse.setSourceCNode(scn); + } + } + targetSEdges = null; + // As all tasks inside one ScheduleNode are executed sequentially, // simply add the execution time of all the ClassNodes inside one ScheduleNode. if(this.executionTime == -1) { diff --git a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java index 06e4fdf5..d2e60d24 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java @@ -29,6 +29,11 @@ public class FlagState extends GraphNode implements Cloneable { // jzhou private int executeTime; private int invokeNum; + // for building multicore codes + private int andmask; + private int checkmask; + private boolean setmask; + private int iuid; /** Class constructor * Creates a new flagstate with all flags set to false. @@ -42,6 +47,10 @@ public class FlagState extends GraphNode implements Cloneable { this.issourcenode=false; this.executeTime = -1; this.invokeNum = 0; + this.andmask = 0; + this.checkmask = 0; + this.setmask = false; + this.iuid = 0; } /** Class constructor @@ -63,6 +72,18 @@ public class FlagState extends GraphNode implements Cloneable { public int getuid() { return uid; } + + public int getiuid() { + return iuid++; + } + + public boolean isSetmask() { + return setmask; + } + + public void setSetmask(boolean setmask) { + this.setmask = setmask; + } /** Accessor method * @param fd FlagDescriptor @@ -317,6 +338,22 @@ public class FlagState extends GraphNode implements Cloneable { this.executeTime = exeTime; } + public int getAndmask() { + return andmask; + } + + public void setAndmask(int andmask) { + this.andmask = andmask; + } + + public int getCheckmask() { + return checkmask; + } + + public void setCheckmask(int checkmask) { + this.checkmask = checkmask; + } + public void calExeTime() throws Exception { Iterator it = this.edges(); if(it.hasNext()) { diff --git a/Robust/src/Analysis/TaskStateAnalysis/TagAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TagAnalysis.java index 82f3d713..e1f0613b 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TagAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TagAnalysis.java @@ -6,6 +6,8 @@ import java.util.Set; import java.util.HashSet; import java.util.Iterator; import java.util.Arrays; +import java.util.Vector; + import Util.Edge; import Analysis.CallGraph.CallGraph; import IR.SymbolTable; @@ -137,6 +139,7 @@ private void computeCallsFlags(FlatMethod fm, Hashtable parammap, Set tagbinding ffantemp=ttp.getTemp(); } } + Vector targetFStates = ffan.getTargetFStates4NewObj(ffantemp.getType().getClassDesc()); FlagState fs=new FlagState(ffantemp.getType().getClassDesc()); for(Iterator it=ffan.getTempFlagPairs();it.hasNext();) { TempFlagPair tfp=(TempFlagPair)it.next(); @@ -174,6 +177,9 @@ private void computeCallsFlags(FlatMethod fm, Hashtable parammap, Set tagbinding else fs2=(FlagState) flagmap.get(fs2); newflags.add(fs2); + if(!targetFStates.contains(fs2)) { + targetFStates.addElement(fs2); + } } } } diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java index 29e44a81..bba02a6e 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java @@ -205,7 +205,9 @@ private void analyseTasks(FlagState fs) { fsnew.setAsSourceNode(); fsnew.addAllocatingTask(td); - ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew); + if(!((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).contains(fsnew)) { + ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew); + } } Stack nodestack=new Stack(); @@ -231,6 +233,11 @@ private void analyseTasks(FlagState fs) { } else if (ffan.getTaskType() == FlatFlagActionNode.TASKEXIT) { Vector fsv_taskexit=evalTaskExitNode(ffan,cd,fs,temp); + Vector initFStates = ffan.getInitFStates(temp.getType().getClassDesc()); + if(!initFStates.contains(fs)) { + initFStates.addElement(fs); + } + Vector targetFStates = ffan.getTargetFStates(fs); for(Enumeration en=fsv_taskexit.elements();en.hasMoreElements();){ FlagState fs_taskexit=(FlagState)en.nextElement(); if (!sourcenodes.containsKey(fs_taskexit)) { @@ -241,6 +248,10 @@ private void analyseTasks(FlagState fs) { FEdge newedge=new FEdge(fs_taskexit,taskname, td, parameterindex); ((Vector)tdToFEdges.get(td)).add(newedge); fs.addEdge(newedge); + + if(!targetFStates.contains(fs_taskexit)) { + targetFStates.addElement(fs_taskexit); + } } continue; } diff --git a/Robust/src/IR/Descriptor.java b/Robust/src/IR/Descriptor.java index edafd624..87d09137 100644 --- a/Robust/src/IR/Descriptor.java +++ b/Robust/src/IR/Descriptor.java @@ -39,4 +39,8 @@ public abstract class Descriptor { public int getNum() { return uniqueid; } + + public String getCoreSafeSymbol(int num) { + return safename + "core" + num + "___"; + } } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index c22122c1..e4a72206 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -36,7 +36,8 @@ public class BuildCode { public static int flagcount = 0; Virtual virtualcalls; TypeUtil typeutil; - private int maxtaskparams=0; + //private int maxtaskparams=0; + protected int maxtaskparams=0; private int maxcount=0; ClassDescriptor[] cdarray; TypeDescriptor[] arraytable; @@ -300,13 +301,17 @@ public class BuildCode { * objets and array that stores supertype and then the code for * the Java methods.. */ - private void outputMethods(PrintWriter outmethod) { + //private void outputMethods(PrintWriter outmethod) { + protected void outputMethods(PrintWriter outmethod) { outmethod.println("#include \"methodheaders.h\""); outmethod.println("#include \"virtualtable.h\""); outmethod.println("#include "); if (state.DSM) { outmethod.println("#include \"localobjects.h\""); } + if(state.MULTICORE) { + outmethod.println("#include \"task.h\""); + } if (state.THREAD||state.DSM) outmethod.println("#include "); if (state.main!=null) { @@ -351,7 +356,8 @@ public class BuildCode { } } - private void outputStructs(PrintWriter outstructs) { + //private void outputStructs(PrintWriter outstructs) { + protected void outputStructs(PrintWriter outstructs) { outstructs.println("#ifndef STRUCTDEFS_H"); outstructs.println("#define STRUCTDEFS_H"); outstructs.println("#include \"classdefs.h\""); @@ -393,7 +399,8 @@ public class BuildCode { } } - private void outputClassDeclarations(PrintWriter outclassdefs) { + //private void outputClassDeclarations(PrintWriter outclassdefs) { + protected void outputClassDeclarations(PrintWriter outclassdefs) { if (state.THREAD||state.DSM) outclassdefs.println("#include "); if(state.OPTIONAL) @@ -416,7 +423,12 @@ public class BuildCode { } if (state.TASK) { outclassdefs.println(" int flag;"); - outclassdefs.println(" void * flagptr;"); + if(!state.MULTICORE) { + outclassdefs.println(" void * flagptr;"); + } /*else { + outclassdefs.println(" int corenum;"); + outclassdefs.println(" int flagptr;"); + }*/ if(state.OPTIONAL){ outclassdefs.println(" int numfses;"); outclassdefs.println(" int * fses;"); @@ -467,7 +479,9 @@ public class BuildCode { outrepairstructs.println(" int __type__;"); if (state.TASK) { outrepairstructs.println(" int __flag__;"); - outrepairstructs.println(" int __flagptr__;"); + if(!state.MULTICORE) { + outrepairstructs.println(" int __flagptr__;"); + } } printRepairStruct(cn, outrepairstructs); outrepairstructs.println("}\n"); @@ -512,7 +526,7 @@ public class BuildCode { } /** This method outputs TaskDescriptor information */ - void generateTaskDescriptor(PrintWriter output, FlatMethod fm, TaskDescriptor task) { + private void generateTaskDescriptor(PrintWriter output, FlatMethod fm, TaskDescriptor task) { for (int i=0;i saveset=lb!=null?locality.getTempSet(lb):null; @@ -949,7 +965,8 @@ public class BuildCode { /* Map flags to integers consistently between inherited * classes. */ - private void mapFlags(ClassDescriptor cn) { + //private void mapFlags(ClassDescriptor cn) { + protected void mapFlags(ClassDescriptor cn) { ClassDescriptor sp=cn.getSuperDesc(); if (sp!=null) mapFlags(sp); @@ -983,7 +1000,8 @@ public class BuildCode { * passed in (when PRECISE GC is enabled) and (2) function * prototypes for the methods */ - private void generateCallStructs(ClassDescriptor cn, PrintWriter classdefout, PrintWriter output, PrintWriter headersout) { + //private void generateCallStructs(ClassDescriptor cn, PrintWriter classdefout, PrintWriter output, PrintWriter headersout) { + protected void generateCallStructs(ClassDescriptor cn, PrintWriter classdefout, PrintWriter output, PrintWriter headersout) { /* Output class structure */ classdefout.println("struct "+cn.getSafeSymbol()+" {"); classdefout.println(" int type;"); @@ -995,7 +1013,11 @@ public class BuildCode { if (state.TASK) { classdefout.println(" int flag;"); - classdefout.println(" void * flagptr;"); + if((!state.MULTICORE) || (cn.getSymbol().equals("TagDescriptor"))) { + classdefout.println(" void * flagptr;"); + } /*else { + classdefout.println(" int flagptr;"); + }*/ if (state.OPTIONAL){ classdefout.println(" int numfses;"); classdefout.println(" int * fses;"); @@ -1312,7 +1334,8 @@ public class BuildCode { /** This method assigns labels to FlatNodes */ - private Hashtable assignLabels(FlatMethod fm) { + //private Hashtable assignLabels(FlatMethod fm) { + protected Hashtable assignLabels(FlatMethod fm) { HashSet tovisit=new HashSet(); HashSet visited=new HashSet(); int labelindex=0; @@ -1345,7 +1368,8 @@ public class BuildCode { /** Generate text string that corresponds to the TempDescriptor td. */ - private String generateTemp(FlatMethod fm, TempDescriptor td, LocalityBinding lb) { + //private String generateTemp(FlatMethod fm, TempDescriptor td, LocalityBinding lb) { + protected String generateTemp(FlatMethod fm, TempDescriptor td, LocalityBinding lb) { MethodDescriptor md=fm.getMethod(); TaskDescriptor task=fm.getTask(); TempObject objecttemps=(TempObject) tempstable.get(lb!=null?lb:md!=null?md:task); @@ -1364,7 +1388,8 @@ public class BuildCode { throw new Error(); } - private void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) { + //private void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) { + protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) { switch(fn.kind()) { case FKind.FlatAtomicEnterNode: generateFlatAtomicEnterNode(fm, lb, (FlatAtomicEnterNode) fn, output); @@ -2147,7 +2172,8 @@ public class BuildCode { output.println("return;"); } - private void generateFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) { + //private void generateFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) { + protected void generateFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) { output.println("if (!"+generateTemp(fm, fcb.getTest(),lb)+") goto "+label+";"); } @@ -2337,14 +2363,29 @@ public class BuildCode { ormask=((Integer)flagortable.get(temp)).intValue(); if (flagandtable.containsKey(temp)) andmask=((Integer)flagandtable.get(temp)).intValue(); - if (ffan.getTaskType()==FlatFlagActionNode.NEWOBJECT) { + /*if (ffan.getTaskType()==FlatFlagActionNode.NEWOBJECT) { output.println("flagorandinit("+generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+", 0x"+Integer.toHexString(andmask)+");"); } else { output.println("flagorand("+generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+", 0x"+Integer.toHexString(andmask)+");"); - } + }*/ + generateFlagOrAnd(ffan, fm, lb, temp, output, ormask, andmask); + generateObjectDistribute(ffan, fm, lb, temp, output); + } + } + + protected void generateFlagOrAnd(FlatFlagActionNode ffan, FlatMethod fm, LocalityBinding lb, TempDescriptor temp, + PrintWriter output, int ormask, int andmask) { + if (ffan.getTaskType()==FlatFlagActionNode.NEWOBJECT) { + output.println("flagorandinit("+generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+", 0x"+Integer.toHexString(andmask)+");"); + } else { + output.println("flagorand("+generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+", 0x"+Integer.toHexString(andmask)+");"); } } + protected void generateObjectDistribute(FlatFlagActionNode ffan, FlatMethod fm, LocalityBinding lb, TempDescriptor temp, PrintWriter output) { + output.println("enqueueObject("+generateTemp(fm, temp, lb)+");"); + } + void generateOptionalHeader(PrintWriter headers) { //GENERATE HEADERS diff --git a/Robust/src/IR/Flat/BuildCodeMultiCore.java b/Robust/src/IR/Flat/BuildCodeMultiCore.java new file mode 100644 index 00000000..4251ae47 --- /dev/null +++ b/Robust/src/IR/Flat/BuildCodeMultiCore.java @@ -0,0 +1,984 @@ +package IR.Flat; + +import java.io.FileOutputStream; +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Queue; +import java.util.Vector; + +import Analysis.Locality.LocalityBinding; +import Analysis.Scheduling.Schedule; +import Analysis.TaskStateAnalysis.FEdge; +import Analysis.TaskStateAnalysis.FlagState; +import Analysis.TaskStateAnalysis.SafetyAnalysis; +import IR.ClassDescriptor; +import IR.Descriptor; +import IR.FlagDescriptor; +import IR.MethodDescriptor; +import IR.State; +import IR.TagVarDescriptor; +import IR.TaskDescriptor; +import IR.TypeDescriptor; +import IR.TypeUtil; +import IR.VarDescriptor; +import IR.Tree.DNFFlag; +import IR.Tree.DNFFlagAtom; +import IR.Tree.FlagExpressionNode; +import IR.Tree.TagExpressionList; + +public class BuildCodeMultiCore extends BuildCode { + private Vector scheduling; + int coreNum; + Schedule currentSchedule; + Hashtable[] fsate2qnames; + String objqs4startupprefix= "objqueuearray4startup"; + String objqs4socketprefix= "objqueuearray4socket"; + String objqueueprefix = "objqueue4parameter_"; + String taskprefix = "task_"; + String taskarrayprefix = "taskarray_core"; + String otqueueprefix = "___otqueue"; + + public BuildCodeMultiCore(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, Vector scheduling, int coreNum) { + super(st, temptovar, typeutil, sa); + this.scheduling = scheduling; + this.coreNum = coreNum; + this.currentSchedule = null; + this.fsate2qnames = null; + } + + public void buildCode() { + /* Create output streams to write to */ + PrintWriter outclassdefs=null; + PrintWriter outstructs=null; + //PrintWriter outrepairstructs=null; + PrintWriter outmethodheader=null; + PrintWriter outmethod=null; + PrintWriter outvirtual=null; + PrintWriter outtask=null; + PrintWriter outtaskdefs=null; + //PrintWriter[] outtaskdefs=null; + //PrintWriter outoptionalarrays=null; + //PrintWriter optionalheaders=null; + + try { + outstructs=new PrintWriter(new FileOutputStream(PREFIX+"structdefs.h"), true); + outmethodheader=new PrintWriter(new FileOutputStream(PREFIX+"methodheaders.h"), true); + outclassdefs=new PrintWriter(new FileOutputStream(PREFIX+"classdefs.h"), true); + outvirtual=new PrintWriter(new FileOutputStream(PREFIX+"virtualtable.h"), true); + outmethod=new PrintWriter(new FileOutputStream(PREFIX+"methods.c"), true); + if (state.TASK) { + outtask=new PrintWriter(new FileOutputStream(PREFIX+"task.h"), true); + outtaskdefs=new PrintWriter(new FileOutputStream(PREFIX+"taskdefs.c"), true); + /*if(this.scheduling != null) { + outtaskdefs = new PrintWriter[this.coreNum]; + for(int i = 0; i < this.scheduling.size(); ++i) { + this.currentSchedule = this.scheduling.elementAt(i); + outtaskdefs[this.currentSchedule.getCoreNum()] = new PrintWriter( + new FileOutputStream(PREFIX+"taskdefs_"+this.currentSchedule.getCoreNum()+".c"), true); + } + }*/ + /* optional + if (state.OPTIONAL){ + outoptionalarrays=new PrintWriter(new FileOutputStream(PREFIX+"optionalarrays.c"), true); + optionalheaders=new PrintWriter(new FileOutputStream(PREFIX+"optionalstruct.h"), true); + } */ + } + /*if (state.structfile!=null) { + outrepairstructs=new PrintWriter(new FileOutputStream(PREFIX+state.structfile+".struct"), true); + }*/ + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + + /* Build the virtual dispatch tables */ + super.buildVirtualTables(outvirtual); + + /* Output includes */ + outmethodheader.println("#ifndef METHODHEADERS_H"); + outmethodheader.println("#define METHODHEADERS_H"); + outmethodheader.println("#include \"structdefs.h\""); + /*if (state.DSM) + outmethodheader.println("#include \"dstm.h\"");*/ + + /* Output Structures */ + super.outputStructs(outstructs); + + // Output the C class declarations + // These could mutually reference each other + super.outputClassDeclarations(outclassdefs); + + // Output function prototypes and structures for parameters + Iterator it=state.getClassSymbolTable().getDescriptorsIterator(); + int numclasses = 0; + while(it.hasNext()) { + ++numclasses; + ClassDescriptor cn=(ClassDescriptor)it.next(); + super.generateCallStructs(cn, outclassdefs, outstructs, outmethodheader); + } + outclassdefs.close(); + + if (state.TASK) { + /* Map flags to integers */ + /* The runtime keeps track of flags using these integers */ + it=state.getClassSymbolTable().getDescriptorsIterator(); + while(it.hasNext()) { + ClassDescriptor cn=(ClassDescriptor)it.next(); + super.mapFlags(cn); + } + /* Generate Tasks */ + generateTaskStructs(outstructs, outmethodheader); + + /* Outputs generic task structures if this is a task + program */ + outputTaskTypes(outtask); + } + + /* Build the actual methods */ + super.outputMethods(outmethod); + + if (state.TASK) { + Iterator[] taskits = new Iterator[this.coreNum]; + for(int i = 0; i < taskits.length; ++i) { + taskits[i] = null; + } + int[] numtasks = new int[this.coreNum]; + // arrays record the queues for startup object & socket object + int[][] numqueues = new int[2][this.coreNum]; + /*Vector qnames[][]= new Vector[2][this.coreNum]; + for(int i = 0; i < qnames.length; ++i) { + qnames[i] = null; + }*/ + /* Output code for tasks */ + for(int i = 0; i < this.scheduling.size(); ++i) { + this.currentSchedule = this.scheduling.elementAt(i); + outputTaskCode(outtaskdefs, outmethod, outtask, taskits, numtasks, numqueues);//, qnames); + /*outputTaskCode(outtaskdefs[this.currentSchedule.getCoreNum()], outmethod); + outtaskdefs[this.currentSchedule.getCoreNum()].close();*/ + } + + // Output task descriptors + boolean comma = false; + for(int index = 0; index < 2; ++index) { + if(index == 0) { + outtaskdefs.println("struct parameterwrapper ** objq4startupobj[] = {"); + } else { + outtaskdefs.println("struct parameterwrapper ** objq4socketobj[] = {"); + } + comma = false; + for(int i = 0; i < this.coreNum; ++i) { + if(comma) { + outtaskdefs.println(","); + } else { + comma = true; + } + outtaskdefs.println("/* object queue array for core " + i + "*/"); + outtaskdefs.print(this.objqs4startupprefix + "_core" + i); + } + outtaskdefs.println("};"); + if(index == 0) { + outtaskdefs.println("int numqueues4startupobj[] = {"); + } else { + outtaskdefs.println("int numqueues4socketobj[] = {"); + } + int[] tmparray = numqueues[index]; + comma = false; + for(int i = 0; i < tmparray.length; ++i) { + if(comma) { + outtaskdefs.print(","); + } else { + comma = true; + } + outtaskdefs.print(tmparray[i]); + } + outtaskdefs.println("};"); + } + + for(int i = 0; i < taskits.length; ++i) { + outtaskdefs.println("struct taskdescriptor * " + this.taskarrayprefix + i + "[]={"); + Iterator taskit = taskits[i]; + if(taskit != null) { + boolean first=true; + while(taskit.hasNext()) { + TaskDescriptor td=(TaskDescriptor)taskit.next(); + if (first) + first=false; + else + outtaskdefs.println(","); + outtaskdefs.print("&" + this.taskprefix +td.getCoreSafeSymbol(i)); + } + } + outtaskdefs.println(); + outtaskdefs.println("};"); + } + outtaskdefs.println("struct taskdescriptor ** taskarray[]= {"); + comma = false; + for(int i = 0; i < taskits.length; ++i) { + if (comma) + outtaskdefs.println(","); + else + comma = true; + outtaskdefs.print(this.taskarrayprefix + i); + } + outtaskdefs.println("};"); + + outtaskdefs.print("int numtasks[]= {"); + for(int i = 0; i < taskits.length; ++i) { + boolean first=true; + if (first) + first=false; + else + outtaskdefs.print(","); + outtaskdefs.print(numtasks[i]); + } + outtaskdefs.println("};"); + + outtaskdefs.println("#ifdef RAW"); + outtaskdefs.println("#include \"raw.h\""); + outtaskdefs.println("int corenum=raw_get_tile_num();"); + outtaskdefs.println("#else"); + outtaskdefs.println("int corenum=0;"); + outtaskdefs.println("#endif"); + + outtaskdefs.close(); + + outtask.println("#endif"); + outtask.close(); + /* Record maximum number of task parameters */ + outstructs.println("#define MAXTASKPARAMS "+maxtaskparams); + } //else if (state.main!=null) { + /* Generate main method */ + // outputMainMethod(outmethod); + //} + + /* Generate information for task with optional parameters */ + /*if (state.TASK&&state.OPTIONAL){ + generateOptionalArrays(outoptionalarrays, optionalheaders, state.getAnalysisResult(), state.getOptionalTaskDescriptors()); + outoptionalarrays.close(); + } */ + + /* Output structure definitions for repair tool */ + /*if (state.structfile!=null) { + buildRepairStructs(outrepairstructs); + outrepairstructs.close(); + }*/ + + /* Close files */ + outmethodheader.println("#endif"); + outmethodheader.close(); + outmethod.close(); + outstructs.println("#endif"); + outstructs.close(); + } + + /** This function outputs (1) structures that parameters are + * passed in (when PRECISE GC is enabled) and (2) function + * prototypes for the tasks */ + + private void generateTaskStructs(PrintWriter output, PrintWriter headersout) { + /* Cycle through tasks */ + for(int i = 0; i < this.scheduling.size(); ++i) { + Schedule tmpschedule = this.scheduling.elementAt(i); + int num = tmpschedule.getCoreNum(); + Iterator taskit = tmpschedule.getTasks().iterator(); + + while(taskit.hasNext()) { + /* Classify parameters */ + TaskDescriptor task=taskit.next(); + FlatMethod fm=state.getMethodFlat(task); + super.generateTempStructs(fm, null); + + ParamsObject objectparams=(ParamsObject) paramstable.get(task); + TempObject objecttemps=(TempObject) tempstable.get(task); + + /* Output parameter structure */ + if (GENERATEPRECISEGC) { + output.println("struct "+task.getCoreSafeSymbol(num)+"_params {"); + output.println(" int size;"); + output.println(" void * next;"); + for(int j=0;jmaxtaskparams) { + maxtaskparams=objectparams.numPointers()+fm.numTags(); + } + } + + /* Output temp structure */ + if (GENERATEPRECISEGC) { + output.println("struct "+task.getCoreSafeSymbol(num)+"_locals {"); + output.println(" int size;"); + output.println(" void * next;"); + for(int j=0;j taskit=this.currentSchedule.getTasks().iterator(); + while(taskit.hasNext()) { + TaskDescriptor td=taskit.next(); + FlatMethod fm=state.getMethodFlat(td); + generateTaskMethod(fm, null, outmethod); + generateTaskDescriptor(outtaskdefs, outtask, fm, td, qnames); + } + + // generate queuearray for this core + int num = this.currentSchedule.getCoreNum(); + boolean comma = false; + for(int i = 0; i < 2; ++i) { + if(i == 0) { + outtaskdefs.println("/* object queue array for class StartupObject on core " + num + "*/"); + } else { + outtaskdefs.println("/* object queue array for class Socket on core " + num + "*/"); + } + if(i == 0) { + outtaskdefs.println("struct parameterwrapper * " + this.objqs4startupprefix + "_core" + num + "[] = {"); + } else { + outtaskdefs.println("struct parameterwrapper * " + this.objqs4socketprefix + "_core" + num + "[] = {"); + } + Vector tmpvector = qnames[i]; + comma = false; + if(tmpvector != null) { + for(int j = 0; j < tmpvector.size(); ++j) { + if(comma) { + outtaskdefs.println(","); + } else { + comma = true; + } + outtaskdefs.print("&" + tmpvector.elementAt(j)); + } + numqueues[i][num] = tmpvector.size(); + } else { + numqueues[i][num] = 0; + } + outtaskdefs.println(); + outtaskdefs.println("};"); + } + + // record the iterator of tasks on this core + taskit=this.currentSchedule.getTasks().iterator(); + taskits[num] = taskit; + numtasks[num] = this.currentSchedule.getTasks().size(); + } + + /** Prints out definitions for generic task structures */ + private void outputTaskTypes(PrintWriter outtask) { + outtask.println("#ifndef _TASK_H"); + outtask.println("#define _TASK_H"); + outtask.println("#include \"ObjectHash.h\""); + outtask.println("#include \"structdefs.h\""); + outtask.println(); + outtask.println("struct tagobjectiterator {"); + outtask.println(" int istag; /* 0 if object iterator, 1 if tag iterator */"); + outtask.println(" struct ObjectIterator it; /* Object iterator */"); + outtask.println(" struct ObjectHash * objectset;"); + outtask.println("#ifdef OPTIONAL"); + outtask.println(" int failedstate;"); + outtask.println("#endif"); + outtask.println(" int slot;"); + outtask.println(" int tagobjindex; /* Index for tag or object depending on use */"); + outtask.println(" /*if tag we have an object binding */"); + outtask.println(" int tagid;"); + outtask.println(" int tagobjectslot;"); + outtask.println(" /*if object, we may have one or more tag bindings */"); + outtask.println(" int numtags;"); + outtask.println(" int tagbindings[MAXTASKPARAMS-1]; /* list slots */"); + outtask.println("};"); + outtask.println(); + outtask.println("struct parameterwrapper {"); + outtask.println(" //struct parameterwrapper *next;"); + outtask.println(" struct ObjectHash * objectset;"); + outtask.println(" int numberofterms;"); + outtask.println(" int * intarray;"); + outtask.println(" int numbertags;"); + outtask.println(" int * tagarray;"); + outtask.println(" struct taskdescriptor * task;"); + outtask.println(" int slot;"); + outtask.println(" struct tagobjectiterator iterators[MAXTASKPARAMS-1];"); + outtask.println("};"); + outtask.println(); + outtask.println("extern struct parameterwrapper ** objq4startupobj[];"); + outtask.println("extern int numqueues4startupobj[];"); + outtask.println("extern struct parameterwrapper ** objq4socketobj[];"); + outtask.println("extern int numqueues4socketobj[];"); + outtask.println(); + outtask.println("struct parameterdescriptor {"); + outtask.println(" int type;"); + outtask.println(" int numberterms;"); + outtask.println(" int *intarray;"); + outtask.println(" struct parameterwrapper * queue;"); + outtask.println(" int numbertags;"); + outtask.println(" int *tagarray;"); + outtask.println("};"); + outtask.println(); + outtask.println("struct taskdescriptor {"); + outtask.println(" void * taskptr;"); + outtask.println(" int numParameters;"); + outtask.println(" int numTotal;"); + outtask.println(" struct parameterdescriptor **descriptorarray;"); + outtask.println(" char * name;"); + outtask.println("};"); + outtask.println(); + outtask.println("extern struct taskdescriptor ** taskarray[];"); + outtask.println("extern int numtasks[];"); + outtask.println("extern int corenum;"); // define corenum to identify different core + outtask.println(); + } + + private void generateObjectTransQueues(PrintWriter output) { + if(this.fsate2qnames == null) { + this.fsate2qnames = new Hashtable[this.coreNum]; + for(int i = 0; i < this.fsate2qnames.length; ++i) { + this.fsate2qnames[i] = null; + } + } + int num = this.currentSchedule.getCoreNum(); + assert(this.fsate2qnames[num] == null); + Hashtable flag2qname = new Hashtable(); + this.fsate2qnames[num] = flag2qname; + Hashtable> targetCoreTbl = this.currentSchedule.getTargetCoreTable(); + Object[] keys = targetCoreTbl.keySet().toArray(); + output.println(); + output.println("/* Object transfer queues for core" + num + ".*/"); + for(int i = 0; i < keys.length; ++i) { + FlagState tmpfstate = (FlagState)keys[i]; + Object[] targetcores = targetCoreTbl.get(tmpfstate).toArray(); + String queuename = this.otqueueprefix + tmpfstate.getClassDescriptor().getCoreSafeSymbol(num) + tmpfstate.getuid() + "___"; + String queueins = queuename + "ins"; + flag2qname.put(tmpfstate, queuename); + output.println("struct " + queuename + " {"); + output.println(" int * cores;"); + output.println(" int index;"); + output.println(" int length;"); + output.println("};"); + output.print("int " + queuename + "cores[] = {"); + for(int j = 0; j < targetcores.length; ++j) { + if(j > 0) { + output.print(", "); + } + output.print(((Integer)targetcores[j]).intValue()); + } + output.println("};"); + output.println("struct " + queuename + " " + queueins + "= {"); + output.println(/*".cores = " + */queuename + "cores,"); + output.println(/*".index = " + */"0,"); + output.println(/*".length = " +*/ targetcores.length + "};"); + } + output.println(); + } + + private void generateTaskMethod(FlatMethod fm, LocalityBinding lb, PrintWriter output) { + /*if (State.PRINTFLAT) + System.out.println(fm.printMethod());*/ + TaskDescriptor task=fm.getTask(); + assert(task != null); + int num = this.currentSchedule.getCoreNum(); + + //ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null?lb:task); + generateTaskHeader(fm, lb, task,output); + TempObject objecttemp=(TempObject) tempstable.get(lb!=null?lb:task); + /*if (state.DSM&&lb.getHasAtomic()) { + output.println("transrecord_t * trans;"); + }*/ + + if (GENERATEPRECISEGC) { + output.print(" struct "+task.getCoreSafeSymbol(num)+"_locals "+localsprefix+"={"); + + output.print(objecttemp.numPointers()+","); + output.print(paramsprefix); + for(int j=0;jflag;"); + } + + /* Assign labels to FlatNode's if necessary.*/ + + Hashtable nodetolabel=super.assignLabels(fm); + + /* Check to see if we need to do a GC if this is a + * multi-threaded program...*/ + + /*if ((state.THREAD||state.DSM)&&GENERATEPRECISEGC) { + if (state.DSM&&lb.isAtomic()) + output.println("checkcollect2(&"+localsprefix+",trans);"); + else + output.println("checkcollect(&"+localsprefix+");"); + }*/ + + /* Do the actual code generation */ + FlatNode current_node=null; + HashSet tovisit=new HashSet(); + HashSet visited=new HashSet(); + tovisit.add(fm.getNext(0)); + while(current_node!=null||!tovisit.isEmpty()) { + if (current_node==null) { + current_node=(FlatNode)tovisit.iterator().next(); + tovisit.remove(current_node); + } + visited.add(current_node); + if (nodetolabel.containsKey(current_node)) + output.println("L"+nodetolabel.get(current_node)+":"); + /*if (state.INSTRUCTIONFAILURE) { + if (state.THREAD||state.DSM) { + output.println("if ((++instructioncount)>failurecount) {instructioncount=0;injectinstructionfailure();}"); + } + else + output.println("if ((--instructioncount)==0) injectinstructionfailure();"); + }*/ + if (current_node.numNext()==0) { + output.print(" "); + super.generateFlatNode(fm, lb, current_node, output); + if (current_node.kind()!=FKind.FlatReturnNode) { + output.println(" return;"); + } + current_node=null; + } else if(current_node.numNext()==1) { + output.print(" "); + super.generateFlatNode(fm, lb, current_node, output); + FlatNode nextnode=current_node.getNext(0); + if (visited.contains(nextnode)) { + output.println("goto L"+nodetolabel.get(nextnode)+";"); + current_node=null; + } else + current_node=nextnode; + } else if (current_node.numNext()==2) { + /* Branch */ + output.print(" "); + super.generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + if (!visited.contains(current_node.getNext(1))) + tovisit.add(current_node.getNext(1)); + if (visited.contains(current_node.getNext(0))) { + output.println("goto L"+nodetolabel.get(current_node.getNext(0))+";"); + current_node=null; + } else + current_node=current_node.getNext(0); + } else throw new Error(); + } + output.println("}\n\n"); + } + + /** This method outputs TaskDescriptor information */ + private void generateTaskDescriptor(PrintWriter output, PrintWriter outtask, FlatMethod fm, TaskDescriptor task, Vector[] qnames) { + int num = this.currentSchedule.getCoreNum(); + + output.println("/* TaskDescriptor information for task " + task.getSymbol() + " on core " + num + "*/"); + + for (int i=0;imaxtaskparams) + maxtaskparams=objectparams.numPrimitives()+fm.numTags(); + } else output.println(") {"); + } + + protected void generateFlagOrAnd(FlatFlagActionNode ffan, FlatMethod fm, LocalityBinding lb, TempDescriptor temp, + PrintWriter output, int ormask, int andmask) { + if (ffan.getTaskType()==FlatFlagActionNode.NEWOBJECT) { + output.println("flagorandinit("+super.generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+", 0x"+Integer.toHexString(andmask)+");"); + } else { + int num = this.currentSchedule.getCoreNum(); + ClassDescriptor cd = temp.getType().getClassDesc(); + Vector initfstates = ffan.getInitFStates(cd); + for(int i = 0; i < initfstates.size(); ++i) { + FlagState tmpFState = initfstates.elementAt(i); + QueueInfo qinfo = outputqueues(tmpFState, num, output); + output.println("flagorand("+super.generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+ + ", 0x"+Integer.toHexString(andmask)+", " + qinfo.qname + + ", " + qinfo.length + ");"); + } + //output.println("flagorand("+generateTemp(fm, temp, lb)+", 0x"+Integer.toHexString(ormask)+", 0x"+Integer.toHexString(andmask)+");"); + } + } + + protected void generateObjectDistribute(FlatFlagActionNode ffan, FlatMethod fm, LocalityBinding lb, TempDescriptor temp, + PrintWriter output) { + ClassDescriptor cd = temp.getType().getClassDesc(); + Vector initfstates = null; + Vector[] targetFStates = null; + if (ffan.getTaskType()==FlatFlagActionNode.NEWOBJECT) { + targetFStates = new Vector[1]; + targetFStates[0] = ffan.getTargetFStates4NewObj(cd); + } else { + initfstates = ffan.getInitFStates(cd); + targetFStates = new Vector[initfstates.size()]; + for(int i = 0; i < initfstates.size(); ++i) { + FlagState fs = initfstates.elementAt(i); + targetFStates[i] = ffan.getTargetFStates(fs); + + if(!fs.isSetmask()) { + Hashtable flags=(Hashtable)flagorder.get(cd); + int andmask=0; + int checkmask=0; + Iterator it_flags = fs.getFlags(); + while(it_flags.hasNext()) { + FlagDescriptor fd = (FlagDescriptor)it_flags.next(); + int flagid=1<<((Integer)flags.get(fd)).intValue(); + andmask|=flagid; + checkmask|=flagid; + } + fs.setAndmask(andmask); + fs.setCheckmask(checkmask); + fs.setSetmask(true); + } + } + } + if((this.currentSchedule == null) && (fm.getMethod().getClassDesc().getSymbol().equals("ServerSocket"))) { + // ServerSocket object will always reside on current core + for(int j = 0; j < targetFStates.length; ++j) { + if(initfstates != null) { + FlagState fs = initfstates.elementAt(j); + output.println("if(" + generateTempFlagName(fm, temp, lb) + "&(0x" + Integer.toHexString(fs.getAndmask()) + + ")==(0x" + Integer.toHexString(fs.getCheckmask()) + ")) {"); + } + Vector tmpfstates = (Vector)targetFStates[j]; + for(int i = 0; i < tmpfstates.size(); ++i) { + FlagState tmpFState = tmpfstates.elementAt(i); + output.println("/* reside on this core*"); + output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+", objq4socketobj[corenum], numqueues4socketobj[corenum]);"); + //output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+");"); + } + if(initfstates != null) { + output.println("}"); + } + } + //output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+");"); + return; + } + + int num = this.currentSchedule.getCoreNum(); + Hashtable> targetCoreTbl = this.currentSchedule.getTargetCoreTable(); + for(int j = 0; j < targetFStates.length; ++j) { + if(initfstates != null) { + FlagState fs = initfstates.elementAt(j); + output.println("if((" + generateTempFlagName(fm, temp, lb) + "&(0x" + Integer.toHexString(fs.getAndmask()) + + "))==(0x" + Integer.toHexString(fs.getCheckmask()) + ")) {"); + } + Vector tmpfstates = (Vector)targetFStates[j]; + for(int i = 0; i < tmpfstates.size(); ++i) { + FlagState tmpFState = tmpfstates.elementAt(i); + Queue queue = targetCoreTbl.get(tmpFState); + if((queue != null) && + ((queue.size() != 1) || + ((queue.size() == 1) && (queue.element().intValue() != num)))) { + // this object may be transferred to other cores + String queuename = (String)this.fsate2qnames[num].get(tmpFState); + String queueins = queuename + "ins"; + + Object[] cores = queue.toArray(); + String index = "0"; + Integer targetcore = (Integer)cores[0]; + if(queue.size() > 1) { + index = queueins + ".index"; + } + if(queue.size() > 1) { + output.println("switch(" + queueins + ".index % " + queueins + ".length) {"); + for(int k = 0; k < cores.length; ++k) { + output.println("case " + k + ":"); + targetcore = (Integer)cores[k]; + if(targetcore.intValue() == num) { + output.println("/* reside on this core*/"); + QueueInfo qinfo = outputqueues(tmpFState, num, output); + output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+", " + qinfo.qname + + ", " + qinfo.length + ");"); + + //output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+");"); + } else { + output.println("/* transfer to core " + targetcore.toString() + "*/"); + // method call of transfer objects + output.println("transferObject("+super.generateTemp(fm, temp, lb)+", " + targetcore.toString() + ");"); + } + output.println("break;"); + } + output.println("}"); + } else { + output.println("/* transfer to core " + targetcore.toString() + "*/"); + // method call of transfer objectts + output.println("transferObject("+super.generateTemp(fm, temp, lb)+", " + targetcore.toString() + ");"); + } + output.println("/* increase index*/"); + output.println("++" + queueins + ".index;"); + } else { + // this object will reside on current core + output.println("/* reside on this core*/"); + QueueInfo qinfo = outputqueues(tmpFState, num, output); + output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+", " + qinfo.qname + + ", " + qinfo.length + ");"); + + //output.println("enqueueObject("+super.generateTemp(fm, temp, lb)+");"); + } + } + if(initfstates != null) { + output.println("}"); + } + } + } + + private QueueInfo outputqueues(FlagState tmpFState, int num, PrintWriter output) { + // queue array + QueueInfo qinfo = new QueueInfo(); + output.println(";"); + qinfo.qname = "queues_" + tmpFState.getLabel() + "_" + tmpFState.getiuid(); + output.println("struct parameterwrapper * " + qinfo.qname + "[] = {"); + Iterator it_edges = tmpFState.getEdgeVector().iterator(); + Vector tasks = new Vector(); + Vector indexes = new Vector(); + boolean comma = false; + qinfo.length = 0; + while(it_edges.hasNext()) { + FEdge fe = (FEdge)it_edges.next(); + TaskDescriptor td = fe.getTask(); + int paraindex = fe.getIndex(); + if((!tasks.contains(td)) || + ((tasks.contains(td)) && (paraindex != indexes.elementAt(tasks.indexOf(td)).intValue()))) { + tasks.addElement(td); + indexes.addElement(paraindex); + if(comma) { + output.println(","); + } else { + comma = true; + } + output.print("&" + this.objqueueprefix + paraindex + "_" + td.getCoreSafeSymbol(num)); + ++qinfo.length; + } + } + output.println("};"); + return qinfo; + } + + private class QueueInfo { + public int length; + public String qname; + } + + private String generateTempFlagName(FlatMethod fm, TempDescriptor td, LocalityBinding lb) { + MethodDescriptor md=fm.getMethod(); + TaskDescriptor task=fm.getTask(); + TempObject objecttemps=(TempObject) tempstable.get(lb!=null?lb:md!=null?md:task); + + if (objecttemps.isLocalPrim(td)||objecttemps.isParamPrim(td)) { + return td.getSafeSymbol() + "_oldflag"; + } + + if (objecttemps.isLocalPtr(td)) { + return localsprefix+"_"+td.getSafeSymbol() + "_oldflag"; + } + + if (objecttemps.isParamPtr(td)) { + return paramsprefix+"_"+td.getSafeSymbol() + "_oldflag"; + } + throw new Error(); + } +} \ No newline at end of file diff --git a/Robust/src/IR/Flat/FlatFlagActionNode.java b/Robust/src/IR/Flat/FlatFlagActionNode.java index 081b36b0..7a587a81 100644 --- a/Robust/src/IR/Flat/FlatFlagActionNode.java +++ b/Robust/src/IR/Flat/FlatFlagActionNode.java @@ -1,9 +1,12 @@ package IR.Flat; +import Analysis.TaskStateAnalysis.FlagState; +import IR.ClassDescriptor; import IR.FlagDescriptor; import IR.TagDescriptor; import java.util.Hashtable; import java.util.HashSet; import java.util.Iterator; +import java.util.Vector; public class FlatFlagActionNode extends FlatNode { Hashtable tempflagpairs; @@ -13,17 +16,55 @@ public class FlatFlagActionNode extends FlatNode { public static final int NEWOBJECT=0; public static final int PRE=1; public static final int TASKEXIT=2; + + Hashtable> cd2initfs; + Hashtable> cd2fs4new; + Hashtable> fs2fs; public FlatFlagActionNode(int taskexit) { tempflagpairs=new Hashtable(); temptagpairs=new Hashtable(); this.taskexit=taskexit; + + this.cd2initfs = null; + this.cd2fs4new = null; + this.fs2fs = null; } public int getTaskType() { return taskexit; } + + public Vector getInitFStates(ClassDescriptor cd) { + if(this.cd2initfs == null) { + this.cd2initfs = new Hashtable>(); + } + if(this.cd2initfs.get(cd) == null) { + this.cd2initfs.put(cd, new Vector()); + } + return this.cd2initfs.get(cd); + } + + public Vector getTargetFStates4NewObj(ClassDescriptor cd) { + if(this.cd2fs4new == null) { + this.cd2fs4new = new Hashtable>(); + } + if(this.cd2fs4new.get(cd) == null) { + this.cd2fs4new.put(cd, new Vector()); + } + return this.cd2fs4new.get(cd); + } + + public Vector getTargetFStates(FlagState fs) { + if(this.fs2fs == null) { + this.fs2fs = new Hashtable>(); + } + if(this.fs2fs.get(fs) == null) { + this.fs2fs.put(fs, new Vector()); + } + return this.fs2fs.get(fs); + } public void addFlagAction(TempDescriptor td, FlagDescriptor fd, boolean status) { TempFlagPair tfp=new TempFlagPair(td,fd); diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 0e66fe01..25c7f42d 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -52,8 +52,10 @@ public class State { public boolean FLATIRGRAPHTASKS=false; public boolean FLATIRGRAPHUSERMETHODS=false; public boolean FLATIRGRAPHLIBMETHODS=false; + public boolean MULTICORE=false; public boolean OWNERSHIP=false; public boolean OPTIONAL=false; + //public boolean RAW=false; public boolean SCHEDULING=false; public boolean THREAD=false; public boolean CONSCHECK=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index ef0c3d1a..cbcbd893 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -13,6 +13,7 @@ import java.util.Vector; import IR.Tree.ParseNode; import IR.Tree.BuildIR; import IR.Tree.SemanticCheck; +import IR.Flat.BuildCodeMultiCore; import IR.Flat.BuildFlat; import IR.Flat.BuildCode; import IR.ClassDescriptor; @@ -91,10 +92,14 @@ public class Main { state.FLATIRGRAPH=true; state.FLATIRGRAPHLIBMETHODS=true; } + else if (option.equals("-multicore")) + state.MULTICORE=true; else if (option.equals("-ownership")) state.OWNERSHIP=true; else if (option.equals("-optional")) state.OPTIONAL=true; + /*else if (option.equals("-raw")) + state.RAW=true;*/ else if (option.equals("-scheduling")) state.SCHEDULING=true; else if (option.equals("-thread")) @@ -241,9 +246,9 @@ public class Main { // 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."); + //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); @@ -253,9 +258,9 @@ public class Main { // 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."); + //origOut.println ("\nRedirect: Round #2"); + //System.out.println ("Test output via 'SimulatorResult.out'."); + //origOut.println ("Test output via 'origOut' reference."); // for test // Randomly set the newRate and probability of FEdges @@ -280,7 +285,7 @@ public class Main { if(numEdges - j == 1) { pfe.setProbability(total); } else { - if(total != 0) { + if((total != 0) && (total != 1)){ do { tint = r.nextInt()%total; } while(tint <= 0); @@ -288,11 +293,12 @@ public class Main { pfe.setProbability(tint); total -= tint; } - do { + /*do { tint = r.nextInt()%10; - } while(tint <= 0); + } while(tint <= 0);*/ //int newRate = tint; - int newRate = (j+1)%2+1; + //int newRate = (j+1)%2+1; + int newRate = 1; /*do { tint = r.nextInt()%100; } while(tint <= 0); @@ -309,9 +315,10 @@ public class Main { FlagState fs = (FlagState)it_flags.next(); Iterator it_edges = fs.edges(); while(it_edges.hasNext()) { - do { + /*do { tint = r.nextInt()%10; - } while(tint <= 0); + } while(tint <= 0);*/ + tint = 1; ((FEdge)it_edges.next()).setExeTime(tint); } } @@ -322,7 +329,9 @@ public class Main { ScheduleAnalysis scheduleAnalysis = new ScheduleAnalysis(state, ta); scheduleAnalysis.preSchedule(); scheduleAnalysis.scheduleAnalysis(); - scheduleAnalysis.setCoreNum(scheduleAnalysis.getSEdges4Test().size()); + //scheduleAnalysis.setCoreNum(scheduleAnalysis.getSEdges4Test().size()); + scheduleAnalysis.setCoreNum(1); + //scheduleAnalysis.setCoreNum(2); scheduleAnalysis.schedule(); //simulate these schedulings @@ -390,22 +399,31 @@ public class Main { } catch (Exception e) { origOut.println ("Redirect: Unable to close files!"); } + + if(state.MULTICORE) { + it_scheduling = scheduleAnalysis.getSchedulingsIter(); + Vector scheduling = (Vector)it_scheduling.next(); + BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, bf.getMap(), tu, sa, scheduling, scheduleAnalysis.getCoreNum()); + bcm.buildCode(); + } } } - if (state.DSM) { - CallGraph callgraph=new CallGraph(state); - if (state.PREFETCH) { - PrefetchAnalysis pa=new PrefetchAnalysis(state, callgraph, tu); + if(!state.MULTICORE) { + if (state.DSM) { + CallGraph callgraph=new CallGraph(state); + if (state.PREFETCH) { + PrefetchAnalysis pa=new PrefetchAnalysis(state, callgraph, tu); + } + LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu); + GenerateConversions gc=new GenerateConversions(la, state); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, la); + bc.buildCode(); + } else { + BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa); + bc.buildCode(); } - LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu); - GenerateConversions gc=new GenerateConversions(la, state); - BuildCode bc=new BuildCode(state, bf.getMap(), tu, la); - bc.buildCode(); - } else { - BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa); - bc.buildCode(); } if (state.FLATIRGRAPH) { diff --git a/Robust/src/Runtime/checkpoint.c b/Robust/src/Runtime/checkpoint.c index 16aee058..d0dce59e 100644 --- a/Robust/src/Runtime/checkpoint.c +++ b/Robust/src/Runtime/checkpoint.c @@ -321,8 +321,14 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru } if (hasflags[type]) { (((void **)cpy)[2])=flagptr; - if (currflag!=oldflag) + if (currflag!=oldflag) { flagorandinit(cpy, 0, 0xFFFFFFFF); +#ifdef MULTICORE + enqueueObject(cpy, NULL,0); //TODO +#else + enqueueObject(cpy); +#endif + } } } } diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index b1dc3a0e..beb67c86 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -25,7 +25,9 @@ #ifdef TASK extern struct genhashtable * activetasks; +#ifndef MULTICORE extern struct parameterwrapper * objectqueues[NUMCLASSES]; +#endif extern struct genhashtable * failedtasks; extern struct taskparamdescriptor *currtpd; extern struct RuntimeHash *forward; @@ -188,6 +190,8 @@ void collect(struct garbagelist * stackptr) { /* Update objectsets */ int i; for(i=0;iobjectset; @@ -200,6 +204,7 @@ void collect(struct garbagelist * stackptr) { ObjectHashrehash(set); /* Rehash the table */ p=p->next; } +#endif } } diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index 6c1ac82b..e929260a 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -79,9 +79,11 @@ void createstartupobject(); #ifdef TASK #include "SimpleHash.h" +#ifndef MULTICORE #include "ObjectHash.h" -#include "task.h" #include "structdefs.h" +#endif +#include "task.h" #ifdef OPTIONAL #include "optionalstruct.h" #endif @@ -96,11 +98,23 @@ struct failedtasklist { }; #endif +#ifdef MULTICORE +void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length); +void flagorandinit(void * ptr, int ormask, int andmask); +void enqueueObject(void * ptr, struct parameterwrapper ** queues, int length); +#else void flagorand(void * ptr, int ormask, int andmask); void flagorandinit(void * ptr, int ormask, int andmask); +void enqueueObject(void * ptr); +#endif void executetasks(); void processtasks(); +#ifdef MULTICORE +void transferObject(void * ptr, int targetcore); +#endif + +#ifndef MULTICORE struct tagobjectiterator { int istag; /* 0 if object iterator, 1 if tag iterator */ struct ObjectIterator it; /* Object iterator */ @@ -129,6 +143,7 @@ struct parameterwrapper { int slot; struct tagobjectiterator iterators[MAXTASKPARAMS-1]; }; +#endif struct taskparamdescriptor { struct taskdescriptor * task; diff --git a/Robust/src/Runtime/socket.c b/Robust/src/Runtime/socket.c index 60709cd2..e9ce2ffe 100644 --- a/Robust/src/Runtime/socket.c +++ b/Robust/src/Runtime/socket.c @@ -292,7 +292,13 @@ int CALL02(___ServerSocket______nativeaccept____L___Socket___,struct ___ServerSo fcntl(newfd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK); RuntimeHashadd(fdtoobject, newfd, (int) VAR(___s___)); addreadfd(newfd); +#ifdef MULTICORE + flagorand(VAR(___this___),0,0xFFFFFFFE,objq4socketobj[corenum],numqueues4socketobj[corenum]); + enqueueObject(VAR(___this___), objq4socketobj[corenum], numqueues4socketobj[corenum]); +#else flagorand(VAR(___this___),0,0xFFFFFFFE); + enqueueObject(VAR(___this___)); +#endif #endif return newfd; } @@ -356,7 +362,13 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___, perror(""); } #ifdef TASK +#ifdef MULTICORE + flagorand(VAR(___this___),0,0xFFFFFFFE,objq4socketobj[corenum],numqueues4socketobj[corenum]); + enqueueObject(VAR(___this___),objq4socketobj[corenum],numqueues4socketobj[corenum]); +#else flagorand(VAR(___this___),0,0xFFFFFFFE); + enqueueObject(VAR(___this___)); +#endif #endif return byteread; } @@ -368,7 +380,13 @@ void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) { RuntimeHashget(fdtoobject, fd, &data); RuntimeHashremove(fdtoobject, fd, data); removereadfd(fd); +#ifdef MULTICORE + flagorand(VAR(___this___),0,0xFFFFFFFE,objq4socketobj[corenum],numqueues4socketobj[corenum]); + enqueueObject(VAR(___this___),objq4socketobj[corenum],numqueues4socketobj[corenum]); +#else flagorand(VAR(___this___),0,0xFFFFFFFE); + enqueueObject(VAR(___this___)); +#endif #endif close(fd); } diff --git a/Robust/src/Runtime/task.c b/Robust/src/Runtime/task.c index 61416da0..ac045dad 100644 --- a/Robust/src/Runtime/task.c +++ b/Robust/src/Runtime/task.c @@ -22,7 +22,9 @@ extern int instaccum; #endif struct genhashtable * activetasks; +#ifndef MULTICORE struct parameterwrapper * objectqueues[NUMCLASSES]; +#endif struct genhashtable * failedtasks; struct taskparamdescriptor * currtpd; struct RuntimeHash * forward; @@ -77,8 +79,14 @@ void createstartupobject(int argc, char ** argv) { ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i-1]=newstring; } - /* Set initialized flag for startup object */ + /* Set initialized flag for startup object */ +#ifdef MULTICORE + flagorand(startupobject,1,0xFFFFFFFF,NULL,0); + enqueueObject(startupobject, objq4startupobj[corenum], numqueues4startupobj[corenum]); +#else flagorand(startupobject,1,0xFFFFFFFF); + enqueueObject(startupobject); +#endif } int hashCodetpd(struct taskparamdescriptor *ftd) { @@ -288,7 +296,11 @@ struct ___TagDescriptor___ * allocate_tag(int index) { /* This function updates the flag for object ptr. It or's the flag with the or mask and and's it with the andmask. */ +#ifdef MULTICORE +void flagbody(struct ___Object___ *ptr, int flag, struct parameterwrapper ** queues, int length); +#else void flagbody(struct ___Object___ *ptr, int flag); +#endif #ifdef OPTIONAL void enqueueoptional(struct ___Object___ * currobj, int numfailedfses, int * failedfses, struct taskdescriptor * task, int index); #endif @@ -297,7 +309,11 @@ void enqueueoptional(struct ___Object___ * currobj, int numfailedfses, int * fai return (*val1)-(*val2); } +#ifdef MULTICORE +void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length) { +#else void flagorand(void * ptr, int ormask, int andmask) { +#endif #ifdef OPTIONAL struct ___Object___ * obj = (struct ___Object___ *)ptr; if(obj->numfses){/*store the information about fses*/ @@ -320,11 +336,15 @@ void flagorand(void * ptr, int ormask, int andmask) { int oldflag=((int *)ptr)[1]; int flag=ormask|oldflag; flag&=andmask; +#ifdef MULTICORE + flagbody(ptr, flag, queues, length); +#else flagbody(ptr, flag); +#endif } } -void intflagorand(void * ptr, int ormask, int andmask) { +bool intflagorand(void * ptr, int ormask, int andmask) { #ifdef OPTIONAL struct ___Object___ * obj = (struct ___Object___ *)ptr; if(obj->numfses) {/*store the information about fses*/ @@ -348,8 +368,15 @@ void intflagorand(void * ptr, int ormask, int andmask) { int flag=ormask|oldflag; flag&=andmask; if (flag==oldflag) /* Don't do anything */ - return; - else flagbody(ptr, flag); + return false; + else { +#ifdef MULTICORE + flagbody(ptr, flag, NULL, 0); +#else + flagbody(ptr, flag); +#endif + return true; + } } } @@ -357,28 +384,67 @@ void flagorandinit(void * ptr, int ormask, int andmask) { int oldflag=((int *)ptr)[1]; int flag=ormask|oldflag; flag&=andmask; +#ifdef MULTICORE + flagbody(ptr,flag,NULL,0); +#else flagbody(ptr,flag); +#endif } +#ifdef MULTICORE +void flagbody(struct ___Object___ *ptr, int flag, struct parameterwrapper ** queues, int length) { +#else void flagbody(struct ___Object___ *ptr, int flag) { +#endif +#ifdef MULTICORE + struct parameterwrapper * flagptr = NULL; + int i = 0; +#else struct parameterwrapper *flagptr=(struct parameterwrapper *)ptr->flagptr; +#endif ptr->flag=flag; /*Remove object from all queues */ +#ifdef MULTICORE + for(i = 0; i < length; ++i) { + flagptr = queues[i]; +#else while(flagptr!=NULL) { +#endif +#ifdef MULTICORE + int next; +#else struct parameterwrapper *next; +#endif int UNUSED, UNUSED2; int * enterflags; ObjectHashget(flagptr->objectset, (int) ptr, (int *) &next, (int *) &enterflags, &UNUSED, &UNUSED2); ObjectHashremove(flagptr->objectset, (int)ptr); if (enterflags!=NULL) free(enterflags); +#ifdef MULTICORE + ; +#else flagptr=next; +#endif } + } + +#ifdef MULTICORE + void enqueueObject(void * vptr, struct parameterwrapper ** queues, int length) { +#else + void enqueueObject(void *vptr) { +#endif + struct ___Object___ *ptr = (struct ___Object___ *)vptr; { struct QueueItem *tmpptr; +#ifdef MULTICORE + struct parameterwrapper * parameter=NULL; + int j; +#else struct parameterwrapper * parameter=objectqueues[ptr->type]; +#endif int i; struct parameterwrapper * prevptr=NULL; struct ___Object___ *tagptr=ptr->___tags___; @@ -386,7 +452,12 @@ void flagbody(struct ___Object___ *ptr, int flag) { /* Outer loop iterates through all parameter queues an object of this type could be in. */ +#ifdef MULTICORE + for(j = 0; j < length; ++j) { + parameter = queues[j]; +#else while(parameter!=NULL) { +#endif /* Check tags */ if (parameter->numbertags>0) { if (tagptr==NULL) @@ -420,19 +491,59 @@ void flagbody(struct ___Object___ *ptr, int flag) { for(i=0;inumberofterms;i++) { int andmask=parameter->intarray[i*2]; int checkmask=parameter->intarray[i*2+1]; - if ((flag&andmask)==checkmask) { + if ((ptr->flag&andmask)==checkmask) { enqueuetasks(parameter, prevptr, ptr, NULL, 0); prevptr=parameter; break; } } nextloop: +#ifdef MULTICORE + ; +#else parameter=parameter->next; +#endif } +#ifdef MULTICORE + /*if(prevptr != NULL) { + ptr->flagptr=prevptr->arrayindex; + } else { + ptr->flagptr = 0; + }*/ +#else ptr->flagptr=prevptr; +#endif } } - + +#ifdef MULTICORE + +void transferObject(void * obj, int targetcore) { + int type=((int *)obj)[0]; + // if (type___localcopy___=newobj; + //} else { + /* We have an array */ + /*struct ArrayObject *ao=(struct ArrayObject *)obj; + int elementsize=classsize[type]; + int length=ao->___length___; + int size=sizeof(struct ArrayObject)+length*elementsize; + struct ___Object___ * newobj=FREEMALLOC(size); + memcpy(newobj, obj, size); + obj->___localcopy___=newobj; + }*/ +} + +#endif + #ifdef OPTIONAL int checktags(struct ___Object___ * currobj, struct fsanalysiswrapper * fswrapper) { @@ -876,7 +987,15 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr retval=0; } else { #endif +#ifdef MULTICORE + /*int arrayindex = 0; + if(prevptr != NULL) { + arrayindex = prevptr->arrayindex; + }*/ + ObjectHashadd(parameter->objectset, (int) ptr, 0, (int) enterflags, numenterflags, enterflags==NULL);//this add the object to parameterwrapper +#else ObjectHashadd(parameter->objectset, (int) ptr, (int) prevptr, (int) enterflags, numenterflags, enterflags==NULL);//this add the object to parameterwrapper +#endif #ifdef OPTIONAL } #endif @@ -1060,7 +1179,13 @@ void executetasks() { void * objptr; // printf("Setting fd %d\n",fd); if (RuntimeHashget(fdtoobject, fd,(int *) &objptr)) { - intflagorand(objptr,1,0xFFFFFFFF); /* Set the first flag to 1 */ + if(intflagorand(objptr,1,0xFFFFFFFF)) { /* Set the first flag to 1 */ +#ifdef MULTICORE + enqueueObject(objptr, NULL, 0); +#else + enqueueObject(objptr); +#endif + } } } } @@ -1343,8 +1468,13 @@ void builditerators(struct taskdescriptor * task, int index, struct parameterwra void printdebug() { int i; int j; +#ifdef MULTICORE + for(i=0;iname); for(j=0;jnumParameters;j++) { struct parameterdescriptor *param=task->descriptorarray[j]; @@ -1388,10 +1518,16 @@ void builditerators(struct taskdescriptor * task, int index, struct parameterwra void processtasks() { int i; +#ifdef MULTICORE + for(i=0;inumParameters;j++) { struct parameterdescriptor *param=task->descriptorarray[j]; struct parameterwrapper * parameter=RUNMALLOC(sizeof(struct parameterwrapper)); @@ -1404,17 +1540,22 @@ void processtasks() { parameter->numbertags=param->numbertags; parameter->tagarray=param->tagarray; parameter->task=task; + parameter->slot=j; /* Link new queue in */ while((*ptr)!=NULL) ptr=&((*ptr)->next); (*ptr)=parameter; } +#endif /* Build iterators for parameters */ for(j=0;jnumParameters;j++) { struct parameterdescriptor *param=task->descriptorarray[j]; - struct parameterwrapper *parameter=param->queue; - parameter->slot=j; + struct parameterwrapper *parameter=param->queue; +#ifdef MULTICORE + parameter->objectset=allocateObjectHash(10); + parameter->task=task; +#endif builditerators(task, j, parameter); } } diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 6fc2d977..62799be4 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -14,6 +14,8 @@ echo "-excprefetch methoddescriptor - exclude prefetches for this method (specif echo -taskstate do task state analysis echo -tagstate do tag state analysis echo -scheduling do task scheduling +echo -multicore generate multi-core version binary +echo "-raw generate raw version binary (should be used with -multicore)" echo -optional enable optional echo -debug generate debug symbols echo -prefetch do prefetch analysis @@ -31,13 +33,16 @@ echo "-enable-assertions execute assert statements during compilation" echo -help help } -ROBUSTROOT=~/research/Robust/src +#ROBUSTROOT=~/research/Robust/src +ROBUSTROOT=~/workspace/Robust/src DSMRUNTIME=$ROBUSTROOT/Runtime/DSTM/interface/ REPAIRROOT=~/research/Repair/RepairCompiler/ CURDIR=`pwd` DSMFLAG=false CHECKFLAG=false RECOVERFLAG=false +MULTICOREFLAG=false +RAWFLAG=false USEDMALLOC=false THREADFLAG=false SPECDIR=`pwd` @@ -105,6 +110,14 @@ JAVAOPTS="$JAVAOPTS -tagstate" elif [[ $1 = '-scheduling' ]] then JAVAOPTS="$JAVAOPTS -scheduling" +elif [[ $1 = '-multicore' ]] +then +MULTICOREFLAG=true +JAVAOPTS="$JAVAOPTS -multicore" +elif [[ $1 = '-raw' ]] +then +RAWFLAG=true +#JAVAOPTS="$JAVAOPTS -raw" elif [[ $1 = '-optional' ]] then JAVAOPTS="$JAVAOPTS -optional" @@ -244,6 +257,14 @@ fi if $RECOVERFLAG then EXTRAOPTIONS="$EXTRAOPTIONS -DTASK" +if $MULTICOREFLAG +then +EXTRAOPTIONS="$EXTRAOPTIONS -DMULTICORE" +fi +if $RAWFLAG +then +EXTRAOPTIONS="$EXTRAOPTIONS -DRAW" +fi FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c" fi