From: jzhou Date: Fri, 1 Aug 2008 07:15:27 +0000 (+0000) Subject: fix some bugs in multi-core version codes generation and runtime X-Git-Tag: preEdgeChange~47 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=71d0bd22fd98e87e779742b3e4283d2659437a58;p=IRC.git fix some bugs in multi-core version codes generation and runtime --- diff --git a/Robust/src/Analysis/Scheduling/SchedulingUtil.java b/Robust/src/Analysis/Scheduling/SchedulingUtil.java index bfa84075..37ff1981 100644 --- a/Robust/src/Analysis/Scheduling/SchedulingUtil.java +++ b/Robust/src/Analysis/Scheduling/SchedulingUtil.java @@ -159,9 +159,9 @@ public class SchedulingUtil { } 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];"); } } } @@ -299,14 +299,19 @@ public class SchedulingUtil { // time coordinate nodes Vector timeNodes = new Vector(); 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 tmplastTasks = new Hashtable(); + Vector tmpisTaskFinish = new Vector(); + Vector tmpisset = new Vector(); String tnode = String.valueOf(tcp.getTimepoint()); if(!timeNodes.contains(tnode)) { timeNodes.add(tnode); @@ -316,6 +321,12 @@ public class SchedulingUtil { 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; @@ -333,11 +344,11 @@ public class SchedulingUtil { 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(";"); @@ -353,10 +364,16 @@ public class SchedulingUtil { 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"); } @@ -377,12 +394,19 @@ public class SchedulingUtil { 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"); } @@ -393,6 +417,7 @@ public class SchedulingUtil { tmpLabel.append("\\n"); } tmpLabel.append("<" + taction.getTd().getSymbol() + ">starts;"); + lastTasks[cNum] = taction.getTd().getSymbol(); if (!(lastTaskNodes[cNum].equals(tmpTaskNode))) { output.print("\t"); @@ -401,13 +426,13 @@ public class SchedulingUtil { } 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: { @@ -415,12 +440,20 @@ public class SchedulingUtil { 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"); } @@ -432,11 +465,19 @@ public class SchedulingUtil { } 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"); } diff --git a/Robust/src/ClassLibrary/Math.java b/Robust/src/ClassLibrary/Math.java index e55c0cf5..247ce63a 100644 --- a/Robust/src/ClassLibrary/Math.java +++ b/Robust/src/ClassLibrary/Math.java @@ -25,4 +25,9 @@ public class Math { public static native double sqrt(double a); public static native double log(double a); public static native double pow(double a, double b); + + public static native float sinf(float a); + public static native float cosf(float a); + public static native float sqrtf(float a); + public static native float powf(float a, float b); } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 21031ba1..b6679ed2 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -315,7 +315,6 @@ public class BuildCode { outmethod.println("#include \"methodheaders.h\""); outmethod.println("#include \"virtualtable.h\""); outmethod.println("#include \"runtime.h\""); - //outmethod.println("#include \"dstm.h\""); if (state.DSM) { outmethod.println("#include \"dstm.h\""); outmethod.println("#include \"localobjects.h\""); diff --git a/Robust/src/IR/Flat/BuildCodeMultiCore.java b/Robust/src/IR/Flat/BuildCodeMultiCore.java index 57a03264..f737624d 100644 --- a/Robust/src/IR/Flat/BuildCodeMultiCore.java +++ b/Robust/src/IR/Flat/BuildCodeMultiCore.java @@ -612,9 +612,11 @@ public class BuildCodeMultiCore extends BuildCode { output.println("for(;tmpindex < tmplen; tmpindex++) {"); output.println(" tmpsum = tmpsum * 10 + *(taskname + tmpindex) - '0';"); output.println("}"); + output.println("#ifdef RAWDEBUG"); output.println("raw_test_pass(0xAAAA);"); output.println("raw_test_pass_reg(tmpsum);"); output.println("#endif"); + output.println("#endif"); for(int i = 0; i < fm.numParameters(); ++i) { TempDescriptor temp = fm.getParameter(i); @@ -645,7 +647,8 @@ public class BuildCodeMultiCore extends BuildCode { output.print(" "); super.generateFlatNode(fm, lb, current_node, output); if (current_node.kind()!=FKind.FlatReturnNode) { - output.println(" flushAll();"); + //output.println(" flushAll();"); + output.println("raw_flush_entire_cache();"); outputTransCode(output); output.println(" return;"); } @@ -1221,7 +1224,8 @@ public class BuildCodeMultiCore extends BuildCode { output.println("return "+generateTemp(fm, frn.getReturnTemp(), lb)+";"); } else { if(fm.getTask() != null) { - output.println("flushAll();"); + //output.println("flushAll();"); + output.println("raw_flush_entire_cache();"); outputTransCode(output); } output.println("return;"); diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index a082dd1f..be373de8 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -305,7 +305,14 @@ public class Main { //int newRate = tint; //int newRate = (j+1)%2+1; int newRate = 1; - //int newRate = 10; + String cdname = cd.getSymbol(); + if(cdname.equals("SeriesRunner")) { + newRate = 10; + } else if(cdname.equals("MapWorker")) { + newRate = 6; + } else if(cdname.equals("ReduceWorker")) { + newRate = 3; + } /*do { tint = r.nextInt()%100; } while(tint <= 0); @@ -407,8 +414,9 @@ public class Main { } if(state.MULTICORE) { - it_scheduling = scheduleAnalysis.getSchedulingsIter(); - Vector scheduling = (Vector)it_scheduling.next(); + //it_scheduling = scheduleAnalysis.getSchedulingsIter(); + //Vector scheduling = (Vector)it_scheduling.next(); + Vector scheduling = scheduleAnalysis.getSchedulings().elementAt(selectedScheduling.elementAt(0)); BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, bf.getMap(), tu, sa, scheduling, scheduleAnalysis.getCoreNum(), pa); bcm.buildCode(); } diff --git a/Robust/src/Makefile.raw.1 b/Robust/src/Makefile.raw.1 index beb104ed..153d672a 100644 --- a/Robust/src/Makefile.raw.1 +++ b/Robust/src/Makefile.raw.1 @@ -2,7 +2,7 @@ TOPDIR=/home/jzhou/starsearch include $(TOPDIR)/Makefile.include RGCCFLAGS += -O2 -RGCCFLAGS += -DTASK -DMULTICORE -DRAW -DY1 +RGCCFLAGS += ${RAWRGCCFLAGS} SIM-CYCLES = 10000 diff --git a/Robust/src/Makefile.raw.2 b/Robust/src/Makefile.raw.2 index 51996c24..1094a2c0 100644 --- a/Robust/src/Makefile.raw.2 +++ b/Robust/src/Makefile.raw.2 @@ -2,7 +2,7 @@ TOPDIR=/home/jzhou/starsearch include $(TOPDIR)/Makefile.include RGCCFLAGS += -O2 -RGCCFLAGS += -DTASK -DMULTICORE -DRAW -DY2 +RGCCFLAGS += ${RAWRGCCFLAGS} SIM-CYCLES = 10000 diff --git a/Robust/src/Makefile.raw.4 b/Robust/src/Makefile.raw.4 index d7b768fa..f0749b01 100644 --- a/Robust/src/Makefile.raw.4 +++ b/Robust/src/Makefile.raw.4 @@ -2,7 +2,7 @@ TOPDIR=/home/jzhou/starsearch include $(TOPDIR)/Makefile.include RGCCFLAGS += -O2 -RGCCFLAGS += -DTASK -DMULTICORE -DRAW -DY4 +RGCCFLAGS += ${RAWRGCCFLAGS} SIM-CYCLES = 10000 diff --git a/Robust/src/Makefile.raw.i.1 b/Robust/src/Makefile.raw.i.1 index fe4c9f8f..5c80e08e 100644 --- a/Robust/src/Makefile.raw.i.1 +++ b/Robust/src/Makefile.raw.i.1 @@ -2,7 +2,7 @@ TOPDIR=/home/jzhou/starsearch include $(TOPDIR)/Makefile.include RGCCFLAGS += -O2 -RGCCFLAGS += -DTASK -DMULTICORE -DRAW -DINTERRUPT -DY1 +RGCCFLAGS += ${RAWRGCCFLAGS} SIM-CYCLES = 10000 diff --git a/Robust/src/Makefile.raw.i.2 b/Robust/src/Makefile.raw.i.2 index 00afada2..1094a2c0 100644 --- a/Robust/src/Makefile.raw.i.2 +++ b/Robust/src/Makefile.raw.i.2 @@ -2,7 +2,7 @@ TOPDIR=/home/jzhou/starsearch include $(TOPDIR)/Makefile.include RGCCFLAGS += -O2 -RGCCFLAGS += -DTASK -DMULTICORE -DRAW -DINTERRUPT -DY2 +RGCCFLAGS += ${RAWRGCCFLAGS} SIM-CYCLES = 10000 diff --git a/Robust/src/Makefile.raw.i.4 b/Robust/src/Makefile.raw.i.4 index e8f40f88..f0749b01 100644 --- a/Robust/src/Makefile.raw.i.4 +++ b/Robust/src/Makefile.raw.i.4 @@ -2,7 +2,7 @@ TOPDIR=/home/jzhou/starsearch include $(TOPDIR)/Makefile.include RGCCFLAGS += -O2 -RGCCFLAGS += -DTASK -DMULTICORE -DRAW -DINTERRUPT -DY4 +RGCCFLAGS += ${RAWRGCCFLAGS} SIM-CYCLES = 10000 diff --git a/Robust/src/Runtime/GenericHashtable.c b/Robust/src/Runtime/GenericHashtable.c index 44782c6c..7528b01e 100755 --- a/Robust/src/Runtime/GenericHashtable.c +++ b/Robust/src/Runtime/GenericHashtable.c @@ -232,22 +232,22 @@ struct genhashtable * genallocatehashtable(unsigned int (*hash_function)(void *) struct genpointerlist **gpl; int i; -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xf000); #endif gpl=(struct genpointerlist **) RUNMALLOC(sizeof(struct genpointerlist *)*geninitialnumbins); -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xf001); #endif for(i=0;ihash_function=hash_function; @@ -257,7 +257,7 @@ struct genhashtable * genallocatehashtable(unsigned int (*hash_function)(void *) ght->counter=0; ght->list=NULL; ght->last=NULL; -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xf004); #endif return ght; diff --git a/Robust/src/Runtime/math.c b/Robust/src/Runtime/math.c index 8baaf3fb..3140f1c0 100644 --- a/Robust/src/Runtime/math.c +++ b/Robust/src/Runtime/math.c @@ -41,3 +41,19 @@ double CALL11(___Math______sqrt____D, double ___a___, double ___a___) { double CALL22(___Math______pow____D_D, double ___a___, double ___b___, double ___a___, double ___b___) { return pow(___a___,___b___); } + +float CALL11(___Math______cosf____F, float ___a___, float ___a___) { + return cosf(___a___); +} + +float CALL11(___Math______sinf____F, float ___a___, float ___a___) { + return sinf(___a___); +} + +float CALL11(___Math______sqrtf____F, float ___a___, float ___a___) { + return sqrtf(___a___); +} + +float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a___, float ___b___) { + return powf(___a___,___b___); +} diff --git a/Robust/src/Runtime/mem.c b/Robust/src/Runtime/mem.c index 2de0dc97..3c1f8d5a 100644 --- a/Robust/src/Runtime/mem.c +++ b/Robust/src/Runtime/mem.c @@ -16,15 +16,19 @@ void * mycalloc(int m, int size) { void * p = NULL; int isize = 2*kCacheLineSize-4+(size-1)&(~kCacheLineMask); +#ifdef RAWDEBUG raw_test_pass(0xdd00); +#endif #ifdef INTERRUPT // shut down interrupt raw_user_interrupts_off(); #endif p = calloc(m, isize); //p = m_calloc(m, isize); +#ifdef RAWDEBUG raw_test_pass_reg(p); raw_test_pass_reg((kCacheLineSize+((int)p-1)&(~kCacheLineMask))); +#endif #ifdef INTERRUPT // re-open interruption raw_user_interrupts_on(); @@ -35,11 +39,15 @@ void * mycalloc(int m, int size) { void * mycalloc_i(int m, int size) { void * p = NULL; int isize = 2*kCacheLineSize-4+(size-1)&(~kCacheLineMask); +#ifdef RAWDEBUG raw_test_pass(0xdd00); +#endif p = calloc(m, isize); //p = m_calloc(m, isize); +#ifdef RAWDEBUG raw_test_pass_reg(p); raw_test_pass_reg((kCacheLineSize+((int)p-1)&(~kCacheLineMask))); +#endif return (void *)(kCacheLineSize+((int)p-1)&(~kCacheLineMask)); } diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index 6be7c0a7..0a52d3d7 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -73,7 +73,6 @@ int msgtype; 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 { @@ -104,39 +103,7 @@ void releasereadlock_I(void* ptr); 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) { @@ -154,10 +121,9 @@ 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 @@ -178,7 +144,9 @@ int main(int argc, char **argv) { 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; @@ -196,7 +164,9 @@ int main(int argc, char **argv) { #endif objqueue.head = NULL; objqueue.tail = NULL; +#ifdef RAWDEBUG raw_test_pass(0xee03); +#endif #ifdef INTERRUPT if (corenum < NUMCORES) { @@ -205,7 +175,9 @@ int main(int argc, char **argv) { //setup_interrupts(); //start_gdn_avail_ints(recvMsg); raw_user_interrupts_on(); +#ifdef RAWDEBUG raw_test_pass(0xee04); +#endif } #endif @@ -302,7 +274,7 @@ void run(void* arg) { processOptions(); #endif initializeexithandler(); -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xee05); #endif /* Create table for failed tasks */ @@ -314,35 +286,41 @@ void run(void* arg) { 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 @@ -358,31 +336,41 @@ void run(void* arg) { } #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; @@ -393,17 +381,20 @@ void run(void* arg) { 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); @@ -424,15 +415,21 @@ void run(void* arg) { #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 @@ -443,9 +440,13 @@ void run(void* arg) { 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; @@ -458,15 +459,22 @@ void run(void* arg) { 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. } } @@ -475,23 +483,33 @@ void run(void* arg) { #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 } } } @@ -654,7 +672,8 @@ void createstartupobject(int argc, char ** argv) { flagorandinit(startupobject,1,0xFFFFFFFF); enqueueObject(startupobject, NULL, 0); #ifdef RAW - flushAll(); + //flushAll(); + raw_flush_entire_cache(); #endif } @@ -685,11 +704,11 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) { #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; @@ -697,11 +716,11 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * 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; @@ -713,47 +732,47 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) { 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___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______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 { @@ -766,21 +785,21 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) { #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___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 } @@ -789,11 +808,11 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) { { 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; @@ -810,13 +829,13 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) { 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______length___) { -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xb00b); #endif ARRAYSET(ao, struct ___Object___*, ao->___cachedCode___++, obj); @@ -837,7 +856,7 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) { } ARRAYSET(aonew, struct ___Object___ *, ao->___cachedCode___, obj); tagd->flagptr=(struct ___Object___ *) aonew; -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xb00c); #endif } @@ -947,7 +966,8 @@ void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** q 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 @@ -973,7 +993,7 @@ void flagorandinit(void * ptr, int ormask, int andmask) { 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 @@ -1007,7 +1027,7 @@ void flagbody(struct ___Object___ *ptr, int flag, struct parameterwrapper ** vqu #endif } ptr->flag=flag; -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xbb000000 + ptr->flag); #endif @@ -1088,7 +1108,7 @@ void flagbody(struct ___Object___ *ptr, int flag, struct parameterwrapper ** vqu 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); @@ -1133,7 +1153,7 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt length = numqueues[corenum][ptr->type]; #endif } -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xeaa1); raw_test_pass_reg(queues); raw_test_pass_reg(length); @@ -1146,7 +1166,7 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt parameter = queues[j]; /* Check tags */ if (parameter->numbertags>0) { -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xeaa2); raw_test_pass_reg(tagptr); #endif @@ -1154,14 +1174,14 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt 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;inumbertags;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 */ @@ -1169,7 +1189,7 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt } } else {//multiple tags struct ArrayObject * ao=(struct ArrayObject *) tagptr; -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xeaa5); #endif for(i=0;inumbertags;i++) { @@ -1181,7 +1201,7 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt goto foundtag; } } -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xeaa6); #endif goto nextloop; @@ -1195,7 +1215,7 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt for(i=0;inumberofterms;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); @@ -1203,7 +1223,7 @@ void enqueueObject_I(void * vptr, struct parameterwrapper ** vqueues, int vlengt 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); @@ -1270,25 +1290,37 @@ void transferObject(struct transObjInfo * transObj) { 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); @@ -1372,17 +1404,27 @@ bool transStallMsg(int targetcore) { 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___)); @@ -1460,13 +1502,17 @@ int receiveObject() { 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) { @@ -1478,7 +1524,9 @@ msg: } else if((msgdataindex == 1) && (msgdata[0] == 0)) { msglength = msgdata[msgdataindex]; } +#ifdef RAWDEBUG raw_test_pass_reg(msgdata[msgdataindex]); +#endif msgdataindex++; /*if(msgdataindex == 0) { @@ -1493,21 +1541,29 @@ msg: 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 @@ -1528,18 +1584,27 @@ msg: 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: { @@ -1550,7 +1615,9 @@ msg: raw_test_done(0xa001); } if(data1 < NUMCORES) { +#ifdef RAWDEBUG raw_test_pass(0xe882); +#endif corestatus[data1] = 0; numsendobjs[data1] = data2; numreceiveobjs[data1] = msgdata[3]; @@ -1571,7 +1638,9 @@ msg: // 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 { @@ -1579,9 +1648,13 @@ msg: } } 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; @@ -1598,7 +1671,9 @@ msg: } else { deny = true; } +#ifdef RAWDEBUG raw_test_pass_reg(rwlock_obj); +#endif } targetcore = data3; calCoords(corenum, &self_y, &self_x); @@ -1608,22 +1683,32 @@ msg: 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: { @@ -1668,8 +1753,10 @@ msg: } 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 { @@ -1677,7 +1764,9 @@ msg: } RuntimeHashremovekey(locktbl, data2); RuntimeHashadd_I(locktbl, data2, rwlock_obj); +#ifdef RAWDEBUG raw_test_pass_reg(rwlock_obj); +#endif } break; } @@ -1692,14 +1781,18 @@ msg: 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 @@ -1766,7 +1859,7 @@ bool getreadlock(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; @@ -1828,17 +1921,27 @@ bool getreadlock(void * ptr) { 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); @@ -1901,7 +2004,7 @@ void releasereadlock(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 3 words //int msgsize = sizeof(int) * 3; int msgsize = 3; @@ -1934,15 +2037,23 @@ void releasereadlock(void * ptr) { 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); @@ -1964,7 +2075,7 @@ void releasereadlock(void * ptr) { 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; @@ -2020,24 +2131,34 @@ bool getreadlock_I(void * ptr) { 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; @@ -2064,26 +2185,50 @@ void releasereadlock_I(void * ptr) { 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; @@ -2103,13 +2248,17 @@ bool getwritelock(void * ptr) { // 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); @@ -2121,15 +2270,21 @@ bool getwritelock(void * 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 @@ -2142,7 +2297,9 @@ bool getwritelock(void * ptr) { 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 @@ -2150,17 +2307,27 @@ bool getwritelock(void * ptr) { 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); @@ -2226,7 +2393,7 @@ void releasewritelock(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 3 words //int msgsize = sizeof(int) * 3; int msgsize = 3; @@ -2241,13 +2408,19 @@ void releasewritelock(void * ptr) { 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(); @@ -2255,7 +2428,9 @@ void releasewritelock(void * ptr) { return; } +#ifdef RAWDEBUG raw_test_pass(0xe663); +#endif calCoords(corenum, &self_y, &self_x); calCoords(targetcore, &target_y, &target_x); // Build the message header @@ -2263,15 +2438,23 @@ void releasewritelock(void * ptr) { 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); @@ -2496,14 +2679,16 @@ void executetasks() { 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 */ @@ -2537,7 +2722,9 @@ void executetasks() { 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) { @@ -2589,15 +2776,24 @@ void executetasks() { for(i=0;iparameterArray[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) { @@ -2613,27 +2809,42 @@ void executetasks() { #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 @@ -2695,7 +2906,7 @@ void executetasks() { /* 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 @@ -2716,10 +2927,12 @@ void executetasks() { 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; @@ -2731,7 +2944,9 @@ void executetasks() { 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) @@ -2754,7 +2969,7 @@ void executetasks() { 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); @@ -2810,7 +3025,9 @@ void executetasks() { */ //fflush(stdout); #ifdef RAW +#ifdef RAWDEBUG raw_test_pass_reg(x); +#endif raw_test_done(0xa009); #else exit(-1); @@ -2827,6 +3044,7 @@ void executetasks() { ((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)); @@ -2835,15 +3053,19 @@ void executetasks() { #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 @@ -2854,6 +3076,7 @@ void executetasks() { } } #endif + } #if 0 #ifndef RAW @@ -2875,7 +3098,7 @@ void executetasks() { } } } -#ifdef RAW +#ifdef RAWDEBUG raw_test_pass(0xe999); #endif } diff --git a/Robust/src/Runtime/raw_dataCache.s b/Robust/src/Runtime/raw_dataCache.s index 97230fad..566bf221 100644 --- a/Robust/src/Runtime/raw_dataCache.s +++ b/Robust/src/Runtime/raw_dataCache.s @@ -2,7 +2,7 @@ .global flushAddr .global invalidateAddr .global flushCacheline - +.global invalidateCacheline flushAddr: # arguments come in on $4 and $5 @@ -29,3 +29,12 @@ flushCacheline: tagfl $4 jr $31 +invalidateCacheline: +# arguments come in on $4 +# $4 has the base tag address + + tagsw $0, $4 +# mtsri PASS, 0x1111 +# mtsr PASS, $8 +# ainv $8, 0 + jr $31 diff --git a/Robust/src/Runtime/raw_interrupt.s b/Robust/src/Runtime/raw_interrupt.s index 2498ff50..0cc4a308 100644 --- a/Robust/src/Runtime/raw_interrupt.s +++ b/Robust/src/Runtime/raw_interrupt.s @@ -52,48 +52,70 @@ vec_extern: vec_timer: empty_vec 0x2304 vec_gdn_avail: - mtsri PASS, 0xef00 +# mtsri PASS, 0xef00 uintoff - addiu $sp,$sp,-64 - sw $31,0x3c($sp) - sw $30,0x38($sp) - sw $23,0x34($sp) - sw $22,0x30($sp) - sw $21,0x2c($sp) - sw $20,0x28($sp) - sw $19,0x24($sp) - sw $18,0x20($sp) - sw $17,0x1c($sp) - sw $16,0x18($sp) - sw $7,0x14($sp) - sw $6,0x10($sp) - sw $5,0xc($sp) - sw $4,0x8($sp) - sw $3,0x4($sp) - sw $2,0x0($sp) + addiu $sp,$sp,-104 + sw $31,0x64($sp) + sw $30,0x60($sp) + sw $23,0x5c($sp) + sw $22,0x58($sp) + sw $21,0x54($sp) + sw $20,0x50($sp) + sw $19,0x4c($sp) + sw $18,0x48($sp) + sw $17,0x44($sp) + sw $16,0x40($sp) + sw $15,0x3c($sp) + sw $14,0x38($sp) + sw $13,0x34($sp) + sw $12,0x30($sp) + sw $11,0x2c($sp) + sw $10,0x28($sp) + sw $9,0x24($sp) + sw $8,0x20($sp) + sw $7,0x1c($sp) + sw $6,0x18($sp) + sw $5,0x14($sp) + sw $4,0x10($sp) + sw $3,0xc($sp) + sw $2,0x8($sp) + .set noat + sw $1,0x4($sp) + .set at jal receiveObject - lw $31,0x3c($sp) - lw $30,0x38($sp) - lw $23,0x34($sp) - lw $22,0x30($sp) - lw $21,0x2c($sp) - lw $20,0x28($sp) - lw $19,0x24($sp) - lw $18,0x20($sp) - lw $17,0x1c($sp) - lw $16,0x18($sp) - lw $7,0x14($sp) - lw $6,0x10($sp) - lw $5,0xc($sp) - lw $4,0x8($sp) - lw $3,0x4($sp) - lw $2,0x0($sp) - addiu $sp,$sp,64 + lw $31,0x64($sp) + lw $30,0x60($sp) + lw $23,0x5c($sp) + lw $22,0x58($sp) + lw $21,0x54($sp) + lw $20,0x50($sp) + lw $19,0x4c($sp) + lw $18,0x48($sp) + lw $17,0x44($sp) + lw $16,0x40($sp) + lw $15,0x3c($sp) + lw $14,0x38($sp) + lw $13,0x34($sp) + lw $12,0x30($sp) + lw $11,0x2c($sp) + lw $10,0x28($sp) + lw $9,0x24($sp) + lw $8,0x20($sp) + lw $7,0x1c($sp) + lw $6,0x18($sp) + lw $5,0x14($sp) + lw $4,0x10($sp) + lw $3,0xc($sp) + lw $2,0x8($sp) + .set noat + lw $1,0x4($sp) + .set at + addiu $sp,$sp,104 - mtsri PASS, 0xefff +# mtsri PASS, 0xefff dret vec_event_counters: empty_vec 0x2306 diff --git a/Robust/src/Runtime/raw_interrupt2.s b/Robust/src/Runtime/raw_interrupt2.s index 6c8620c7..27c6af13 100644 --- a/Robust/src/Runtime/raw_interrupt2.s +++ b/Robust/src/Runtime/raw_interrupt2.s @@ -52,48 +52,70 @@ vec_extern: vec_timer: empty_vec 0x2304 vec_gdn_avail: - mtsri PASS, 0xef00 +# mtsri PASS, 0xef00 uintoff - addiu $sp,$sp,-64 - sw $31,0x3c($sp) - sw $30,0x38($sp) - sw $23,0x34($sp) - sw $22,0x30($sp) - sw $21,0x2c($sp) - sw $20,0x28($sp) - sw $19,0x24($sp) - sw $18,0x20($sp) - sw $17,0x1c($sp) - sw $16,0x18($sp) - sw $7,0x14($sp) - sw $6,0x10($sp) - sw $5,0xc($sp) - sw $4,0x8($sp) - sw $3,0x4($sp) - sw $2,0x0($sp) + addiu $sp,$sp,-104 + sw $31,0x64($sp) + sw $30,0x60($sp) + sw $23,0x5c($sp) + sw $22,0x58($sp) + sw $21,0x54($sp) + sw $20,0x50($sp) + sw $19,0x4c($sp) + sw $18,0x48($sp) + sw $17,0x44($sp) + sw $16,0x40($sp) + sw $15,0x3c($sp) + sw $14,0x38($sp) + sw $13,0x34($sp) + sw $12,0x30($sp) + sw $11,0x2c($sp) + sw $10,0x28($sp) + sw $9,0x24($sp) + sw $8,0x20($sp) + sw $7,0x1c($sp) + sw $6,0x18($sp) + sw $5,0x14($sp) + sw $4,0x10($sp) + sw $3,0xc($sp) + sw $2,0x8($sp) + .set noat + sw $1,0x4($sp) + .set at jal receiveObject - lw $31,0x3c($sp) - lw $30,0x38($sp) - lw $23,0x34($sp) - lw $22,0x30($sp) - lw $21,0x2c($sp) - lw $20,0x28($sp) - lw $19,0x24($sp) - lw $18,0x20($sp) - lw $17,0x1c($sp) - lw $16,0x18($sp) - lw $7,0x14($sp) - lw $6,0x10($sp) - lw $5,0xc($sp) - lw $4,0x8($sp) - lw $3,0x4($sp) - lw $2,0x0($sp) - addiu $sp,$sp,64 + lw $31,0x64($sp) + lw $30,0x60($sp) + lw $23,0x5c($sp) + lw $22,0x58($sp) + lw $21,0x54($sp) + lw $20,0x50($sp) + lw $19,0x4c($sp) + lw $18,0x48($sp) + lw $17,0x44($sp) + lw $16,0x40($sp) + lw $15,0x3c($sp) + lw $14,0x38($sp) + lw $13,0x34($sp) + lw $12,0x30($sp) + lw $11,0x2c($sp) + lw $10,0x28($sp) + lw $9,0x24($sp) + lw $8,0x20($sp) + lw $7,0x1c($sp) + lw $6,0x18($sp) + lw $5,0x14($sp) + lw $4,0x10($sp) + lw $3,0xc($sp) + lw $2,0x8($sp) + .set noat + lw $1,0x4($sp) + .set at + addiu $sp,$sp,104 - mtsri PASS, 0xefff +# mtsri PASS, 0xefff dret vec_event_counters: empty_vec 0x2306 diff --git a/Robust/src/Runtime/raw_interrupt4.s b/Robust/src/Runtime/raw_interrupt4.s index 3c9f697e..e579fab1 100644 --- a/Robust/src/Runtime/raw_interrupt4.s +++ b/Robust/src/Runtime/raw_interrupt4.s @@ -52,48 +52,70 @@ vec_extern: vec_timer: empty_vec 0x2304 vec_gdn_avail: - mtsri PASS, 0xef00 +# mtsri PASS, 0xef00 uintoff - addiu $sp,$sp,-64 - sw $31,0x3c($sp) - sw $30,0x38($sp) - sw $23,0x34($sp) - sw $22,0x30($sp) - sw $21,0x2c($sp) - sw $20,0x28($sp) - sw $19,0x24($sp) - sw $18,0x20($sp) - sw $17,0x1c($sp) - sw $16,0x18($sp) - sw $7,0x14($sp) - sw $6,0x10($sp) - sw $5,0xc($sp) - sw $4,0x8($sp) - sw $3,0x4($sp) - sw $2,0x0($sp) + addiu $sp,$sp,-104 + sw $31,0x64($sp) + sw $30,0x60($sp) + sw $23,0x5c($sp) + sw $22,0x58($sp) + sw $21,0x54($sp) + sw $20,0x50($sp) + sw $19,0x4c($sp) + sw $18,0x48($sp) + sw $17,0x44($sp) + sw $16,0x40($sp) + sw $15,0x3c($sp) + sw $14,0x38($sp) + sw $13,0x34($sp) + sw $12,0x30($sp) + sw $11,0x2c($sp) + sw $10,0x28($sp) + sw $9,0x24($sp) + sw $8,0x20($sp) + sw $7,0x1c($sp) + sw $6,0x18($sp) + sw $5,0x14($sp) + sw $4,0x10($sp) + sw $3,0xc($sp) + sw $2,0x8($sp) + .set noat + sw $1,0x4($sp) + .set at jal receiveObject - lw $31,0x3c($sp) - lw $30,0x38($sp) - lw $23,0x34($sp) - lw $22,0x30($sp) - lw $21,0x2c($sp) - lw $20,0x28($sp) - lw $19,0x24($sp) - lw $18,0x20($sp) - lw $17,0x1c($sp) - lw $16,0x18($sp) - lw $7,0x14($sp) - lw $6,0x10($sp) - lw $5,0xc($sp) - lw $4,0x8($sp) - lw $3,0x4($sp) - lw $2,0x0($sp) - addiu $sp,$sp,64 + lw $31,0x64($sp) + lw $30,0x60($sp) + lw $23,0x5c($sp) + lw $22,0x58($sp) + lw $21,0x54($sp) + lw $20,0x50($sp) + lw $19,0x4c($sp) + lw $18,0x48($sp) + lw $17,0x44($sp) + lw $16,0x40($sp) + lw $15,0x3c($sp) + lw $14,0x38($sp) + lw $13,0x34($sp) + lw $12,0x30($sp) + lw $11,0x2c($sp) + lw $10,0x28($sp) + lw $9,0x24($sp) + lw $8,0x20($sp) + lw $7,0x1c($sp) + lw $6,0x18($sp) + lw $5,0x14($sp) + lw $4,0x10($sp) + lw $3,0xc($sp) + lw $2,0x8($sp) + .set noat + lw $1,0x4($sp) + .set at + addiu $sp,$sp,104 - mtsri PASS, 0xefff +# mtsri PASS, 0xefff dret vec_event_counters: empty_vec 0x2306 diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 14ca8b37..e5a01ecc 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -52,6 +52,7 @@ MULTICOREFLAG=false TRANSSTATSFLAG=false RAWFLAG=false RAWCONFIG='' +RAWDEBUGFLAG=false INTERRUPTFLAG=false THREADSIMULATEFLAG=false; USEDMALLOC=false @@ -185,6 +186,7 @@ cd $CURDIR shift elif [[ $1 = '-debug' ]] then +RAWDEBUGFLAG=true EXTRAOPTIONS="$EXTRAOPTIONS -g" elif [[ $1 = '-runtimedebug' ]] then @@ -291,9 +293,17 @@ cd $RAWDIR make clean rm ./* +export RAWRGCCFLAGS="-DTASK -DMULTICORE -DRAW" + +if $RAWDEBUGFLAG +then #debug version +RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWDEBUG" +fi + if $INTERRUPTFLAG then #INTERRUPT version MAKEFILE="$MAKEFILE.i" +RAWRGCCFLAGS="${RAWRGCCFLAGS} -DINTERRUPT" fi #INTERRUPT version MAKEFILE="$MAKEFILE.$RAWCONFIG"