public class BuildOoOJavaCode extends BuildCode {
- OoOJavaAnalysis oooa;
+ protected OoOJavaAnalysis oooa;
- String maxTaskRecSizeStr="__maxTaskRecSize___";
+ protected String maxTaskRecSizeStr="__maxTaskRecSize___";
- String mlperrstr =
+ protected String mlperrstr =
"if(status != 0) { "+
"sprintf(errmsg, \"MLP error at %s:%d\", __FILE__, __LINE__); "+
"perror(errmsg); exit(-1); }";
- RuntimeConflictResolver rcr = null;
+ protected RuntimeConflictResolver rcr = null;
- public BuildOoOJavaCode( State st,
- Hashtable temptovar,
- TypeUtil typeutil,
- SafetyAnalysis sa,
- OoOJavaAnalysis oooa
- ) {
- super( st, temptovar, typeutil, sa);
+
+ public BuildOoOJavaCode(State st,
+ Hashtable temptovar,
+ TypeUtil typeutil,
+ SafetyAnalysis sa,
+ OoOJavaAnalysis oooa, CallGraph callgraph
+ ) {
+ super( st, temptovar, typeutil, sa, callgraph);
this.oooa = oooa;
}
- protected void additionalIncludesMethodsHeader( PrintWriter outmethodheader ) {
+ protected void additionalIncludesMethodsHeader(PrintWriter outmethodheader) {
outmethodheader.println("#include <stdlib.h>");
outmethodheader.println("#include <stdio.h>");
// have to initialize some SESE compiler data before
// analyzing normal methods, which must happen before
// generating SESE internal code
-
+
Iterator<FlatSESEEnterNode> seseit = oooa.getAllSESEs().iterator();
-
+
+ while( seseit.hasNext() ) {
+ FlatSESEEnterNode fsen = seseit.next();
+ initializeSESE(fsen);
+ }
+
//TODO signal the object that will report errors
if( state.RCR ) {
try {
- rcr = new RuntimeConflictResolver( PREFIX,
- oooa,
- oooa.getDisjointAnalysis().getEffectsAnalysis().getAllEffects(),
- state );
+ rcr = new RuntimeConflictResolver(PREFIX,
+ oooa,
+ state);
System.out.println("Runtime Conflict Resolver started.");
} catch (FileNotFoundException e) {
System.out.println("Runtime Conflict Resolver could not create output file.");
}
}
-
- while( seseit.hasNext() ) {
- FlatSESEEnterNode fsen = seseit.next();
- initializeSESE( fsen );
- }
}
- protected void initializeSESE( FlatSESEEnterNode fsen ) {
+ protected void initializeSESE(FlatSESEEnterNode fsen) {
- FlatMethod fm = fsen.getfmEnclosing();
+ FlatMethod fm = fsen.getfmEnclosing();
MethodDescriptor md = fm.getMethod();
- ClassDescriptor cn = md.getClassDesc();
-
+ ClassDescriptor cn = md.getClassDesc();
+
// Creates bogus method descriptor to index into tables
Modifiers modBogus = new Modifiers();
- MethodDescriptor mdBogus =
- new MethodDescriptor( modBogus,
- new TypeDescriptor( TypeDescriptor.VOID ),
- "sese_"+fsen.getPrettyIdentifier()+fsen.getIdentifier()
- );
-
- mdBogus.setClassDesc( fsen.getcdEnclosing() );
- FlatMethod fmBogus = new FlatMethod( mdBogus, null );
- fsen.setfmBogus( fmBogus );
- fsen.setmdBogus( mdBogus );
+ MethodDescriptor mdBogus =
+ new MethodDescriptor(modBogus,
+ new TypeDescriptor(TypeDescriptor.VOID),
+ "sese_"+fsen.getPrettyIdentifier()+fsen.getIdentifier()
+ );
+
+ mdBogus.setClassDesc(fsen.getcdEnclosing() );
+ FlatMethod fmBogus = new FlatMethod(mdBogus, null);
+ fsen.setfmBogus(fmBogus);
+ fsen.setmdBogus(mdBogus);
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
- inSetAndOutSet.addAll( fsen.getInVarSet() );
- inSetAndOutSet.addAll( fsen.getOutVarSet() );
+ inSetAndOutSet.addAll(fsen.getInVarSet() );
+ inSetAndOutSet.addAll(fsen.getOutVarSet() );
// Build paramsobj for bogus method descriptor
- ParamsObject objectparams = new ParamsObject( mdBogus, tag++ );
- paramstable.put( mdBogus, objectparams );
-
+ ParamsObject objectparams = new ParamsObject(mdBogus, tag++);
+ paramstable.put(mdBogus, objectparams);
+
Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
while( itr.hasNext() ) {
TempDescriptor temp = itr.next();
TypeDescriptor type = temp.getType();
if( type.isPtr() ) {
- objectparams.addPtr( temp );
+ objectparams.addPtr(temp);
} else {
- objectparams.addPrim( temp );
+ objectparams.addPrim(temp);
}
}
-
+
// Build normal temp object for bogus method descriptor
- TempObject objecttemps = new TempObject( objectparams, mdBogus, tag++ );
- tempstable.put( mdBogus, objecttemps );
+ TempObject objecttemps = new TempObject(objectparams, mdBogus, tag++);
+ tempstable.put(mdBogus, objecttemps);
for( Iterator nodeit = fsen.getNodeSet().iterator(); nodeit.hasNext(); ) {
- FlatNode fn = (FlatNode)nodeit.next();
+ FlatNode fn = (FlatNode)nodeit.next();
TempDescriptor[] writes = fn.writesTemps();
for( int i = 0; i < writes.length; i++ ) {
- TempDescriptor temp = writes[i];
- TypeDescriptor type = temp.getType();
-
- if( type.isPtr() ) {
- objecttemps.addPtr( temp );
- } else {
- objecttemps.addPrim( temp );
- }
+ TempDescriptor temp = writes[i];
+ TypeDescriptor type = temp.getType();
+
+ if( type.isPtr() ) {
+ objecttemps.addPtr(temp);
+ } else {
+ objecttemps.addPrim(temp);
+ }
}
}
}
}
}
-
- protected void additionalCodeGen( PrintWriter outmethodheader,
- PrintWriter outstructs,
- PrintWriter outmethod ) {
+
+ protected void additionalCodeGen(PrintWriter outmethodheader,
+ PrintWriter outstructs,
+ PrintWriter outmethod) {
// Output function prototypes and structures for SESE's and code
// spit out a global to inform all worker threads with
// the maximum size is for any task record
- outmethod.println( "int "+maxTaskRecSizeStr+" = 0;" );
+ outmethod.println("int "+maxTaskRecSizeStr+" = 0;");
- // first generate code for each sese's internals
+ // first generate code for each sese's internals
Iterator<FlatSESEEnterNode> seseit;
seseit = oooa.getAllSESEs().iterator();
-
+
while( seseit.hasNext() ) {
FlatSESEEnterNode fsen = seseit.next();
- generateMethodSESE( fsen, outstructs, outmethodheader, outmethod );
+ generateMethodSESE(fsen, outstructs, outmethodheader, outmethod);
}
// then write the invokeSESE switch to decouple scheduler
// from having to do unique details of sese invocation
- generateSESEinvocationMethod( outmethodheader, outmethod );
+ generateSESEinvocationMethod(outmethodheader, outmethod);
}
- protected void additionalCodeAtTopOfMain( PrintWriter outmethod ) {
-
+ protected void additionalCodeAtTopOfMain(PrintWriter outmethod) {
+
// do a calculation to determine which task record
// is the largest, store that as a global value for
// allocating records
" ) > "+maxTaskRecSizeStr+
" ) { "+maxTaskRecSizeStr+
" = sizeof( "+fsen.getSESErecordName()+
- " ); }" );
+ " ); }");
}
-
+
outmethod.println(" runningSESE = NULL;");
outmethod.println(" workScheduleInit( "+state.OOO_NUMCORES+", invokeSESEmethod );");
-
+
//initializes data structures needed for the RCR traverser
if( state.RCR && rcr != null ) {
outmethod.println(" initializeStructsRCR();");
}
- protected void additionalCodeAtBottomOfMain( PrintWriter outmethod ) {
+ protected void additionalCodeAtBottomOfMain(PrintWriter outmethod) {
outmethod.println(" workScheduleBegin();");
}
- protected void additionalIncludesMethodsImplementation( PrintWriter outmethod ) {
+ protected void additionalIncludesMethodsImplementation(PrintWriter outmethod) {
outmethod.println("#include <stdlib.h>");
outmethod.println("#include <stdio.h>");
outmethod.println("#include \"mlp_runtime.h\"");
outmethod.println("#include \"psemaphore.h\"");
-
+
if( state.RCR ) {
outmethod.println("#include \"trqueue.h\"");
outmethod.println("#include \"RuntimeConflictResolver.h\"");
}
- protected void additionalIncludesStructsHeader( PrintWriter outstructs ) {
+ protected void additionalIncludesStructsHeader(PrintWriter outstructs) {
outstructs.println("#include \"mlp_runtime.h\"");
outstructs.println("#include \"psemaphore.h\"");
if( state.RCR ) {
}
- protected void additionalClassObjectFields( PrintWriter outclassdefs ) {
+ protected void additionalClassObjectFields(PrintWriter outclassdefs) {
outclassdefs.println(" int oid;");
- outclassdefs.println(" int allocsite;");
}
- protected void additionalCodeAtTopMethodsImplementation( PrintWriter outmethod ) {
+ protected void additionalCodeAtTopMethodsImplementation(PrintWriter outmethod) {
outmethod.print("extern __thread int oid;\n");
outmethod.print("extern int oidIncrement;\n");
}
- protected void additionalCodeAtTopFlatMethodBody( PrintWriter output, FlatMethod fm ) {
+ protected void additionalCodeAtTopFlatMethodBody(PrintWriter output, FlatMethod fm) {
// declare variables for naming static and dynamic SESE's
- ContextTaskNames context = oooa.getContextTaskNames( fm );
+ ContextTaskNames context = oooa.getContextTaskNames(fm);
output.println(" /* static SESE names */");
Iterator<SESEandAgePair> pItr = context.getNeededStaticNames().iterator();
SESEandAgePair pair = pItr.next();
output.println(" void* "+pair+" = NULL;");
}
-
+
output.println(" /* dynamic variable sources */");
Iterator<TempDescriptor> dynSrcItr = context.getDynamicVarSet().iterator();
while( dynSrcItr.hasNext() ) {
TempDescriptor dynSrcVar = dynSrcItr.next();
output.println(" SESEcommon* "+dynSrcVar+"_srcSESE = NULL;");
output.println(" INTPTR "+dynSrcVar+"_srcOffset = 0x1;");
- }
-
-
- // eom - set up related allocation sites's waiting queues
- // TODO: we have to do a table-based thing here...
- // jjenista, I THINK WE LOSE THIS ALTOGETHER!
- /*
- FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 );
- if(callerSESEplaceholder!= oooa.getMainSESE()){
- Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(callerSESEplaceholder);
- if (graph != null && graph.hasConflictEdge()) {
- output.println(" // set up waiting queues ");
- output.println(" int numMemoryQueue=0;");
- output.println(" int memoryQueueItemID=0;");
- Set<Analysis.OoOJava.SESELock> lockSet = oooa.getLockMappings(graph);
- System.out.println("#lockSet="+lockSet.hashCode());
- System.out.println("lockset="+lockSet);
- for (Iterator iterator = lockSet.iterator(); iterator.hasNext();) {
- Analysis.OoOJava.SESELock seseLock = (Analysis.OoOJava.SESELock) iterator.next();
- System.out.println("id="+seseLock.getID());
- System.out.println("#="+seseLock);
- }
- System.out.println("size="+lockSet.size());
- if (lockSet.size() > 0) {
- output.println(" numMemoryQueue=" + lockSet.size() + ";");
- output.println(" runningSESE->numMemoryQueue=numMemoryQueue;");
- output.println(" runningSESE->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);");
- output.println();
- }
- }
}
- */
}
protected void generateMethodSESE(FlatSESEEnterNode fsen,
- PrintWriter outputStructs,
- PrintWriter outputMethHead,
- PrintWriter outputMethods) {
+ PrintWriter outputStructs,
+ PrintWriter outputMethHead,
+ PrintWriter outputMethods) {
+
+ ParamsObject objectparams = (ParamsObject) paramstable.get(fsen.getmdBogus() );
+ TempObject objecttemps = (TempObject) tempstable.get(fsen.getmdBogus() );
- ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() );
- TempObject objecttemps = (TempObject) tempstable .get( fsen.getmdBogus() );
-
// generate locals structure
outputStructs.println("struct "+
- fsen.getcdEnclosing().getSafeSymbol()+
- fsen.getmdBogus().getSafeSymbol()+"_"+
- fsen.getmdBogus().getSafeMethodDescriptor()+
- "_locals {");
-
+ fsen.getcdEnclosing().getSafeSymbol()+
+ fsen.getmdBogus().getSafeSymbol()+"_"+
+ fsen.getmdBogus().getSafeMethodDescriptor()+
+ "_locals {");
+
outputStructs.println(" int size;");
outputStructs.println(" void * next;");
outputStructs.println(" void * "+temp.getSafeSymbol()+";");
else
outputStructs.println(" struct "+
- temp.getType().getSafeSymbol()+" * "+
- temp.getSafeSymbol()+";");
+ temp.getType().getSafeSymbol()+" * "+
+ temp.getSafeSymbol()+";");
}
outputStructs.println("};\n");
-
+
// divide in-set and out-set into objects and primitives to prep
// for the record generation just below
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
- inSetAndOutSet.addAll( fsen.getInVarSet() );
- inSetAndOutSet.addAll( fsen.getOutVarSet() );
+ inSetAndOutSet.addAll(fsen.getInVarSet() );
+ inSetAndOutSet.addAll(fsen.getOutVarSet() );
Set<TempDescriptor> inSetAndOutSetObjs = new HashSet<TempDescriptor>();
Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
TempDescriptor temp = itr.next();
TypeDescriptor type = temp.getType();
if( type.isPtr() ) {
- inSetAndOutSetObjs.add( temp );
+ inSetAndOutSetObjs.add(temp);
} else {
- inSetAndOutSetPrims.add( temp );
+ inSetAndOutSetPrims.add(temp);
}
}
// generate the SESE record structure
outputStructs.println(fsen.getSESErecordName()+" {");
-
+
// data common to any SESE, and it must be placed first so
// a module that doesn't know what kind of SESE record this
// is can cast the pointer to a common struct
// implementation unless there is actually a problem...
Vector<TempDescriptor> inset=fsen.getInVarsForDynamicCoarseConflictResolution();
- for(int i=0; i<inset.size();i++) {
+ for(int i=0; i<inset.size(); i++) {
TempDescriptor temp=inset.get(i);
if (temp.getType().isNull())
- outputStructs.println(" void * "+temp.getSafeSymbol()+
- "; /* in-or-out-set obj in gl */");
+ outputStructs.println(" void * "+temp.getSafeSymbol()+
+ "; /* in-or-out-set obj in gl */");
else
- outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+
- temp.getSafeSymbol()+"; /* in-or-out-set obj in gl */");
+ outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+
+ temp.getSafeSymbol()+"; /* in-or-out-set obj in gl */");
}
for(int i=0; i<objectparams.numPointers(); i++) {
TempDescriptor temp=objectparams.getPointer(i);
if (!inset.contains(temp)) {
- if (temp.getType().isNull())
- outputStructs.println(" void * "+temp.getSafeSymbol()+
- "; /* in-or-out-set obj in gl */");
- else
- outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+
- temp.getSafeSymbol()+"; /* in-or-out-set obj in gl */");
+ if (temp.getType().isNull())
+ outputStructs.println(" void * "+temp.getSafeSymbol()+
+ "; /* in-or-out-set obj in gl */");
+ else
+ outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+
+ temp.getSafeSymbol()+"; /* in-or-out-set obj in gl */");
}
}
-
+
outputStructs.println(" /* next is primitives for in-set and out-set and dynamic tracking */");
Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
while( itrPrims.hasNext() ) {
TempDescriptor temp = itrPrims.next();
TypeDescriptor type = temp.getType();
- if(type.isPrimitive()){
- outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+
- temp.getSafeSymbol()+"; /* in-set or out-set primitive */");
- }
+ if(type.isPrimitive()) {
+ outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+
+ temp.getSafeSymbol()+"; /* in-set or out-set primitive */");
+ }
}
-
+
// note that the sese record pointer will be added below, just primitive part of tracking here
Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
while( itrDynInVars.hasNext() ) {
TempDescriptor dynInVar = itrDynInVars.next();
outputStructs.println(" INTPTR "+dynInVar+"_srcOffset; /* dynamic tracking primitive */");
- }
-
-
- outputStructs.println(" /* everything after this should be pointers to an SESE record */" );
+ }
+
+
+ outputStructs.println(" /* everything after this should be pointers to an SESE record */");
// other half of info for dynamic tracking, the SESE record pointer
itrDynInVars = fsen.getDynamicInVarSet().iterator();
TempDescriptor dynInVar = itrDynInVars.next();
String depRecField = dynInVar+"_srcSESE";
outputStructs.println(" SESEcommon* "+depRecField+";");
- addingDepRecField( fsen, depRecField );
- }
-
+ addingDepRecField(fsen, depRecField);
+ }
+
// statically known sese sources are record pointers, too
Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
while( itrStaticInVarSrcs.hasNext() ) {
}
if (state.RCR) {
- if (inset.size()!=0)
- outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];");
+ if (inset.size()!=0) {
+ outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];");
+ }
}
-
+
if( fsen.getFirstDepRecField() != null ) {
outputStructs.println(" /* compiler believes first dependent SESE record field above is: "+
- fsen.getFirstDepRecField()+" */" );
+ fsen.getFirstDepRecField()+" */");
}
outputStructs.println("};\n");
-
+
// write method declaration to header file
outputMethHead.print("void ");
outputMethHead.print(fsen.getSESEmethodName()+"(");
outputMethHead.println(");\n");
- generateFlatMethodSESE( fsen.getfmBogus(),
- fsen.getcdEnclosing(),
- fsen,
- fsen.getFlatExit(),
- outputMethods );
+ generateFlatMethodSESE(fsen.getfmBogus(),
+ fsen.getcdEnclosing(),
+ fsen,
+ fsen.getFlatExit(),
+ outputMethods);
}
// used when generating the specific SESE record struct
- // to remember the FIRST field name of sese records
+ // to remember the FIRST field name of sese records
// that the current SESE depends on--we need to know the
// offset to the first one for garbage collection
- protected void addingDepRecField( FlatSESEEnterNode fsen,
- String field ) {
+ protected void addingDepRecField(FlatSESEEnterNode fsen,
+ String field) {
if( fsen.getFirstDepRecField() == null ) {
- fsen.setFirstDepRecField( field );
+ fsen.setFirstDepRecField(field);
}
fsen.incNumDepRecs();
}
- private void generateFlatMethodSESE(FlatMethod fm,
- ClassDescriptor cn,
- FlatSESEEnterNode fsen,
- FlatSESEExitNode seseExit,
- PrintWriter output
+ private void generateFlatMethodSESE(FlatMethod fm,
+ ClassDescriptor cn,
+ FlatSESEEnterNode fsen,
+ FlatSESEExitNode seseExit,
+ PrintWriter output
) {
MethodDescriptor md = fm.getMethod();
output.print(objecttemp.numPointers()+",");
output.print("&(((SESEcommon*)(___params___))[1])");
for(int j=0; j<objecttemp.numPointers(); j++)
- output.print(", NULL");
+ output.print(", NULL");
output.println("};");
}
TempDescriptor td=objecttemp.getPrimitive(i);
TypeDescriptor type=td.getType();
if (type.isNull())
- output.println(" void * "+td.getSafeSymbol()+";");
+ output.println(" void * "+td.getSafeSymbol()+";");
else if (type.isClass()||type.isArray())
- output.println(" struct "+type.getSafeSymbol()+" * "+td.getSafeSymbol()+";");
+ output.println(" struct "+type.getSafeSymbol()+" * "+td.getSafeSymbol()+";");
else
- output.println(" "+type.getSafeSymbol()+" "+td.getSafeSymbol()+";");
+ output.println(" "+type.getSafeSymbol()+" "+td.getSafeSymbol()+";");
}
// declare variables for naming static and dynamic SESE's
- ContextTaskNames context = oooa.getContextTaskNames( fsen );
+ ContextTaskNames context = oooa.getContextTaskNames(fsen);
output.println(" /* static SESE names */");
Iterator<SESEandAgePair> pItr = context.getNeededStaticNames().iterator();
SESEandAgePair pair = pItr.next();
output.println(" SESEcommon* "+pair+" = NULL;");
}
-
+
// declare variables for tracking dynamic sources
output.println(" /* dynamic variable sources */");
Iterator<TempDescriptor> dynSrcItr = context.getDynamicVarSet().iterator();
TempDescriptor dynSrcVar = dynSrcItr.next();
output.println(" SESEcommon* "+dynSrcVar+"_srcSESE = NULL;");
output.println(" INTPTR "+dynSrcVar+"_srcOffset = 0x1;");
- }
+ }
// declare local temps for in-set primitives, and if it is
TempDescriptor temp = itrInSet.next();
TypeDescriptor type = temp.getType();
if( !type.isPtr() ) {
- if( fsen.getReadyInVarSet().contains( temp ) ) {
- output.println(" "+type+" "+temp+" = "+paramsprefix+"->"+temp+";");
- } else {
- output.println(" "+type+" "+temp+";");
- }
+ if( fsen.getReadyInVarSet().contains(temp) ) {
+ output.println(" "+type+" "+temp+" = "+paramsprefix+"->"+temp+";");
+ } else {
+ output.println(" "+type+" "+temp+";");
+ }
}
- }
+ }
// declare local temps for out-set primitives if its not already
// in the in-set, and it's value will get written so no problem
while( itrOutSet.hasNext() ) {
TempDescriptor temp = itrOutSet.next();
TypeDescriptor type = temp.getType();
- if( !type.isPtr() && !fsen.getInVarSet().contains( temp ) ) {
- output.println(" "+type+" "+temp+";");
+ if( !type.isPtr() && !fsen.getInVarSet().contains(temp) ) {
+ output.println(" "+type+" "+temp+";");
}
}
output.println(" runningSESE = &(___params___->common);");
output.println(" childSESE = 0;");
output.println(" ");
-
+
// eom - setup memory queue
output.println(" // set up memory queues ");
output.println(" int numMemoryQueue=0;");
output.println(" int memoryQueueItemID=0;");
- Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph( fsen );
+ Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(fsen);
if( graph != null && graph.hasConflictEdge() ) {
output.println(" {");
- Set<Analysis.OoOJava.SESELock> lockSet = oooa.getLockMappings( graph );
+ Set<Analysis.OoOJava.SESELock> lockSet = oooa.getLockMappings(graph);
System.out.println("#lockSet="+lockSet);
if( lockSet.size() > 0 ) {
output.println(" numMemoryQueue=" + lockSet.size() + ";");
// set up a task's mem pool to recycle the allocation of children tasks
// don't bother if the task never has children (a leaf task)
- output.println( "#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
+ output.println("/////////////////////////////////////////////");
+ output.println("//");
+ output.println("// TODO: use poolcreate to make one record pool");
+ output.println("// per WORKER THREAD and never destroy it...");
+ output.println("//");
+ output.println("/////////////////////////////////////////////");
if( !fsen.getIsLeafSESE() ) {
output.println(" runningSESE->taskRecordMemPool = poolcreate( "+
maxTaskRecSizeStr+", freshTaskRecordInitializer );");
// make it clear we purposefully did not initialize this
output.println(" runningSESE->taskRecordMemPool = (MemPool*)0x7;");
}
- output.println( "#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
- // copy in-set into place, ready vars were already
+ // copy in-set into place, ready vars were already
// copied when the SESE was issued
Iterator<TempDescriptor> tempItr;
tempItr = fsen.getStaticInVarSet().iterator();
while( tempItr.hasNext() ) {
TempDescriptor temp = tempItr.next();
- VariableSourceToken vst = fsen.getStaticInVarSrc( temp );
- SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
- output.println(" "+generateTemp( fsen.getfmBogus(), temp)+
- " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+ VariableSourceToken vst = fsen.getStaticInVarSrc(temp);
+ SESEandAgePair srcPair = new SESEandAgePair(vst.getSESE(), vst.getAge() );
+ output.println(" "+generateTemp(fsen.getfmBogus(), temp)+
+ " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
}
-
+
output.println(" // decrement references to static sources");
for( Iterator<SESEandAgePair> pairItr = fsen.getStaticInVarSrcs().iterator(); pairItr.hasNext(); ) {
SESEandAgePair srcPair = pairItr.next();
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" {");
output.println(" SESEcommon* src = &("+paramsprefix+"->"+srcPair+"->common);");
output.println(" RELEASE_REFERENCE_TO( src );");
output.println(" }");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
}
while( tempItr.hasNext() ) {
TempDescriptor temp = tempItr.next();
TypeDescriptor type = temp.getType();
-
+
// go grab it from the SESE source
output.println(" if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
String typeStr;
if( type.isNull() ) {
- typeStr = "void*";
+ typeStr = "void*";
} else if( type.isClass() || type.isArray() ) {
- typeStr = "struct "+type.getSafeSymbol()+"*";
+ typeStr = "struct "+type.getSafeSymbol()+"*";
} else {
- typeStr = type.getSafeSymbol();
+ typeStr = type.getSafeSymbol();
}
-
- output.println(" "+generateTemp( fsen.getfmBogus(), temp)+
- " = *(("+typeStr+"*) ((void*)"+
- paramsprefix+"->"+temp+"_srcSESE + "+
- paramsprefix+"->"+temp+"_srcOffset));");
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println(" "+generateTemp(fsen.getfmBogus(), temp)+
+ " = *(("+typeStr+"*) ((void*)"+
+ paramsprefix+"->"+temp+"_srcSESE + "+
+ paramsprefix+"->"+temp+"_srcOffset));");
+
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" SESEcommon* src = "+paramsprefix+"->"+temp+"_srcSESE;");
output.println(" RELEASE_REFERENCE_TO( src );");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
// or if the source was our parent, its already in our record to grab
output.println(" } else {");
- output.println(" "+generateTemp( fsen.getfmBogus(), temp)+
- " = "+paramsprefix+"->"+temp+";");
+ output.println(" "+generateTemp(fsen.getfmBogus(), temp)+
+ " = "+paramsprefix+"->"+temp+";");
output.println(" }");
}
// Check to see if we need to do a GC if this is a
- // multi-threaded program...
+ // multi-threaded program...
if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
- output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
//Don't bother if we aren't in recursive methods...The loops case will catch it
// if (callgraph.getAllMethods(md).contains(md)) {
// if(this.state.MULTICOREGC) {
// output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
// }
// }
- }
+ }
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_TASKEXECUTE");
}
HashSet<FlatNode> exitset=new HashSet<FlatNode>();
- exitset.add(seseExit);
+ exitset.add(seseExit);
generateCode(fsen.getNext(0), fm, exitset, output);
- output.println("}\n\n");
+ output.println("}\n\n");
}
) {
outmethodheader.println("void* invokeSESEmethod( void* seseRecord );");
- outmethod.println( "void* invokeSESEmethod( void* seseRecord ) {");
- outmethod.println( " int status;");
- outmethod.println( " char errmsg[128];");
+ outmethod.println("void* invokeSESEmethod( void* seseRecord ) {");
+ outmethod.println(" int status;");
+ outmethod.println(" char errmsg[128];");
// generate a case for each SESE class that can be invoked
- outmethod.println( " switch( ((SESEcommon*)seseRecord)->classID ) {");
- outmethod.println( " ");
+ outmethod.println(" switch( ((SESEcommon*)seseRecord)->classID ) {");
+ outmethod.println(" ");
Iterator<FlatSESEEnterNode> seseit;
seseit = oooa.getAllSESEs().iterator();
while( seseit.hasNext() ) {
FlatSESEEnterNode fsen = seseit.next();
- outmethod.println( " /* "+fsen.getPrettyIdentifier()+" */");
- outmethod.println( " case "+fsen.getIdentifier()+":");
- outmethod.println( " "+fsen.getSESEmethodName()+"( seseRecord );");
-
+ outmethod.println(" /* "+fsen.getPrettyIdentifier()+" */");
+ outmethod.println(" case "+fsen.getIdentifier()+":");
+ outmethod.println(" "+fsen.getSESEmethodName()+"( seseRecord );");
+
if( fsen.getIsMainSESE() ) {
- outmethod.println( " workScheduleExit();");
+ outmethod.println(" workScheduleExit();");
}
- outmethod.println( " break;");
- outmethod.println( "");
+ outmethod.println(" break;");
+ outmethod.println("");
}
// default case should never be taken, error out
- outmethod.println( " default:");
- outmethod.println( " printf(\"Error: unknown SESE class ID in invoke method.\\n\");");
- outmethod.println( " exit(-30);");
- outmethod.println( " break;");
- outmethod.println( " }");
- outmethod.println( " return NULL;");
- outmethod.println( "}\n\n");
+ outmethod.println(" default:");
+ outmethod.println(" printf(\"Error: unknown SESE class ID in invoke method.\\n\");");
+ outmethod.println(" exit(-30);");
+ outmethod.println(" break;");
+ outmethod.println(" }");
+ outmethod.println(" return NULL;");
+ outmethod.println("}\n\n");
}
- protected void stallMEMRCR( FlatMethod fm,
- FlatNode fn,
- Set<WaitingElement> waitingElementSet, PrintWriter output) {
+ protected void stallMEMRCR(FlatMethod fm,
+ FlatNode fn,
+ Set<WaitingElement> waitingElementSet, PrintWriter output) {
output.println("// stall on parent's stall sites ");
output.println(" {");
output.println(" REntry* rentry;");
output.println(" // stallrecord sometimes is used as a task record for instance ");
output.println(" // when you call RELEASE_REFERENCE_TO on a stall record.");
output.println(" // so the parent field must be initialized.");
- output.println(" SESEstall * stallrecord=(SESEstall *) poolalloc(runningSESE->taskRecordMemPool);");
+ output.println(" SESEstall * stallrecord=(SESEstall *) poolalloc(runningSESE->taskRecordMemPool);");
output.println(" stallrecord->common.parent=runningSESE;");
output.println(" stallrecord->common.unresolvedDependencies=10000;");
output.println(" stallrecord->common.rcrstatus=1;");
output.println(" stallrecord->common.offsetToParamRecords=(INTPTR) & (((SESEstall *)0)->rcrRecords);");
- output.println(" stallrecord->common.refCount = 10003;");
+ output.println(" stallrecord->common.refCount = 3;");
output.println(" int localCount=10000;");
output.println(" stallrecord->rcrRecords[0].index=0;");
output.println(" stallrecord->rcrRecords[0].flag=0;");
output.println(" stallrecord->tag=runningSESEstallSem.tag;");
TempDescriptor stalltd=null;
- for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext(); ) {
WaitingElement waitingElement =(WaitingElement) iterator.next();
if (waitingElement.getStatus() >= ConflictNode.COARSE) {
- output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["
- + waitingElement.getQueueID() + "]," + waitingElement.getStatus()
- + ", (SESEcommon *) stallrecord, 1LL);");
+ output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["
+ + waitingElement.getQueueID() + "]," + waitingElement.getStatus()
+ + ", (SESEcommon *) stallrecord, 1LL);");
} else {
- throw new Error("Fine-grained conflict: This should not happen in RCR");
+ throw new Error("Fine-grained conflict: This should not happen in RCR");
}
output.println(" rentry->queue=runningSESE->memoryQueueArray["
- + waitingElement.getQueueID() + "];");
+ + waitingElement.getQueueID() + "];");
output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["
- + waitingElement.getQueueID() + "],rentry)==NOTREADY) {");
+ + waitingElement.getQueueID() + "],rentry)==NOTREADY) {");
output.println(" localCount--;");
output.println(" }");
output.println("#if defined(RCR)&&!defined(OOO_DISABLE_TASKMEMPOOL)");
"]->rentrypool, rentry);");
output.println("#endif");
if (stalltd==null) {
- stalltd=waitingElement.getTempDesc();
+ stalltd=waitingElement.getTempDesc();
} else if (stalltd!=waitingElement.getTempDesc()) {
- throw new Error("Multiple temp descriptors at stall site"+stalltd+"!="+waitingElement.getTempDesc());
+ throw new Error("Multiple temp descriptors at stall site"+stalltd+"!="+waitingElement.getTempDesc());
}
}
output.println(" if(!atomic_sub_and_test(localCount, &(stallrecord->common.unresolvedDependencies))) {");
//have to do fine-grained work also
output.println(" stallrecord->___obj___=(struct ___Object___ *)"
- + generateTemp(fm, stalltd) + ";");
+ + generateTemp(fm, stalltd) + ";");
output.println(" stallrecord->common.classID=-"
- + rcr.getTraverserID(stalltd, fn) + ";");
-
+ + rcr.getTraverserID(stalltd, fn) + ";");
+
output.println(" enqueueTR(TRqueue, (void *)stallrecord);");
if (state.COREPROF) {
output.println("#ifdef CP_EVENTID_TASKSTALLMEM");
output
- .println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
+ .println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
output.println("#endif");
- }
-
+ }
+
output.println(" psem_take( &runningSESEstallSem, (struct garbagelist *)&___locals___ );");
-
+
if (state.COREPROF) {
output.println("#ifdef CP_EVENTID_TASKSTALLMEM");
output
- .println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );");
+ .println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );");
output.println("#endif");
}
- output.println(" } else {");//exit if condition
+ output.println(" } else {"); //exit if condition
//release traversers reference if we didn't use traverser
output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
- output.println(" RELEASE_REFERENCE_TO((SESEcommon *)stallrecord);");
+ output.println(" RELEASE_REFERENCES_TO((SESEcommon *)stallrecord, 2);");
output.println("#endif");
output.println(" }");
//release our reference to stall record
output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" RELEASE_REFERENCE_TO((SESEcommon *)stallrecord);");
output.println("#endif");
- output.println(" }");//exit block
+ output.println(" }"); //exit block
}
- protected void additionalCodePreNode( FlatMethod fm,
- FlatNode fn,
- PrintWriter output ) {
+ protected void additionalCodePreNode(FlatMethod fm,
+ FlatNode fn,
+ PrintWriter output) {
// insert pre-node actions from the code plan
-
+
CodePlan cp = oooa.getCodePlan(fn);
if( cp != null ) {
FlatMethod fmContext;
if( currentSESE.getIsCallerProxySESE() ) {
- fmContext = oooa.getContainingFlatMethod( fn );
+ fmContext = oooa.getContainingFlatMethod(fn);
} else {
fmContext = currentSESE.getfmBogus();
}
ContextTaskNames contextTaskNames;
if( currentSESE.getIsCallerProxySESE() ) {
- contextTaskNames = oooa.getContextTaskNames( oooa.getContainingFlatMethod( fn ) );
+ contextTaskNames = oooa.getContextTaskNames(oooa.getContainingFlatMethod(fn) );
} else {
- contextTaskNames = oooa.getContextTaskNames( currentSESE );
+ contextTaskNames = oooa.getContextTaskNames(currentSESE);
}
// for each sese and age pair that this parent statement
while( vstItr.hasNext() ) {
VariableSourceToken vst = vstItr.next();
- SESEandAgePair pair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+ SESEandAgePair pair = new SESEandAgePair(vst.getSESE(), vst.getAge() );
output.println(" {");
output.println(" "+
output.println(" pthread_mutex_unlock( &(childCom->lock) );");
output.println(" }");
- // copy things we might have stalled for
- Iterator<TempDescriptor> tdItr = cp.getCopySet( vst ).iterator();
+ // copy things we might have stalled for
+ Iterator<TempDescriptor> tdItr = cp.getCopySet(vst).iterator();
while( tdItr.hasNext() ) {
TempDescriptor td = tdItr.next();
- output.println(" "+generateTemp( fmContext, td)+
+ output.println(" "+generateTemp(fmContext, td)+
" = child->"+vst.getAddrVar().getSafeSymbol()+";");
}
output.println(" }");
}
-
+
// for each variable with a dynamic source, stall just for that variable
Iterator<TempDescriptor> dynItr = cp.getDynamicStallSet().iterator();
while( dynItr.hasNext() ) {
output.println(" } else {");
output.println(" pthread_mutex_unlock( &(childCom->lock) );");
output.println(" }");
-
+
TypeDescriptor type = dynVar.getType();
String typeStr;
if( type.isNull() ) {
} else {
typeStr = type.getSafeSymbol();
}
-
- output.println(" "+generateTemp( fmContext, dynVar )+
+
+ output.println(" "+generateTemp(fmContext, dynVar)+
" = *(("+typeStr+"*) ((void*)"+
dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
// copy the dynamic sources
Iterator dynAssignItr = cp.getDynAssigns().entrySet().iterator();
while( dynAssignItr.hasNext() ) {
- Map.Entry me = (Map.Entry) dynAssignItr.next();
+ Map.Entry me = (Map.Entry)dynAssignItr.next();
TempDescriptor lhs = (TempDescriptor) me.getKey();
TempDescriptor rhs = (TempDescriptor) me.getValue();
output.println(" {");
output.println(" SESEcommon* oldSrc = "+lhs+"_srcSESE;");
-
+
output.println(" "+lhs+"_srcSESE = "+rhs+"_srcSESE;");
output.println(" "+lhs+"_srcOffset = "+rhs+"_srcOffset;");
// this variable pointed to, do release last in case we're just
// copying the same value in because 1->2->1 is safe but ref count
// 1->0->1 has a window where it looks like it should be free'd
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" if( "+rhs+"_srcSESE != NULL ) {");
output.println(" ADD_REFERENCE_TO( "+rhs+"_srcSESE );");
output.println(" }");
output.println(" RELEASE_REFERENCE_TO( oldSrc );");
output.println(" }");
output.println(" }");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
}
// for each lhs that is dynamic from a non-dynamic source, set the
// dynamic source vars to the current SESE
dynItr = cp.getDynAssignCurr().iterator();
while( dynItr.hasNext() ) {
- TempDescriptor dynVar = dynItr.next();
+ TempDescriptor dynVar = dynItr.next();
- assert contextTaskNames.getDynamicVarSet().contains( dynVar );
+ assert contextTaskNames.getDynamicVarSet().contains(dynVar);
// first release a reference to current record
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" if( "+dynVar+"_srcSESE != NULL ) {");
output.println(" RELEASE_REFERENCE_TO( oldSrc );");
output.println(" }");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
output.println(" "+dynVar+"_srcSESE = NULL;");
}
-
+
// handling stall site, consider that one of several tasks might be
// executing, so create a switch on task ID, because waiting elements
// generated by this stall site should be inserted into possibly a
boolean atLeastOneCase = false;
// create a case for each class of task that might be executing
- Iterator<FlatSESEEnterNode> taskItr = oooa.getPossibleExecutingRBlocks( fn ).iterator();
+ Iterator<FlatSESEEnterNode> taskItr = oooa.getPossibleExecutingRBlocks(fn).iterator();
while( taskItr.hasNext() ) {
FlatSESEEnterNode parent = taskItr.next();
- ConflictGraph graph = oooa.getConflictGraph( parent );
+ ConflictGraph graph = oooa.getConflictGraph(parent);
if( graph == null ) {
continue;
}
- Set<SESELock> seseLockSet = oooa.getLockMappings( graph );
- Set<WaitingElement> waitingElementSet = graph.getStallSiteWaitingElementSet( fn, seseLockSet );
-
+ Set<SESELock> seseLockSet = oooa.getLockMappings(graph);
+ Set<WaitingElement> waitingElementSet = graph.getStallSiteWaitingElementSet(fn, seseLockSet);
+
if( waitingElementSet.size() == 0 ) {
continue;
}
// IS EXACTLY ONE CASE, DON'T GENERATE A SWITCH AT ALL
if( atLeastOneCase == false ) {
atLeastOneCase = true;
- output.println(" // potential stall site ");
+ output.println(" // potential stall site ");
output.println(" switch( runningSESE->classID ) {");
}
} else {
output.println(" REntry* rentry;");
-
+
for( Iterator iterator = waitingElementSet.iterator(); iterator.hasNext(); ) {
WaitingElement waitingElement = (WaitingElement) iterator.next();
output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
output.println("#endif");
}
-
+
output.println(" psem_take( &runningSESEstallSem, (struct garbagelist *)&___locals___ );");
-
+
if (state.COREPROF) {
output.println("#ifdef CP_EVENTID_TASKSTALLMEM");
output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );");
}
}
}
-
- protected void additionalCodePostNode( FlatMethod fm,
- FlatNode fn,
- PrintWriter output ) {
+
+ protected void additionalCodePostNode(FlatMethod fm,
+ FlatNode fn,
+ PrintWriter output) {
// insert post-node actions from the code-plan (none right now...)
}
- public void generateFlatSESEEnterNode( FlatMethod fm,
- FlatSESEEnterNode fsen,
- PrintWriter output ) {
+ public void generateFlatSESEEnterNode(FlatMethod fm,
+ FlatSESEEnterNode fsen,
+ PrintWriter output) {
// there may be an SESE in an unreachable method, skip over
- if( !oooa.getAllSESEs().contains( fsen ) ) {
+ if( !oooa.getAllSESEs().contains(fsen) ) {
return;
}
}
// allocate the space for this record
- output.println( "#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
- output.println( "#ifdef CP_EVENTID_POOLALLOC");
- output.println( " CP_LOGEVENT( CP_EVENTID_POOLALLOC, CP_EVENTTYPE_BEGIN );");
- output.println( "#endif");
+ output.println("#ifdef CP_EVENTID_POOLALLOC");
+ output.println(" CP_LOGEVENT( CP_EVENTID_POOLALLOC, CP_EVENTTYPE_BEGIN );");
+ output.println("#endif");
if( !fsen.getIsMainSESE() ) {
output.println(" "+
fsen.getSESErecordName()+"* seseToIssue = ("+
fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
fsen.getSESErecordName()+" ) );");
}
- output.println( "#ifdef CP_EVENTID_POOLALLOC");
- output.println( " CP_LOGEVENT( CP_EVENTID_POOLALLOC, CP_EVENTTYPE_END );");
- output.println( "#endif");
+ output.println("#ifdef CP_EVENTID_POOLALLOC");
+ output.println(" CP_LOGEVENT( CP_EVENTID_POOLALLOC, CP_EVENTTYPE_END );");
+ output.println("#endif");
- output.println( "#else // OOO_DISABLE_TASKMEMPOOL" );
- output.println(" "+
- fsen.getSESErecordName()+"* seseToIssue = ("+
- fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
- fsen.getSESErecordName()+" ) );");
- output.println( "#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#else // OOO_DISABLE_TASKMEMPOOL");
+ output.println(" "+
+ fsen.getSESErecordName()+"* seseToIssue = ("+
+ fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
+ fsen.getSESErecordName()+" ) );");
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
// set up the SESE in-set and out-set objects, which look
// record to the first dependent record pointer?
output.println(" seseToIssue->common.numDependentSESErecords="+
fsen.getNumDepRecs()+";");
-
+
// we only need this (and it will only compile) when the number of dependent
// SESE records is non-zero
if( fsen.getFirstDepRecField() != null ) {
fsen.getSESErecordName()+"*)0)->"+fsen.getFirstDepRecField()+");"
);
}
-
+
if( state.RCR &&
- fsen.getInVarsForDynamicCoarseConflictResolution().size() > 0
+ fsen.getInVarsForDynamicCoarseConflictResolution().size() > 0
) {
output.println(" seseToIssue->common.offsetToParamRecords=(INTPTR) & ((("+
fsen.getSESErecordName()+"*)0)->rcrRecords);");
output.println(" seseToIssue->common.unresolvedDependencies = 10000;");
output.println(" seseToIssue->common.parentsStallSem = NULL;");
output.println(" initQueue(&seseToIssue->common.forwardList);");
- output.println(" seseToIssue->common.doneExecuting = FALSE;");
+ output.println(" seseToIssue->common.doneExecuting = FALSE;");
output.println(" seseToIssue->common.numRunningChildren = 0;");
- output.println( "#ifdef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifdef OOO_DISABLE_TASKMEMPOOL");
output.println(" pthread_cond_init( &(seseToIssue->common.runningChildrenCond), NULL );");
output.println("#endif");
output.println(" seseToIssue->common.parent = runningSESE;");
if( state.RCR ) {
// if we're using RCR, ref count is 3 because the traverser has
// a reference, too
- if( !fsen.getIsMainSESE() && fsen.getInVarsForDynamicCoarseConflictResolution().size()>0){
+ if( !fsen.getIsMainSESE() && fsen.getInVarsForDynamicCoarseConflictResolution().size()>0) {
output.println(" seseToIssue->common.refCount = 10003;");
} else {
output.println(" seseToIssue->common.refCount = 10002;");
assert !fsen.getIsCallerProxySESE();
FlatSESEEnterNode parent = fsen.getLocalParent();
if( parent != null && !parent.getIsCallerProxySESE() ) {
- output.println(" seseToIssue->"+temp+" = "+
- generateTemp( parent.getfmBogus(), temp )+";");
+ output.println(" seseToIssue->"+temp+" = "+
+ generateTemp(parent.getfmBogus(), temp)+";");
} else {
- output.println(" seseToIssue->"+temp+" = "+
- generateTemp( fsen.getfmEnclosing(), temp )+";");
+ output.println(" seseToIssue->"+temp+" = "+
+ generateTemp(fsen.getfmEnclosing(), temp)+";");
}
}
-
+
// before potentially adding this SESE to other forwarding lists,
// create it's lock
- output.println( "#ifdef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifdef OOO_DISABLE_TASKMEMPOOL");
output.println(" pthread_mutex_init( &(seseToIssue->common.lock), NULL );");
output.println("#endif");
-
+
if( !fsen.getIsMainSESE() ) {
// count up outstanding dependencies, static first, then dynamic
Iterator<SESEandAgePair> staticSrcsItr = fsen.getStaticInVarSrcs().iterator();
while( staticSrcsItr.hasNext() ) {
- SESEandAgePair srcPair = staticSrcsItr.next();
- output.println(" {");
- output.println(" SESEcommon* src = (SESEcommon*)"+srcPair+";");
- output.println(" pthread_mutex_lock( &(src->lock) );");
+ SESEandAgePair srcPair = staticSrcsItr.next();
+ output.println(" {");
+ output.println(" SESEcommon* src = (SESEcommon*)"+srcPair+";");
+ output.println(" pthread_mutex_lock( &(src->lock) );");
// FORWARD TODO - ...what? make it a chain of arrays instead of true linked-list?
- output.println(" if( !src->doneExecuting ) {");
- output.println(" addNewItem( &src->forwardList, seseToIssue );");
- output.println(" ++(localCount);");
- output.println(" }");
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println(" if( !src->doneExecuting ) {");
+ output.println(" addNewItem( &src->forwardList, seseToIssue );");
+ output.println(" ++(localCount);");
+ output.println(" }");
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" ADD_REFERENCE_TO( src );");
- output.println("#endif" );
- output.println(" pthread_mutex_unlock( &(src->lock) );");
- output.println(" }");
+ output.println("#endif");
+ output.println(" pthread_mutex_unlock( &(src->lock) );");
+ output.println(" }");
- // whether or not it is an outstanding dependency, make sure
- // to pass the static name to the child's record
- output.println(" seseToIssue->"+srcPair+" = "+
+ // whether or not it is an outstanding dependency, make sure
+ // to pass the static name to the child's record
+ output.println(" seseToIssue->"+srcPair+" = "+
"("+srcPair.getSESE().getSESErecordName()+"*)"+
srcPair+";");
}
-
+
// dynamic sources might already be accounted for in the static list,
// so only add them to forwarding lists if they're not already there
Iterator<TempDescriptor> dynVarsItr = fsen.getDynamicInVarSet().iterator();
while( dynVarsItr.hasNext() ) {
- TempDescriptor dynInVar = dynVarsItr.next();
- output.println(" {");
- output.println(" SESEcommon* src = (SESEcommon*)"+dynInVar+"_srcSESE;");
+ TempDescriptor dynInVar = dynVarsItr.next();
+ output.println(" {");
+ output.println(" SESEcommon* src = (SESEcommon*)"+dynInVar+"_srcSESE;");
- // the dynamic source is NULL if it comes from your own space--you can't pass
- // the address off to the new child, because you're not done executing and
- // might change the variable, so copy it right now
- output.println(" if( src != NULL ) {");
- output.println(" pthread_mutex_lock( &(src->lock) );");
+ // the dynamic source is NULL if it comes from your own space--you can't pass
+ // the address off to the new child, because you're not done executing and
+ // might change the variable, so copy it right now
+ output.println(" if( src != NULL ) {");
+ output.println(" pthread_mutex_lock( &(src->lock) );");
// FORWARD TODO
- output.println(" if( isEmpty( &src->forwardList ) ||");
- output.println(" seseToIssue != peekItem( &src->forwardList ) ) {");
- output.println(" if( !src->doneExecuting ) {");
- output.println(" addNewItem( &src->forwardList, seseToIssue );");
- output.println(" ++(localCount);");
- output.println(" }");
- output.println(" }");
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println(" if( isEmpty( &src->forwardList ) ||");
+ output.println(" seseToIssue != peekItem( &src->forwardList ) ) {");
+ output.println(" if( !src->doneExecuting ) {");
+ output.println(" addNewItem( &src->forwardList, seseToIssue );");
+ output.println(" ++(localCount);");
+ output.println(" }");
+ output.println(" }");
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" ADD_REFERENCE_TO( src );");
- output.println("#endif" );
- output.println(" pthread_mutex_unlock( &(src->lock) );");
- output.println(" seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
- output.println(" } else {");
+ output.println("#endif");
+ output.println(" pthread_mutex_unlock( &(src->lock) );");
+ output.println(" seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
+ output.println(" } else {");
// determine whether this new task instance is in a method context,
FlatSESEEnterNode parent = fsen.getLocalParent();
if( parent != null && !parent.getIsCallerProxySESE() ) {
output.println(" seseToIssue->"+dynInVar+" = "+
- generateTemp( parent.getfmBogus(), dynInVar )+";");
+ generateTemp(parent.getfmBogus(), dynInVar)+";");
} else {
output.println(" seseToIssue->"+dynInVar+" = "+
- generateTemp( fsen.getfmEnclosing(), dynInVar )+";");
+ generateTemp(fsen.getfmEnclosing(), dynInVar)+";");
}
-
- output.println(" }");
- output.println(" }");
-
- // even if the value is already copied, make sure your NULL source
- // gets passed so child knows it already has the dynamic value
- output.println(" seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;");
+
+ output.println(" }");
+ output.println(" }");
+
+ // even if the value is already copied, make sure your NULL source
+ // gets passed so child knows it already has the dynamic value
+ output.println(" seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;");
}
- // maintain pointers for finding dynamic SESE
+ // maintain pointers for finding dynamic SESE
// instances from static names, do a shuffle as instances age
// and also release references that have become too old
if( !fsen.getIsMainSESE() ) {
- FlatSESEEnterNode currentSESE = fsen.getLocalParent();
+ FlatSESEEnterNode currentSESE = fsen.getLocalParent();
ContextTaskNames contextTaskNames;
if( currentSESE == null ) {
- contextTaskNames = oooa.getContextTaskNames( oooa.getContainingFlatMethod( fsen ) );
+ contextTaskNames = oooa.getContextTaskNames(oooa.getContainingFlatMethod(fsen) );
} else {
- contextTaskNames = oooa.getContextTaskNames( currentSESE );
+ contextTaskNames = oooa.getContextTaskNames(currentSESE);
}
- SESEandAgePair pairNewest = new SESEandAgePair( fsen, 0 );
- SESEandAgePair pairOldest = new SESEandAgePair( fsen, fsen.getOldestAgeToTrack() );
- if( contextTaskNames.getNeededStaticNames().contains( pairNewest ) ) {
+ SESEandAgePair pairNewest = new SESEandAgePair(fsen, 0);
+ SESEandAgePair pairOldest = new SESEandAgePair(fsen, fsen.getOldestAgeToTrack() );
+ if( contextTaskNames.getNeededStaticNames().contains(pairNewest) ) {
output.println(" {");
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" SESEcommon* oldest = "+pairOldest+";");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) {
- SESEandAgePair pair1 = new SESEandAgePair( fsen, i );
- SESEandAgePair pair2 = new SESEandAgePair( fsen, i-1 );
+ SESEandAgePair pair1 = new SESEandAgePair(fsen, i);
+ SESEandAgePair pair2 = new SESEandAgePair(fsen, i-1);
output.println(" "+pair1+" = "+pair2+";");
- }
+ }
output.println(" "+pairNewest+" = &(seseToIssue->common);");
// no need to add a reference to whatever is the newest record, because
// we initialized seseToIssue->refCount to *2*
// but release a reference to whatever was the oldest BEFORE the shift
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" if( oldest != NULL ) {");
output.println(" RELEASE_REFERENCE_TO( oldest );");
output.println(" }");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
output.println(" }");
}
}
boolean atLeastOneCase = false;
// create a case for each class of task that might be executing
- Iterator<FlatSESEEnterNode> taskItr = oooa.getPossibleExecutingRBlocks( fsen ).iterator();
+ Iterator<FlatSESEEnterNode> taskItr = oooa.getPossibleExecutingRBlocks(fsen).iterator();
while( taskItr.hasNext() ) {
FlatSESEEnterNode parent = taskItr.next();
- ConflictGraph graph = oooa.getConflictGraph( parent );
+ ConflictGraph graph = oooa.getConflictGraph(parent);
if( graph == null || !graph.hasConflictEdge() ) {
continue;
SESEWaitingQueue seseWaitingQueue =
graph.getWaitingElementSetBySESEID(fsen.getIdentifier(), seseLockSet);
-
+
if( seseWaitingQueue.getWaitingElementSize() == 0 ) {
continue;
}
if( atLeastOneCase == false ) {
atLeastOneCase = true;
- output.println(" // add new task instance to current task's memory queues if needed ");
+ output.println(" // add new task instance to current task's memory queues if needed ");
output.println(" switch( runningSESE->classID ) {");
}
output.println(" seseToIssue->common.rentryIdx=0;");
Set<Integer> queueIDSet=seseWaitingQueue.getQueueIDSet();
- for (Iterator iterator = queueIDSet.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = queueIDSet.iterator(); iterator.hasNext(); ) {
Integer key = (Integer) iterator.next();
int queueID=key.intValue();
- Set<WaitingElement> waitingQueueSet =
+ Set<WaitingElement> waitingQueueSet =
seseWaitingQueue.getWaitingElementSet(queueID);
int enqueueType=seseWaitingQueue.getType(queueID);
if(enqueueType==SESEWaitingQueue.EXCEPTION) {
output.println(" INITIALIZEBUF(runningSESE->memoryQueueArray[" + queueID+ "]);");
}
- for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2.hasNext();) {
- WaitingElement waitingElement
+ for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2.hasNext(); ) {
+ WaitingElement waitingElement
= (WaitingElement) iterator2.next();
if (waitingElement.getStatus() >= ConflictNode.COARSE) {
output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ queueID+ "],"
// static in-var case
VariableSourceToken vst = fsen.getStaticInVarSrc(td);
if (vst != null) {
-
+
String srcId = "SESE_" + vst.getSESE().getPrettyIdentifier()
- + vst.getSESE().getIdentifier()
- + "_" + vst.getAge();
+ + vst.getSESE().getIdentifier()
+ + "_" + vst.getAge();
output.println(" pointer=(void*)&seseToIssue->"
+ srcId
+ "->"
output.println(" rentry->queue=runningSESE->memoryQueueArray["
+ waitingElement.getQueueID()
+ "];");
-
- if(enqueueType==SESEWaitingQueue.NORMAL){
+
+ if(enqueueType==SESEWaitingQueue.NORMAL) {
output.println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;");
output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["
+ waitingElement.getQueueID()
output.println(" ADDRENTRYTOBUF(runningSESE->memoryQueueArray[" + waitingElement.getQueueID() + "],rentry);");
}
}
- if(enqueueType!=SESEWaitingQueue.NORMAL){
+ if(enqueueType!=SESEWaitingQueue.NORMAL) {
output.println(" localCount+=RESOLVEBUF(runningSESE->memoryQueueArray["
+ queueID+ "],&seseToIssue->common);");
- }
+ }
}
output.println(" } break; // end case "+parent.getIdentifier());
- output.println();
+ output.println();
}
if( atLeastOneCase ) {
output.println(" } // end stall site switch");
}
- }
-
+ }
+
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_PREPAREMEMQ");
output.println(" CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_END );");
// Enqueue Task Record
if (state.RCR) {
- if( fsen != oooa.getMainSESE() && fsen.getInVarsForDynamicCoarseConflictResolution().size()>0){
+ if( fsen != oooa.getMainSESE() && fsen.getInVarsForDynamicCoarseConflictResolution().size()>0) {
output.println(" enqueueTR(TRqueue, (void *)seseToIssue);");
}
}
output.println(" workScheduleSubmit( (void*)seseToIssue );");
output.println(" }");
-
+
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_TASKDISPATCH");
}
- void dispatchMEMRC( FlatMethod fm,
- FlatSESEEnterNode newChild,
- PrintWriter output ) {
-
+ void dispatchMEMRC(FlatMethod fm,
+ FlatSESEEnterNode newChild,
+ PrintWriter output) {
// what we need to do here is create RCR records for the
// new task and insert it into the appropriate parent queues
+ // IF NEEDED!!!!!!!!
assert newChild.getParents().size() > 0;
output.println(" switch( runningSESE->classID ) {");
while( pItr.hasNext() ) {
FlatSESEEnterNode parent = pItr.next();
- ConflictGraph graph = oooa.getConflictGraph( parent );
+ ConflictGraph graph = oooa.getConflictGraph(parent);
if( graph != null && graph.hasConflictEdge() ) {
Set<SESELock> seseLockSet = oooa.getLockMappings(graph);
output.println(" seseToIssue->common.rentryIdx=0;");
Vector<TempDescriptor> invars=newChild.getInVarsForDynamicCoarseConflictResolution();
//System.out.println(fm.getMethod()+"["+invars+"]");
-
+
Vector<Long> queuetovar=new Vector<Long>();
- for(int i=0;i<invars.size();i++) {
+ for(int i=0; i<invars.size(); i++) {
TempDescriptor td=invars.get(i);
Set<WaitingElement> weset=seseWaitingQueue.getWaitingElementSet(td);
+
+ //TODO FIX MEEEEE!!!!
+ //Weset is sometimes null which breaks the following code and
+ //we don't know what weset = null means. For now, we bail when it's null
+ //until we find out what to do....
+// if(weset == null) {
+// continue;
+// }
+ //UPDATE: This hack DOES NOT FIX IT!.
+
+
+
int numqueues=0;
Set<Integer> queueSet=new HashSet<Integer>();
- for (Iterator iterator = weset.iterator(); iterator.hasNext();) {
- WaitingElement we = (WaitingElement) iterator.next();
- Integer queueID=new Integer( we.getQueueID());
- if(!queueSet.contains(queueID)){
+ for (Iterator iterator = weset.iterator(); iterator.hasNext(); ) {
+ WaitingElement we = (WaitingElement) iterator.next();
+ Integer queueID=new Integer(we.getQueueID());
+ if(!queueSet.contains(queueID)) {
numqueues++;
queueSet.add(queueID);
- }
+ }
}
output.println(" seseToIssue->rcrRecords["+i+"].flag="+numqueues+";");
output.println(" seseToIssue->rcrRecords["+i+"].next=NULL;");
output.println(" int dispCount"+i+"=0;");
- for (Iterator<WaitingElement> wtit = weset.iterator(); wtit.hasNext();) {
+ for (Iterator<WaitingElement> wtit = weset.iterator(); wtit.hasNext(); ) {
WaitingElement waitingElement = wtit.next();
int queueID = waitingElement.getQueueID();
if (queueID >= queuetovar.size())
queuetovar.setSize(queueID + 1);
Long l = queuetovar.get(queueID);
- long val = (l != null) ? l.longValue() : 0;
+ long val = (l != null)?l.longValue():0;
val = val | (1 << i);
queuetovar.set(queueID, new Long(val));
}
}
HashSet generatedqueueentry=new HashSet();
- for(int i=0;i<invars.size();i++) {
+ for(int i=0; i<invars.size(); i++) {
TempDescriptor td=invars.get(i);
Set<WaitingElement> weset=seseWaitingQueue.getWaitingElementSet(td);
- for(Iterator<WaitingElement> wtit=weset.iterator();wtit.hasNext();) {
+
+
+
+ //TODO FIX MEEEEE!!!!
+ //Weset is sometimes null which breaks the following code and
+ //we don't know what weset = null means. For now, we bail when it's null
+ //until we find out what to do....
+// if(weset == null) {
+// continue;
+// }
+ //UPDATE: This hack DOES NOT FIX IT!.
+
+
+
+ for(Iterator<WaitingElement> wtit=weset.iterator(); wtit.hasNext(); ) {
WaitingElement waitingElement=wtit.next();
int queueID=waitingElement.getQueueID();
-
- if(waitingElement.isBogus()){
+
+ if(waitingElement.isBogus()) {
continue;
}
-
+
if (generatedqueueentry.contains(queueID))
continue;
- else
+ else
generatedqueueentry.add(queueID);
-
+
assert(waitingElement.getStatus()>=ConflictNode.COARSE);
long mask=queuetovar.get(queueID);
output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "]," + waitingElement.getStatus() + ", &(seseToIssue->common), "+mask+"LL);");
output.println(" rentry->count=2;");
output.println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;");
output.println(" rentry->queue=runningSESE->memoryQueueArray[" + waitingElement.getQueueID()+"];");
-
+
output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],rentry)==READY) {");
- for(int j=0;mask!=0;j++) {
+ for(int j=0; mask!=0; j++) {
if ((mask&1)==1)
output.println(" dispCount"+j+"++;");
mask=mask>>1;
}
output.println(" } else ");
output.println(" refCount--;");
- }
+ }
if (newChild.getDynamicInVarSet().contains(td)) {
// dynamic in-var case
- //output.println(" pointer=seseToIssue->"+waitingElement.getDynID()+
- // "_srcSESE+seseToIssue->"+waitingElement.getDynID()+
+ //output.println(" pointer=seseToIssue->"+waitingElement.getDynID()+
+ // "_srcSESE+seseToIssue->"+waitingElement.getDynID()+
// "_srcOffset;");
//output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+
// ", &(seseToIssue->common), pointer );");
}
}
- for(int i=0;i<invars.size();i++) {
+ for(int i=0; i<invars.size(); i++) {
output.println(" if(!dispCount"+i+" || !atomic_sub_and_test(dispCount"+i+",&(seseToIssue->rcrRecords["+i+"].flag)))");
output.println(" localCount++;");
}
}
}
- output.println(" default: {");
- output.println(" printf(\"Error: unknown SESE class ID %d in dispatchMEMRC.\\n\", runningSESE->classID);");
- output.println(" exit( -1 );");
- output.println(" }");
output.println(" } // end switch");
output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
}
- public void generateFlatSESEExitNode( FlatMethod fm,
- FlatSESEExitNode fsexn,
- PrintWriter output ) {
+ public void generateFlatSESEExitNode(FlatMethod fm,
+ FlatSESEExitNode fsexn,
+ PrintWriter output) {
// get the enter node for this exit that has meta data embedded
FlatSESEEnterNode fsen = fsexn.getFlatEnter();
// there may be an SESE in an unreachable method, skip over
- if( !oooa.getAllSESEs().contains( fsen ) ) {
+ if( !oooa.getAllSESEs().contains(fsen) ) {
return;
}
// it should only appear in analysis results
assert !fsen.getIsCallerProxySESE();
-
+
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_TASKEXECUTE");
output.println(" CP_LOGEVENT( CP_EVENTID_TASKEXECUTE, CP_EVENTTYPE_END );");
output.println(" CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_BEGIN );");
output.println("#endif");
}
-
+
// this SESE cannot be done until all of its children are done
// so grab your own lock with the condition variable for watching
- // that the number of your running children is greater than zero
+ // that the number of your running children is greater than zero
output.println(" atomic_add(childSESE, &runningSESE->numRunningChildren);");
output.println(" pthread_mutex_lock( &(runningSESE->lock) );");
output.println(" if( runningSESE->numRunningChildren > 0 ) {");
output.println(" }");
- // copy out-set from local temps into the sese record
- Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
+
+ ////////////////////////////////////////
+ // go through all out-vars and determine where to get them
+ ////////////////////////////////////////
+ output.println(" // copy ready out-set primitive variables from locals into record");
+ Iterator<TempDescriptor> itr = fsen.getReadyOutVarSet().iterator();
while( itr.hasNext() ) {
TempDescriptor temp = itr.next();
- // only have to do this for primitives non-arrays
+ // only have to do this for primitives, non-arrays
if( !(
temp.getType().isPrimitive() && !temp.getType().isArray()
- )
- ) {
- continue;
+ )
+ ) {
+ continue;
}
- String from;
+ String from = generateTemp(fsen.getfmBogus(), temp);
- // determine whether this new task instance is in a method context,
- // or within the body of another task
- assert !fsen.getIsCallerProxySESE();
- FlatSESEEnterNode parent = fsen.getLocalParent();
- if( parent != null && !parent.getIsCallerProxySESE() ) {
- from = generateTemp( parent.getfmBogus(), temp );
- } else {
- from = generateTemp( fsen.getfmEnclosing(), temp );
- }
+ output.println(" "+paramsprefix+
+ "->"+temp.getSafeSymbol()+
+ " = "+from+";");
+ }
+ // static vars are from a known SESE
+ Iterator<TempDescriptor> tempItr;
+ output.println(" // copy out-set from static sources");
+ tempItr = fsen.getStaticOutVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+ VariableSourceToken vst = fsen.getStaticOutVarSrc(temp);
+ SESEandAgePair srcPair = new SESEandAgePair(vst.getSESE(), vst.getAge() );
output.println(" "+paramsprefix+
- "->"+temp.getSafeSymbol()+
- " = "+from+";");
- }
-
+ "->"+temp.getSafeSymbol()+
+ " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+ }
+
+ //output.println(" // decrement references to static sources");
+ //for( Iterator<SESEandAgePair> pairItr = fsen.getStaticOutVarSrcs().iterator(); pairItr.hasNext(); ) {
+ // SESEandAgePair srcPair = pairItr.next();
+ // output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ // output.println(" {");
+ // output.println(" SESEcommon* src = &("+paramsprefix+"->"+srcPair+"->common);");
+ // output.println(" RELEASE_REFERENCE_TO( src );");
+ // output.println(" }");
+ // output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ //}
+
+ output.println(" // copy out-set from dynamic sources");
+ tempItr = fsen.getDynamicOutVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+ TypeDescriptor type = temp.getType();
+
+ // go grab it from the SESE source, when the source is NULL it is
+ // this exiting task, so nothing to do!
+ output.println(" if( "+temp+"_srcSESE != NULL ) {");
+
+ output.println(" "+paramsprefix+
+ "->"+temp.getSafeSymbol()+
+ " = *(void**)( (void*)"+
+ temp+"_srcSESE + "+
+ temp+"_srcOffset);");
+
+ //output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ //output.println(" SESEcommon* src = "+paramsprefix+"->"+temp+"_srcSESE;");
+ //output.println(" RELEASE_REFERENCE_TO( src );");
+ //output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+
+ output.println(" }");
+ }
+
+
+
+
// mark yourself done, your task data is now read-only
output.println(" runningSESE->doneExecuting = TRUE;");
// FORWARD TODO
output.println(" while( !isEmpty( &runningSESE->forwardList ) ) {");
output.println(" SESEcommon* consumer = (SESEcommon*) getItem( &runningSESE->forwardList );");
-
-
+
+
if (!state.RCR) {
output.println(" if(consumer->rentryIdx>0){");
output.println(" // resolved null pointer");
output.println(" workScheduleSubmit( (void*)consumer );");
output.println(" }");
output.println(" }");
-
-
+
+
// clean up its lock element from waiting queue, and decrement dependency count for next SESE block
if( !fsen.getIsMainSESE() ) {
output.println();
output.println(" }");
output.println(" }");
}
-
+
Vector<TempDescriptor> inset=fsen.getInVarsForDynamicCoarseConflictResolution();
if (state.RCR && inset.size() > 0) {
/* Make sure the running SESE is finished */
int weaklyConnectedComponentIndex = rcr.getWeakID(inset.get(i), fsen);
output.println(" rcr_RETIREHASHTABLE(hashstruct[" + weaklyConnectedComponentIndex
- + "],&(___params___->common), rec->array[idx2], (BinItem_rcr *) rec->ptrarray[idx2]);");
+ + "],&(___params___->common), rec->array[idx2], (BinItem_rcr *) rec->ptrarray[idx2]);");
- output.println(" }");// exit idx2 for loop
+ output.println(" }"); // exit idx2 for loop
output.println(" rec=rec->next;");
- output.println(" }");// exit rec while loop
+ output.println(" }"); // exit rec while loop
}
output.println("}");
}
// that serve as sources, release the parent's ref of each
// non-null var of these types
output.println(" // releasing static SESEs");
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
- ContextTaskNames contextTaskNames = oooa.getContextTaskNames( fsen );
+ ContextTaskNames contextTaskNames = oooa.getContextTaskNames(fsen);
Iterator<SESEandAgePair> pItr = contextTaskNames.getNeededStaticNames().iterator();
while( pItr.hasNext() ) {
output.println(" if( "+dynSrcVar+"_srcSESE != NULL ) {");
output.println(" RELEASE_REFERENCE_TO( "+dynSrcVar+"_srcSESE );");
output.println(" }");
- }
+ }
// destroy this task's mempool if it is not a leaf task
if( !fsen.getIsLeafSESE() ) {
output.println(" returnTR();");
}
}
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
output.println("{");
// THIS task's record to the PARENT'S task record pool, and only if
// the reference count is now zero
if( !fsen.getIsMainSESE() ) {
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" RELEASE_REFERENCE_TO( runningSESE );");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
} else {
// the main task has no parent, just free its record
output.println(" mlpFreeSESErecord( runningSESE );");
}
- // last of all, decrement your parent's number of running children
+ // last of all, decrement your parent's number of running children
output.println(" if( myparent != NULL ) {");
output.println(" if( atomic_sub_and_test( 1, &(myparent->numRunningChildren) ) ) {");
output.println(" pthread_mutex_lock ( &(myparent->lock) );");
output.println(" }");
output.println("}");
-
+
// as this thread is wrapping up the task, make sure the thread-local var
// for the currently running task record references an invalid task
output.println(" runningSESE = (SESEcommon*) 0x1;");
}
}
-
- public void generateFlatWriteDynamicVarNode( FlatMethod fm,
- FlatWriteDynamicVarNode fwdvn,
- PrintWriter output
- ) {
-
+
+ public void generateFlatWriteDynamicVarNode(FlatMethod fm,
+ FlatWriteDynamicVarNode fwdvn,
+ PrintWriter output
+ ) {
+
Hashtable<TempDescriptor, VSTWrapper> writeDynamic = fwdvn.getVar2src();
assert writeDynamic != null;
Iterator wdItr = writeDynamic.entrySet().iterator();
while( wdItr.hasNext() ) {
- Map.Entry me = (Map.Entry) wdItr.next();
- TempDescriptor refVar = (TempDescriptor) me.getKey();
- VSTWrapper vstW = (VSTWrapper) me.getValue();
+ Map.Entry me = (Map.Entry)wdItr.next();
+ TempDescriptor refVar = (TempDescriptor) me.getKey();
+ VSTWrapper vstW = (VSTWrapper) me.getValue();
VariableSourceToken vst = vstW.vst;
output.println(" {");
output.println(" SESEcommon* oldSrc = "+refVar+"_srcSESE;");
if( vst == null ) {
- // if there is no given source, this variable is ready so
- // mark src pointer NULL to signify that the var is up-to-date
- output.println(" "+refVar+"_srcSESE = NULL;");
+ // if there is no given source, this variable is ready so
+ // mark src pointer NULL to signify that the var is up-to-date
+ output.println(" "+refVar+"_srcSESE = NULL;");
} else {
// otherwise we track where it will come from
- SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
- output.println(" "+refVar+"_srcSESE = "+instance+";");
+ SESEandAgePair instance = new SESEandAgePair(vst.getSESE(), vst.getAge() );
+ output.println(" "+refVar+"_srcSESE = "+instance+";");
output.println(" "+refVar+"_srcOffset = (INTPTR) &((("+
vst.getSESE().getSESErecordName()+"*)0)->"+vst.getAddrVar()+");");
}
// this variable pointed to, do release last in case we're just
// copying the same value in because 1->2->1 is safe but ref count
// 1->0->1 has a window where it looks like it should be free'd
- output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
output.println(" if( "+refVar+"_srcSESE != NULL ) {");
output.println(" ADD_REFERENCE_TO( "+refVar+"_srcSESE );");
output.println(" }");
output.println(" if( oldSrc != NULL ) {");
output.println(" RELEASE_REFERENCE_TO( oldSrc );");
output.println(" }");
- output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ output.println("#endif // OOO_DISABLE_TASKMEMPOOL");
output.println(" }");
- }
+ }
}
- protected void generateFlatNew( FlatMethod fm,
- FlatNew fn,
- PrintWriter output ) {
+ protected void generateFlatNew(FlatMethod fm,
+ FlatNew fn,
+ PrintWriter output) {
if( fn.getType().isArray() ) {
- int arrayid = state.getArrayNumber( fn.getType() )+state.numClasses();
+ int arrayid = state.getArrayNumber(fn.getType() )+state.numClasses();
if( GENERATEPRECISEGC ) {
- output.println(generateTemp( fm, fn.getDst())+
+ output.println(generateTemp(fm, fn.getDst())+
"=allocate_newarray_mlp("+localsprefixaddr+
- ", "+arrayid+", "+generateTemp( fm, fn.getSize())+
+ ", "+arrayid+", "+generateTemp(fm, fn.getSize())+
", oid, "+
- oooa.getDisjointAnalysis().getAllocationSiteFromFlatNew( fn ).getUniqueAllocSiteID()+
+ oooa.getHeapAnalysis().getAllocationSiteFromFlatNew(fn).getUniqueAllocSiteID()+
");");
output.println(" oid += oidIncrement;");
} else {
- output.println(generateTemp( fm, fn.getDst())+
+ output.println(generateTemp(fm, fn.getDst())+
"=allocate_newarray("+arrayid+
- ", "+generateTemp( fm, fn.getSize())+
+ ", "+generateTemp(fm, fn.getSize())+
");");
}
} else {
// not an array
if( GENERATEPRECISEGC ) {
- output.println( generateTemp( fm, fn.getDst())+
- "=allocate_new_mlp("+localsprefixaddr+
- ", "+fn.getType().getClassDesc().getId()+
- ", oid, "+
- oooa.getDisjointAnalysis().getAllocationSiteFromFlatNew( fn ).getUniqueAllocSiteID()+
- ");");
- output.println(" oid += oidIncrement;");
+ output.println(generateTemp(fm, fn.getDst())+
+ "=allocate_new_mlp("+localsprefixaddr+
+ ", "+fn.getType().getClassDesc().getId()+
+ ", oid, "+
+ oooa.getHeapAnalysis().getAllocationSiteFromFlatNew(fn).getUniqueAllocSiteID()+
+ ");");
+ output.println(" oid += oidIncrement;");
} else {
- output.println( generateTemp( fm, fn.getDst())+
- "=allocate_new("+fn.getType().getClassDesc().getId()+
- ");");
+ output.println(generateTemp(fm, fn.getDst())+
+ "=allocate_new("+fn.getType().getClassDesc().getId()+
+ ");");
}
}
}
- private int calculateSizeOfSESEParamList(FlatSESEEnterNode fsen){
-
+ private int calculateSizeOfSESEParamList(FlatSESEEnterNode fsen) {
+
Set<TempDescriptor> tdSet=new HashSet<TempDescriptor>();
-
- for (Iterator iterator = fsen.getInVarSet().iterator(); iterator.hasNext();) {
+
+ for (Iterator iterator = fsen.getInVarSet().iterator(); iterator.hasNext(); ) {
TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
- if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+ if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()) {
tdSet.add(tempDescriptor);
- }
+ }
}
-
- for (Iterator iterator = fsen.getOutVarSet().iterator(); iterator.hasNext();) {
+
+ for (Iterator iterator = fsen.getOutVarSet().iterator(); iterator.hasNext(); ) {
TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
- if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+ if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()) {
tdSet.add(tempDescriptor);
- }
- }
-
+ }
+ }
+
return tdSet.size();
}
-
- private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen){
+
+ private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen) {
HashMap <String,Integer> map=new HashMap();
HashSet <TempDescriptor> processed=new HashSet<TempDescriptor>();
String rtr="";
-
+
// space for all in and out set primitives
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
- inSetAndOutSet.addAll( fsen.getInVarSet() );
- inSetAndOutSet.addAll( fsen.getOutVarSet() );
-
+ inSetAndOutSet.addAll(fsen.getInVarSet() );
+ inSetAndOutSet.addAll(fsen.getOutVarSet() );
+
Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
TempDescriptor temp = itr.next();
TypeDescriptor type = temp.getType();
if( !type.isPtr() ) {
- inSetAndOutSetPrims.add( temp );
+ inSetAndOutSetPrims.add(temp);
}
}
-
+
Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
while( itrPrims.hasNext() ) {
TempDescriptor temp = itrPrims.next();
TypeDescriptor type = temp.getType();
- if(type.isPrimitive()){
+ if(type.isPrimitive()) {
Integer count=map.get(type.getSymbol());
- if(count==null){
+ if(count==null) {
count=new Integer(1);
map.put(type.getSymbol(), count);
- }else{
+ } else {
map.put(type.getSymbol(), new Integer(count.intValue()+1));
}
- }
+ }
}
-
+
Set<String> keySet=map.keySet();
- for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext(); ) {
String key = (String) iterator.next();
rtr+="+sizeof("+key+")*"+map.get(key);
}
- return rtr;
+ return rtr;
}
+
}