outstructs.println("#endif");
outstructs.println("#endif");
if( state.MLP ) {
+ outstructs.println("#include \"mlp_runtime.h\"");
outstructs.println("#include \"psemaphore.h\"");
}
// generate the SESE record structure
outputStructs.println(fsen.getSESErecordName()+" {");
- // 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;");
+ // 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
+ outputStructs.println(" SESEcommon common;");
// then garbage list stuff
outputStructs.println(" INTPTR size;");
while( pItr.hasNext() ) {
SESEandAgePair p = pItr.next();
output.println(" {");
- output.println(" SESErecord* child = (SESErecord*) "+p+";");
+ output.println(" SESEcommon* child = (SESEcommon*) "+p+";");
output.println(" psem_take( &(child->stallSem) );");
output.println(" }");
}
output.println(" "+fsen.getSESErecordName()+"* seseToIssue = ("+
fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
fsen.getSESErecordName()+" ) );");
- output.println(" seseToIssue->classID = "+fsen.getIdentifier()+";");
- output.println(" psem_init( &(seseToIssue->stallSem) );");
+ output.println(" seseToIssue->common.classID = "+fsen.getIdentifier()+";");
+ output.println(" psem_init( &(seseToIssue->common.stallSem) );");
// give pointers to in-set variables, when this SESE is ready to
// execute it should copy values from the pointers because they
if( fsexn.getFlatEnter() != mlpa.getRootSESE() ) {
output.println(" {");
- output.println(" psem_give( &("+paramsprefix+"->stallSem) );");
+ output.println(" psem_give( &("+paramsprefix+"->common.stallSem) );");
output.println(" }");
}
}
void* mlpAllocSESErecord( int size ) {
-
- void* newrec = RUNMALLOC( size );
-
- /*
- SESErecord* commonView = (SESErecord*) newrec;
- commonView->classID = classID;
- pthread_mutex_init( &(newrec->lock), NULL );
- newrec->forwardList = createQueue();
- newrec->doneExecuting = FALSE;
- */
-
+ void* newrec = RUNMALLOC( size );
return newrec;
}
void mlpFreeSESErecord( void* seseRecord ) {
-
- /*
- SESErecord* commonView = (SESErecord*) seseRecord;
- pthread_mutex_destroy( &(commonView->lock) );
- freeQueue( commonView->forwardList );
- */
-
RUNFREE( seseRecord );
}
-/*
-struct rootSESEinSetObjs { char** argv; };
-struct rootSESEinSetPrims { int argc; };
-*/
-
void mlpInit( int numProcessors,
void(*workFunc)(void*),
int argc, char** argv,
int maxSESEage ) {
- //SESErecord* rootSESE;
-
- //struct rootSESEinSetObjs* inObjs = RUNMALLOC( sizeof( struct rootSESEinSetObjs ) );
- //struct rootSESEinSetPrims* inPrims = RUNMALLOC( sizeof( struct rootSESEinSetPrims ) );
-
// first initialize the work scheduler
- workScheduleInit( numProcessors, workFunc );
-
- // the prepare the root SESE
- //inObjs->argv = argv;
- //inPrims->argc = argc;
- //rootSESE = mlpCreateSESErecord( 0, inObjs, NULL, inPrims, NULL );
-
- // skip the issue step because the root SESE will
- // never have outstanding dependencies
- //workScheduleSubmit( (void*) rootSESE );
+ //workScheduleInit( numProcessors, workFunc );
- // now the work scheduler is initialized and work is
- // in the hopper, so begin processing. This call
- // will not return
- workScheduleBegin();
+ //workScheduleBegin();
}
#include "psemaphore.h"
-// forward delcarations
-//struct SESErecord_t;
-
-
-// note that this record is never used other than
-// to cast a customized record and have easy access
-// the common fields listed here
-typedef struct SESErecord_t {
+// these fields are common to any SESE, and casting the
+// generated SESE record to this can be used, because
+// the common structure is always the first item in a
+// customized SESE record
+typedef struct SESEcommon_t {
// the identifier for the class of sese's that
// are instances of one particular static code block
struct Queue* forwardList;
int doneExecuting;
-} SESErecord;
+} SESEcommon;
/*
void(*func)(void*) ) {
int i, status;
- numWorkers = numProcessors;
+ numWorkers = numProcessors*5;
workFunc = func;
dequeWorkUnits = createQueue();