outmethod.println("#include \"mlp_runtime.h\"");
outmethod.println("#include \"psemaphore.h\"");
- if( state.RCR && rcr != null) {
+ if( state.RCR ) {
+ outmethod.println("#include \"trqueue.h\"");
outmethod.println("#include \"RuntimeConflictResolver.h\"");
+ outmethod.println("#include \"rcr_runtime.h\"");
}
}
}
if (state.RCR) {
- outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];");
+ if (inset.size()!=0)
+ outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];");
}
if( fsen.getFirstDepRecField() != null ) {
for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next();
- if(state.RCR && rcr != null){
+ if(state.RCR) {
Analysis.OoOJava.ConflictGraph conflictGraph = graph;
Hashtable<Taint, Set<Effect>> conflicts;
ReachGraph rg = oooa.getDisjointAnalysis().getReachGraph(currentSESE.getmdEnclosing());
}
output.println(" } ");
- if(state.RCR && rcr != null) {
+ if(state.RCR) {
output.println(" "+rcr.getTraverserInvocation(waitingElement.getTempDesc(),
generateTemp(fm, waitingElement.getTempDesc(), null), fn));
}
);
}
- if (state.RCR) {
+ if (state.RCR&&fsen.getInVarsForDynamicCoarseConflictResolution().size()>0) {
output.println(" seseToIssue->common.offsetToParamRecords=(INTPTR)sizeof("+fsen.getSESErecordName()+") - (INTPTR) & ((("+fsen.getSESErecordName()+"*)0)->rcrRecords);");
}
output.println(" CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_END );");
output.println("#endif");
}
-
+
// Enqueue Task Record
if (state.RCR) {
- output.println(" enqueueTR((void *)seseToIssue);");
+ output.println(" enqueueTR(TRqueue, (void *)seseToIssue);");
}
// if there were no outstanding dependencies, issue here
cFile.println("#include \"" + hashAndQueueCFileDir + "hashRCR.h\"\n#include \""
+ hashAndQueueCFileDir + "Queue_RCR.h\"\n#include <stdlib.h>");
cFile.println("#include \"classdefs.h\"");
+ cFile.println("#include \"structdefs.h\"");
+ cFile.println("#include \"mlp_runtime.h\"");
cFile.println("#include \"RuntimeConflictResolver.h\"");
cFile.println("#include \"hashStructure.h\"");
//Prints out the master traverser Invocation that'll call all other traverser
//based on traverserID
printMasterTraverserInvocation();
+ printResumeTraverserInvocation();
//TODO this is only temporary, remove when thread local vars implemented.
createMasterHashTableArray();
}
private void printMasterTraverserInvocation() {
- headerFile.println("\nint traverse(SESECommon * record);");
- cFile.println("\nint traverse(SESECommon * record) {");
+ headerFile.println("\nint tasktraverse(SESEcommon * record);");
+ cFile.println("\nint tasktraverse(SESEcommon * record) {");
cFile.println(" switch(record->classID) {");
for(Iterator<FlatSESEEnterNode> seseit=oooa.getAllSESEs().iterator();seseit.hasNext();) {
//This will print the traverser invocation that takes in a traverserID and
//starting ptr
- private void printAltMasterTraverserInvocation() {
+ private void printResumeTraverserInvocation() {
headerFile.println("\nint traverse(void * startingPtr, int traverserID);");
cFile.println("\nint traverse(void * startingPtr, int traverserID) {");
cFile.println(" switch(traverserID) {");
tail++;
if(tail & SIZE)
tail = 0;
- myRXRQueue.tail=tail;
+ myRCRQueue.tail=tail;
return ptr;
}
HashStructure* rcr_createHashtable(int sizeofWaitingQueue){
int i=0;
HashStructure* newTable=(HashStructure*)RUNMALLOC(sizeof(HashStructure));
- for(i=0;i<NUMBINS;i++){
+ for(i=0;i<RNUMBINS;i++){
newTable->array[i].head=NULL;
newTable->array[i].tail=NULL;
}
}
inline int rcr_generateKey(void * ptr){
- return (((struct genericObjectStruct *) ptr)->oid)&H_MASK;
+ return (((struct genericObjectStruct *) ptr)->oid)&RH_MASK;
}
int rcr_WRITEBINCASE(HashStructure *T, void *ptr, int traverserID, SESEcommon *task, void *heaproot) {
retval=NOTREADY;
}
- if (readbintail->index==NUMREAD) { // create new read group
+ if (readbintail->index==RNUMREAD) { // create new read group
ReadBinItem_rcr* rb=rcr_createReadBinItem();
td = &rb->array[rb->index++];
#define TRUE 1\r
#define FALSE 0\r
\r
-#define NUMBINS 64\r
-#define NUMREAD 64\r
-#define NUMRENTRY 256\r
-#define H_MASK (NUMBINS<<4)-1\r
+#define RNUMBINS 64\r
+#define RNUMREAD 64\r
+#define RNUMRENTRY 256\r
+#define RH_MASK (RNUMBINS<<4)-1\r
\r
//Note: put resolved things at the end and unresolved at the front.\r
typedef struct BinItem_rcr {\r
\r
\r
typedef struct Hashtable_rcr {\r
- BinElement_rcr array[NUMBINS];\r
+ BinElement_rcr array[RNUMBINS];\r
WaitingQueueBin * waitingQueue;\r
} HashStructure;\r
\r
\r
typedef struct ReadBinItem_rcr {\r
BinItem_rcr item;\r
- TraverserData array[NUMREAD];\r
+ TraverserData array[RNUMREAD];\r
//We don't need a head index since if the item before it was freed, then all these would be considered ready as well.\r
int index;\r
\r
+#include "trqueue.h"
#include "rcr_runtime.h"
#include "mlp_runtime.h"
+__thread struct trQueue * TRqueue;
+
void workerTR(void *x) {
struct trQueue * queue=(struct trQueue *)x;
- while(true) {
+ while(1) {
SESEcommon * tmp;
do {
- tmp=(SESEcommon *) dequeueTR(TRqueue);
+ tmp=(SESEcommon *) dequeueTR(queue);
if (tmp!=NULL)
break;
sched_yield();
#ifndef RCR_RUNTIME_H
#define RCR_RUNTIME_H
-extern __thread struct trqueue * TRqueue;
+extern __thread struct trQueue * TRqueue;
void workerTR(void *);
#include "trqueue.h"
#include "stdlib.h"
#include "stdio.h"
+#include "mlp_lock.h"
//0 would mean sucess
//1 would mean fail
//since if we reach SIZE, we will stop operation, it doesn't matter
//that we overwrite the element in the queue
-void enqueueTR(trQueue *q, void * ptr) {
+void enqueueTR(struct trQueue *q, void * ptr) {
unsigned int head=q->head+1;
if (head&TRSIZE)
head=0;
q->elements[head] = ptr;
BARRIER();
q->head=head;
- return 0;
}
-void * dequeueTR(trQueue *q) {
+void * dequeueTR(struct trQueue *q) {
unsigned int tail=q->tail;
if(q->head==tail)
return NULL;
//NOTE: SIZE MUST BE A POWER OF TWO;
//SIZE is used as mask to check overflow
-#define SIZE 16384
+#define TRSIZE 16384
struct trQueue {
- void * elements[SIZE];
+ void * elements[TRSIZE];
volatile unsigned int head;
char buffer[60];//buffer us to the next cache line
volatile unsigned int tail;