} else {
output.print(se.getTargetCNode().getClusterLabel());
}
- output.println(" [label=\"" + se.getLabel() + "\", color=red, style=dashed]");
+ output.println(" [label=\"" + se.getLabel() + "\", color=red, style=dashed];");
} else {
- output.println(se.getTargetFState().getLabel() + " [label=\"" + se.getLabel() + "\", color=red, style=dashed]");
+ output.println(se.getTargetFState().getLabel() + " [label=\"" + se.getLabel() + "\", color=red, style=dashed];");
}
}
}
// time coordinate nodes
Vector<String> timeNodes = new Vector<String>();
String[] lastTaskNodes = new String[coreNum];
+ String[] lastTasks = new String[coreNum];
boolean[] isTaskFinish = new boolean[coreNum];
for(j = 0; j < coreNum; j++) {
lastTaskNodes[j] = "first";
isTaskFinish[j] = true;
+ lastTasks[j] = "";
}
timeNodes.add("0");
for(j = 0; j < checkpoints.size(); j++) {
CheckPoint tcp = checkpoints.elementAt(j);
+ Hashtable<Integer, String> tmplastTasks = new Hashtable<Integer, String>();
+ Vector<Integer> tmpisTaskFinish = new Vector<Integer>();
+ Vector<Integer> tmpisset = new Vector<Integer>();
String tnode = String.valueOf(tcp.getTimepoint());
if(!timeNodes.contains(tnode)) {
timeNodes.add(tnode);
for(int i = 0; i < actions.size(); i++) {
Action taction = actions.elementAt(i);
int cNum = taction.getCoreNum();
+ if(!tmplastTasks.contains(cNum)) {
+ tmplastTasks.put(cNum, lastTasks[cNum]);
+ }
+ if(!(tmpisset.contains(cNum)) && (isTaskFinish[cNum]) && !(tmpisTaskFinish.contains(cNum))) {
+ tmpisTaskFinish.add(cNum); // records those with task finished the first time visit it
+ }
String tmpTaskNode = "\"" + tnode + "core" + cNum + "\"";
StringBuffer tmpLabel = null;
boolean isfirst = false;
if(!(lastTaskNodes[cNum].equals(tmpTaskNode))) {
output.print("\t");
if(lastTaskNodes[cNum].equals("first")) {
- output.println("\"core " + cNum + "\"->" + tmpTaskNode);
+ output.print("\"core " + cNum + "\"->" + tmpTaskNode);
} else {
output.print(lastTaskNodes[cNum] + "->" + tmpTaskNode);
}
- if(isTaskFinish[cNum]) {
+ if(tmpisTaskFinish.contains(cNum)) {
output.print(" [style=invis]");
}
output.println(";");
if(!(lastTaskNodes[cNum].equals("first"))) {
if(!(lastTaskNodes[cNum].equals(tmpTaskNode))) {
output.print("\t");
- output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode);
+ output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode + ";");
lastTaskNodes[cNum] = tmpTaskNode;
}
- isTaskFinish[cNum] = true;
+ if(tmpisset.contains(cNum)) {
+ isTaskFinish[cNum] &= true;
+ } else {
+ isTaskFinish[cNum] = true;
+ tmpisset.add(cNum);
+ }
+ lastTasks[cNum] = "";
} else {
throw new Exception("Error: unexpected task finish");
}
tmpLabel.append(";");
}
}
- if(!(lastTaskNodes[cNum].equals("first")) &&
- !(lastTaskNodes[cNum].equals(tmpTaskNode))) {
- output.print("\t");
- output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode);
- lastTaskNodes[cNum] = tmpTaskNode;
- isTaskFinish[cNum] = true;
+ if(!(lastTaskNodes[cNum].equals("first"))) {
+ if (!(lastTaskNodes[cNum].equals(tmpTaskNode))) {
+ output.print("\t");
+ output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode + ";");
+ lastTaskNodes[cNum] = tmpTaskNode;
+ }
+ if(tmpisset.contains(cNum)) {
+ isTaskFinish[cNum] &= true;
+ } else {
+ isTaskFinish[cNum] = true;
+ tmpisset.add(cNum);
+ }
+ lastTasks[cNum] = "";
} else {
throw new Exception("Error: unexpected task finish");
}
tmpLabel.append("\\n");
}
tmpLabel.append("<" + taction.getTd().getSymbol() + ">starts;");
+ lastTasks[cNum] = taction.getTd().getSymbol();
if (!(lastTaskNodes[cNum].equals(tmpTaskNode))) {
output.print("\t");
} else {
output.print(lastTaskNodes[cNum] + "->" + tmpTaskNode);
}
- if(isTaskFinish[cNum]) {
+ if(tmpisTaskFinish.contains(cNum)) {
output.print(" [style=invis]");
}
output.println(";");
lastTaskNodes[cNum] = tmpTaskNode;
}
- isTaskFinish[cNum] = false;
+ isTaskFinish[cNum] &= false;
break;
}
case Action.TASKABORT: {
tmpLabel.append("\\n");
}
tmpLabel.append("<" + taction.getTd().getSymbol() + ">aborts;");
- if(!(lastTaskNodes[cNum].equals("first")) &&
- !(lastTaskNodes[cNum].equals(tmpTaskNode))) {
- output.print("\t");
- output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode);
- lastTaskNodes[cNum] = tmpTaskNode;
- isTaskFinish[cNum] = true;
+ if(!(lastTaskNodes[cNum].equals("first")) &&
+ (tmplastTasks.get(cNum).equals(taction.getTd().getSymbol()))) {
+ if(!(lastTaskNodes[cNum].equals(tmpTaskNode))) {
+ output.print("\t");
+ output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode + ";");
+ lastTaskNodes[cNum] = tmpTaskNode;
+ }
+ if(tmpisset.contains(cNum)) {
+ isTaskFinish[cNum] &= true;
+ } else {
+ isTaskFinish[cNum] = true;
+ tmpisset.add(cNum);
+ }
+ lastTasks[cNum] = "";
} else {
throw new Exception("Error: unexpected task aborts");
}
}
tmpLabel.append("<" + taction.getTd().getSymbol() + ">removes;");
if(!(lastTaskNodes[cNum].equals("first")) &&
- !(lastTaskNodes[cNum].equals(tmpTaskNode))) {
- output.print("\t");
- output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode);
- lastTaskNodes[cNum] = tmpTaskNode;
- isTaskFinish[cNum] = true;
+ (tmplastTasks.get(cNum).equals(taction.getTd().getSymbol()))) {
+ if(!(lastTaskNodes[cNum].equals(tmpTaskNode))) {
+ output.print("\t");
+ output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode + ";");
+ lastTaskNodes[cNum] = tmpTaskNode;
+ }
+ if(tmpisset.contains(cNum)) {
+ isTaskFinish[cNum] &= true;
+ } else {
+ isTaskFinish[cNum] = true;
+ tmpisset.add(cNum);
+ }
+ lastTasks[cNum] = "";
} else {
throw new Exception("Error: unexpected task remove");
}
int msgdataindex;
int msglength;
void calCoords(int core_num, int* coordY, int* coordX);
-void recvMsg(void);
#elif defined THREADSIMULATE
static struct RuntimeHash* locktbl;
struct thread_data {
bool getwritelock(void* ptr);
void releasewritelock(void* ptr);
-void flushAll(void);
-
-void flushAll(void) {
-#ifdef RAW
- int i = 0;
-#ifdef INTERRUPT
- raw_user_interrupts_off();
-#endif
- raw_test_pass(0xec00);
- for(i = 0; i < 512; ++i) {
- int base = i << 5;
- int off1 = 1 << 14;
- flushCacheline(base);
- flushCacheline(base|off1);
- }
-#ifdef INTERRUPT
- raw_user_interrupts_on();
-#endif
- raw_test_pass(0xec02);
-#endif
-}
-
#ifdef RAW
-void recvMsg() {
- //raw_test_pass(0xefee);
- //raw_user_interrupts_off();
- //raw_test_pass(0xef00);
- receiveObject();
- //raw_test_pass(0xefff);
- //raw_user_interrupts_on();
- //raw_test_pass(0xefef);
-}
-
void begin() {
#else
int main(int argc, char **argv) {
bool allStall = true;
int sumsendobj = 0;
- raw_test_pass_reg(&locktable);
- raw_test_pass_reg(&msglength);
- raw_test_pass_reg(&i);
+#ifdef RAWDEBUG
raw_test_pass(0xee01);
+#endif
corenum = raw_get_abs_pos_x() + 4 * raw_get_abs_pos_y();
// initialize the arrays
msgtype = -1;
msgdataindex = 0;
msglength = 30;
+#ifdef RAWDEBUG
raw_test_pass(0xee02);
+#endif
// create the lock table, lockresult table and obj queue
locktable.size = 20;
#endif
objqueue.head = NULL;
objqueue.tail = NULL;
+#ifdef RAWDEBUG
raw_test_pass(0xee03);
+#endif
#ifdef INTERRUPT
if (corenum < NUMCORES) {
//setup_interrupts();
//start_gdn_avail_ints(recvMsg);
raw_user_interrupts_on();
+#ifdef RAWDEBUG
raw_test_pass(0xee04);
+#endif
}
#endif
processOptions();
#endif
initializeexithandler();
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xee05);
#endif
/* Create table for failed tasks */
receiveObject();
}
} else {
+#ifdef RAWDEBUG
raw_test_pass(0xee06);
+#endif
#endif
/*failedtasks=genallocatehashtable((unsigned int (*)(void *)) &hashCodetpd,
(int (*)(void *,void *)) &comparetpd);*/
failedtasks = NULL;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xee07);
#endif
/* Create queue of active tasks */
activetasks=genallocatehashtable((unsigned int (*)(void *)) &hashCodetpd,
(int (*)(void *,void *)) &comparetpd);
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xee08);
#endif
/* Process task information */
processtasks();
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xee09);
#endif
+ if(STARTUPCORE == corenum) {
/* Create startup object */
createstartupobject(argc, argv);
-#ifdef RAW
+ }
+#ifdef RAWDEBUG
raw_test_pass(0xee0a);
#endif
#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xee0b);
+#endif
while(true) {
/*#ifndef INTERRUPT
}
#endif
+#ifdef RAWDEBUG
raw_test_pass(0xee0c);
+#endif
// check if there are some pending objects, if yes, enqueue them and executetasks again
tocontinue = false;
+#ifdef RAWDEBUG
raw_test_pass(0xee0d);
+#endif
while(!isEmpty(&objqueue)) {
void * obj = NULL;
#ifdef INTERRUPT
raw_user_interrupts_off();
#endif
+#ifdef RAWDEBUG
raw_test_pass(0xeee1);
+#endif
sendStall = false;
tocontinue = true;
objitem = getTail(&objqueue);
//obj = objitem->objectptr;
objInfo = (struct transObjInfo *)objitem->objectptr;
obj = objInfo->objptr;
+#ifdef RAWDEBUG
raw_test_pass_reg((int)obj);
+#endif
// grab lock and flush the obj
getreadlock_I(obj);
while(!lockflag) {
receiveObject();
}
grount = lockresult;
+#ifdef RAWDEBUG
raw_test_pass_reg(grount);
+#endif
lockresult = 0;
lockobj = 0;
if(grount == 1) {
int k = 0;
+ raw_invalidate_cache_range(obj, classsize[((struct ___Object___ *)obj)->type]);
// flush the obj
- for(k = 0; k < classsize[((struct ___Object___ *)obj)->type]; ++k) {
+ /*for(k = 0; k < classsize[((struct ___Object___ *)obj)->type]; ++k) {
invalidateAddr(obj + k);
- }
+ }*/
// enqueue the object
for(k = 0; k < objInfo->length; ++k) {
int taskindex = objInfo->queues[2 * k];
int paramindex = objInfo->queues[2 * k + 1];
struct parameterwrapper ** queues = &(paramqueues[corenum][taskindex][paramindex]);
+#ifdef RAWDEBUG
raw_test_pass_reg(taskindex);
raw_test_pass_reg(paramindex);
+#endif
enqueueObject_I(obj, queues, 1);
}
removeItem(&objqueue, objitem);
#ifdef INTERRUPT
raw_user_interrupts_on();
#endif
+#ifdef RAWDEBUG
raw_test_pass(0xee0e);
+#endif
}
+#ifdef RAWDEBUG
raw_test_pass(0xee0f);
+#endif
if(!tocontinue) {
// check if stop
if(STARTUPCORE == corenum) {
if(isfirst) {
+#ifdef RAWDEBUG
raw_test_pass(0xee10);
+#endif
isfirst = false;
}
#ifdef INTERRUPT
numreceiveobjs[corenum] = self_numreceiveobjs;
// check the status of all cores
allStall = true;
+#ifdef RAWDEBUG
raw_test_pass_reg(NUMCORES);
+#endif
for(i = 0; i < NUMCORES; ++i) {
+#ifdef RAWDEBUG
raw_test_pass(0xe000 + corestatus[i]);
+#endif
if(corestatus[i] != 0) {
allStall = false;
break;
sumsendobj = 0;
for(i = 0; i < NUMCORES; ++i) {
sumsendobj += numsendobjs[i];
+#ifdef RAWDEBUG
raw_test_pass(0xf000 + numsendobjs[i]);
+#endif
}
for(i = 0; i < NUMCORES; ++i) {
sumsendobj -= numreceiveobjs[i];
+#ifdef RAWDEBUG
raw_test_pass(0xf000 + numreceiveobjs[i]);
+#endif
}
if(0 == sumsendobj) {
// terminate
+#ifdef RAWDEBUG
raw_test_pass(0xee11);
+#endif
+ raw_test_pass(raw_get_cycle());
raw_test_done(1); // All done.
}
}
#endif
} else {
if(!sendStall) {
+#ifdef RAWDEBUG
raw_test_pass(0xee12);
+#endif
if(isfirst) {
// wait for some time
int halt = 10000;
+#ifdef RAWDEBUG
raw_test_pass(0xee13);
+#endif
while(halt--){}
isfirst = false;
+#ifdef RAWDEBUG
raw_test_pass(0xee14);
+#endif
} else {
// send StallMsg to startup core
+#ifdef RAWDEBUG
raw_test_pass(0xee15);
+#endif
sendStall = transStallMsg(STARTUPCORE);
isfirst = true;
}
} else {
isfirst = true;
+#ifdef RAWDEBUG
raw_test_pass(0xee16);
+#endif
}
}
}
flagorandinit(startupobject,1,0xFFFFFFFF);
enqueueObject(startupobject, NULL, 0);
#ifdef RAW
- flushAll();
+ //flushAll();
+ raw_flush_entire_cache();
#endif
}
#endif
struct ArrayObject * ao=NULL;
struct ___Object___ * tagptr=obj->___tags___;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb0);
#endif
if (tagptr==NULL) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb1);
#endif
obj->___tags___=(struct ___Object___ *)tagd;
/* Have to check if it is already set */
if (tagptr->type==TAGTYPE) {
struct ___TagDescriptor___ * td=(struct ___TagDescriptor___ *) tagptr;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb2);
#endif
if (td==tagd) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb3);
#endif
return;
tagd=(struct ___TagDescriptor___ *)ptrarray[3];
td=(struct ___TagDescriptor___ *) obj->___tags___;
#else
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb4);
#endif
ao=allocate_newarray(TAGARRAYTYPE,TAGARRAYINTERVAL);
#endif
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb5);
#endif
ARRAYSET(ao, struct ___TagDescriptor___ *, 0, td);
ARRAYSET(ao, struct ___TagDescriptor___ *, 1, tagd);
obj->___tags___=(struct ___Object___ *) ao;
ao->___cachedCode___=2;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb6);
#endif
} else {
/* Array Case */
int i;
struct ArrayObject *ao=(struct ArrayObject *) tagptr;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb7);
#endif
for(i=0;i<ao->___cachedCode___;i++) {
struct ___TagDescriptor___ * td=ARRAYGET(ao, struct ___TagDescriptor___*, i);
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb8);
#endif
if (td==tagd) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebb9);
#endif
return;
}
}
if (ao->___cachedCode___<ao->___length___) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebba);
#endif
ARRAYSET(ao, struct ___TagDescriptor___ *, ao->___cachedCode___, tagd);
ao->___cachedCode___++;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebbb);
#endif
} else {
#else
struct ArrayObject * aonew=allocate_newarray(TAGARRAYTYPE,TAGARRAYINTERVAL+ao->___length___);
#endif
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebbc);
#endif
aonew->___cachedCode___=ao->___length___+1;
for(i=0;i<ao->___length___;i++) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebbd);
#endif
ARRAYSET(aonew, struct ___TagDescriptor___*, i, ARRAYGET(ao, struct ___TagDescriptor___*, i));
}
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebbe);
#endif
ARRAYSET(aonew, struct ___TagDescriptor___ *, ao->___length___, tagd);
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xebbf);
#endif
}
{
struct ___Object___ * tagset=tagd->flagptr;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xb008);
#endif
if(tagset==NULL) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xb009);
#endif
tagd->flagptr=obj;
ARRAYSET(ao, struct ___Object___ *, 1, obj);
ao->___cachedCode___=2;
tagd->flagptr=(struct ___Object___ *)ao;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xb00a);
#endif
} else {
struct ArrayObject *ao=(struct ArrayObject *) tagset;
if (ao->___cachedCode___<ao->___length___) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xb00b);
#endif
ARRAYSET(ao, struct ___Object___*, ao->___cachedCode___++, obj);
}
ARRAYSET(aonew, struct ___Object___ *, ao->___cachedCode___, obj);
tagd->flagptr=(struct ___Object___ *) aonew;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xb00c);
#endif
}
int oldflag=((int *)ptr)[1];
int flag=ormask|oldflag;
flag&=andmask;
-#ifdef RAW
+#ifdef RAWDEBUG
+ raw_test_pass_reg((int)ptr);
raw_test_pass(0xaa000000 + oldflag);
raw_test_pass(0xaa000000 + flag);
#endif
int oldflag=((int *)ptr)[1];
int flag=ormask|oldflag;
flag&=andmask;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xaa100000 + oldflag);
raw_test_pass(0xaa100000 + flag);
#endif
#endif
}
ptr->flag=flag;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xbb000000 + ptr->flag);
#endif
int andmask=parameter->intarray[i*2];
int checkmask=parameter->intarray[i*2+1];
if ((ptr->flag&andmask)==checkmask) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xcc000000 + andmask);
raw_test_pass_reg((int)ptr);
raw_test_pass(0xcc000000 + ptr->flag);
length = numqueues[corenum][ptr->type];
#endif
}
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa1);
raw_test_pass_reg(queues);
raw_test_pass_reg(length);
parameter = queues[j];
/* Check tags */
if (parameter->numbertags>0) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa2);
raw_test_pass_reg(tagptr);
#endif
goto nextloop;//that means the object has no tag but that param needs tag
else if(tagptr->type==TAGTYPE) {//one tag
struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa3);
#endif
for(i=0;i<parameter->numbertags;i++) {
//slotid is parameter->tagarray[2*i];
int tagid=parameter->tagarray[2*i+1];
if (tagid!=tagptr->flag) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa4);
#endif
goto nextloop; /*We don't have this tag */
}
} else {//multiple tags
struct ArrayObject * ao=(struct ArrayObject *) tagptr;
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa5);
#endif
for(i=0;i<parameter->numbertags;i++) {
goto foundtag;
}
}
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa6);
#endif
goto nextloop;
for(i=0;i<parameter->numberofterms;i++) {
int andmask=parameter->intarray[i*2];
int checkmask=parameter->intarray[i*2+1];
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa7);
raw_test_pass(0xcc000000 + andmask);
raw_test_pass_reg(ptr);
raw_test_pass(0xcc000000 + checkmask);
#endif
if ((ptr->flag&andmask)==checkmask) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xeaa8);
#endif
enqueuetasks_I(parameter, prevptr, ptr, NULL, 0);
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(0);
+#ifdef RAWDEBUG
raw_test_pass(0);
+#endif
gdn_send(msgsize);
+#ifdef RAWDEBUG
raw_test_pass_reg(msgsize);
+#endif
gdn_send(obj);
+#ifdef RAWDEBUG
raw_test_pass_reg(obj);
- //gdn_send(isshared);
- //raw_test_pass_reg(isshared);
+#endif
for(i = 0; i < transObj->length; ++i) {
int taskindex = transObj->queues[2*i];
int paramindex = transObj->queues[2*i+1];
gdn_send(taskindex);
+#ifdef RAWDEBUG
raw_test_pass_reg(taskindex);
+#endif
gdn_send(paramindex);
+#ifdef RAWDEBUG
raw_test_pass_reg(paramindex);
+#endif
}
+#ifdef RAWDEBUG
raw_test_pass(0xffff);
+#endif
++(self_numsendobjs);
#elif defined THREADSIMULATE
int numofcore = pthread_getspecific(key);
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(1);
+#ifdef RAWDEBUG
raw_test_pass(1);
+#endif
gdn_send(corenum);
+#ifdef RAWDEBUG
raw_test_pass_reg(corenum);
+#endif
gdn_send(self_numsendobjs);
+#ifdef RAWDEBUG
raw_test_pass_reg(self_numsendobjs);
+#endif
gdn_send(self_numreceiveobjs);
+#ifdef RAWDEBUG
raw_test_pass_reg(self_numreceiveobjs);
raw_test_pass(0xffff);
+#endif
return true;
#elif defined THREADSIMULATE
struct ___Object___ *newobj = RUNMALLOC(sizeof(struct ___Object___));
int self_y, self_x, target_y, target_x;
int targetcore = 0;
if(gdn_input_avail() == 0) {
+#ifdef RAWDEBUG
if(corenum < NUMCORES) {
raw_test_pass(0xd001);
}
+#endif
return -1;
}
msg:
+#ifdef RAWDEBUG
raw_test_pass(0xcccc);
+#endif
while((gdn_input_avail() != 0) && (msgdataindex < msglength)) {
msgdata[msgdataindex] = gdn_receive();
if(msgdataindex == 0) {
} else if((msgdataindex == 1) && (msgdata[0] == 0)) {
msglength = msgdata[msgdataindex];
}
+#ifdef RAWDEBUG
raw_test_pass_reg(msgdata[msgdataindex]);
+#endif
msgdataindex++;
/*if(msgdataindex == 0) {
msgdata = (int *)RUNMALLOC_I(msglength * sizeof(int));
msgdata[msgdataindex] = msgtype;
}
+#ifdef RAWDEBUG
raw_test_pass_reg(msgtype);
+#endif
} else if((msgdataindex == 1) && (msgtype == 0)) {
// object transfer msg
msglength = gdn_receive();
msgdata = (int *)RUNMALLOC_I(msglength * sizeof(int));
msgdata[0] = msgtype;
msgdata[msgdataindex] = msglength;
+#ifdef RAWDEBUG
raw_test_pass_reg(msgdata[msgdataindex]);
+#endif
} else {
msgdata[msgdataindex] = gdn_receive();
+#ifdef RAWDEBUG
raw_test_pass_reg(msgdata[msgdataindex]);
+#endif
}
msgdataindex++;*/
}
+#ifdef RAWDEBUG
raw_test_pass(0xffff);
+#endif
if(msgdataindex == msglength) {
// received a whole msg
int type, data1, data2; // will receive at least 3 words including type
transObj->queues = RUNMALLOC_I(sizeof(int)*(msglength - 3));
for(k = 0; k < transObj->length; ++k) {
transObj->queues[2*k] = msgdata[3+2*k];
+#ifdef RAWDEBUG
raw_test_pass_reg(transObj->queues[2*k]);
+#endif
transObj->queues[2*k+1] = msgdata[3+2*k+1];
+#ifdef RAWDEBUG
raw_test_pass_reg(transObj->queues[2*k+1]);
+#endif
}
//memcpy(transObj->queues, msgdata[3], sizeof(int)*(msglength - 3));
addNewItem_I(&objqueue, (void *)transObj);
++(self_numreceiveobjs);
+#ifdef RAWDEBUG
raw_test_pass(0xe881);
+#endif
/*
addNewItem_I(&objqueue, (void *)data2);
++(self_numreceiveobjs);
- raw_test_pass(0xe881);*/
+#ifdef RAWDEBUG
+ raw_test_pass(0xe881);
+#endif
+ */
break;
}
case 1: {
raw_test_done(0xa001);
}
if(data1 < NUMCORES) {
+#ifdef RAWDEBUG
raw_test_pass(0xe882);
+#endif
corestatus[data1] = 0;
numsendobjs[data1] = data2;
numreceiveobjs[data1] = msgdata[3];
// first time to operate on this shared object
// create a lock for it
// the lock is an integer: 0 -- stall, >0 -- read lock, -1 -- write lock
+#ifdef RAWDEBUG
raw_test_pass(0xe883);
+#endif
if(data1 == 0) {
RuntimeHashadd_I(locktbl, data2, 1);
} else {
}
} else {
int rwlock_obj = 0;
+#ifdef RAWDEBUG
raw_test_pass(0xe884);
+#endif
RuntimeHashget(locktbl, data2, &rwlock_obj);
+#ifdef RAWDEBUG
raw_test_pass_reg(rwlock_obj);
+#endif
if(0 == rwlock_obj) {
if(data1 == 0) {
rwlock_obj = 1;
} else {
deny = true;
}
+#ifdef RAWDEBUG
raw_test_pass_reg(rwlock_obj);
+#endif
}
targetcore = data3;
calCoords(corenum, &self_y, &self_x);
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
if(deny == true) {
// deny the lock request
gdn_send(4); // lock request
+#ifdef RAWDEBUG
raw_test_pass(4);
+#endif
} else {
// grount the lock request
gdn_send(3); // lock request
+#ifdef RAWDEBUG
raw_test_pass(3);
+#endif
}
gdn_send(data1); // lock type
+#ifdef RAWDEBUG
raw_test_pass_reg(data1);
+#endif
gdn_send(data2); // lock target
+#ifdef RAWDEBUG
raw_test_pass_reg(data2);
raw_test_pass(0xffff);
+#endif
break;
}
case 3: {
} else {
int rwlock_obj = 0;
RuntimeHashget(locktbl, data2, &rwlock_obj);
+#ifdef RAWDEBUG
raw_test_pass(0xe885);
raw_test_pass_reg(rwlock_obj);
+#endif
if(data1 == 0) {
rwlock_obj--;
} else {
}
RuntimeHashremovekey(locktbl, data2);
RuntimeHashadd_I(locktbl, data2, rwlock_obj);
+#ifdef RAWDEBUG
raw_test_pass_reg(rwlock_obj);
+#endif
}
break;
}
msgtype = -1;
//msgdataindex = 0;
msglength = 30;
+#ifdef RAWDEBUG
raw_test_pass(0xe886);
+#endif
if(gdn_input_avail() != 0) {
goto msg;
}
return type;
} else {
// not a whole msg
+#ifdef RAWDEBUG
raw_test_pass(0xe887);
+#endif
return -2;
}
#elif defined THREADSIMULATE
#ifdef RAW
unsigned msgHdr;
int self_y, self_x, target_y, target_x;
- int targetcore = ((int)ptr) % TOTALCORE;
+ int targetcore = ((int)ptr >> 1) % TOTALCORE;
// for 32 bit machine, the size is always 4 words
//int msgsize = sizeof(int) * 4;
int msgsize = 4;
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(2); // lock request
+ #ifdef RAWDEBUG
raw_test_pass(2);
+#endif
gdn_send(0); // read lock
+#ifdef RAWDEBUG
raw_test_pass(0);
+#endif
gdn_send(ptr);
+#ifdef RAWDEBUG
raw_test_pass_reg(ptr);
+#endif
gdn_send(corenum);
+#ifdef RAWDEBUG
raw_test_pass_reg(corenum);
raw_test_pass(0xffff);
+#endif
return true;
#elif defined THREADSIMULATE
int numofcore = pthread_getspecific(key);
#ifdef RAW
unsigned msgHdr;
int self_y, self_x, target_y, target_x;
- int targetcore = ((int)ptr) % TOTALCORE;
+ int targetcore = ((int)ptr >> 1) % TOTALCORE;
// for 32 bit machine, the size is always 3 words
//int msgsize = sizeof(int) * 3;
int msgsize = 3;
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(5); // lock release
+#ifdef RAWDEBUG
raw_test_pass(5);
+#endif
gdn_send(0); // read lock
+#ifdef RAWDEBUG
raw_test_pass(0);
+#endif
gdn_send(ptr);
+#ifdef RAWDEBUG
raw_test_pass_reg(ptr);
raw_test_pass(0xffff);
+#endif
#elif defined THREADSIMULATE
int numofcore = pthread_getspecific(key);
int rc = pthread_rwlock_rdlock(&rwlock_tbl);
bool getreadlock_I(void * ptr) {
unsigned msgHdr;
int self_y, self_x, target_y, target_x;
- int targetcore = ((int)ptr) % TOTALCORE;
+ int targetcore = ((int)ptr >> 1) % TOTALCORE;
// for 32 bit machine, the size is always 4 words
//int msgsize = sizeof(int) * 4;
int msgsize = 4;
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(2); // lock request
+#ifdef RAWDEBUG
raw_test_pass(2);
+#endif
gdn_send(0); // read lock
+#ifdef RAWDEBUG
raw_test_pass(0);
+#endif
gdn_send(ptr);
+#ifdef RAWDEBUG
raw_test_pass_reg(ptr);
+#endif
gdn_send(corenum);
+#ifdef RAWDEBUG
raw_test_pass_reg(corenum);
raw_test_pass(0xffff);
+#endif
return true;
}
void releasereadlock_I(void * ptr) {
unsigned msgHdr;
int self_y, self_x, target_y, target_x;
- int targetcore = ((int)ptr) % TOTALCORE;
+ int targetcore = ((int)ptr >> 1) % TOTALCORE;
// for 32 bit machine, the size is always 3 words
//int msgsize = sizeof(int) * 3;
int msgsize = 3;
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(5); // lock release
+#ifdef RAWDEBUG
raw_test_pass(5);
+#endif
gdn_send(0); // read lock
+#ifdef RAWDEBUG
raw_test_pass(0);
+#endif
gdn_send(ptr);
+#ifdef RAWDEBUG
raw_test_pass_reg(ptr);
raw_test_pass(0xffff);
+#endif
}
#endif
+// not reentrant
bool getwritelock(void * ptr) {
#ifdef RAW
unsigned msgHdr;
int self_y, self_x, target_y, target_x;
- int targetcore = ((int)ptr) % TOTALCORE;
+ int targetcore = ((int)ptr >> 1) % TOTALCORE;
// for 32 bit machine, the size is always 4 words
//int msgsize = sizeof(int) * 4;
int msgsize= 4;
+ int tc = TOTALCORE;
+#ifdef INTERRUPT
+ //raw_user_interrupts_off();
+#endif
+ //targetcore = ((int)ptr) % tc;
+#ifdef INTERRUPT
+ //raw_user_interrupts_on();
+#endif
+
+#ifdef RAWDEBUG
+ raw_test_pass(0xe551);
+ raw_test_pass_reg(ptr);
+ raw_test_pass_reg(targetcore);
+ raw_test_pass_reg(tc);
+#endif
lockobj = (int)ptr;
lockflag = false;
// first time to operate on this shared object
// create a lock for it
// the lock is an integer: 0 -- stall, >0 -- read lock, -1 -- write lock
+#ifdef RAWDEBUG
raw_test_pass(0xe552);
+#endif
RuntimeHashadd_I(locktbl, (int)ptr, -1);
} else {
int rwlock_obj = 0;
RuntimeHashget(locktbl, (int)ptr, &rwlock_obj);
+#ifdef RAWDEBUG
raw_test_pass(0xe553);
raw_test_pass_reg(rwlock_obj);
+#endif
if(0 == rwlock_obj) {
rwlock_obj = -1;
RuntimeHashremovekey(locktbl, (int)ptr);
#ifdef INTERRUPT
raw_user_interrupts_on();
#endif
+#ifdef RAWDEBUG
raw_test_pass(0xe554);
raw_test_pass_reg(lockresult);
+#endif
if(lockobj == (int)ptr) {
if(deny) {
lockresult = 0;
+#ifdef RAWDEBUG
raw_test_pass(0);
+#endif
} else {
lockresult = 1;
- raw_test_pass(1);
+#ifdef RAWDEBUG
+ raw_test_pass(1);
+#endif
}
lockflag = true;
#ifndef INTERRUPT
return true;
}
+#ifdef RAWDEBUG
raw_test_pass(0xe555);
+#endif
calCoords(corenum, &self_y, &self_x);
calCoords(targetcore, &target_y, &target_x);
// Build the message header
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
gdn_send(2); // lock request
+#ifdef RAWDEBUG
raw_test_pass(2);
+#endif
gdn_send(1); // write lock
+#ifdef RAWDEBUG
raw_test_pass(1);
+#endif
gdn_send(ptr);
+#ifdef RAWDEBUG
raw_test_pass_reg(ptr);
+#endif
gdn_send(corenum);
+#ifdef RAWDEBUG
raw_test_pass_reg(corenum);
raw_test_pass(0xffff);
+#endif
return true;
#elif defined THREADSIMULATE
int numofcore = pthread_getspecific(key);
#ifdef RAW
unsigned msgHdr;
int self_y, self_x, target_y, target_x;
- int targetcore = ((int)ptr) % TOTALCORE;
+ int targetcore = ((int)ptr >> 1) % TOTALCORE;
// for 32 bit machine, the size is always 3 words
//int msgsize = sizeof(int) * 3;
int msgsize = 3;
raw_test_done(0xa008);
} else {
int rwlock_obj = 0;
+#ifdef RAWDEBUG
raw_test_pass(0xe662);
+#endif
RuntimeHashget(locktbl, (int)ptr, &rwlock_obj);
+#ifdef RAWDEBUG
raw_test_pass_reg(rwlock_obj);
+#endif
rwlock_obj++;
RuntimeHashremovekey(locktbl, (int)ptr);
RuntimeHashadd_I(locktbl, (int)ptr, rwlock_obj);
+#ifdef RAWDEBUG
raw_test_pass_reg(rwlock_obj);
+#endif
}
#ifdef INTERRUPT
raw_user_interrupts_on();
return;
}
+#ifdef RAWDEBUG
raw_test_pass(0xe663);
+#endif
calCoords(corenum, &self_y, &self_x);
calCoords(targetcore, &target_y, &target_x);
// Build the message header
self_y, self_x,
target_y, target_x);
gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
raw_test_pass(0xbbbb);
raw_test_pass(0xb000 + targetcore);
+#endif
gdn_send(5); // lock release
+ #ifdef RAWDEBUG
raw_test_pass(5);
+#endif
gdn_send(1); // write lock
+#ifdef RAWDEBUG
raw_test_pass(1);
+#endif
gdn_send(ptr);
+#ifdef RAWDEBUG
raw_test_pass_reg(ptr);
raw_test_pass(0xffff);
+#endif
#elif defined THREADSIMULATE
int numofcore = pthread_getspecific(key);
int rc = pthread_rwlock_rdlock(&rwlock_tbl);
struct parameterwrapper *pw=NULL;
int j = 0;
int x = 0;
+ bool lock = true;
#ifdef RAW
int grount = 0;
int andmask=0;
int checkmask=0;
-
+#ifdef RAWDEBUG
raw_test_pass(0xe991);
#endif
+#endif
#ifndef RAW
/* Set up signal handlers */
while((hashsize(activetasks)>0)||(maxreadfd>0)) {
#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xe992);
+#endif
#else
/* Check if any filedescriptors have IO pending */
if (maxreadfd>0) {
for(i=0;i<numparams;i++) {
void * parameter=currtpd->parameterArray[i];
#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xe993);
- // require locks for this parameter
+#endif
+
+ if(((struct ___Object___ *)parameter)->type == STARTUPTYPE) {
+ lock = false;
+ taskpointerarray[i+OFFSET]=parameter;
+ goto execute;
+ }
+ // require locks for this parameter if it is not a startup object
getwritelock(parameter);
grount = 0;
+
+#ifdef INTERRUPT
raw_user_interrupts_off();
+#endif
while(!lockflag) {
-//#ifndef INTERRUPT
receiveObject();
-//#endif
}
#ifndef INTERRUPT
if(reside) {
#ifndef INTERRUPT
reside = false;
#endif
+#ifdef INTERRUPT
raw_user_interrupts_on();
+#endif
if(grount == 0) {
+#ifdef RAWDEBUG
raw_test_pass(0xe994);
+#endif
// can not get the lock, try later
for(j = 0; j < i; ++j) {
releasewritelock(taskpointerarray[j+OFFSET]);
}
genputtable(activetasks, currtpd, currtpd);
+ if(hashsize(activetasks) == 1) {
+ // only one task right now, wait a little while before next try
+ int halt = 10000;
+ while(halt--){}
+ }
goto newtask;
}
// flush the object
{
- int tmp = 0;
+ raw_invalidate_cache_range((int)parameter, classsize[((struct ___Object___ *)parameter)->type]);
+ /*int tmp = 0;
for(tmp = 0; tmp < classsize[((struct ___Object___ *)parameter)->type]; ++tmp) {
invalidateAddr(parameter + tmp);
- }
+ }*/
}
#endif
tmpparam = (struct ___Object___ *)parameter;
#ifdef THREADSIMULATE
+ if(((struct ___Object___ *)parameter)->type == STARTUPTYPE) {
+ lock = false;
+ taskpointerarray[i+OFFSET]=parameter;
+ goto execute;
+ }
if(0 == tmpparam->isolate) {
isolateflags[i] = 0;
// shared object, need to flush with current value
/* Check that object is still in queue */
{
if (!ObjectHashcontainskey(pw->objectset, (int) parameter)) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xe995);
#endif
// release grabbed locks
for(tmpi = 0; tmpi < pw->numberofterms; ++tmpi) {
andmask=pw->intarray[tmpi*2];
checkmask=pw->intarray[tmpi*2+1];
+#ifdef RAWDEBUG
raw_test_pass(0xdd000000 + andmask);
raw_test_pass_reg((int)parameter);
raw_test_pass(0xdd000000 + ((struct ___Object___ *)parameter)->flag);
raw_test_pass(0xdd000000 + checkmask);
+#endif
if((((struct ___Object___ *)parameter)->flag&andmask)==checkmask) {
ismet = true;
break;
int next;
int UNUSED, UNUSED2;
int * enterflags;
+#ifdef RAWDEBUG
raw_test_pass(0xe996);
+#endif
ObjectHashget(pw->objectset, (int) parameter, (int *) &next, (int *) &enterflags, &UNUSED, &UNUSED2);
ObjectHashremove(pw->objectset, (int)parameter);
if (enterflags!=NULL)
int slotid=pd->tagarray[2*j]+numparams;
struct ___TagDescriptor___ *tagd=currtpd->parameterArray[slotid];
if (!containstag(parameter, tagd)) {
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xe997);
#endif
RUNFREE(currtpd->parameterArray);
*/
//fflush(stdout);
#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass_reg(x);
+#endif
raw_test_done(0xa009);
#else
exit(-1);
((int *)taskpointerarray)[0]=currtpd->numParameters;
taskpointerarray[1]=NULL;
#endif
+execute:
if(debugtask){
#ifndef RAW
printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
#ifndef RAW
printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
#endif
- } else
+ } else {
((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
+ }
+ if(lock) {
#ifdef RAW
- for(i = 0; i < numparams; ++i) {
+ for(i = 0; i < numparams; ++i) {
int j = 0;
struct ___Object___ * tmpparam = (struct ___Object___ *)taskpointerarray[i+OFFSET];
+#ifdef RAWDEBUG
raw_test_pass(0xe998);
raw_test_pass(0xdd100000 + tmpparam->flag);
+#endif
releasewritelock(tmpparam);
}
#elif defined THREADSIMULATE
}
}
#endif
+ }
#if 0
#ifndef RAW
}
}
}
-#ifdef RAW
+#ifdef RAWDEBUG
raw_test_pass(0xe999);
#endif
}