From: jjenista Date: Thu, 30 Jul 2009 22:06:27 +0000 (+0000) Subject: An implementation of parent/child stalling that compiles but hangs during execution... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=43f7c8f2c005b614f88ebb76816b4e26cf1b87d0;p=IRC.git An implementation of parent/child stalling that compiles but hangs during execution. Committing this stable version before tinkering to fix the problem --- diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java index 1a3f322b..2d2d8e8a 100644 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ b/Robust/src/Analysis/MLP/CodePlan.java @@ -30,9 +30,8 @@ public class CodePlan { public Set getWriteToDynamicSrc() { return writeToDynamicSrc; - } - - + } + public void addStall2CopySet( SESEandAgePair stallPair, Set copySet ) { @@ -44,8 +43,12 @@ public class CodePlan { } } - public Hashtable< SESEandAgePair, Set > getStall2copySet() { - return stall2copySet; + public Set getStallPairs() { + return stall2copySet.keySet(); + } + + public Set getCopySet( SESEandAgePair stallPair ) { + return stall2copySet.get( stallPair ); } diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index b658a2e5..38f378c4 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -143,11 +143,11 @@ public class MLPAnalysis { if( state.MLPDEBUG ) { System.out.println( "" ); //System.out.println( "\nSESE Hierarchy\n--------------\n" ); printSESEHierarchy(); - System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness(); + //System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness(); //System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) ); //System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) ); //System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) ); - //System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); + System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index b7e9dec7..ad5f6c1e 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -183,6 +183,7 @@ public class BuildCode { outmethodheader.println("#include "); outmethodheader.println("#include "); outmethodheader.println("#include \"mlp_runtime.h\""); + outmethodheader.println("#include \"psemaphore.h\""); } /* Output Structures */ @@ -459,6 +460,7 @@ public class BuildCode { outmethod.println("#include "); outmethod.println("#include "); outmethod.println("#include \"mlp_runtime.h\""); + outmethod.println("#include \"psemaphore.h\""); } @@ -510,6 +512,9 @@ public class BuildCode { outstructs.println("#define INTPTR int"); outstructs.println("#endif"); outstructs.println("#endif"); + if( state.MLP ) { + outstructs.println("#include \"psemaphore.h\""); + } /* Output #defines that the runtime uses to determine type * numbers for various objects it needs */ @@ -1748,9 +1753,13 @@ public class BuildCode { // generate the SESE record structure outputStructs.println(fsen.getSESErecordName()+" {"); - // class ID comes first + // SESE's static class ID outputStructs.println(" int classID;"); + // child is issued with this locked, and it + // unlocks it when it completes + outputStructs.println(" psemaphore stallSem;"); + // then garbage list stuff outputStructs.println(" INTPTR size;"); outputStructs.println(" void * next;"); @@ -1869,13 +1878,11 @@ public class BuildCode { // declare variables for naming SESE's - /* Iterator pItr = fsen.getNeededStaticNames().iterator(); while( pItr.hasNext() ) { SESEandAgePair p = pItr.next(); - output.println(" SESErecord* "+p+";"); + output.println(" void* "+p+";"); } - */ // copy in-set into place Iterator itrInSet = fsen.getInVarSet().iterator(); @@ -2205,6 +2212,27 @@ public class BuildCode { } protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) { + + // insert pre-node actions from the code plan + if( state.MLP ) { + + CodePlan cp = mlpa.getCodePlan( fn ); + if( cp != null ) { + + // for each sese and age pair that this parent statement + // must stall on, take that child's stall semaphore, the + // copying of values comes after the statement + Iterator pItr = cp.getStallPairs().iterator(); + while( pItr.hasNext() ) { + SESEandAgePair p = pItr.next(); + output.println(" {"); + output.println(" SESErecord* child = (SESErecord*) "+p+";"); + output.println(" psem_take( &(child->stallSem) );"); + output.println(" }"); + } + } + } + switch(fn.kind()) { case FKind.FlatAtomicEnterNode: generateFlatAtomicEnterNode(fm, lb, (FlatAtomicEnterNode) fn, output); @@ -2312,18 +2340,22 @@ public class BuildCode { throw new Error(); } + // insert post-node actions from the code-plan + /* if( state.MLP ) { - /* CodePlan cp = mlpa.getCodePlan( fn ); if( cp != null ) { - Set writeDynamic = cp.getWriteToDynamicSrc(); if( writeDynamic != null ) { - + Iterator vstItr = writeDynamic.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + + } } } - */ } + */ } public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) { @@ -2663,6 +2695,7 @@ public class BuildCode { fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+ fsen.getSESErecordName()+" ) );"); output.println(" seseToIssue->classID = "+fsen.getIdentifier()+";"); + output.println(" psem_init( &(seseToIssue->stallSem) );"); // give pointers to in-set variables, when this SESE is ready to // execute it should copy values from the pointers because they @@ -2681,16 +2714,29 @@ public class BuildCode { output.println("(INTPTR) &("+temp.getSafeSymbol()+");"); } } + + // for finding dynamic SESE instances from static names + if( fsen != mlpa.getRootSESE() ) { + SESEandAgePair p = new SESEandAgePair( fsen, 0 ); + output.println(" "+p+" = seseToIssue;"); + } + // submit the SESE as work output.println(" workScheduleSubmit( (void*) seseToIssue );"); output.println(" }"); } - public void generateFlatSESEExitNode(FlatMethod fm, LocalityBinding lb, FlatSESEExitNode fsen, PrintWriter output) { + public void generateFlatSESEExitNode(FlatMethod fm, LocalityBinding lb, FlatSESEExitNode fsexn, PrintWriter output) { if( !state.MLP ) { // SESE nodes can be parsed for normal compilation, just skip over them return; } + + if( fsexn.getFlatEnter() != mlpa.getRootSESE() ) { + output.println(" {"); + output.println(" psem_give( &("+paramsprefix+"->stallSem) );"); + output.println(" }"); + } } private void generateFlatCheckNode(FlatMethod fm, LocalityBinding lb, FlatCheckNode fcn, PrintWriter output) { diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index 53c90e1c..1fb78a16 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -20,6 +20,10 @@ typedef struct SESErecord_t { // are instances of one particular static code block int classID; + // a parent waits on this semaphore when stalling on + // this child, the child gives it at its SESE exit + psemaphore stallSem; + // the lock guards the following data SESE's // use to coordinate with one another pthread_mutex_t lock; @@ -30,9 +34,12 @@ typedef struct SESErecord_t { /* +// a parent remembers an SESE instance, say class ID=2 +// and age=0, by declaring an SESEvarSrc seseID2_age0 +// and keeping the fields up-to-date typedef struct SESEvarSrc_t { - void* seseRecord; - int offset; + void* sese; + INTPTR addr; } SESEvarSrc; */