output.println("}");
}
- Vector<TranObjInfo> sendto = new Vector<TranObjInfo>();
+ //Vector<TranObjInfo> sendto = new Vector<TranObjInfo>();
Queue<Integer> queue = null;
if(targetCoreTbl != null) {
queue = targetCoreTbl.get(tmpFState);
} else {
tmpinfo.fs = tmpFState;
}
- if(!contains(sendto, tmpinfo)) {
+ // fixed 05/12/09, it's very likely to repeatedly send an object to the same core
+ // as sheduled
+ //if(!contains(sendto, tmpinfo)) {
qinfo = outputtransqueues(tmpinfo.fs, targetcore, output);
output.println("tmpObjInfo = RUNMALLOC(sizeof(struct transObjInfo));");
output.println("tmpObjInfo->objptr = (void *)" + tmpinfo.name + ";");
output.println("tmpObjInfo->queues = " + qinfo.qname + ";");
output.println("tmpObjInfo->length = " + qinfo.length + ";");
output.println("addNewItem(totransobjqueue, (void*)tmpObjInfo);");
- sendto.add(tmpinfo);
- }
+ //sendto.add(tmpinfo);
+ //}
output.println("}");
}
output.println("break;");
} else {
tmpinfo.fs = tmpFState;
}
- if(!contains(sendto, tmpinfo)) {
+ // fixed 05/12/09, it's very likely to repeatedly send an object to the same core
+ // as sheduled
+ //if(!contains(sendto, tmpinfo)) {
qinfo = outputtransqueues(tmpinfo.fs, targetcore, output);
output.println("tmpObjInfo = RUNMALLOC(sizeof(struct transObjInfo));");
output.println("tmpObjInfo->objptr = (void *)" + tmpinfo.name + ";");
output.println("tmpObjInfo->queues = " + qinfo.qname + ";");
output.println("tmpObjInfo->length = " + qinfo.length + ";");
output.println("addNewItem(totransobjqueue, (void*)tmpObjInfo);");
- sendto.add(tmpinfo);
- }
+ //sendto.add(tmpinfo);
+ //}
output.println("}");
}
output.println("/* increase index*/");
} else {
tmpinfo.fs = tmpFState;
}
- if(!contains(sendto, tmpinfo)) {
+ // fixed 05/12/09, it's very likely to repeatedly send an object to the same core
+ // as sheduled
+ //if(!contains(sendto, tmpinfo)) {
qinfo = outputtransqueues(tmpinfo.fs, targetcores.elementAt(i), output);
output.println("tmpObjInfo = RUNMALLOC(sizeof(struct transObjInfo));");
output.println("tmpObjInfo->objptr = (void *)" + tmpinfo.name + ";");
output.println("tmpObjInfo->queues = " + qinfo.qname + ";");
output.println("tmpObjInfo->length = " + qinfo.length + ";");
output.println("addNewItem(totransobjqueue, (void*)tmpObjInfo);");
- sendto.add(tmpinfo);
- }
+ //sendto.add(tmpinfo);
+ //}
output.println("}");
//}
}
}*/
void * mycalloc(int m, int size) {
+ void * p = NULL;
+ int isize = 2*BAMBOO_CACHE_LINE_SIZE-4+(size-1)&(~BAMBOO_CACHE_LINE_MASK);
+ BAMBOO_START_CRITICAL_SECTION_MEM();
+ p = BAMBOO_LOCAL_MEM_CALLOC(m, isize); // calloc(m, isize);
+ BAMBOO_CLOSE_CRITICAL_SECTION_MEM();
+ return (void *)(BAMBOO_CACHE_LINE_SIZE+((int)p-1)&(~BAMBOO_CACHE_LINE_MASK));
+}
+
+void * mycalloc_share(int m, int size) {
void * p = NULL;
int isize = 2*BAMBOO_CACHE_LINE_SIZE-4+(size-1)&(~BAMBOO_CACHE_LINE_MASK);
BAMBOO_START_CRITICAL_SECTION_MEM();
void * mycalloc_i(int m, int size) {
void * p = NULL;
int isize = 2*BAMBOO_CACHE_LINE_SIZE-4+(size-1)&(~BAMBOO_CACHE_LINE_MASK);
- p = BAMBOO_SHARE_MEM_CALLOC(m, isize); // calloc(m, isize);
+ p = BAMBOO_LOCAL_MEM_CALLOC(m, isize); // calloc(m, isize);
return (void *)(BAMBOO_CACHE_LINE_SIZE+((int)p-1)&(~BAMBOO_CACHE_LINE_MASK));
}
//#define PTR(x) (x)
#else
void * mycalloc(int m, int size);
+void * mycalloc_share(int m, int size);
void * mycalloc_i(int m, int size);
void myfree(void * ptr);
-#define FREEMALLOC(x) mycalloc(1,x)
+#define FREEMALLOC(x) mycalloc_share(1,x)
#define RUNMALLOC(x) mycalloc(1,x) // handle interruption inside
#define RUNMALLOC_I(x) mycalloc_i(1,x) // with interruption blocked beforehand
#define RUNFREE(x) myfree(x);
inline void fakeExecution(void) __attribute__((always_inline));
inline void terminate(void) __attribute__((always_inline));
-inline void send_msg_1(int targetcore, int n0) __attribute__((always_inline));
-inline void send_msg_2(int targetcore, int n0, int n1) __attribute__((always_inline));
-inline void send_msg_3(int targetcore, int n0, int n1, int n2) __attribute__((always_inline));
-inline void send_msg_4(int targetcore, int n0, int n1, int n2, int n3) __attribute__((always_inline));
-inline void send_msg_5(int targetcore, int n0, int n1, int n2, int n3, int n4) __attribute__((always_inline));
-inline void send_msg_6(int targetcore, int n0, int n1, int n2, int n3, int n4, int n5) __attribute__((always_inline));
-inline void cache_msg_2(int targetcore, int n0, int n1) __attribute__((always_inline));
-inline void cache_msg_3(int targetcore, int n0, int n1, int n2) __attribute__((always_inline));
-inline void cache_msg_4(int targetcore, int n0, int n1, int n2, int n3) __attribute__((always_inline));
-inline void cache_msg_6(int targetcore, int n0, int n1, int n2, int n3, int n4, int n5) __attribute__((always_inline));
+inline void send_msg_1(int targetcore, unsigned long n0) __attribute__((always_inline));
+inline void send_msg_2(int targetcore, unsigned long n0, unsigned long n1) __attribute__((always_inline));
+inline void send_msg_3(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2) __attribute__((always_inline));
+inline void send_msg_4(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3) __attribute__((always_inline));
+inline void send_msg_5(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3, unsigned long n4) __attribute__((always_inline));
+inline void send_msg_6(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3, unsigned long n4, unsigned long n5) __attribute__((always_inline));
+inline void cache_msg_2(int targetcore, unsigned long n0, unsigned long n1) __attribute__((always_inline));
+inline void cache_msg_3(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2) __attribute__((always_inline));
+inline void cache_msg_4(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3) __attribute__((always_inline));
+inline void cache_msg_6(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3, unsigned long n4, unsigned long n5) __attribute__((always_inline));
inline void transferObject(struct transObjInfo * transObj);
inline int receiveMsg(void) __attribute__((always_inline));
// BAMBOO_GET_NUM_OF_CORE(): compute the # of current residing core //
// BAMBOO_DEBUGPRINT(x): print out integer x //
// BAMBOO_DEBUGPRINT_REG(x): print out value of variable x //
+// BAMBOO_LOCAL_MEM_CALLOC(x, y): allocate an array of x elements each of whose //
+// size in bytes is y on local memory //
// BAMBOO_SHARE_MEM_CALLOC(x, y): allocate an array of x elements each of whose //
// size in bytes is y on shared memory //
// BAMBOO_START_CRITICAL_SECTION_OBJ_QUEUE() //
while(!isEmpty(&objqueue)) {
void * obj = NULL;
BAMBOO_START_CRITICAL_SECTION_OBJ_QUEUE();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
#ifdef PROFILE
//isInterrupt = false;
-#endif
+#endif
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xeee1);
#endif
#ifdef DEBUG
BAMBOO_DEBUGPRINT_REG(taskindex);
BAMBOO_DEBUGPRINT_REG(paramindex);
+ struct ___Object___ * tmpptr = (struct ___Object___ *)obj;
+ tprintf("Process %x(%d): receive obj %x(%lld), ptrflag %x\n", corenum, corenum, (int)obj, (long)obj, tmpptr->flag);
#endif
+
enqueueObject_I(obj, queues, 1);
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT_REG(hashsize(activetasks));
+#endif
}
removeItem(&objqueue, objitem);
releasewritelock_I(obj);
//isInterrupt = true;
#endif
BAMBOO_CLOSE_CRITICAL_SECTION_OBJ_QUEUE();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
break;
}
BAMBOO_CLOSE_CRITICAL_SECTION_OBJ_QUEUE();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
}
#ifdef PROFILE
if(isChecking) {
(waitconfirm && (numconfirm == 0))) {
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee04);
+ BAMBOO_DEBUGPRINT_REG(waitconfirm);
#endif
BAMBOO_START_CRITICAL_SECTION_STATUS();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
corestatus[corenum] = 0;
numsendobjs[corenum] = self_numsendobjs;
numreceiveobjs[corenum] = self_numreceiveobjs;
// out progiling data
#ifdef PROFILE
BAMBOO_CLOSE_CRITICAL_SECTION_STATUS();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
for(i = 1; i < NUMCORES; ++i) {
// send profile request msg to core i
send_msg_2(i, 6, totalexetime);
outputProfileData();
while(true) {
BAMBOO_START_CRITICAL_SECTION_STATUS();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
profilestatus[corenum] = 0;
// check the status of all cores
allStall = true;
if(!allStall) {
int halt = 100;
BAMBOO_CLOSE_CRITICAL_SECTION_STATUS();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
while(halt--) {
}
} else {
numconfirm = 0;
}
BAMBOO_CLOSE_CRITICAL_SECTION_STATUS();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
}
} else {
if(!sendStall) {
}
}
}
-
+
/* Check flags */
for(i=0; i<parameter->numberofterms; i++) {
int andmask=parameter->intarray[i*2];
// reside on this core
int deny = 0;
BAMBOO_START_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
deny = processlockrequest(0, lock2require, (int)ptr, corenum, corenum, false);
BAMBOO_CLOSE_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
if(deny == -1) {
// redirected
return true;
if(targetcore == corenum) {
BAMBOO_START_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
// reside on this core
if(!RuntimeHashcontainskey(locktbl, reallock)) {
// no locks for this object, something is wrong
lockvalue->value--;
}
BAMBOO_CLOSE_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
return;
} else {
// send lock release msg
// reside on this core
int deny = 0;
BAMBOO_START_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
deny = processlockrequest(1, lock2require, (int)ptr, corenum, corenum, false);
BAMBOO_CLOSE_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe555);
BAMBOO_DEBUGPRINT_REG(lockresult);
if(targetcore == corenum) {
BAMBOO_START_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
// reside on this core
if(!RuntimeHashcontainskey(locktbl, reallock)) {
// no locks for this object, something is wrong
lockvalue->value++;
}
BAMBOO_CLOSE_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
return;
} else {
// send lock release msg
if(targetcore == corenum) {
BAMBOO_START_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
// reside on this core
if(!RuntimeHashcontainskey(locktbl, reallock)) {
// no locks for this object, something is wrong
#endif
}
BAMBOO_CLOSE_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
return;
} else {
// send lock release with redirect info msg
#endif
getwritelock(lock);
BAMBOO_START_CRITICAL_SECTION();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
#ifdef PROFILE
//isInterrupt = false;
#endif
//isInterrupt = true;
#endif
BAMBOO_CLOSE_CRITICAL_SECTION();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
if(grount == 0) {
int j = 0;
BAMBOO_CACHE_FLUSH_RANGE((int)parameter, classsize[((struct ___Object___ *)parameter)->type]);
/*
BAMBOO_START_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf001);
+#endif
if(RuntimeHashcontainskey(objRedirectLockTbl, (int)parameter)) {
int redirectlock_r = 0;
RuntimeHashget(objRedirectLockTbl, (int)parameter, &redirectlock_r);
RuntimeHashremovekey(objRedirectLockTbl, (int)parameter);
}
BAMBOO_CLOSE_CRITICAL_SECTION_LOCK();
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xf000);
+#endif
*/
#endif
tmpparam = (struct ___Object___ *)parameter;