output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", runningSESE, (void*)&" +generateTemp(fm,waitingElement.getTempDesc(),lb)+ ");");
}
output.println(" psem_init( &(rentry->parentStallSem) );");
+ output.println(" rentry->tag=rentry->parentStallSem.tag;");
output.println(" rentry->queue=runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
- output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()
- + "],rentry)==NOTREADY){");
+ output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],rentry)==NOTREADY){");
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_TASKSTALLMEM");
output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
output.println("#endif");
}
- output.println(" psem_take( &(rentry->parentStallSem), (struct garbagelist *)&___locals___ );");
+ if(state.RCR) {
+ //no need to enqueue parent effect if coarse grained conflict clears us
+ output.println(" stallrecord.common.parentsStallSem=&rentry->parentStallSem;");
+ output.println(" stallrecord.tag=rentry->tag;");
+ output.println(" "+rcr.getTraverserInvocation(waitingElement.getTempDesc(), generateTemp(fm, waitingElement.getTempDesc(), null)+", &stallrecord", fn));
+ }
+ output.println(" psem_take( &(rentry->parentStallSem), (struct garbagelist *)&___locals___ );");
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_TASKSTALLMEM");
output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );");
output.println("#endif");
}
output.println(" } ");
-
- if(state.RCR) {
- output.println(" "+rcr.getTraverserInvocation(waitingElement.getTempDesc(),
- generateTemp(fm, waitingElement.getTempDesc(), null), fn));
- }
}
output.println(" }");
}
if( waitingElement.getStatus() >= ConflictNode.COARSE ){
// HERE! a parent might conflict with a child
output.println(" rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", runningSESE);");
- }else{
+ } else {
output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", runningSESE, (void*)&___locals___."+ waitingElement.getDynID() + ");");
}
- output.println(" psem_init( &(rentry->parentStallSem) );");
+ output.println(" psem_init(&(rentry->parentStallSem));");
+ output.println(" rentry->tag=rentry->parentStallSem->tag;");
output.println(" rentry->queue=runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
- output
- .println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()
- + "],rentry)==NOTREADY){");
+ output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+"],rentry)==NOTREADY) {");
if( state.COREPROF ) {
output.println("#ifdef CP_EVENTID_TASKSTALLMEM");
output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
flatname = fn.toString();
}
- return "traverse___" + removeInvalidChars(invar.getSafeSymbol()) +
+ return "traverse___" + invar.getSafeSymbol() +
removeInvalidChars(flatname) + "___("+varString+");";
}
public String removeInvalidChars(String in) {
StringBuilder s = new StringBuilder(in);
for(int i = 0; i < s.length(); i++) {
- if(s.charAt(i) == ' ' || s.charAt(i) == '.' || s.charAt(i) == '=') {
+ if(s.charAt(i) == ' ' || s.charAt(i) == '.' || s.charAt(i) == '='||s.charAt(i)=='['||s.charAt(i)==']') {
s.deleteCharAt(i);
i--;
}
private void printResumeTraverserInvocation() {
headerFile.println("\nint traverse(void * startingPtr, SESEcommon * record, int traverserID);");
cFile.println("\nint traverse(void * startingPtr, SESEcommon *record, int traverserID) {");
- cFile.println(" switch(traverserID) {");
+ cFile.println(" switch(traverserID) {");
for(Taint t: doneTaints.keySet()) {
cFile.println(" case " + doneTaints.get(t)+ ":");
if(t.isRBlockTaint()) {
cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr, ("+t.getSESE().getSESErecordName()+" *)record", t.getSESE()));
} else if (t.isStallSiteTaint()){
- cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr, record", t.getStallSite()));
+ cFile.println("/* " + this.getTraverserInvocation(t.getVar(), "startingPtr, record", t.getStallSite())+"*/");
} else {
System.out.println("RuntimeConflictResolver encountered a taint that is neither SESE nor stallsite: " + t);
}
+ cFile.println(" break;");
}
if(RuntimeConflictResolver.cSideDebug) {
int index=-1;
if (taint.isStallSiteTaint()) {
- methodName= "void traverse___" + removeInvalidChars(inVar) +
- removeInvalidChars(rBlock) + "___(void * InVar, SESEcommon *record)";
+ methodName= "void traverse___" + inVar + removeInvalidChars(rBlock) + "___(void * InVar, SESEstall *record)";
} else {
- methodName= "void traverse___" + removeInvalidChars(inVar) +
- removeInvalidChars(rBlock) + "___(void * InVar, "+taint.getSESE().getSESErecordName() +" *record)";
+ methodName= "void traverse___" + inVar + removeInvalidChars(rBlock) + "___(void * InVar, "+taint.getSESE().getSESErecordName() +" *record)";
FlatSESEEnterNode fsese=taint.getSESE();
TempDescriptor tmp=taint.getVar();
index=fsese.getInVarsForDynamicCoarseConflictResolution().indexOf(tmp);
headerFile.println(methodName + ";");
cFile.println(" int totalcount=RUNBIAS;\n");
if (taint.isStallSiteTaint()) {
- //need to add this
+ cFile.println(" record->rcrRecords[0].count=RUNBIAS;\n");
+ cFile.println(" record->rcrRecords[0].index=0;\n");
} else {
cFile.println(" record->rcrRecords["+index+"].count=RUNBIAS;\n");
cFile.println(" record->rcrRecords["+index+"].index=0;\n");
}
if (taint.isStallSiteTaint()) {
//need to add this
+ cFile.println(" if(atomic_sub_and_test(RUNBIAS-totalcount,&(record->rcrRecords[0].count))) {");
+ cFile.println(" psem_give_tag(record->common.parentsStallSem, record->tag);");
+ cFile.println("}");
} else {
cFile.println(" if(atomic_sub_and_test(RUNBIAS-totalcount,&(record->rcrRecords["+index+"].count))) {");
cFile.println(" int flag=LOCKXCHG32(&(record->rcrRecords["+index+"].flag),0);");
workScheduleSubmit(seseCommon);
}
}else if(rentry->type==PARENTREAD || rentry->type==PARENTWRITE ||rentry->type==PARENTCOARSE){
- psem_give(&(rentry->parentStallSem));
+ psem_give_tag(&(rentry->parentStallSem), rentry->tag);
}
}
int numRunningChildren;
struct SESEcommon_t* parent;
-
+
int numMemoryQueue;
int rentryIdx;
int unresolvedRentryIdx;
// to the parent record's memory pool
MemPool* taskRecordMemPool;
volatile int refCount;
-
} SESEcommon;
-
// a thread-local var refers to the currently
// running task
extern __thread SESEcommon* runningSESE;
struct SCC_t* scc;
struct MemoryQueue_t* queue;
psemaphore parentStallSem;
+ int tag;
SESEcommon* seseRec;
INTPTR* pointer;
int isBufMode;
int shift=__builtin_ctzll(mask)+1;
index+=shift;
if (atomic_sub_and_test(1,&array[index].count)) {
- int flag=LOCKXCHG32(&array[index].flag,0);
- if (flag) {
- if(atomic_sub_and_test(1, &(record->unresolvedDependencies)))
- workScheduleSubmit((void *)record);
+ if(unlikely(record->classID==STALLCLASSID)) {
+ //parent stall...clear it
+ psem_give_tag(record->parentsStallSem, ((SESEstall *)record)->tag);
+ } else {
+ int flag=LOCKXCHG32(&array[index].flag,0);
+ if (flag) {
+ if(atomic_sub_and_test(1, &(record->unresolvedDependencies)))
+ workScheduleSubmit((void *)record);
+ }
}
}
mask=mask>>shift;
#include "trqueue.h"
-#include "rcr_runtime.h"
#include "mlp_runtime.h"
+#include "rcr_runtime.h"
+
void * workerTR(void *x) {
struct trQueue * queue=(struct trQueue *)x;
}
return NULL;
}
+
+__thread SESEstall stallrecord;
int array[RCRSIZE];
struct rcrRecord *next;
};
+
+#define STALLCLASSID 1939921
+
+typedef struct SESEstall_t {
+ SESEcommon common;
+ int size;
+ void * next;
+ struct rcrRecord rcrRecords[1];
+ int tag;
+} SESEstall;
+
+extern __thread SESEstall stallrecord;
#endif
pthread_mutex_init( &(sem->lock), NULL );
pthread_cond_init ( &(sem->cond), NULL );
sem->signaled = 0;
+ sem->tag = 0;
}
}
-void psem_give( psemaphore* sem ) {
+void psem_give( psemaphore* sem) {
pthread_mutex_lock ( &(sem->lock) );
sem->signaled = 1;
pthread_cond_signal ( &(sem->cond) );
pthread_mutex_unlock( &(sem->lock) );
}
+void psem_give_tag( psemaphore* sem, int tag) {
+ pthread_mutex_lock ( &(sem->lock) );
+ if (sem->tag==tag) {
+ sem->signaled = 1;
+ pthread_cond_signal ( &(sem->cond) );
+ }
+ pthread_mutex_unlock( &(sem->lock) );
+}
+
void psem_reset( psemaphore* sem ) {
// this should NEVER BE CALLED if it is possible
exit( -1 );
}
pthread_mutex_unlock( &(sem->lock) );
+ sem->tag++;
sem->signaled = 0;
}
pthread_mutex_t lock;
pthread_cond_t cond;
int signaled;
+ int tag;
} psemaphore;
void psem_init ( psemaphore* sem );
void psem_take ( psemaphore* sem, struct garbagelist* gl );
-void psem_give ( psemaphore* sem );
+void psem_give_tag ( psemaphore* sem, int tag );
+void psem_give ( psemaphore* sem);
void psem_reset( psemaphore* sem );
pthread_attr_init( &nattr );
pthread_attr_setdetachstate( &nattr, PTHREAD_CREATE_DETACHED );
+ //set up the stall site SESErecord
+ stallrecord.common.classID=STALLCLASSID;
+ stallrecord.common.offsetToParamRecords=(INTPTR) &((SESEstall *)0)->rcrRecords;
+
if( TRqueue == NULL ) {
TRqueue = allocTR();
}
}
}
}
- sese print {
- for(int i=0;i<10;i++)
- System.out.println(r[i].f);
- }
+ for(int i=0;i<10;i++)
+ System.out.println(r[i].f);
}
}