From 4724bb9f48056b3d9eaaef1693403bfc8cd3e4a8 Mon Sep 17 00:00:00 2001 From: jzhou Date: Wed, 11 May 2011 01:20:49 +0000 Subject: [PATCH] Code clean --- Robust/src/Runtime/bamboo/GCSharedHash.c | 151 +++---- Robust/src/Runtime/bamboo/GCSharedHash.h | 2 +- Robust/src/Runtime/bamboo/MGCHash.c | 49 +- Robust/src/Runtime/bamboo/multicorecache.c | 354 +++++---------- Robust/src/Runtime/bamboo/multicorecache.h | 65 ++- Robust/src/Runtime/bamboo/multicoregarbage.c | 378 ++++++++-------- Robust/src/Runtime/bamboo/multicoregarbage.h | 20 +- .../src/Runtime/bamboo/multicoregccompact.c | 106 ++--- .../src/Runtime/bamboo/multicoregccompact.h | 6 +- Robust/src/Runtime/bamboo/multicoregcflush.c | 2 +- .../src/Runtime/bamboo/multicoregcprofile.c | 47 +- .../src/Runtime/bamboo/multicoregcprofile.h | 53 ++- Robust/src/Runtime/bamboo/multicorehelper.h | 2 + Robust/src/Runtime/bamboo/multicoremem.c | 419 +----------------- .../src/Runtime/bamboo/multicoremem_helper.h | 414 +++++++++++++++++ .../src/Runtime/bamboo/multicoretaskprofile.c | 56 +-- .../src/Runtime/bamboo/multicoretaskprofile.h | 58 ++- 17 files changed, 1021 insertions(+), 1161 deletions(-) create mode 100644 Robust/src/Runtime/bamboo/multicoremem_helper.h diff --git a/Robust/src/Runtime/bamboo/GCSharedHash.c b/Robust/src/Runtime/bamboo/GCSharedHash.c index c2e53409..6e12e4cb 100755 --- a/Robust/src/Runtime/bamboo/GCSharedHash.c +++ b/Robust/src/Runtime/bamboo/GCSharedHash.c @@ -29,14 +29,14 @@ struct GCSharedHash * allocateGCSharedHash(int size) { } thisvar=(struct GCSharedHash *)FREEMALLOC_NGC(sizeof(struct GCSharedHash)); if(thisvar == NULL) { - return NULL; + return NULL; } thisvar->size = size; thisvar->bucket = (struct GCSharedNode **)FREEMALLOC_NGC(sizeof(struct GCSharedNode *)*size); if(thisvar->bucket == NULL) { - FREE_NGC(thisvar); - return NULL; + FREE_NGC(thisvar); + return NULL; } /* Set allocation blocks*/ thisvar->listhead=NULL; @@ -62,7 +62,7 @@ bool GCSharedHashrehash(struct GCSharedHash * thisvar) { struct GCSharedNode ** newbucket = (struct GCSharedNode **) FREEMALLOC_NGC(sizeof(struct GCSharedNode *)*newsize); if(newbucket == NULL) { - return false; + return false; } int i; for(i=thisvar->size-1; i>=0; i--) { @@ -88,21 +88,19 @@ int GCSharedHashadd(struct GCSharedHash * thisvar,int key, int data) { if (thisvar->numelements>=thisvar->size) { int newsize=2*thisvar->size+1; - struct GCSharedNode ** newbucket = - (struct GCSharedNode **)FREEMALLOC_NGC( - sizeof(struct GCSharedNode *)*newsize); - if(newbucket == NULL) { - return -1; - } + struct GCSharedNode ** newbucket=(struct GCSharedNode **)FREEMALLOC_NGC(sizeof(struct GCSharedNode *)*newsize); + if(newbucket == NULL) { + return -1; + } int i; for(i=thisvar->size-1; i>=0; i--) { struct GCSharedNode *ptr; for(ptr=thisvar->bucket[i]; ptr!=NULL;) { - struct GCSharedNode * nextptr=ptr->next; - unsigned int newhashkey=(unsigned int)ptr->key % newsize; - ptr->next=newbucket[newhashkey]; - newbucket[newhashkey]=ptr; - ptr=nextptr; + struct GCSharedNode * nextptr=ptr->next; + unsigned int newhashkey=(unsigned int)ptr->key % newsize; + ptr->next=newbucket[newhashkey]; + newbucket[newhashkey]=ptr; + ptr=nextptr; } } thisvar->size=newsize; @@ -125,9 +123,9 @@ int GCSharedHashadd(struct GCSharedHash * thisvar,int key, int data) { { struct GCSharedNode *node=FREEMALLOC_NGC(sizeof(struct GCSharedNode)); - if(node == NULL) { - return -1; - } + if(node == NULL) { + return -1; + } node->data=data; node->key=key; node->next=(*ptr); @@ -162,15 +160,13 @@ struct GCSharedHash * allocateGCSharedHash_I(int size) { } thisvar=(struct GCSharedHash *)FREEMALLOC_NGC_I(sizeof(struct GCSharedHash)); if(thisvar == NULL) { - return NULL; + return NULL; } thisvar->size = size; - thisvar->bucket = - (struct GCSharedNode **)FREEMALLOC_NGC_I( - sizeof(struct GCSharedNode *)*size); + thisvar->bucket=(struct GCSharedNode **)FREEMALLOC_NGC_I(sizeof(struct GCSharedNode *)*size); if(thisvar->bucket == NULL) { - FREE_NGC_I(thisvar); - return NULL; + FREE_NGC_I(thisvar); + return NULL; } /* Set allocation blocks*/ thisvar->listhead=NULL; @@ -187,21 +183,19 @@ int GCSharedHashadd_I(struct GCSharedHash * thisvar,int key, int data) { if (thisvar->numelements>=thisvar->size) { int newsize=2*thisvar->size+1; - struct GCSharedNode ** newbucket = - (struct GCSharedNode **)FREEMALLOC_NGC_I( - sizeof(struct GCSharedNode *)*newsize); - if(newbucket == NULL) { - return -1; - } + struct GCSharedNode ** newbucket=(struct GCSharedNode **)FREEMALLOC_NGC_I(sizeof(struct GCSharedNode *)*newsize); + if(newbucket == NULL) { + return -1; + } int i; for(i=thisvar->size-1; i>=0; i--) { struct GCSharedNode *ptr; for(ptr=thisvar->bucket[i]; ptr!=NULL;) { - struct GCSharedNode * nextptr=ptr->next; - unsigned int newhashkey=(unsigned int)ptr->key % newsize; - ptr->next=newbucket[newhashkey]; - newbucket[newhashkey]=ptr; - ptr=nextptr; + struct GCSharedNode * nextptr=ptr->next; + unsigned int newhashkey=(unsigned int)ptr->key % newsize; + ptr->next=newbucket[newhashkey]; + newbucket[newhashkey]=ptr; + ptr=nextptr; } } thisvar->size=newsize; @@ -224,9 +218,9 @@ int GCSharedHashadd_I(struct GCSharedHash * thisvar,int key, int data) { { struct GCSharedNode *node=FREEMALLOC_NGC_I(sizeof(struct GCSharedNode)); - if(node == NULL) { - return -1; - } + if(node == NULL) { + return -1; + } node->data=data; node->key=key; node->next=(*ptr); @@ -266,8 +260,7 @@ int GCSharedHashget(struct GCSharedHash *thisvar, int key, int *data) { /* MGCSHAREDHASH ********************************************************/ -mgcsharedhashtbl_t * mgcsharedhashCreate(unsigned int size, - double loadfactor) { +mgcsharedhashtbl_t * mgcsharedhashCreate(unsigned int size,double loadfactor) { mgcsharedhashtbl_t * ctable; mgcsharedhashlistnode_t * nodes; int i; @@ -279,8 +272,7 @@ mgcsharedhashtbl_t * mgcsharedhashCreate(unsigned int size, return NULL; } // Allocate space for the hash table - ctable->table = (mgcsharedhashlistnode_t *)FREEMALLOC_NGC( - size*sizeof(mgcsharedhashlistnode_t)); + ctable->table=(mgcsharedhashlistnode_t *)FREEMALLOC_NGC(size*sizeof(mgcsharedhashlistnode_t)); if(ctable->table == NULL) { BAMBOO_EXIT(); // TODO return NULL; @@ -298,8 +290,7 @@ mgcsharedhashtbl_t * mgcsharedhashCreate(unsigned int size, return ctable; } -mgcsharedhashtbl_t * mgcsharedhashCreate_I(unsigned int size, - double loadfactor) { +mgcsharedhashtbl_t * mgcsharedhashCreate_I(unsigned int size,double loadfactor) { mgcsharedhashtbl_t * ctable; mgcsharedhashlistnode_t * nodes; int i; @@ -311,8 +302,7 @@ mgcsharedhashtbl_t * mgcsharedhashCreate_I(unsigned int size, return NULL; } // Allocate space for the hash table - ctable->table = (mgcsharedhashlistnode_t *)FREEMALLOC_NGC_I( - size*sizeof(mgcsharedhashlistnode_t)); + ctable->table=(mgcsharedhashlistnode_t *)FREEMALLOC_NGC_I(size*sizeof(mgcsharedhashlistnode_t)); if(ctable->table == NULL) { BAMBOO_EXIT(); // TODO return NULL; @@ -334,28 +324,26 @@ void mgcsharedhashReset(mgcsharedhashtbl_t * tbl) { mgcsharedhashlistnode_t * ptr = tbl->table; if ((tbl->numelements) < (tbl->size>>6)) { - mgcsharedhashlistnode_t *top = &ptr[tbl->size]; - mgcsharedhashlistnode_t * list = tbl->list; - while(list != NULL) { + mgcsharedhashlistnode_t *top = &ptr[tbl->size]; + mgcsharedhashlistnode_t * list = tbl->list; + while(list != NULL) { mgcsharedhashlistnode_t * next = list->next; if ((list >= ptr) && (list < top)) { - //zero in list + //zero in list list->key=NULL; list->next=NULL; } list = next; - } + } } else { - BAMBOO_MEMSET_WH(tbl->table, '\0', - sizeof(mgcsharedhashlistnode_t)*tbl->size); + BAMBOO_MEMSET_WH(tbl->table,'\0',sizeof(mgcsharedhashlistnode_t)*tbl->size); } mgcsharedliststruct_t * structs = tbl->structs; while(structs != NULL) { mgcsharedliststruct_t * next = structs->next; - BAMBOO_MEMSET_WH(structs->array, '\0', - structs->num * sizeof(mgcsharedhashlistnode_t)); - structs->num = 0; + BAMBOO_MEMSET_WH(structs->array,'\0',structs->num*sizeof(mgcsharedhashlistnode_t)); + structs->num = 0; structs = next; } tbl->numelements = 0; @@ -378,16 +366,16 @@ int mgcsharedhashInsert(mgcsharedhashtbl_t * tbl, void * key, void * val) { ptr->key=key; ptr->val=val; } else { // Insert to the next empty place - mgcsharedhashlistnode_t *top = &tbl->table[tbl->size]; + mgcsharedhashlistnode_t *top = &tbl->table[tbl->size]; do { - ptr++; - } while((ptr < top) && (ptr->key != NULL)); - if(ptr >= top) { - return -1; - } else { - ptr->key = key; - ptr->val = val; - } + ptr++; + } while((ptr < top) && (ptr->key != NULL)); + if(ptr >= top) { + return -1; + } else { + ptr->key = key; + ptr->val = val; + } } ptr->next = tbl->list; tbl->list = ptr; @@ -410,20 +398,20 @@ int mgcsharedhashInsert_I(mgcsharedhashtbl_t * tbl, void * key, void * val) { ptr->key=key; ptr->val=val; } else { // Insert to the next empty place - mgcsharedhashlistnode_t * top = &tbl->table[tbl->size]; - mgcsharedhashlistnode_t * start = ptr; + mgcsharedhashlistnode_t * top = &tbl->table[tbl->size]; + mgcsharedhashlistnode_t * start = ptr; do { - ptr++; - if(ptr->key == 0) { - break; - } - } while(ptr < top); - if(ptr >= top) { - return -1; - } else { - ptr->key = key; - ptr->val = val; - } + ptr++; + if(ptr->key == 0) { + break; + } + } while(ptr < top); + if(ptr >= top) { + return -1; + } else { + ptr->key = key; + ptr->val = val; + } } ptr->next = tbl->list; tbl->list = ptr; @@ -432,11 +420,10 @@ int mgcsharedhashInsert_I(mgcsharedhashtbl_t * tbl, void * key, void * val) { } // Search for an address for a given oid -INLINE void * mgcsharedhashSearch(mgcsharedhashtbl_t * tbl, void * key) { +void * mgcsharedhashSearch(mgcsharedhashtbl_t * tbl, void * key) { //REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE] - mgcsharedhashlistnode_t * node = - &tbl->table[(((unsigned INTPTR)key)&tbl->mask)>>(GC_SHIFT_BITS)]; - mgcsharedhashlistnode_t *top = &tbl->table[tbl->size]; + mgcsharedhashlistnode_t * node=&tbl->table[(((unsigned INTPTR)key)&tbl->mask)>>(GC_SHIFT_BITS)]; + mgcsharedhashlistnode_t *top=&tbl->table[tbl->size]; do { if(node->key == key) { diff --git a/Robust/src/Runtime/bamboo/GCSharedHash.h b/Robust/src/Runtime/bamboo/GCSharedHash.h index 6d0fe470..b54a4a84 100755 --- a/Robust/src/Runtime/bamboo/GCSharedHash.h +++ b/Robust/src/Runtime/bamboo/GCSharedHash.h @@ -28,7 +28,7 @@ struct GCSharedHash { struct GCSharedNode *listtail; }; -inline int GCSharedHashcountset(struct GCSharedHash * thisvar); +int GCSharedHashcountset(struct GCSharedHash * thisvar); /* RuntimeHashException *************************************************/ diff --git a/Robust/src/Runtime/bamboo/MGCHash.c b/Robust/src/Runtime/bamboo/MGCHash.c index 598162b7..4fc3eaef 100644 --- a/Robust/src/Runtime/bamboo/MGCHash.c +++ b/Robust/src/Runtime/bamboo/MGCHash.c @@ -188,7 +188,7 @@ void mgchashInsert_I(mgchashtable_t * tbl, void * key, void *val) { #endif // Search for an address for a given oid -INLINE void * mgchashSearch(mgchashtable_t * tbl, void * key) { +void * mgchashSearch(mgchashtable_t * tbl, void * key) { //REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE] mgchashlistnode_t *node = &tbl->table[(((unsigned INTPTR)key)&tbl->mask)>>(GC_SHIFT_BITS)]; @@ -206,7 +206,7 @@ INLINE void * mgchashSearch(mgchashtable_t * tbl, void * key) { unsigned int mgchashResize(mgchashtable_t * tbl, unsigned int newsize) { mgchashlistnode_t *node, *ptr, *curr; // curr and next keep track of the // current and the next - // mgchashlistnodes in a linked list + // mgchashlistnodes in a linked list unsigned int oldsize; int isfirst; // Keeps track of the first element in the // chashlistnode_t for each bin in hashtable @@ -234,30 +234,29 @@ unsigned int mgchashResize(mgchashtable_t * tbl, unsigned int newsize) { mgchashlistnode_t *tmp,*next; if ((key=curr->key) == 0) { - //Exit inner loop if there the first element is 0 - break; - //key = val =0 for element if not present within the hash table - } + //Exit inner loop if there the first element is 0 + break; + //key = val =0 for element if not present within the hash table + } index = (((unsigned INTPTR)key) & mask) >> (GC_SHIFT_BITS); tmp=&node[index]; next = curr->next; // Insert into the new table if(tmp->key == 0) { - tmp->key = key; - tmp->val = curr->val; + tmp->key = key; + tmp->val = curr->val; } /* NOTE: Add this case if you change this... This case currently never happens because of the way things rehash....*/ else if (isfirst) { - mgchashlistnode_t *newnode= RUNMALLOC(1*sizeof(mgchashlistnode_t)); - newnode->key = curr->key; - newnode->val = curr->val; - newnode->next = tmp->next; - tmp->next=newnode; - } - else { - curr->next=tmp->next; - tmp->next=curr; + mgchashlistnode_t *newnode= RUNMALLOC(1*sizeof(mgchashlistnode_t)); + newnode->key = curr->key; + newnode->val = curr->val; + newnode->next = tmp->next; + tmp->next=newnode; + } else { + curr->next=tmp->next; + tmp->next=curr; } isfirst = 0; @@ -273,7 +272,7 @@ unsigned int mgchashResize(mgchashtable_t * tbl, unsigned int newsize) { unsigned int mgchashResize_I(mgchashtable_t * tbl, unsigned int newsize) { mgchashlistnode_t *node, *ptr, *curr; // curr and next keep track of the // current and the next - // mgchashlistnodes in a linked list + // mgchashlistnodes in a linked list unsigned int oldsize; int isfirst; // Keeps track of the first element in the chashlistnode_t // for each bin in hashtable @@ -313,9 +312,8 @@ unsigned int mgchashResize_I(mgchashtable_t * tbl, unsigned int newsize) { if(tmp->key == 0) { tmp->key = key; tmp->val = curr->val; - } /* - NOTE: Add this case if you change this... - This case currently never happens because of the way things rehash....*/ + } /*NOTE: Add this case if you change this... + This case currently never happens because of the way things rehash..*/ else if (isfirst) { mgchashlistnode_t *newnode=RUNMALLOC_I(1*sizeof(mgchashlistnode_t)); newnode->key = curr->key; @@ -365,8 +363,7 @@ struct MGCHash * allocateMGCHash(int size, } thisvar=(struct MGCHash *)RUNMALLOC(sizeof(struct MGCHash)); thisvar->size = size; - thisvar->bucket = - (struct MGCNode *) RUNMALLOC(sizeof(struct MGCNode)*size); + thisvar->bucket=(struct MGCNode *) RUNMALLOC(sizeof(struct MGCNode)*size); //Set data counts thisvar->num4conflicts = conflicts; return thisvar; @@ -417,8 +414,7 @@ int MGCHashadd(struct MGCHash * thisvar, int data) { } #ifdef MULTICORE -struct MGCHash * allocateMGCHash_I(int size, - int conflicts) { +struct MGCHash * allocateMGCHash_I(int size,int conflicts) { struct MGCHash *thisvar; if (size <= 0) { #ifdef MULTICORE @@ -430,8 +426,7 @@ struct MGCHash * allocateMGCHash_I(int size, } thisvar=(struct MGCHash *)RUNMALLOC_I(sizeof(struct MGCHash)); thisvar->size = size; - thisvar->bucket = - (struct MGCNode *) RUNMALLOC_I(sizeof(struct MGCNode)*size); + thisvar->bucket=(struct MGCNode *) RUNMALLOC_I(sizeof(struct MGCNode)*size); //Set data counts thisvar->num4conflicts = conflicts; return thisvar; diff --git a/Robust/src/Runtime/bamboo/multicorecache.c b/Robust/src/Runtime/bamboo/multicorecache.c index 812a7789..391ac3c6 100644 --- a/Robust/src/Runtime/bamboo/multicorecache.c +++ b/Robust/src/Runtime/bamboo/multicorecache.c @@ -12,68 +12,6 @@ typedef struct gc_cache_revise_info { } gc_cache_revise_info_t; gc_cache_revise_info_t gc_cache_revise_infomation; -INLINE void samplingDataInit() { - gc_cache_revise_infomation.to_page_start_va = (unsigned int)to->ptr; - unsigned int toindex = (unsigned int)(tobase-gcbaseva)/(BAMBOO_PAGE_SIZE); - gc_cache_revise_infomation.to_page_end_va = gcbaseva + - (BAMBOO_PAGE_SIZE)*(toindex+1); - gc_cache_revise_infomation.to_page_index = toindex; - gc_cache_revise_infomation.orig_page_start_va = (unsigned int)orig->ptr; - gc_cache_revise_infomation.orig_page_end_va = gcbaseva+(BAMBOO_PAGE_SIZE) - *(((unsigned int)(orig->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE)+1); - gc_cache_revise_infomation.orig_page_index = - ((unsigned int)(orig->blockbase)-gcbaseva)/(BAMBOO_PAGE_SIZE); -} - -INLINE void samplingDataConvert(unsigned int current_ptr) { - unsigned int tmp_factor = - current_ptr-gc_cache_revise_infomation.to_page_start_va; - unsigned int topage=gc_cache_revise_infomation.to_page_index; - unsigned int oldpage = gc_cache_revise_infomation.orig_page_index; - int * newtable=&gccachesamplingtbl_r[topage]; - int * oldtable=&gccachesamplingtbl[oldpage]; - - for(int tt = 0; tt < NUMCORESACTIVE; tt++) { - (*newtable) = ((*newtable)+(*oldtable)*tmp_factor); - newtable=(int*)(((char *)newtable)+size_cachesamplingtbl_local_r); - oldtable=(int*) (((char *)oldtable)+size_cachesamplingtbl_local); - } -} - -INLINE void completePageConvert(struct moveHelper * orig, - struct moveHelper * to, - unsigned int current_ptr, - bool closeToPage) { - unsigned int ptr = 0; - unsigned int tocompare = 0; - if(closeToPage) { - ptr = to->ptr; - tocompare = gc_cache_revise_infomation.to_page_end_va; - } else { - ptr = orig->ptr; - tocompare = gc_cache_revise_infomation.orig_page_end_va; - } - if((unsigned int)ptr >= (unsigned int)tocompare) { - // end of an orig/to page - // compute the impact of this page for the new page - samplingDataConvert(current_ptr); - // prepare for an new orig page - unsigned int tmp_index = - (unsigned int)((unsigned int)orig->ptr-gcbaseva)/(BAMBOO_PAGE_SIZE); - gc_cache_revise_infomation.orig_page_start_va = orig->ptr; - gc_cache_revise_infomation.orig_page_end_va = gcbaseva + - (BAMBOO_PAGE_SIZE)*(unsigned int)(tmp_index+1); - gc_cache_revise_infomation.orig_page_index = tmp_index; - gc_cache_revise_infomation.to_page_start_va = to->ptr; - if(closeToPage) { - gc_cache_revise_infomation.to_page_end_va = gcbaseva+(BAMBOO_PAGE_SIZE) - *(((unsigned int)(to->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE)+1); - gc_cache_revise_infomation.to_page_index = - ((unsigned int)(to->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE); - } - } -} - // prepare for cache adaption: // -- flush the shared heap // -- clean dtlb entries @@ -92,6 +30,55 @@ void cacheAdapt_gc(bool isgccachestage) { // the master core decides how to adapt cache strategy for the mutator // according to collected statistic data +// compute the start address of page #page_index +#define CACHEADAPT_PAGE_START_ADDRESS(page_index) \ + (gcbaseva + (BAMBOO_PAGE_SIZE) * (page_index)) +// find the core that accesses the page #page_index most +#define CACHEADAPT_FIND_HOTEST_CORE(page_index,hotestcore,hotfreq) \ + { \ + int *local_tbl=&gccachesamplingtbl_r[page_index]; \ + for(int i = 0; i < NUMCORESACTIVE; i++) { \ + int freq = *local_tbl; \ + local_tbl=(int *)(((char *)local_tbl)+size_cachesamplingtbl_local_r); \ + if(*((unsigned int)(hotfreq)) < freq) { \ + *((unsigned int)(hotfreq)) = freq; \ + *((unsigned int)(hotestcore)) = i; \ + } \ + } \ + } +// find the core that accesses the page #page_index most and comput the total +// access time of the page at the same time +#define CACHEADAPT_FIND_HOTEST_CORE_W_TOTALFREQ(page_index,hotestcore,hotfreq,totalfreq) \ + { \ + int *local_tbl=&gccachesamplingtbl_r[page_index]; \ + for(int i = 0; i < NUMCORESACTIVE; i++) { \ + int freq = *local_tbl; \ + local_tbl=(int *)(((char *)local_tbl)+size_cachesamplingtbl_local_r); \ + *((unsigned int)(totalfreq)) = *((unsigned int)(totalfreq)) + freq; \ + if(*((unsigned int)(hotfreq)) < freq) { \ + *((unsigned int)(hotfreq)) = freq; \ + *((unsigned int)(hotestcore)) = i; \ + } \ + } \ + } +// Set the policy as hosted by coren +// NOTE: (x,y) should be changed to (x+1, y+1)!!! +#define CACHEADAPT_POLICY_SET_HOST_CORE(policy, coren) \ + { \ + (policy).cache_mode = BAMBOO_CACHE_MODE_COORDS; \ + (policy).lotar_x = bamboo_cpu2coords[2*(coren)]+1; \ + (policy).lotar_y = bamboo_cpu2coords[2*(coren)+1]+1; \ + } +// store the new policy information at tmp_p in gccachepolicytbl +#define CACHEADAPT_CHANGE_POLICY_4_PAGE(tmp_p,page_index,policy,numchanged) \ + { \ + *((int*)(tmp_p)) = (page_index); \ + (tmp_p)++; \ + *((int*)(tmp_p)) = (policy).word; \ + (tmp_p)++; \ + (numchanged)++; \ + } + // make all pages hfh int cacheAdapt_policy_h4h(){ unsigned int page_index = 0; @@ -100,14 +87,10 @@ int cacheAdapt_policy_h4h(){ unsigned int numchanged = 0; int * tmp_p = gccachepolicytbl+1; for(page_index = 0; page_index < page_num; page_index++) { - page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index; + page_sva = CACHEADAPT_PAGE_START_ADDRESS(page_index); bamboo_cache_policy_t policy = {0}; policy.cache_mode = BAMBOO_CACHE_MODE_HASH; - *tmp_p = page_index; - tmp_p++; - *tmp_p = policy.word; - tmp_p++; - numchanged++; + CACHEADAPT_CHANGE_POLICY_4_PAGE(tmp_p,page_index,policy,numchanged); } return numchanged; @@ -121,21 +104,13 @@ int cacheAdapt_policy_local(){ unsigned int numchanged = 0; int * tmp_p = gccachepolicytbl+1; for(page_index = 0; page_index < page_num; page_index++) { - page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index; + page_sva = CACHEADAPT_PAGE_START_ADDRESS(page_index); bamboo_cache_policy_t policy = {0}; unsigned int block = 0; BLOCKINDEX(page_sva, &block); unsigned int coren = gc_block2core[block%(NUMCORES4GC*2)]; - // locally cache the page in the hotest core - // NOTE: (x,y) should be changed to (x+1, y+1)!!! - policy.cache_mode = BAMBOO_CACHE_MODE_COORDS; - policy.lotar_x = bamboo_cpu2coords[2*coren]+1; - policy.lotar_y = bamboo_cpu2coords[2*coren+1]+1; - *tmp_p = page_index; - tmp_p++; - *tmp_p = policy.word; - tmp_p++; - numchanged++; + CACHEADAPT_POLICY_SET_HOST_CORE(policy, coren); + CACHEADAPT_CHANGE_POLICY_4_PAGE(tmp_p,page_index,policy,numchanged); } return numchanged; @@ -148,22 +123,11 @@ int cacheAdapt_policy_hotest(){ unsigned int numchanged = 0; int * tmp_p = gccachepolicytbl+1; for(page_index = 0; page_index < page_num; page_index++) { - page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index; + page_sva = CACHEADAPT_PAGE_START_ADDRESS(page_index); bamboo_cache_policy_t policy = {0}; unsigned int hotestcore = 0; unsigned int hotfreq = 0; - - int *local_tbl=&gccachesamplingtbl_r[page_index]; - for(int i = 0; i < NUMCORESACTIVE; i++) { - int freq = *local_tbl; - local_tbl=(int *)(((char *)local_tbl)+size_cachesamplingtbl_local_r); - - // check the freqency, decide if this page is hot for the core - if(hotfreq < freq) { - hotfreq = freq; - hotestcore = i; - } - } + CACHEADAPT_FIND_HOTEST_CORE(page_index,&hotestcore,&hotfreq); // TODO // Decide the cache strategy for this page // If decide to adapt a new cache strategy, write into the shared block of @@ -175,15 +139,8 @@ int cacheAdapt_policy_hotest(){ continue; } else { // locally cache the page in the hotest core - // NOTE: (x,y) should be changed to (x+1, y+1)!!! - policy.cache_mode = BAMBOO_CACHE_MODE_COORDS; - policy.lotar_x = bamboo_cpu2coords[2*hotestcore]+1; - policy.lotar_y = bamboo_cpu2coords[2*hotestcore+1]+1; - *tmp_p = page_index; - tmp_p++; - *tmp_p = policy.word; - tmp_p++; - numchanged++; + CACHEADAPT_POLICY_SET_HOST_CORE(policy, hotestcore); + CACHEADAPT_CHANGE_POLICY_4_PAGE(tmp_p,page_index,policy,numchanged); } } @@ -201,24 +158,12 @@ int cacheAdapt_policy_dominate(){ unsigned int numchanged = 0; int * tmp_p = gccachepolicytbl+1; for(page_index = 0; page_index < page_num; page_index++) { - page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index; + page_sva = CACHEADAPT_PAGE_START_ADDRESS(page_index); bamboo_cache_policy_t policy = {0}; unsigned int hotestcore = 0; unsigned long long totalfreq = 0; unsigned int hotfreq = 0; - - int *local_tbl=&gccachesamplingtbl_r[page_index]; - for(int i = 0; i < NUMCORESACTIVE; i++) { - int freq = *local_tbl; - local_tbl=(int *)(((char *)local_tbl)+size_cachesamplingtbl_local_r); - totalfreq += freq; - // check the freqency, decide if this page is hot for the core - if(hotfreq < freq) { - hotfreq = freq; - hotestcore = i; - } - } - + CACHEADAPT_FIND_HOTEST_CORE_W_TOTALFREQ(page_index,&hotestcore,&hotfreq,&totalfreq); // Decide the cache strategy for this page // If decide to adapt a new cache strategy, write into the shared block of // the gcpolicytbl @@ -227,35 +172,36 @@ int cacheAdapt_policy_dominate(){ // this page has not been accessed, do not change its cache policy continue; } - totalfreq = - (totalfreq*GC_CACHE_ADAPT_DOMINATE_THRESHOLD)/100/BAMBOO_PAGE_SIZE; + totalfreq=(totalfreq*GC_CACHE_ADAPT_DOMINATE_THRESHOLD)/100/BAMBOO_PAGE_SIZE; hotfreq/=BAMBOO_PAGE_SIZE; if(hotfreq < totalfreq) { // use hfh policy.cache_mode = BAMBOO_CACHE_MODE_HASH; } else { // locally cache the page in the hotest core - // NOTE: (x,y) should be changed to (x+1, y+1)!!! - policy.cache_mode = BAMBOO_CACHE_MODE_COORDS; - policy.lotar_x = bamboo_cpu2coords[2*hotestcore]+1; - policy.lotar_y = bamboo_cpu2coords[2*hotestcore+1]+1; + CACHEADAPT_POLICY_SET_HOST_CORE(policy, hotestcore); } - *tmp_p = page_index; - tmp_p++; - *tmp_p = policy.word; - tmp_p++; - numchanged++; + CACHEADAPT_CHANGE_POLICY_4_PAGE(tmp_p,page_index,policy,numchanged); } return numchanged; } #define GC_CACHE_ADAPT_OVERLOAD_THRESHOLD 10 +// record the worklocad of the hotestcore into core2heavypages +#define CACHEADAPT_RECORD_PAGE_WORKLOAD(hotestcore,totalfreq,hotfreq,remoteaccess,tmp_p) \ + { \ + workload[hotestcore] += (totalfreq); \ + total_workload += (totalfreq); \ + unsigned long long remoteaccess = (totalfreq) - (hotfreq); \ + unsigned int index = (unsigned int)core2heavypages[hotestcore][0]; \ + core2heavypages[hotestcore][3*index+3] = (remoteaccess); \ + core2heavypages[hotestcore][3*index+2] = (totalfreq); \ + core2heavypages[hotestcore][3*index+1] = (unsigned long long)((tmp_p)-1); \ + core2heavypages[hotestcore][0]++; \ + } -void gc_quicksort(unsigned long long *array, - unsigned int left, - unsigned int right, - unsigned int offset) { +void gc_quicksort(unsigned long long *array,unsigned int left,unsigned int right,unsigned int offset) { unsigned int pivot = 0;; unsigned int leftIdx = left; unsigned int rightIdx = right; @@ -289,6 +235,23 @@ void gc_quicksort(unsigned long long *array, return; } +INLINE void cacheAdapt_h4h_remote_accesses(unsigned long long workload_threshold,unsigned long long ** core2heavypages, unsigned long long * workload,int i) { + int j = 1; + unsigned int index = (unsigned int)core2heavypages[i][0]; + if(workload[i] > workload_threshold) { + // sort according to the remoteaccess + gc_quicksort(&core2heavypages[i][0], 1, index, 0); + while((workload[i] > workload_threshold) && (j workload_threshold) { - // sort according to the remoteaccess - gc_quicksort(&core2heavypages[i][0], 1, index, 0); - while((workload[i] > workload_threshold) && (j workload_threshold) { - // sort according to the remoteaccess - gc_quicksort(&core2heavypages[i][0], 1, index, 0); - while((workload[i] > workload_threshold) && (jptr; + unsigned int toindex = (unsigned int)(tobase-gcbaseva)/(BAMBOO_PAGE_SIZE); + gc_cache_revise_infomation.to_page_end_va = gcbaseva + + (BAMBOO_PAGE_SIZE)*(toindex+1); + gc_cache_revise_infomation.to_page_index = toindex; + gc_cache_revise_infomation.orig_page_start_va = (unsigned int)orig->ptr; + gc_cache_revise_infomation.orig_page_end_va = gcbaseva+(BAMBOO_PAGE_SIZE) + *(((unsigned int)(orig->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE)+1); + gc_cache_revise_infomation.orig_page_index = + ((unsigned int)(orig->blockbase)-gcbaseva)/(BAMBOO_PAGE_SIZE); +} + +INLINE static void samplingDataConvert(unsigned int current_ptr) { + unsigned int tmp_factor = + current_ptr-gc_cache_revise_infomation.to_page_start_va; + unsigned int topage=gc_cache_revise_infomation.to_page_index; + unsigned int oldpage = gc_cache_revise_infomation.orig_page_index; + int * newtable=&gccachesamplingtbl_r[topage]; + int * oldtable=&gccachesamplingtbl[oldpage]; + + for(int tt = 0; tt < NUMCORESACTIVE; tt++) { + (*newtable) = ((*newtable)+(*oldtable)*tmp_factor); + newtable=(int*)(((char *)newtable)+size_cachesamplingtbl_local_r); + oldtable=(int*) (((char *)oldtable)+size_cachesamplingtbl_local); + } +} + +INLINE static void completePageConvert(struct moveHelper * orig,struct moveHelper * to,unsigned int current_ptr,bool closeToPage) { + unsigned int ptr = 0; + unsigned int tocompare = 0; + if(closeToPage) { + ptr = to->ptr; + tocompare = gc_cache_revise_infomation.to_page_end_va; + } else { + ptr = orig->ptr; + tocompare = gc_cache_revise_infomation.orig_page_end_va; + } + if((unsigned int)ptr >= (unsigned int)tocompare) { + // end of an orig/to page + // compute the impact of this page for the new page + samplingDataConvert(current_ptr); + // prepare for an new orig page + unsigned int tmp_index = + (unsigned int)((unsigned int)orig->ptr-gcbaseva)/(BAMBOO_PAGE_SIZE); + gc_cache_revise_infomation.orig_page_start_va = orig->ptr; + gc_cache_revise_infomation.orig_page_end_va = gcbaseva + + (BAMBOO_PAGE_SIZE)*(unsigned int)(tmp_index+1); + gc_cache_revise_infomation.orig_page_index = tmp_index; + gc_cache_revise_infomation.to_page_start_va = to->ptr; + if(closeToPage) { + gc_cache_revise_infomation.to_page_end_va = gcbaseva+(BAMBOO_PAGE_SIZE) + *(((unsigned int)(to->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE)+1); + gc_cache_revise_infomation.to_page_index = + ((unsigned int)(to->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE); + } + } +} + void cacheAdapt_gc(bool isgccachestage); void cacheAdapt_master(); void cacheAdapt_mutator(); diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index 8a42ae66..53f33c30 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -31,15 +31,15 @@ void dumpSMem() { udn_tile_coord_y()); for(i=BAMBOO_BASE_VA; (unsinged int)i<(unsigned int)gcbaseva; i+= 4*16) { printf("(%x,%x) 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x \n", - udn_tile_coord_x(), udn_tile_coord_y(), - *((int *)(i)), *((int *)(i + 4)), - *((int *)(i + 4*2)), *((int *)(i + 4*3)), - *((int *)(i + 4*4)), *((int *)(i + 4*5)), - *((int *)(i + 4*6)), *((int *)(i + 4*7)), - *((int *)(i + 4*8)), *((int *)(i + 4*9)), - *((int *)(i + 4*10)), *((int *)(i + 4*11)), - *((int *)(i + 4*12)), *((int *)(i + 4*13)), - *((int *)(i + 4*14)), *((int *)(i + 4*15))); + udn_tile_coord_x(), udn_tile_coord_y(), + *((int *)(i)), *((int *)(i + 4)), + *((int *)(i + 4*2)), *((int *)(i + 4*3)), + *((int *)(i + 4*4)), *((int *)(i + 4*5)), + *((int *)(i + 4*6)), *((int *)(i + 4*7)), + *((int *)(i + 4*8)), *((int *)(i + 4*9)), + *((int *)(i + 4*10)), *((int *)(i + 4*11)), + *((int *)(i + 4*12)), *((int *)(i + 4*13)), + *((int *)(i + 4*14)), *((int *)(i + 4*15))); } sblock = gcreservedsb; bool advanceblock = false; @@ -50,39 +50,38 @@ void dumpSMem() { if(j%((BAMBOO_SMEM_SIZE)/(4*16)) == 0) { // finished a sblock if(j < ((BAMBOO_LARGE_SMEM_BOUND)/(4*16))) { - if((j > 0) && (j%((BAMBOO_SMEM_SIZE_L)/(4*16)) == 0)) { - // finished a block - block++; - advanceblock = true; - } + if((j > 0) && (j%((BAMBOO_SMEM_SIZE_L)/(4*16)) == 0)) { + // finished a block + block++; + advanceblock = true; + } } else { - // finished a block - block++; - advanceblock = true; + // finished a block + block++; + advanceblock = true; } // compute core # if(advanceblock) { - coren = gc_block2core[block%(NUMCORES4GC*2)]; + coren = gc_block2core[block%(NUMCORES4GC*2)]; } // compute core coordinate x = BAMBOO_COORDS_X(coren); y = BAMBOO_COORDS_Y(coren); printf("(%x,%x) ==== %d, %d : core (%d,%d), saddr %x====\n", - udn_tile_coord_x(), udn_tile_coord_y(), - block, sblock++, x, y, - (sblock-1)*(BAMBOO_SMEM_SIZE)+gcbaseva); + udn_tile_coord_x(), udn_tile_coord_y(),block, sblock++, x, y, + (sblock-1)*(BAMBOO_SMEM_SIZE)+gcbaseva); } j++; printf("(%x,%x) 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x \n", - udn_tile_coord_x(), udn_tile_coord_y(), - *((int *)(i)), *((int *)(i + 4)), - *((int *)(i + 4*2)), *((int *)(i + 4*3)), - *((int *)(i + 4*4)), *((int *)(i + 4*5)), - *((int *)(i + 4*6)), *((int *)(i + 4*7)), - *((int *)(i + 4*8)), *((int *)(i + 4*9)), - *((int *)(i + 4*10)), *((int *)(i + 4*11)), - *((int *)(i + 4*12)), *((int *)(i + 4*13)), - *((int *)(i + 4*14)), *((int *)(i + 4*15))); + udn_tile_coord_x(), udn_tile_coord_y(), + *((int *)(i)), *((int *)(i + 4)), + *((int *)(i + 4*2)), *((int *)(i + 4*3)), + *((int *)(i + 4*4)), *((int *)(i + 4*5)), + *((int *)(i + 4*6)), *((int *)(i + 4*7)), + *((int *)(i + 4*8)), *((int *)(i + 4*9)), + *((int *)(i + 4*10)), *((int *)(i + 4*11)), + *((int *)(i + 4*12)), *((int *)(i + 4*13)), + *((int *)(i + 4*14)), *((int *)(i + 4*15))); } printf("(%x,%x) \n", udn_tile_coord_x(), udn_tile_coord_y()); } @@ -207,9 +206,50 @@ bool gc_checkAllCoreStatus_I() { return true; } +INLINE void checkMarkStatus_p2() { + // check if the sum of send objs and receive obj are the same + // yes->check if the info is the latest; no->go on executing + unsigned int sumsendobj = 0; + for(int i = 0; i < NUMCORESACTIVE; i++) { + sumsendobj += gcnumsendobjs[gcnumsrobjs_index][i]; + } + for(int i = 0; i < NUMCORESACTIVE; i++) { + sumsendobj -= gcnumreceiveobjs[gcnumsrobjs_index][i]; + } + if(0 == sumsendobj) { + // Check if there are changes of the numsendobjs or numreceiveobjs + // on each core + int i = 0; + for(i = 0; i < NUMCORESACTIVE; i++) { + if((gcnumsendobjs[0][i]!=gcnumsendobjs[1][i])||(gcnumreceiveobjs[0][i]!=gcnumreceiveobjs[1][i]) ) { + break; + } + } + if(i == NUMCORESACTIVE) { + // all the core status info are the latest,stop mark phase + gcphase = COMPACTPHASE; + // restore the gcstatus for all cores + for(int i = 0; i < NUMCORESACTIVE; i++) { + gccorestatus[i] = 1; + } + } else { + // There were changes between phase 1 and phase 2, can not decide + // whether the mark phase has been finished + waitconfirm = false; + // As it fails in phase 2, flip the entries + gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } + } else { + // There were changes between phase 1 and phase 2, can not decide + // whether the mark phase has been finished + waitconfirm = false; + // As it fails in phase 2, flip the entries + gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } +} + INLINE void checkMarkStatus() { - if((!waitconfirm) || - (waitconfirm && (numconfirm == 0))) { + if((!waitconfirm)||(waitconfirm && (numconfirm == 0))) { unsigned int entry_index = 0; if(waitconfirm) { // phase 2 @@ -235,47 +275,7 @@ INLINE void checkMarkStatus() { GC_SEND_MSG_1_TO_CLIENT(GCMARKCONFIRM); } else { // Phase 2 - // check if the sum of send objs and receive obj are the same - // yes->check if the info is the latest; no->go on executing - unsigned int sumsendobj = 0; - for(int i = 0; i < NUMCORESACTIVE; i++) { - sumsendobj += gcnumsendobjs[gcnumsrobjs_index][i]; - } - for(int i = 0; i < NUMCORESACTIVE; i++) { - sumsendobj -= gcnumreceiveobjs[gcnumsrobjs_index][i]; - } - if(0 == sumsendobj) { - // Check if there are changes of the numsendobjs or numreceiveobjs on - // each core - bool ischanged = false; - for(int i = 0; i < NUMCORESACTIVE; i++) { - if((gcnumsendobjs[0][i] != gcnumsendobjs[1][i]) || - (gcnumreceiveobjs[0][i] != gcnumreceiveobjs[1][i]) ) { - ischanged = true; - break; - } - } - if(!ischanged) { - // all the core status info are the latest,stop mark phase - gcphase = COMPACTPHASE; - // restore the gcstatus for all cores - for(int i = 0; i < NUMCORESACTIVE; i++) { - gccorestatus[i] = 1; - } - } else { - // There were changes between phase 1 and phase 2, can not decide - // whether the mark phase has been finished - waitconfirm = false; - // As it fails in phase 2, flip the entries - gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0; - } - } else { - // There were changes between phase 1 and phase 2, can not decide - // whether the mark phase has been finished - waitconfirm = false; - // As it fails in phase 2, flip the entries - gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0; - } + checkMarkStatus_p2(); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); } } else { @@ -287,7 +287,6 @@ INLINE void checkMarkStatus() { // compute load balance for all cores INLINE int loadbalance(unsigned int * heaptop) { // compute load balance - // get the total loads unsigned int tloads = gcloads[STARTUPCORE]; for(int i = 1; i < NUMCORES4GC; i++) { @@ -326,27 +325,27 @@ INLINE unsigned int sortLObjs() { // find the place to insert while(true) { if(i == 0) { - if(tmp_block->prev == NULL) { - break; - } - if(tmp_block->prev->lobjs[NUMLOBJPTRS-1] > tmp_lobj) { - tmp_block->lobjs[i] = tmp_block->prev->lobjs[NUMLOBJPTRS-1]; - tmp_block->lengths[i] = tmp_block->prev->lengths[NUMLOBJPTRS-1]; - tmp_block->hosts[i] = tmp_block->prev->hosts[NUMLOBJPTRS-1]; - tmp_block = tmp_block->prev; - i = NUMLOBJPTRS-1; - } else { - break; - } // if(tmp_block->prev->lobjs[NUMLOBJPTRS-1] < tmp_lobj) + if(tmp_block->prev == NULL) { + break; + } + if(tmp_block->prev->lobjs[NUMLOBJPTRS-1] > tmp_lobj) { + tmp_block->lobjs[i] = tmp_block->prev->lobjs[NUMLOBJPTRS-1]; + tmp_block->lengths[i] = tmp_block->prev->lengths[NUMLOBJPTRS-1]; + tmp_block->hosts[i] = tmp_block->prev->hosts[NUMLOBJPTRS-1]; + tmp_block = tmp_block->prev; + i = NUMLOBJPTRS-1; + } else { + break; + } // if(tmp_block->prev->lobjs[NUMLOBJPTRS-1] < tmp_lobj) } else { - if(tmp_block->lobjs[i-1] > tmp_lobj) { - tmp_block->lobjs[i] = tmp_block->lobjs[i-1]; - tmp_block->lengths[i] = tmp_block->lengths[i-1]; - tmp_block->hosts[i] = tmp_block->hosts[i-1]; - i--; - } else { - break; - } + if(tmp_block->lobjs[i-1] > tmp_lobj) { + tmp_block->lobjs[i] = tmp_block->lobjs[i-1]; + tmp_block->lengths[i] = tmp_block->lengths[i-1]; + tmp_block->hosts[i] = tmp_block->hosts[i-1]; + i--; + } else { + break; + } } } // insert it @@ -383,11 +382,9 @@ INLINE bool cacheLObjs() { size = gclobjtail2->lengths[gclobjtailindex2]; // set the mark field to , indicating that this obj has been moved // and need to be flushed - ((struct ___Object___ *)(gclobjtail2->lobjs[gclobjtailindex2]))->marked = - COMPACTED; + ((struct ___Object___ *)(gclobjtail2->lobjs[gclobjtailindex2]))->marked=COMPACTED; dst -= size; - if((unsigned int)dst < - (unsigned int)(gclobjtail2->lobjs[gclobjtailindex2]+size)) { + if((unsigned int)dst<(unsigned int)(gclobjtail2->lobjs[gclobjtailindex2]+size)) { memmove(dst, gclobjtail2->lobjs[gclobjtailindex2], size); } else { memcpy(dst, gclobjtail2->lobjs[gclobjtailindex2], size); @@ -410,18 +407,18 @@ void updateSmemTbl(unsigned int coren, unsigned int localtop) { for(int i=0; i<2; i++) { toset = gc_core2block[2*coren+i]+(unsigned int)(NUMCORES4GC*2)*j; if(toset < ltopcore) { - bamboo_smemtbl[toset]=(toset (unsigned int)(gcbaseva+BAMBOO_SMEM_SIZE_L)) - && (((unsigned int)gcloads[0]%(BAMBOO_SMEM_SIZE)) == 0)) { + if(((unsigned int)gcloads[0]>(unsigned int)(gcbaseva+BAMBOO_SMEM_SIZE_L))&&(((unsigned int)gcloads[0]%(BAMBOO_SMEM_SIZE)) == 0)) { // edge of a block, check if this is exactly the heaptop BASEPTR(0, gcfilledblocks[0]-1, &(gcloads[0])); - gcloads[0]+=(gcfilledblocks[0]>1?(BAMBOO_SMEM_SIZE):(BAMBOO_SMEM_SIZE_L)); + gcloads[0]+=BLOCKSIZE(gcfilledblocks[0]<=1); } updateSmemTbl(0, gcloads[0]); for(int i = 1; i < NUMCORES4GC; i++) { unsigned int tmptop = 0; - if((gcfilledblocks[i] > 0) - && (((unsigned int)gcloads[i] % (BAMBOO_SMEM_SIZE)) == 0)) { + if((gcfilledblocks[i] > 0)&&(((unsigned int)gcloads[i]%(BAMBOO_SMEM_SIZE)) == 0)) { // edge of a block, check if this is exactly the heaptop BASEPTR(i, gcfilledblocks[i]-1, &gcloads[i]); - gcloads[i] += - (gcfilledblocks[i]>1?(BAMBOO_SMEM_SIZE):(BAMBOO_SMEM_SIZE_L)); + gcloads[i]+=BLOCKSIZE(gcfilledblocks[i]<=1); tmptop = gcloads[i]; } updateSmemTbl(i, gcloads[i]); @@ -459,14 +453,27 @@ INLINE unsigned int checkCurrHeapTop() { unsigned int tmpheaptop = 0; for(int i = gcnumblock-1; i >= 0; i--) { if(bamboo_smemtbl[i] > 0) { - return gcbaseva+bamboo_smemtbl[i]+((i= isize) { - remain -= isize; - // move the large obj - if((unsigned int)gcheaptop < (unsigned int)(tmpheaptop+size)) { - memmove(tmpheaptop, gcheaptop, size); - } else { - memcpy(tmpheaptop, gcheaptop, size); - } - // fill the remaining space with -2 padding - BAMBOO_MEMSET_WH(tmpheaptop+size, -2, isize-size); - - gcheaptop += size; - cpysize += isize; - // cache the mapping info - gcmappingtbl[OBJMAPPINGINDEX((unsigned int)ptr)]=(unsigned int)tmpheaptop; - tmpheaptop += isize; - - // update bamboo_smemtbl - bamboo_smemtbl[b] += isize; + remain -= isize; + // move the large obj + movelobj(tmpheaptop,ptr,size,isize); + cpysize += isize; + // update bamboo_smemtbl + bamboo_smemtbl[b] += isize; } else { - // this object acrosses blocks - if(cpysize > 0) { - CLOSEBLOCK(base, cpysize+BAMBOO_CACHE_LINE_SIZE); - bamboo_smemtbl[b] += BAMBOO_CACHE_LINE_SIZE; - cpysize = 0; - base = tmpheaptop; - if(remain == 0) { - remain = ((tmpheaptop-gcbaseva)<(BAMBOO_LARGE_SMEM_BOUND)) ? - BAMBOO_SMEM_SIZE_L : BAMBOO_SMEM_SIZE; - } - remain -= BAMBOO_CACHE_LINE_SIZE; - tmpheaptop += BAMBOO_CACHE_LINE_SIZE; - BLOCKINDEX(tmpheaptop, &b); - sb = (unsigned int)(tmpheaptop-gcbaseva)/(BAMBOO_SMEM_SIZE)+gcreservedsb; - } - - // move the large obj - if((unsigned int)gcheaptop < (unsigned int)(tmpheaptop+size)) { - memmove(tmpheaptop, gcheaptop, size); - } else { - memcpy(tmpheaptop, gcheaptop, size); - } - // fill the remaining space with -2 padding - BAMBOO_MEMSET_WH(tmpheaptop+size, -2, isize-size); - gcheaptop += size; - // cache the mapping info - gcmappingtbl[OBJMAPPINGINDEX((unsigned int)ptr)]=(unsigned int)tmpheaptop; - tmpheaptop += isize; - - // set the gcsbstarttbl and bamboo_smemtbl - unsigned int tmpsbs=1+(unsigned int)(isize-remain-1)/BAMBOO_SMEM_SIZE; - for(int k = 1; k < tmpsbs; k++) { - gcsbstarttbl[sb+k] = -1; - } - sb += tmpsbs; - bound = (b 0) { + CLOSEBLOCK(base, cpysize+BAMBOO_CACHE_LINE_SIZE); + bamboo_smemtbl[b] += BAMBOO_CACHE_LINE_SIZE; + cpysize = 0; + base = tmpheaptop; + if(remain == 0) { + remain = BLOCKSIZE((tmpheaptop-gcbaseva)<(BAMBOO_LARGE_SMEM_BOUND)); + } + remain -= BAMBOO_CACHE_LINE_SIZE; + tmpheaptop += BAMBOO_CACHE_LINE_SIZE; + BLOCKINDEX(tmpheaptop, &b); + sb = (unsigned int)(tmpheaptop-gcbaseva)/(BAMBOO_SMEM_SIZE)+gcreservedsb; + } + // move the obj + movelobj(tmpheaptop,ptr,size,isize); + + // set the gcsbstarttbl and bamboo_smemtbl + unsigned int tmpsbs=1+(unsigned int)(isize-remain-1)/BAMBOO_SMEM_SIZE; + for(int k = 1; k < tmpsbs; k++) { + gcsbstarttbl[sb+k] = -1; + } + sb += tmpsbs; + bound = BLOCKSIZE(b0)) { - dstcore = j; - haspending = true; - } else { - hasrunning = true; - } + // not finished, check if it has pending move requests + if((gcfilledblocks[j]==gcstopblock[j])&&(gcrequiredmems[j]>0)) { + dstcore = j; + haspending = true; + } else { + hasrunning = true; + } } j++; } @@ -190,17 +179,14 @@ INLINE void resolvePendingMoveRequest() { // find match unsigned int tomove = 0; unsigned int startaddr = 0; - gcrequiredmems[dstcore] = assignSpareMem(sourcecore, - gcrequiredmems[dstcore], - &tomove, - &startaddr); + gcrequiredmems[dstcore] = assignSpareMem(sourcecore,gcrequiredmems[dstcore],&tomove,&startaddr); if(STARTUPCORE == dstcore) { - gcdstcore = sourcecore; - gctomove = true; - gcmovestartaddr = startaddr; - gcblock2fill = tomove; + gcdstcore = sourcecore; + gctomove = true; + gcmovestartaddr = startaddr; + gcblock2fill = tomove; } else { - send_msg_4(dstcore,GCMOVESTART,sourcecore,startaddr,tomove); + send_msg_4(dstcore,GCMOVESTART,sourcecore,startaddr,tomove); } gcmovepending--; nosparemem = true; @@ -228,8 +214,7 @@ outernextSBlock: // check if across a big block // TODO now do not zero out the whole memory, maybe the last two conditions // are useless now - if((blockbase>=bound)||(origptr>=bound) - ||((origptr!=NULL)&&(*((int*)origptr))==0)||((*((int*)blockbase))==0)) { + if((blockbase>=bound)||(origptr>=bound)||((origptr!=NULL)&&(*((int*)origptr))==0)||((*((int*)blockbase))==0)) { innernextSBlock: // end of current heap block, jump to next one orig->numblocks++; @@ -240,8 +225,7 @@ outernextSBlock: return false; } orig->blockbase = orig->base; - orig->sblockindex = - (unsigned int)(orig->blockbase-gcbaseva)/BAMBOO_SMEM_SIZE; + orig->sblockindex=(unsigned int)(orig->blockbase-gcbaseva)/BAMBOO_SMEM_SIZE; sbchanged = true; unsigned int blocknum = 0; BLOCKINDEX(orig->base, &blocknum); @@ -282,8 +266,7 @@ outernextSBlock: } // return false if there are no available data to compact -INLINE bool initOrig_Dst(struct moveHelper * orig, - struct moveHelper * to) { +INLINE bool initOrig_Dst(struct moveHelper * orig,struct moveHelper * to) { // init the dst ptr to->numblocks = 0; to->top = to->offset = BAMBOO_CACHE_LINE_SIZE; @@ -328,9 +311,7 @@ INLINE void nextBlock(struct moveHelper * to) { to->ptr = to->base + to->offset; } -INLINE unsigned int findValidObj(struct moveHelper * orig, - struct moveHelper * to, - int * type) { +INLINE unsigned int findValidObj(struct moveHelper * orig,struct moveHelper * to,int * type) { unsigned int size = 0; while(true) { CACHEADAPT_COMPLETE_PAGE_CONVERT(orig, to, to->ptr, false); @@ -444,17 +425,11 @@ INLINE bool moveobj(struct moveHelper * orig, struct moveHelper * to, unsigned i // move to next obj orig->ptr += isize; - return ((((unsigned int)(orig->ptr) > (unsigned int)(orig->bound)) - || ((unsigned int)(orig->ptr) == (unsigned int)(orig->blockbound))) - &&!nextSBlock(orig)); + return ((((unsigned int)(orig->ptr) > (unsigned int)(orig->bound))||((unsigned int)(orig->ptr) == (unsigned int)(orig->blockbound)))&&!nextSBlock(orig)); } // should be invoked with interrupt closed -bool gcfindSpareMem_I(unsigned int * startaddr, - unsigned int * tomove, - unsigned int * dstcore, - unsigned int requiredmem, - unsigned int requiredcore) { +bool gcfindSpareMem_I(unsigned int * startaddr,unsigned int * tomove,unsigned int * dstcore,unsigned int requiredmem,unsigned int requiredcore) { for(int k = 0; k < NUMCORES4GC; k++) { if((gccorestatus[k] == 0) && (gcfilledblocks[k] < gcstopblock[k])) { // check if this stopped core has enough mem @@ -469,11 +444,7 @@ bool gcfindSpareMem_I(unsigned int * startaddr, return false; } -bool gcfindSpareMem(unsigned int * startaddr, - unsigned int * tomove, - unsigned int * dstcore, - unsigned int requiredmem, - unsigned int requiredcore) { +bool gcfindSpareMem(unsigned int * startaddr,unsigned int * tomove,unsigned int * dstcore,unsigned int requiredmem,unsigned int requiredcore) { BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); for(int k = 0; k < NUMCORES4GC; k++) { if((gccorestatus[k] == 0) && (gcfilledblocks[k] < gcstopblock[k])) { @@ -491,11 +462,7 @@ bool gcfindSpareMem(unsigned int * startaddr, return false; } -INLINE bool compacthelper(struct moveHelper * orig, - struct moveHelper * to, - int * filledblocks, - unsigned int * heaptopptr, - bool * localcompact) { +INLINE bool compacthelper(struct moveHelper * orig,struct moveHelper * to,int * filledblocks,unsigned int * heaptopptr,bool * localcompact) { // scan over all objs in this block, compact the marked objs // loop stop when finishing either scanning all active objs or // fulfilled the gcstopblock @@ -528,8 +495,7 @@ innercompact: if((unsigned int)(orig->ptr) < (unsigned int)gcmarkedptrbound) { // ask for more mem gctomove = false; - if(gcfindSpareMem(&gcmovestartaddr, &gcblock2fill, &gcdstcore, - gccurr_heaptop, BAMBOO_NUM_OF_CORE)) { + if(gcfindSpareMem(&gcmovestartaddr,&gcblock2fill,&gcdstcore,gccurr_heaptop,BAMBOO_NUM_OF_CORE)) { gctomove = true; } else { return false; @@ -558,10 +524,10 @@ innercompact: to->ptr = gcmovestartaddr; to->numblocks = gcblock2fill - 1; - to->bound = ((to->numblocks==0)?BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE_L)+BAMBOO_SMEM_SIZE*to->numblocks; + to->bound = BLOCKBOUND(to->numblocks); BASEPTR(gcdstcore, to->numblocks, &(to->base)); to->offset = to->ptr - to->base; - to->top = (to->numblocks==0)?(to->offset):(to->bound-BAMBOO_SMEM_SIZE+to->offset); + to->top=(to->numblocks==0)?(to->offset):(to->bound-BAMBOO_SMEM_SIZE+to->offset); to->base = to->ptr; to->offset = BAMBOO_CACHE_LINE_SIZE; to->ptr += to->offset; // for header @@ -627,7 +593,7 @@ void compact_master(struct moveHelper * orig, struct moveHelper * to) { if(gctomove) { to->ptr = gcmovestartaddr; to->numblocks = gcblock2fill - 1; - to->bound = (to->numblocks==0) ? BAMBOO_SMEM_SIZE_L : BAMBOO_SMEM_SIZE_L+BAMBOO_SMEM_SIZE*to->numblocks; + to->bound = BLOCKBOUND(to->numblocks); BASEPTR(gcdstcore, to->numblocks, &(to->base)); to->offset = to->ptr - to->base; to->top = (to->numblocks==0)?(to->offset):(to->bound-BAMBOO_SMEM_SIZE+to->offset); diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.h b/Robust/src/Runtime/bamboo/multicoregccompact.h index d693d8d7..4032d538 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.h +++ b/Robust/src/Runtime/bamboo/multicoregccompact.h @@ -21,11 +21,7 @@ struct moveHelper { #define GC_BLOCK_REMAIN_SIZE(b, p) \ ((b)list;ptr!=NULL;ptr=ptr->inext) { + for(struct genpointerlist * ptr=activetasks->list;ptr!=NULL;ptr=ptr->inext){ struct taskparamdescriptor *tpd=ptr->src; for(int i=0; inumParameters; i++) { // the parameter can not be NULL diff --git a/Robust/src/Runtime/bamboo/multicoregcprofile.c b/Robust/src/Runtime/bamboo/multicoregcprofile.c index 72d7f152..0daec7d2 100644 --- a/Robust/src/Runtime/bamboo/multicoregcprofile.c +++ b/Robust/src/Runtime/bamboo/multicoregcprofile.c @@ -2,10 +2,9 @@ #ifdef GC_PROFILE #include "multicoregcprofile.h" #include "runtime_arch.h" -#include "structdefs.h" #include "mem.h" -INLINE void initmulticoregcprofiledata() { +void initmulticoregcprofiledata() { if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { // startup core to initialize corestatus[] gc_infoIndex = 0; @@ -19,50 +18,6 @@ INLINE void initmulticoregcprofiledata() { gc_num_profiles = NUMCORESACTIVE - 1; } -INLINE void gc_profileInit() { - gc_num_livespace = 0; - gc_num_freespace = 0; - gc_num_lobj = 0; - gc_num_lobjspace = 0; - gc_num_liveobj = 0; - gc_num_forwardobj = 0; - gc_num_profiles = NUMCORESACTIVE - 1; -} - -INLINE void gc_profileStart(void) { - if(!gc_infoOverflow) { - GCInfo* gcInfo = RUNMALLOC(sizeof(struct gc_info)); - gc_infoArray[gc_infoIndex] = gcInfo; - gcInfo->index = 1; - gcInfo->time[0] = BAMBOO_GET_EXE_TIME(); - } -} - -INLINE void gc_profileItem(void) { - if(!gc_infoOverflow) { - GCInfo* gcInfo = gc_infoArray[gc_infoIndex]; - gcInfo->time[gcInfo->index++] = BAMBOO_GET_EXE_TIME(); - } -} - -INLINE void gc_profileEnd(void) { - if(!gc_infoOverflow) { - GCInfo* gcInfo = gc_infoArray[gc_infoIndex]; - gcInfo->time[gcInfo->index++] = BAMBOO_GET_EXE_TIME(); - gcInfo->time[gcInfo->index++] = gc_num_livespace; - gcInfo->time[gcInfo->index++] = gc_num_freespace; - gcInfo->time[gcInfo->index++] = gc_num_lobj; - gcInfo->time[gcInfo->index++] = gc_num_lobjspace; - gcInfo->time[gcInfo->index++] = gc_num_obj; - gcInfo->time[gcInfo->index++] = gc_num_liveobj; - gcInfo->time[gcInfo->index++] = gc_num_forwardobj; - gc_infoIndex++; - if(gc_infoIndex == GCINFOLENGTH) { - gc_infoOverflow = true; - } - } -} - // output the profiling data void gc_outputProfileData() { int i = 0; diff --git a/Robust/src/Runtime/bamboo/multicoregcprofile.h b/Robust/src/Runtime/bamboo/multicoregcprofile.h index 4a63185f..10d52ba4 100644 --- a/Robust/src/Runtime/bamboo/multicoregcprofile.h +++ b/Robust/src/Runtime/bamboo/multicoregcprofile.h @@ -2,6 +2,8 @@ #define BAMBOO_MULTICORE_GC_PROFILE_H #ifdef MULTICORE_GC #include "multicore.h" +#include "runtime_arch.h" +#include "structdefs.h" #ifdef GC_PROFILE #define GCINFOLENGTH 100 @@ -34,14 +36,53 @@ unsigned int gc_num_profiles; volatile bool gc_profile_flag; #endif - -INLINE void initmulticoregcprofiledata(void); -INLINE void gc_profileInit(void); -INLINE void gc_profileStart(void); -INLINE void gc_profileItem(void); -INLINE void gc_profileEnd(void); +void initmulticoregcprofiledata(void); void gc_outputProfileData(); +INLINE static void gc_profileInit() { + gc_num_livespace = 0; + gc_num_freespace = 0; + gc_num_lobj = 0; + gc_num_lobjspace = 0; + gc_num_liveobj = 0; + gc_num_forwardobj = 0; + gc_num_profiles = NUMCORESACTIVE - 1; +} + +INLINE static void gc_profileStart(void) { + if(!gc_infoOverflow) { + GCInfo* gcInfo = RUNMALLOC(sizeof(struct gc_info)); + gc_infoArray[gc_infoIndex] = gcInfo; + gcInfo->index = 1; + gcInfo->time[0] = BAMBOO_GET_EXE_TIME(); + } +} + +INLINE static void gc_profileItem(void) { + if(!gc_infoOverflow) { + GCInfo* gcInfo = gc_infoArray[gc_infoIndex]; + gcInfo->time[gcInfo->index++] = BAMBOO_GET_EXE_TIME(); + } +} + +INLINE static void gc_profileEnd(void) { + if(!gc_infoOverflow) { + GCInfo* gcInfo = gc_infoArray[gc_infoIndex]; + gcInfo->time[gcInfo->index++] = BAMBOO_GET_EXE_TIME(); + gcInfo->time[gcInfo->index++] = gc_num_livespace; + gcInfo->time[gcInfo->index++] = gc_num_freespace; + gcInfo->time[gcInfo->index++] = gc_num_lobj; + gcInfo->time[gcInfo->index++] = gc_num_lobjspace; + gcInfo->time[gcInfo->index++] = gc_num_obj; + gcInfo->time[gcInfo->index++] = gc_num_liveobj; + gcInfo->time[gcInfo->index++] = gc_num_forwardobj; + gc_infoIndex++; + if(gc_infoIndex == GCINFOLENGTH) { + gc_infoOverflow = true; + } + } +} + #define INIT_MULTICORE_GCPROFILE_DATA() initmulticoregcprofiledata() #define GC_OUTPUT_PROFILE_DATA() gc_outputProfileData() // send the num of obj/liveobj/forwardobj to the startupcore diff --git a/Robust/src/Runtime/bamboo/multicorehelper.h b/Robust/src/Runtime/bamboo/multicorehelper.h index 2d8c7f40..0a66c83e 100644 --- a/Robust/src/Runtime/bamboo/multicorehelper.h +++ b/Robust/src/Runtime/bamboo/multicorehelper.h @@ -1,3 +1,5 @@ +// NOTE: this file should be changed to be generated automatically + #ifndef BAMBOO_MULTICORE_HELPER_H #define BAMBOO_MULTICORE_HELPER_H diff --git a/Robust/src/Runtime/bamboo/multicoremem.c b/Robust/src/Runtime/bamboo/multicoremem.c index 44e373d5..98cde60e 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.c +++ b/Robust/src/Runtime/bamboo/multicoremem.c @@ -4,414 +4,7 @@ #ifdef MULTICORE_GC #include "multicorehelper.h" - -#ifdef SMEMF -#define NUM_CORES2TEST 5 -#ifdef GC_1 -int core2test[1][NUM_CORES2TEST] = { - {0, -1, -1, -1, -1} -}; -#elif defined GC_56 -int core2test[56][NUM_CORES2TEST] = { - { 0, -1, 7, -1, 1}, { 1, -1, 8, 0, 2}, { 2, -1, 9, 1, 3}, - { 3, -1, 10, 2, 4}, { 4, -1, 11, 3, 5}, { 5, -1, 12, 4, 6}, - { 6, -1, 13, 5, -1}, { 7, 0, 14, -1, 8}, { 8, 1, 15, 7, 9}, - { 9, 2, 16, 8, 10}, {10, 3, 17, 9, 11}, {11, 4, 18, 10, 12}, - {12, 5, 19, 11, 13}, {13, 6, 20, 12, -1}, {14, 7, 21, -1, 15}, - {15, 8, 22, 14, 16}, {16, 9, 23, 15, 17}, {17, 10, 24, 16, 18}, - {18, 11, 25, 17, 19}, {19, 12, 26, 18, 20}, {20, 13, 27, 19, -1}, - {21, 14, 28, -1, 22}, {22, 15, 29, 21, 23}, {23, 16, 30, 22, 24}, - {24, 17, 31, 23, 25}, {25, 18, 32, 24, 26}, {26, 19, 33, 25, 27}, - {27, 20, 34, 26, -1}, {28, 21, 35, -1, 29}, {29, 22, 36, 28, 30}, - {30, 23, 37, 29, 31}, {31, 24, 38, 30, 32}, {32, 25, 39, 31, 33}, - {33, 26, 40, 32, 34}, {34, 27, 41, 33, -1}, {35, 28, 42, -1, 36}, - {36, 29, 43, 35, 37}, {37, 30, 44, 36, 38}, {38, 31, 45, 37, 39}, - {39, 32, 46, 38, 40}, {40, 33, 47, 39, 41}, {41, 34, 48, 40, -1}, - {42, 35, 49, -1, 43}, {43, 36, 50, 42, 44}, {44, 37, 51, 43, 45}, - {45, 38, 52, 44, 46}, {46, 39, 53, 45, 47}, {47, 40, 54, 46, 48}, - {48, 41, 55, 47, -1}, {49, 42, -1, -1, 50}, {50, 43, -1, 49, 51}, - {51, 44, -1, 50, 52}, {52, 45, -1, 51, 53}, {53, 46, -1, 52, 54}, - {54, 47, -1, 53, 55}, {55, 48, -1, 54, -1} -}; -#elif defined GC_62 -int core2test[62][NUM_CORES2TEST] = { - { 0, -1, 6, -1, 1}, { 1, -1, 7, 0, 2}, { 2, -1, 8, 1, 3}, - { 3, -1, 9, 2, 4}, { 4, -1, 10, 3, 5}, { 5, -1, 11, 4, -1}, - { 6, 0, 14, -1, 7}, { 7, 1, 15, 6, 8}, { 8, 2, 16, 7, 9}, - { 9, 3, 17, 8, 10}, {10, 4, 18, 9, 11}, {11, 5, 19, 10, 12}, - {12, -1, 20, 11, 13}, {13, -1, 21, 12, -1}, {14, 6, 22, -1, 15}, - {15, 7, 23, 14, 16}, {16, 8, 24, 15, 17}, {17, 9, 25, 16, 18}, - {18, 10, 26, 17, 19}, {19, 11, 27, 18, 20}, {20, 12, 28, 19, 21}, - {21, 13, 29, 28, -1}, {22, 14, 30, -1, 23}, {23, 15, 31, 22, 24}, - {24, 16, 32, 23, 25}, {25, 17, 33, 24, 26}, {26, 18, 34, 25, 27}, - {27, 19, 35, 26, 28}, {28, 20, 36, 27, 29}, {29, 21, 37, 28, -1}, - {30, 22, 38, -1, 31}, {31, 23, 39, 30, 32}, {32, 24, 40, 31, 33}, - {33, 25, 41, 32, 34}, {34, 26, 42, 33, 35}, {35, 27, 43, 34, 36}, - {36, 28, 44, 35, 37}, {37, 29, 45, 36, -1}, {38, 30, 46, -1, 39}, - {39, 31, 47, 38, 40}, {40, 32, 48, 39, 41}, {41, 33, 49, 40, 42}, - {42, 34, 50, 41, 43}, {43, 35, 51, 42, 44}, {44, 36, 52, 43, 45}, - {45, 37, 53, 44, -1}, {46, 38, 54, -1, 47}, {47, 39, 55, 46, 48}, - {48, 40, 56, 47, 49}, {49, 41, 57, 48, 50}, {50, 42, 58, 49, 51}, - {51, 43, 59, 50, 52}, {52, 44, 60, 51, 53}, {53, 45, 61, 52, -1}, - {54, 46, -1, -1, 55}, {55, 47, -1, 54, 56}, {56, 48, -1, 55, 57}, - {57, 49, -1, 56, 59}, {58, 50, -1, 57, 59}, {59, 51, -1, 58, 60}, - {60, 52, -1, 59, 61}, {61, 53, -1, 60, -1} -}; -#endif // GC_1 -#elif defined SMEMM -unsigned int gcmem_mixed_threshold = 0; -unsigned int gcmem_mixed_usedmem = 0; -#define NUM_CORES2TEST 13 -#ifdef GC_1 -int core2test[1][NUM_CORES2TEST] = { - {0, -1, -1, -1, -1, -1, -1, -1, -1} -}; -#elif defined GC_2 -int core2test[2][NUM_CORES2TEST] = { - { 0, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, - { 1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} -}; -#elif defined GC_4 -int core2test[4][NUM_CORES2TEST] = { - { 0, -1, -1, 2, 1, -1, -1, -1, -1, -1, -1, -1, -1}, - { 1, -1, 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - { 2, 0, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1}, - { 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} -}; -#elif defined GC_8 -int core2test[8][NUM_CORES2TEST] = { - { 0, -1, -1, 4, 1, -1, -1, -1, -1, -1, 5, 2, -1}, - { 1, -1, 0, 5, 2, -1, -1, -1, 4, -1, 6, 3, -1}, - { 2, -1, 1, 6, 3, -1, -1, 0, 5, -1, 7, -1, -1}, - { 3, -1, 2, 7, -1, -1, -1, 1, 6, -1, -1, -1, -1}, - { 4, 0, -1, -1, 5, -1, -1, -1, -1, -1, -1, 6, 1}, - { 5, 1, 4, -1, 6, -1, 0, -1, -1, -1, -1, 7, 2}, - { 6, 2, 5, -1, 7, -1, 1, 4, -1, -1, -1, -1, 3}, - { 7, 3, 6, -1, -1, -1, 2, 5, -1, -1, -1, -1, -1} -}; -#elif defined GC_16 -int core2test[16][NUM_CORES2TEST] = { - { 0, -1, -1, 4, 1, -1, -1, -1, -1, 8, 5, 2, -1}, - { 1, -1, 0, 5, 2, -1, -1, -1, 4, 9, 6, 3, -1}, - { 2, -1, 1, 6, 3, -1, -1, 0, 5, 10, 7, -1, -1}, - { 3, -1, 2, 7, -1, -1, -1, 1, 6, 11, -1, -1, -1}, - { 4, 0, -1, 8, 5, -1, -1, -1, -1, 12, 9, 6, 1}, - { 5, 1, 4, 9, 6, -1, 0, -1, 8, 13, 10, 7, 2}, - { 6, 2, 5, 10, 7, -1, 1, 4, 9, 14, 11, -1, 3}, - { 7, 3, 6, 11, -1, -1, 2, 5, 10, 15, -1, -1, -1}, - { 8, 4, -1, 12, 9, 0, -1, -1, -1, -1, 13, 10, 5}, - { 9, 5, 8, 13, 10, 1, 4, -1, 12, -1, 14, 11, 6}, - {10, 6, 9, 14, 11, 2, 5, 8, 13, -1, 15, -1, 7}, - {11, 7, 10, 15, -1, 3, 6, 9, 14, -1, -1, -1, -1}, - {12, 8, -1, -1, 13, 4, -1, -1, -1, -1, -1, 14, 9}, - {13, 9, 12, -1, 14, 5, 8, -1, -1, -1, -1, 15, 10}, - {14, 10, 13, -1, 15, 6, 9, 12, -1, -1, -1, -1, 11}, - {15, 11, 14, -1, -1, 7, 10, 13, -1, -1, -1, -1, -1} -}; -#elif defined GC_32 -int core2test[32][NUM_CORES2TEST] = { - { 0, -1, -1, 4, 1, -1, -1, -1, -1, 8, 5, 2, -1}, - { 1, -1, 0, 5, 2, -1, -1, -1, 4, 9, 6, 3, -1}, - { 2, -1, 1, 6, 3, -1, -1, 0, 5, 10, 7, -1, -1}, - { 3, -1, 2, 7, -1, -1, -1, 1, 6, 11, -1, -1, -1}, - { 4, 0, -1, 8, 5, -1, -1, -1, -1, 12, 9, 6, 1}, - { 5, 1, 4, 9, 6, -1, 0, -1, 8, 13, 10, 7, 2}, - { 6, 2, 5, 10, 7, -1, 1, 4, 9, 14, 11, -1, 3}, - { 7, 3, 6, 11, -1, -1, 2, 5, 10, 15, -1, -1, -1}, - { 8, 4, -1, 12, 9, 0, -1, -1, -1, 16, 13, 10, 5}, - { 9, 5, 8, 13, 10, 1, 4, -1, 12, 17, 14, 11, 6}, - {10, 6, 9, 14, 11, 2, 5, 8, 13, 18, 15, -1, 7}, - {11, 7, 10, 15, -1, 3, 6, 9, 14, 19, -1, -1, -1}, - {12, 8, -1, 16, 13, 4, -1, -1, -1, 20, 17, 14, 9}, - {13, 9, 12, 17, 14, 5, 8, -1, 16, 21, 18, 15, 10}, - {14, 10, 13, 18, 15, 6, 9, 12, 17, 22, 19, -1, 11}, - {15, 11, 14, 19, -1, 7, 10, 13, 18, 23, -1, -1, -1}, - {16, 12, -1, 20, 17, 8, -1, -1, -1, 24, 21, 18, 13}, - {17, 13, 16, 21, 18, 9, 12, -1, 20, 25, 22, 19, 14}, - {18, 14, 17, 22, 19, 10, 13, 16, 21, 26, 23, -1, 15}, - {19, 15, 18, 23, -1, 11, 14, 17, 22, 27, -1, -1, -1}, - {20, 16, -1, 24, 21, 12, -1, -1, -1, 28, 25, 22, 17}, - {21, 17, 20, 25, 22, 13, 16, -1, 24, 29, 26, 23, 18}, - {22, 18, 21, 26, 23, 14, 17, 20, 25, 30, 27, -1, 19}, - {23, 19, 22, 27, -1, 15, 18, 21, 26, 31, -1, -1, -1}, - {24, 20, -1, 28, 25, 16, -1, -1, -1, -1, 29, 26, 21}, - {25, 21, 24, 29, 26, 17, 20, -1, 28, -1, 30, 27, 22}, - {26, 22, 25, 30, 27, 18, 21, 24, 29, -1, 31, -1, 23}, - {27, 23, 26, 31, -1, 19, 22, 25, 30, -1, -1, -1, -1}, - {28, 24, -1, -1, 29, 20, -1, -1, -1, -1, -1, 30, 25}, - {29, 25, 28, -1, 30, 21, 24, -1, -1, -1, -1, 31, 26}, - {30, 26, 29, -1, 31, 22, 25, 28, -1, -1, -1, -1, 27}, - {31, 27, 30, -1, -1, 23, 26, 29, -1, -1, -1, -1, -1} -}; -#elif defined GC_36 -int core2test[36][NUM_CORES2TEST] = { - { 0, -1, -1, 6, 1, -1, -1, -1, -1, 12, 7, 2, -1}, - { 1, -1, 0, 7, 2, -1, -1, -1, 6, 13, 8, 3, -1}, - { 2, -1, 1, 8, 3, -1, -1, 0, 7, 14, 9, 4, -1}, - { 3, -1, 2, 9, 4, -1, -1, 1, 8, 15, 10, 5, -1}, - { 4, -1, 3, 10, 5, -1, -1, 2, 9, 16, 11, -1, -1}, - { 5, -1, 4, 11, -1, -1, -1, 3, 10, 17, -1, -1, -1}, - { 6, 0, -1, 12, 7, -1, -1, -1, -1, 18, 13, 8, 1}, - { 7, 1, 6, 13, 8, -1, 0, -1, 12, 19, 14, 9, 2}, - { 8, 2, 7, 14, 9, -1, 1, 6, 13, 20, 15, 10, 3}, - { 9, 3, 8, 15, 10, -1, 2, 7, 14, 21, 16, 11, 4}, - {10, 4, 9, 16, 11, -1, 3, 8, 15, 22, 17, -1, 5}, - {11, 5, 10, 17, -1, -1, 4, 9, 16, 23, -1, -1, -1}, - {12, 6, -1, 18, 13, 0, -1, -1, -1, 24, 19, 14, 7}, - {13, 7, 12, 19, 14, 1, 6, -1, 18, 25, 20, 15, 8}, - {14, 8, 13, 20, 15, 2, 7, 12, 19, 26, 21, 16, 9}, - {15, 9, 14, 21, 16, 3, 8, 13, 20, 27, 22, 17, 10}, - {16, 10, 15, 22, 17, 4, 9, 14, 21, 28, 23, -1, 11}, - {17, 11, 16, 23, -1, 5, 10, 15, 22, 29, -1, -1, -1}, - {18, 12, -1, 24, 19, 6, -1, -1, -1, 30, 25, 20, 13}, - {19, 13, 18, 25, 20, 7, 12, -1, 24, 31, 26, 21, 14}, - {20, 14, 19, 26, 21, 8, 13, 18, 25, 32, 27, 22, 15}, - {21, 15, 20, 27, 22, 9, 14, 19, 26, 33, 28, 23, 16}, - {22, 16, 21, 28, 23, 10, 15, 20, 27, 34, 29, -1, 17}, - {23, 17, 22, 29, -1, 11, 16, 21, 28, 35, -1, -1, -1}, - {24, 18, -1, 30, 25, 12, -1, -1, -1, -1, 31, 26, 19}, - {25, 19, 24, 31, 26, 13, 18, -1, 30, -1, 32, 27, 20}, - {26, 20, 25, 32, 27, 14, 19, 24, 31, -1, 33, 28, 21}, - {27, 21, 26, 33, 28, 15, 20, 25, 32, -1, 34, 29, 22}, - {28, 22, 27, 34, 29, 16, 21, 26, 33, -1, 35, -1, 23}, - {29, 23, 28, 35, -1, 17, 22, 27, 34, -1, -1, -1, -1}, - {30, 24, -1, -1, 31, 18, -1, -1, -1, -1, -1, 32, 25}, - {31, 25, 30, -1, 32, 19, 24, -1, -1, -1, -1, 33, 26}, - {32, 26, 31, -1, 33, 20, 25, 30, -1, -1, -1, 34, 27}, - {33, 27, 32, -1, 34, 21, 26, 31, -1, -1, -1, 35, 28}, - {34, 28, 33, -1, 35, 22, 27, 32, -1, -1, -1, -1, 29}, - {35, 29, 34, -1, -1, 23, 28, 33, -1, -1, -1, -1, -1} -}; -#elif defined GC_48 -int core2test[48][NUM_CORES2TEST] = { - { 0, -1, -1, 6, 1, -1, -1, -1, -1, 12, 7, 2, -1}, - { 1, -1, 0, 7, 2, -1, -1, -1, 6, 13, 8, 3, -1}, - { 2, -1, 1, 8, 3, -1, -1, 0, 7, 14, 9, 4, -1}, - { 3, -1, 2, 9, 4, -1, -1, 1, 8, 15, 10, 5, -1}, - { 4, -1, 3, 10, 5, -1, -1, 2, 9, 16, 11, -1, -1}, - { 5, -1, 4, 11, -1, -1, -1, 3, 10, 17, -1, -1, -1}, - { 6, 0, -1, 12, 7, -1, -1, -1, -1, 18, 13, 8, 1}, - { 7, 1, 6, 13, 8, -1, 0, -1, 12, 19, 14, 9, 2}, - { 8, 2, 7, 14, 9, -1, 1, 6, 13, 20, 15, 10, 3}, - { 9, 3, 8, 15, 10, -1, 2, 7, 14, 21, 16, 11, 4}, - {10, 4, 9, 16, 11, -1, 3, 8, 15, 22, 17, -1, 5}, - {11, 5, 10, 17, -1, -1, 4, 9, 16, 23, -1, -1, -1}, - {12, 6, -1, 18, 13, 0, -1, -1, -1, 24, 19, 14, 7}, - {13, 7, 12, 29, 14, 1, 6, -1, 18, 25, 20, 15, 8}, - {14, 8, 13, 20, 15, 2, 7, 12, 19, 26, 21, 16, 9}, - {15, 9, 14, 21, 16, 3, 8, 13, 20, 27, 22, 17, 10}, - {16, 10, 15, 22, 17, 4, 9, 14, 21, 28, 23, -1, 11}, - {17, 11, 16, 23, -1, 5, 10, 15, 22, 29, -1, -1, -1}, - {18, 12, -1, 24, 19, 6, -1, -1, -1, 30, 25, 20, 13}, - {19, 13, 18, 25, 20, 7, 12, -1, 24, 31, 26, 21, 14}, - {20, 14, 19, 26, 21, 8, 13, 18, 25, 32, 27, 22, 15}, - {21, 15, 20, 27, 22, 9, 14, 19, 26, 33, 28, 23, 16}, - {22, 16, 21, 28, 23, 10, 15, 20, 27, 34, 29, -1, 17}, - {23, 17, 22, 29, -1, 11, 16, 21, 28, 35, -1, -1, -1}, - {24, 18, -1, 30, 25, 12, -1, -1, -1, 36, 31, 26, 19}, - {25, 19, 24, 31, 26, 13, 18, -1, 30, 37, 32, 27, 20}, - {26, 20, 25, 32, 27, 14, 19, 24, 31, 38, 33, 28, 21}, - {27, 21, 26, 33, 28, 15, 20, 25, 32, 39, 34, 29, 22}, - {28, 22, 27, 34, 29, 16, 21, 26, 33, 40, 35, -1, 23}, - {29, 23, 28, 35, -1, 17, 22, 27, 34, 41, -1, -1, -1}, - {30, 24, -1, 36, 31, 18, -1, -1, -1, 42, 37, 32, 25}, - {31, 25, 30, 37, 32, 19, 24, -1, 36, 43, 38, 33, 26}, - {32, 26, 31, 38, 33, 20, 25, 30, 37, 44, 39, 34, 27}, - {33, 27, 32, 39, 34, 21, 26, 31, 38, 45, 40, 35, 28}, - {34, 28, 33, 40, 35, 22, 27, 32, 39, 46, 41, -1, 29}, - {35, 29, 34, 41, -1, 23, 28, 33, 40, 47, -1, -1, -1}, - {36, 30, -1, 42, 37, 24, -1, -1, -1, -1, 43, 38, 31}, - {37, 31, 36, 43, 38, 25, 30, -1, 42, -1, 44, 39, 32}, - {38, 32, 37, 44, 39, 26, 31, 36, 43, -1, 45, 40, 33}, - {39, 33, 38, 45, 40, 27, 32, 37, 44, -1, 46, 41, 34}, - {40, 34, 39, 46, 41, 28, 33, 38, 45, -1, 47, -1, 35}, - {41, 35, 40, 47, -1, 29, 34, 39, 46, -1, -1, -1, -1}, - {42, 36, -1, -1, 43, 30, -1, -1, -1, -1, -1, 44, 37}, - {43, 37, 42, -1, 44, 31, 36, -1, -1, -1, -1, 45, 38}, - {44, 38, 43, -1, 45, 32, 37, 42, -1, -1, -1, 46, 39}, - {45, 39, 44, -1, 46, 33, 38, 43, -1, -1, -1, 47, 40}, - {46, 40, 45, -1, 47, 34, 39, 44, -1, -1, -1, -1, 41}, - {47, 41, 46, -1, -1, 35, 40, 45, -1, -1, -1, -1, -1}, -}; -#elif defined GC_50 -int core2test[50][NUM_CORES2TEST] = { - { 0, -1, -1, 6, 1, -1, -1, -1, -1, 12, 7, 2, -1}, - { 1, -1, 0, 7, 2, -1, -1, -1, 6, 13, 8, 3, -1}, - { 2, -1, 1, 8, 3, -1, -1, 0, 7, 14, 9, 4, -1}, - { 3, -1, 2, 9, 4, -1, -1, 1, 8, 15, 10, 5, -1}, - { 4, -1, 3, 10, 5, -1, -1, 2, 9, 16, 11, -1, -1}, - { 5, -1, 4, 11, -1, -1, -1, 3, 10, 17, -1, -1, -1}, - { 6, 0, -1, 12, 7, -1, -1, -1, -1, 18, 13, 8, 1}, - { 7, 1, 6, 13, 8, -1, 0, -1, 12, 19, 14, 9, 2}, - { 8, 2, 7, 14, 9, -1, 1, 6, 13, 20, 15, 10, 3}, - { 9, 3, 8, 15, 10, -1, 2, 7, 14, 21, 16, 11, 4}, - {10, 4, 9, 16, 11, -1, 3, 8, 15, 22, 17, -1, 5}, - {11, 5, 10, 17, -1, -1, 4, 9, 16, 23, -1, -1, -1}, - {12, 6, -1, 18, 13, 0, -1, -1, -1, 24, 19, 14, 7}, - {13, 7, 12, 29, 14, 1, 6, -1, 18, 25, 20, 15, 8}, - {14, 8, 13, 20, 15, 2, 7, 12, 19, 26, 21, 16, 9}, - {15, 9, 14, 21, 16, 3, 8, 13, 20, 27, 22, 17, 10}, - {16, 10, 15, 22, 17, 4, 9, 14, 21, 28, 23, -1, 11}, - {17, 11, 16, 23, -1, 5, 10, 15, 22, 29, -1, -1, -1}, - {18, 12, -1, 24, 19, 6, -1, -1, -1, 30, 25, 20, 13}, - {19, 13, 18, 25, 20, 7, 12, -1, 24, 31, 26, 21, 14}, - {20, 14, 19, 26, 21, 8, 13, 18, 25, 32, 27, 22, 15}, - {21, 15, 20, 27, 22, 9, 14, 19, 26, 33, 28, 23, 16}, - {22, 16, 21, 28, 23, 10, 15, 20, 27, 34, 29, -1, 17}, - {23, 17, 22, 29, -1, 11, 16, 21, 28, 35, -1, -1, -1}, - {24, 18, -1, 30, 25, 12, -1, -1, -1, 36, 31, 26, 19}, - {25, 19, 24, 31, 26, 13, 18, -1, 30, 37, 32, 27, 20}, - {26, 20, 25, 32, 27, 14, 19, 24, 31, 38, 33, 28, 21}, - {27, 21, 26, 33, 28, 15, 20, 25, 32, 39, 34, 29, 22}, - {28, 22, 27, 34, 29, 16, 21, 26, 33, 40, 35, -1, 23}, - {29, 23, 28, 35, -1, 17, 22, 27, 34, 41, -1, -1, -1}, - {30, 24, -1, 36, 31, 18, -1, -1, -1, 43, 37, 32, 25}, - {31, 25, 30, 37, 32, 19, 24, -1, 36, 44, 38, 33, 26}, - {32, 26, 31, 38, 33, 20, 25, 30, 37, 45, 39, 34, 27}, - {33, 27, 32, 39, 34, 21, 26, 31, 38, 46, 40, 35, 28}, - {34, 28, 33, 40, 35, 22, 27, 32, 39, 47, 41, -1, 29}, - {35, 29, 34, 41, -1, 23, 28, 33, 40, 48, 42, -1, -1}, - {36, 30, -1, 43, 37, 24, -1, -1, -1, -1, 44, 38, 31}, - {37, 31, 36, 44, 38, 25, 30, -1, 43, -1, 45, 39, 32}, - {38, 32, 37, 45, 39, 26, 31, 36, 44, -1, 46, 40, 33}, - {39, 33, 38, 46, 40, 27, 32, 37, 45, -1, 47, 41, 34}, - {40, 34, 39, 47, 41, 28, 33, 38, 46, -1, 48, 42, 35}, - {41, 35, 40, 48, 42, 29, 34, 39, 47, -1, 49, -1, -1}, - {42, -1, 41, 49, -1, -1, 35, 40, 48, -1, -1, -1, -1}, - {43, 36, -1, -1, 44, 30, -1, -1, -1, -1, -1, 45, 37}, - {44, 37, 43, -1, 45, 31, 36, -1, -1, -1, -1, 46, 38}, - {45, 38, 44, -1, 46, 32, 37, 43, -1, -1, -1, 47, 39}, - {46, 39, 45, -1, 47, 33, 38, 44, -1, -1, -1, 48, 40}, - {47, 40, 46, -1, 48, 34, 39, 45, -1, -1, -1, 49, 41}, - {48, 41, 47, -1, 49, 35, 40, 46, -1, -1, -1, -1, 42}, - {49, 42, 48, -1, -1, -1, 41, 47, -1, -1, -1, -1, -1} -}; -#elif defined GC_56 -int core2test[56][NUM_CORES2TEST] = { - { 0, -1, -1, 7, 1, -1, -1, -1, -1, 14, 8, 2, -1}, - { 1, -1, 0, 8, 2, -1, -1, -1, 7, 15, 9, 3, -1}, - { 2, -1, 1, 9, 3, -1, -1, 0, 8, 16, 10, 4, -1}, - { 3, -1, 2, 10, 4, -1, -1, 1, 9, 17, 11, 5, -1}, - { 4, -1, 3, 11, 5, -1, -1, 2, 10, 18, 12, 6, -1}, - { 5, -1, 4, 12, 6, -1, -1, 3, 11, 19, 13, -1, -1}, - { 6, -1, 5, 13, -1, -1, -1, 4, 12, 20, -1, -1, -1}, - { 7, 0, -1, 14, 8, -1, -1, -1, -1, 21, 15, 9, 1}, - { 8, 1, 7, 15, 9, -1, 0, -1, 14, 22, 16, 10, 2}, - { 9, 2, 8, 16, 10, -1, 1, 7, 15, 23, 17, 11, 3}, - {10, 3, 9, 17, 11, -1, 2, 8, 16, 24, 18, 12, 4}, - {11, 4, 10, 18, 12, -1, 3, 9, 17, 25, 19, 13, 5}, - {12, 5, 11, 19, 13, -1, 4, 10, 18, 26, 20, -1, 6}, - {13, 6, 12, 20, -1, -1, 5, 11, 19, 27, -1, -1, -1}, - {14, 7, -1, 21, 15, 0, -1, -1, -1, 28, 22, 16, 8}, - {15, 8, 14, 22, 16, 1, 7, -1, 21, 29, 23, 17, 9}, - {16, 9, 15, 23, 17, 2, 8, 14, 22, 30, 24, 18, 10}, - {17, 10, 16, 24, 18, 3, 9, 15, 23, 31, 25, 19, 11}, - {18, 11, 17, 25, 19, 4, 10, 16, 24, 32, 26, 20, 12}, - {19, 12, 18, 26, 20, 5, 11, 17, 25, 33, 27, -1, 13}, - {20, 13, 19, 27, -1, 6, 12, 18, 26, 34, -1, -1, -1}, - {21, 14, -1, 28, 22, 7, -1, -1, -1, 35, 29, 23, 15}, - {22, 15, 21, 29, 23, 8, 14, -1, 28, 36, 30, 24, 16}, - {23, 16, 22, 30, 24, 9, 15, 21, 29, 37, 31, 25, 17}, - {24, 17, 23, 31, 25, 10, 16, 22, 40, 38, 32, 26, 18}, - {25, 18, 24, 32, 26, 11, 17, 23, 31, 39, 33, 27, 19}, - {26, 19, 25, 33, 27, 12, 18, 24, 32, 40, 34, -1, 20}, - {27, 20, 26, 34, -1, 13, 19, 25, 33, 41, -1, -1, -1}, - {28, 21, -1, 35, 29, 14, -1, -1, -1, 42, 36, 30, 22}, - {29, 22, 28, 36, 30, 15, 21, -1, 35, 43, 37, 31, 23}, - {30, 23, 29, 37, 31, 16, 22, 28, 36, 44, 38, 32, 24}, - {31, 24, 30, 38, 32, 17, 23, 29, 37, 45, 39, 33, 25}, - {32, 25, 31, 39, 33, 18, 24, 30, 38, 46, 40, 34, 26}, - {33, 26, 32, 40, 34, 19, 25, 31, 39, 47, 41, -1, 27}, - {34, 27, 33, 41, -1, 20, 26, 32, 40, 48, -1, -1, -1}, - {35, 28, -1, 42, 36, 21, -1, -1, -1, 49, 43, 37, 29}, - {36, 29, 35, 43, 37, 22, 28, -1, 42, 50, 44, 38, 30}, - {37, 30, 36, 44, 38, 23, 29, 35, 43, 51, 45, 39, 31}, - {38, 31, 37, 45, 39, 24, 30, 36, 44, 52, 46, 40, 32}, - {39, 32, 38, 46, 40, 25, 31, 37, 45, 53, 47, 41, 33}, - {40, 33, 39, 47, 41, 26, 32, 38, 46, 54, 48, -1, 34}, - {41, 34, 40, 48, -1, 27, 33, 39, 47, 55, -1, -1, -1}, - {42, 35, -1, 49, 43, 28, -1, -1, -1, -1, 50, 44, 36}, - {43, 36, 42, 50, 44, 29, 35, -1, 49, -1, 51, 45, 37}, - {44, 37, 43, 51, 45, 30, 36, 42, 50, -1, 52, 46, 38}, - {45, 38, 44, 52, 46, 31, 37, 43, 51, -1, 53, 47, 39}, - {46, 39, 45, 53, 47, 32, 38, 44, 52, -1, 54, 48, 40}, - {47, 40, 46, 54, 48, 33, 39, 45, 53, -1, 55, -1, 41}, - {48, 41, 47, 55, -1, 34, 40, 46, 54, -1, -1, -1, -1}, - {49, 42, -1, -1, 50, 35, -1, -1, -1, -1, -1, 51, 43}, - {50, 43, 49, -1, 51, 36, 42, -1, -1, -1, -1, 52, 44}, - {51, 44, 50, -1, 52, 37, 43, 49, -1, -1, -1, 53, 45}, - {52, 45, 51, -1, 53, 38, 44, 50, -1, -1, -1, 54, 46}, - {53, 46, 52, -1, 54, 39, 45, 51, -1, -1, -1, 55, 47}, - {54, 47, 53, -1, 55, 40, 46, 52, -1, -1, -1, -1, 48}, - {55, 48, 54, -1, -1, 41, 47, 53, -1, -1, -1, -1, -1} -}; -#elif defined GC_62 -int core2test[62][NUM_CORES2TEST] = { - { 0, -1, -1, 6, 1, -1, -1, -1, -1, 14, 7, 2, -1}, - { 1, -1, 0, 7, 2, -1, -1, -1, 6, 15, 8, 3, -1}, - { 2, -1, 1, 8, 3, -1, -1, 0, 7, 16, 9, 4, -1}, - { 3, -1, 2, 9, 4, -1, -1, 1, 8, 17, 10, 5, -1}, - { 4, -1, 3, 10, 5, -1, -1, 2, 9, 18, 11, -1, -1}, - { 5, -1, 4, 11, -1, -1, -1, 3, 10, 19, 12, -1, -1}, - { 6, 0, -1, 14, 7, -1, -1, -1, -1, 22, 15, 8, 1}, - { 7, 1, 6, 15, 8, -1, 0, -1, 14, 23, 16, 9, 2}, - { 8, 2, 7, 16, 9, -1, 1, 6, 15, 24, 17, 10, 3}, - { 9, 3, 8, 17, 10, -1, 2, 7, 16, 25, 18, 11, 4}, - {10, 4, 9, 18, 11, -1, 3, 8, 17, 26, 19, 12, 5}, - {11, 5, 10, 19, 12, -1, 4, 9, 18, 27, 20, 13, -1}, - {12, -1, 11, 20, 13, -1, 5, 10, 19, 28, 21, -1, -1}, - {13, -1, 12, 21, -1, -1, -1, 11, 20, 29, -1, -1, -1}, - {14, 6, -1, 22, 15, 0, -1, -1, -1, 30, 23, 16, 7}, - {15, 7, 14, 23, 16, 1, 6, -1, 22, 31, 24, 17, 8}, - {16, 8, 15, 24, 17, 2, 7, 14, 23, 32, 25, 18, 9}, - {17, 9, 16, 25, 18, 3, 8, 15, 24, 33, 26, 19, 10}, - {18, 10, 17, 26, 19, 4, 9, 16, 25, 34, 27, 20, 11}, - {19, 11, 18, 27, 20, 5, 10, 17, 26, 35, 28, 21, 12}, - {20, 12, 19, 28, 21, -1, 11, 18, 27, 36, 29, -1, 13}, - {21, 13, 28, 29, -1, -1, 12, 19, 28, 37, -1, -1, -1}, - {22, 14, -1, 30, 23, 6, -1, -1, -1, 38, 31, 24, 15}, - {23, 15, 22, 31, 24, 7, 14, -1, 30, 39, 32, 25, 16}, - {24, 16, 23, 32, 25, 8, 15, 22, 31, 40, 33, 26, 17}, - {25, 17, 24, 33, 26, 9, 16, 23, 32, 41, 34, 27, 18}, - {26, 18, 25, 34, 27, 10, 17, 24, 33, 42, 35, 28, 19}, - {27, 19, 26, 35, 28, 11, 18, 25, 34, 43, 36, 29, 20}, - {28, 20, 27, 36, 29, 12, 19, 26, 35, 44, 37, -1, 21}, - {29, 21, 28, 37, -1, 13, 20, 27, 36, 45, -1, -1, -1}, - {30, 22, -1, 38, 31, 14, -1, -1, -1, 46, 39, 32, 23}, - {31, 23, 30, 39, 32, 15, 22, -1, 38, 47, 40, 33, 24}, - {32, 24, 31, 40, 33, 16, 23, 30, 39, 48, 41, 34, 25}, - {33, 25, 32, 41, 34, 17, 24, 31, 40, 49, 42, 35, 26}, - {34, 26, 33, 42, 35, 18, 25, 32, 41, 50, 43, 36, 27}, - {35, 27, 34, 43, 36, 19, 26, 33, 42, 51, 44, 37, 28}, - {36, 28, 35, 44, 37, 20, 27, 34, 43, 52, 45, -1, 29}, - {37, 29, 36, 45, -1, 21, 28, 35, 44, 53, -1, -1, -1}, - {38, 30, -1, 46, 39, 22, -1, -1, -1, 54, 47, 40, 31}, - {39, 31, 38, 47, 40, 23, 30, -1, 46, 55, 48, 41, 32}, - {40, 32, 39, 48, 41, 24, 31, 38, 47, 56, 49, 42, 33}, - {41, 33, 40, 49, 42, 25, 32, 39, 48, 57, 50, 43, 34}, - {42, 34, 41, 50, 43, 26, 33, 40, 49, 58, 51, 44, 35}, - {43, 35, 42, 51, 44, 27, 34, 41, 50, 59, 52, 45, 36}, - {44, 36, 43, 52, 45, 28, 35, 42, 51, 60, 53, -1, 37}, - {45, 37, 44, 53, -1, 29, 36, 43, 52, 61, -1, -1}, - {46, 38, -1, 54, 47, 30, -1, -1, -1, -1, 55, 48, 39}, - {47, 39, 46, 55, 48, 31, 38, -1, 54, -1, 56, 49, 40}, - {48, 40, 47, 56, 49, 32, 39, 46, 55 -1, 57, 50, 41}, - {49, 41, 48, 57, 50, 33, 40, 47, 56, -1, 58, 51, 42}, - {50, 42, 49, 58, 51, 34, 41, 48, 57, -1, 59, 52, 43}, - {51, 43, 50, 59, 52, 35, 42, 49, 58, -1, 60, 53, 44}, - {52, 44, 51, 60, 53, 36, 43, 50, 59, -1, 61, -1, 45}, - {53, 45, 52, 61, -1, 37, 44, 51, 60, -1, -1, -1, -1}, - {54, 46, -1, -1, 55, 38, -1, -1, -1, -1, -1, 56, 47}, - {55, 47, 54, -1, 56, 39, 46, -1, -1, -1, -1, 57, 48}, - {56, 48, 55, -1, 57, 40, 47, 54, -1, -1, -1, 58, 49}, - {57, 49, 56, -1, 58, 41, 48, 55, -1, -1, -1, 59, 50}, - {58, 50, 57, -1, 59, 42, 49, 56, -1, -1, -1, 60, 51}, - {59, 51, 58, -1, 60, 43, 50, 57, -1, -1, -1, 61, 52}, - {60, 52, 59, -1, 61, 44, 51, 58, -1, -1, -1, -1, 53}, - {61, 53, 60, -1, -1, 45, 52, 59, -1, -1, -1, -1, -1} -}; -#endif // GC_1 -#endif // SMEMF +#include "multicoremem_helper.h" INLINE void setupsmemmode(void) { #ifdef SMEML @@ -447,13 +40,11 @@ INLINE void * mallocmem(int tofindb, int * allocsize) { void * mem = NULL; // find suitable block - mem=gcbaseva+bamboo_smemtbl[tofindb]+((tofindbexitIndex = index; -} - -inline void addNewObjInfo(void * nobj) { - if(taskInfoArray[taskInfoIndex]->newObjs == NULL) { - taskInfoArray[taskInfoIndex]->newObjs = createQueue(); - } - addNewItem(taskInfoArray[taskInfoIndex]->newObjs, nobj); -} - -inline void profileTaskStart(char * taskname) { - if(!taskInfoOverflow) { - TaskInfo* taskInfo = RUNMALLOC(sizeof(struct task_info)); - taskInfoArray[taskInfoIndex] = taskInfo; - taskInfo->taskName = taskname; - taskInfo->startTime = BAMBOO_GET_EXE_TIME(); - taskInfo->endTime = -1; - taskInfo->exitIndex = -1; - taskInfo->newObjs = NULL; - } -} - -inline void profileTaskEnd() { - if(!taskInfoOverflow) { - taskInfoArray[taskInfoIndex]->endTime = BAMBOO_GET_EXE_TIME(); - taskInfoIndex++; - if(taskInfoIndex == TASKINFOLENGTH) { - taskInfoOverflow = true; - } - } -} - -#ifdef PROFILE_INTERRUPT -INLINE void profileInterruptStart_I(void) { - if(!interruptInfoOverflow) { - InterruptInfo* intInfo = RUNMALLOC_I(sizeof(struct interrupt_info)); - interruptInfoArray[interruptInfoIndex] = intInfo; - intInfo->startTime = BAMBOO_GET_EXE_TIME(); - intInfo->endTime = -1; - } -} - -INLINE void profileInterruptEnd_I(void) { - if(!interruptInfoOverflow) { - interruptInfoArray[interruptInfoIndex]->endTime=BAMBOO_GET_EXE_TIME(); - interruptInfoIndex++; - if(interruptInfoIndex == INTERRUPTINFOLENGTH) { - interruptInfoOverflow = true; - } - } -} -#endif // PROFILE_INTERRUPT - // output the profiling data void outputProfileData() { #ifdef USEIO diff --git a/Robust/src/Runtime/bamboo/multicoretaskprofile.h b/Robust/src/Runtime/bamboo/multicoretaskprofile.h index 908fee38..20c37e1e 100644 --- a/Robust/src/Runtime/bamboo/multicoretaskprofile.h +++ b/Robust/src/Runtime/bamboo/multicoretaskprofile.h @@ -33,10 +33,62 @@ int interruptInfoIndex; bool interruptInfoOverflow; #endif -INLINE void profileTaskStart(char * taskname); -INLINE void profileTaskEnd(void); void outputProfileData(); -INLINE void inittaskprofiledata(); +void inittaskprofiledata(); + +INLINE static void setTaskExitIndex(int index) { + taskInfoArray[taskInfoIndex]->exitIndex = index; +} + +INLINE static void addNewObjInfo(void * nobj) { + if(taskInfoArray[taskInfoIndex]->newObjs == NULL) { + taskInfoArray[taskInfoIndex]->newObjs = createQueue(); + } + addNewItem(taskInfoArray[taskInfoIndex]->newObjs, nobj); +} + +INLINE static void profileTaskStart(char * taskname) { + if(!taskInfoOverflow) { + TaskInfo* taskInfo = RUNMALLOC(sizeof(struct task_info)); + taskInfoArray[taskInfoIndex] = taskInfo; + taskInfo->taskName = taskname; + taskInfo->startTime = BAMBOO_GET_EXE_TIME(); + taskInfo->endTime = -1; + taskInfo->exitIndex = -1; + taskInfo->newObjs = NULL; + } +} + +INLINE staitc void profileTaskEnd() { + if(!taskInfoOverflow) { + taskInfoArray[taskInfoIndex]->endTime = BAMBOO_GET_EXE_TIME(); + taskInfoIndex++; + if(taskInfoIndex == TASKINFOLENGTH) { + taskInfoOverflow = true; + } + } +} + +#ifdef PROFILE_INTERRUPT +INLINE static void profileInterruptStart_I(void) { + if(!interruptInfoOverflow) { + InterruptInfo* intInfo = RUNMALLOC_I(sizeof(struct interrupt_info)); + interruptInfoArray[interruptInfoIndex] = intInfo; + intInfo->startTime = BAMBOO_GET_EXE_TIME(); + intInfo->endTime = -1; + } +} + +INLINE static void profileInterruptEnd_I(void) { + if(!interruptInfoOverflow) { + interruptInfoArray[interruptInfoIndex]->endTime=BAMBOO_GET_EXE_TIME(); + interruptInfoIndex++; + if(interruptInfoIndex == INTERRUPTINFOLENGTH) { + interruptInfoOverflow = true; + } + } +} +#endif // PROFILE_INTERRUPT #define INIT_TASKPROFILE_DATA() inittaskprofiledata() #define PROFILE_TASK_START(s) profileTaskStart(s) -- 2.34.1