extern struct parameterwrapper ** objectqueues[][NUMCLASSES];
extern struct taskparamdescriptor *currtpd;
+extern struct LockValue runtime_locks[MAXTASKPARAMS];
+extern int runtime_locklen;
+
struct pointerblock {
void * ptrs[NUMPTRS];
struct pointerblock *next;
}
// compute core #
if(advanceblock) {
- coren = gc_block2core[block%124];
+ coren = gc_block2core[block%(NUMCORES*2)];
}
// compute core coordinate
int tmpcore = coren;
int j = 0;
int toset = 0;
do{
- toset = gc_core2block[2*coren+i]+124*j;
+ toset = gc_core2block[2*coren+i]+(NUMCORES*2)*j;
if(toset < ltopcore) {
gcsmemtbl[toset] = (toset<NUMCORES)?BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
} else if(toset == ltopcore) {
BAMBOO_CLOSE_CRITICAL_SECTION();
item = getNextQueueItem(item);
} // while(item != NULL)
+
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xe508);
+#endif
+ // enqueue lock related info
+ for(i = 0; i < runtime_locklen; ++i) {
+ gc_enqueue_I((void *)(runtime_locks[i].redirectlock));
+ if(runtime_locks[i].value != NULL) {
+ gc_enqueue_I((void *)(runtime_locks[i].value));
+ }
+ }
+
} // void tomark(struct garbagelist * stackptr)
inline void markObj(void * objptr) {
ptr->key = flushObj((void *)ptr->key);
ptr=ptr->lnext;
}
+ ObjectHashrehash(set);
}
}
}
ptr=ptr->inext;
}
+ genrehash(activetasks);
// flush cached transferred obj
struct QueueItem * tmpobjptr = getHead(&objqueue);
totransobj->objptr = flushObj(totransobj->objptr);
item = getNextQueueItem(item);
} // while(item != NULL)
+
+ // enqueue lock related info
+ for(i = 0; i < runtime_locklen; ++i) {
+ runtime_locks[i].redirectlock = (int)flushObj(runtime_locks[i].redirectlock);
+ if(runtime_locks[i].value != NULL) {
+ runtime_locks[i].value = (int)flushObj(runtime_locks[i].value);
+ }
+ }
+
} // void flushRuntimeObj(struct garbagelist * stackptr)
inline void flush(struct garbagelist * stackptr) {
#ifndef MULTICORE_HELPER_H
#define MULTICORE_HELPER_H
+#ifdef GC_1
+// NUMCORES = 1
+static int gc_core2block[2] = {0,1};
+
+static int gc_block2core[2] = { 0, 0};
+#elif defined GC_62
+// NUMCORES = 62
static int gc_core2block[124] = {0,123, 15,108, 16,107, 31,92, 32,91, 47,76,
1,122, 14,109, 17,106, 30,93, 33,90, 46,77, 48,75, 61,62,
2,121, 13,110, 18,105, 29,94, 34,89, 45,78, 49,74, 60,63,
5, 11, 19, 27, 35, 43, 51, 59, 58, 50, 42, 34, 26, 18, 10, 4,
3, 9, 17, 25, 33, 41, 49, 57, 56, 48, 40, 32, 24, 16, 8, 2,
1, 7, 15, 23, 31, 39, 47, 55, 54, 46, 38, 30, 22, 14, 6, 0};
+#endif
#endif // MULTICORE_HELPER_H
// data structures for task invocation
struct genhashtable * activetasks;
struct taskparamdescriptor * currtpd;
+struct LockValue runtime_locks[MAXTASKPARAMS];
+int runtime_locklen;
// specific functions used inside critical sections
void enqueueObject_I(void * ptr,
/*interruptInfoIndex = 0;
interruptInfoOverflow = false;*/
#endif
+
+ for(i = 0; i < MAXTASKPARAMS; i++) {
+ runtime_locks[i].redirectlock = 0;
+ runtime_locks[i].value = 0;
+ }
+ runtime_locklen = 0;
}
inline __attribute__((always_inline))
struct freeMemItem * prev = NULL;
int i = 0;
int j = 0;
- *tofindb = gc_core2block[2*coren+i]+124*j;
+ *tofindb = gc_core2block[2*coren+i]+(NUMCORES*2)*j;
// check available shared mem chunks
do {
int foundsmem = 0;
i = 0;
j++;
}
- *tofindb = gc_core2block[2*coren+i]+124*j;
+ *tofindb = gc_core2block[2*coren+i]+(NUMCORES*2)*j;
} // while(startb > tofindb)
if(startb <= *tofindb) {
if((endb >= *tofindb) && (freemem->size >= isize)) {
int x = 0;
bool islock = true;
- struct LockValue locks[MAXTASKPARAMS];
- int locklen = 0;
int grount = 0;
int andmask=0;
int checkmask=0;
// (TODO, this table should be empty after all locks are released)
// reset all locks
for(j = 0; j < MAXTASKPARAMS; j++) {
- locks[j].redirectlock = 0;
- locks[j].value = 0;
+ runtime_locks[j].redirectlock = 0;
+ runtime_locks[j].value = 0;
}
// get all required locks
- locklen = 0;
+ runtime_locklen = 0;
// check which locks are needed
for(i = 0; i < numparams; i++) {
void * param = currtpd->parameterArray[i];
tmplock = (int)(((struct ___Object___ *)param)->lock);
}
// insert into the locks array
- for(j = 0; j < locklen; j++) {
- if(locks[j].value == tmplock) {
+ for(j = 0; j < runtime_locklen; j++) {
+ if(runtime_locks[j].value == tmplock) {
insert = false;
break;
- } else if(locks[j].value > tmplock) {
+ } else if(runtime_locks[j].value > tmplock) {
break;
}
}
if(insert) {
- int h = locklen;
+ int h = runtime_locklen;
for(; h > j; h--) {
- locks[h].redirectlock = locks[h-1].redirectlock;
- locks[h].value = locks[h-1].value;
+ runtime_locks[h].redirectlock = runtime_locks[h-1].redirectlock;
+ runtime_locks[h].value = runtime_locks[h-1].value;
}
- locks[j].value = tmplock;
- locks[j].redirectlock = (int)param;
- locklen++;
+ runtime_locks[j].value = tmplock;
+ runtime_locks[j].redirectlock = (int)param;
+ runtime_locklen++;
}
} // line 2713: for(i = 0; i < numparams; i++)
// grab these required locks
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe991);
#endif
- for(i = 0; i < locklen; i++) {
- int * lock = (int *)(locks[i].redirectlock);
+ for(i = 0; i < runtime_locklen; i++) {
+ int * lock = (int *)(runtime_locks[i].redirectlock);
islock = true;
// require locks for this parameter if it is not a startup object
#ifdef DEBUG
BAMBOO_DEBUGPRINT_REG((int)lock);
- BAMBOO_DEBUGPRINT_REG((int)(locks[i].value));
+ BAMBOO_DEBUGPRINT_REG((int)(runtime_locks[i].value));
#endif
getwritelock(lock);
BAMBOO_START_CRITICAL_SECTION();
int j = 0;
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe992);
+ BAMBOO_DEBUGPRINT_REG(lock);
#endif
// can not get the lock, try later
// releas all grabbed locks for previous parameters
for(j = 0; j < i; ++j) {
- lock = (int*)(locks[j].redirectlock);
+ lock = (int*)(runtime_locks[j].redirectlock);
releasewritelock(lock);
}
genputtable(activetasks, currtpd, currtpd);
#endif
goto newtask;
} // line 2794: if(grount == 0)
- } // line 2752: for(i = 0; i < locklen; i++)
+ } // line 2752: for(i = 0; i < runtime_locklen; i++)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe993);
if (!ObjectHashcontainskey(pw->objectset, (int) parameter)) {
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe994);
+ BAMBOO_DEBUGPRINT_REG(parameter);
#endif
// release grabbed locks
- for(j = 0; j < locklen; ++j) {
- int * lock = (int *)(locks[j].redirectlock);
+ for(j = 0; j < runtime_locklen; ++j) {
+ int * lock = (int *)(runtime_locks[j].redirectlock);
releasewritelock(lock);
}
RUNFREE(currtpd->parameterArray);
int * enterflags;
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe995);
+ BAMBOO_DEBUGPRINT_REG(parameter);
#endif
ObjectHashget(pw->objectset, (int) parameter, (int *) &next,
(int *) &enterflags, &UNUSED, &UNUSED2);
if (enterflags!=NULL)
RUNFREE(enterflags);
// release grabbed locks
- for(j = 0; j < locklen; ++j) {
- int * lock = (int *)(locks[j].redirectlock);
+ for(j = 0; j < runtime_locklen; ++j) {
+ int * lock = (int *)(runtime_locks[j].redirectlock);
releasewritelock(lock);
}
RUNFREE(currtpd->parameterArray);
{
// release grabbed locks
int tmpj = 0;
- for(tmpj = 0; tmpj < locklen; ++tmpj) {
- int * lock = (int *)(locks[tmpj].redirectlock);
+ for(tmpj = 0; tmpj < runtime_locklen; ++tmpj) {
+ int * lock = (int *)(runtime_locks[tmpj].redirectlock);
releasewritelock(lock);
}
}
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe999);
#endif
- for(i = 0; i < locklen; ++i) {
- void * ptr = (void *)(locks[i].redirectlock);
- int * lock = (int *)(locks[i].value);
+ for(i = 0; i < runtime_locklen; ++i) {
+ void * ptr = (void *)(runtime_locks[i].redirectlock);
+ int * lock = (int *)(runtime_locks[i].value);
#ifdef DEBUG
BAMBOO_DEBUGPRINT_REG((int)ptr);
BAMBOO_DEBUGPRINT_REG((int)lock);