#include "MGCHash.h"
#ifdef MULTICORE
+#include "structdefs.h"
#include "runtime_arch.h"
#else
#include <stdio.h>
/* mgchash ********************************************************/
mgchashtable_t * mgchashCreate(unsigned int size, double loadfactor) {
mgchashtable_t *ctable;
- mgchashlistnode_t *nodes;
- int i;
if (size <= 0) {
#ifdef MULTICORE
}
void mgchashreset(mgchashtable_t * tbl) {
- mgchashlistnode_t *ptr = tbl->table;
- int i;
+ /* mgchashlistnode_t *ptr = tbl->table;
- /*if (tbl->numelements<(tbl->size>>6)) {
+ if (tbl->numelements<(tbl->size>>6)) {
mgchashlistnode_t *top=&ptr[tbl->size];
mgchashlistnode_t * list = tbl->list;
while(list != NULL) {
list = next;
}
} else {*/
- BAMBOO_MEMSET_WH(tbl->table, '\0', sizeof(mgchashlistnode_t)*tbl->size);
+ BAMBOO_MEMSET_WH(tbl->table, 0, sizeof(mgchashlistnode_t)*tbl->size);
//}
// TODO now never release any allocated memory, may need to be changed
while(tbl->structs->next!=NULL) {
#ifdef MULTICORE_GC
mgchashtable_t * mgchashCreate_I(unsigned int size, double loadfactor) {
mgchashtable_t *ctable;
- mgchashlistnode_t *nodes;
- int i;
if (size <= 0) {
#ifdef MULTICORE
//Delete the entire hash table
void mgchashDelete(mgchashtable_t * tbl) {
- int i;
mgcliststruct_t *ptr=tbl->structs;
while(ptr!=NULL) {
mgcliststruct_t *next=ptr->next;
thisvar=(struct MGCHash *)RUNMALLOC(sizeof(struct MGCHash));
thisvar->size = size;
thisvar->mask = ((size>>1)-1)<<1;
- thisvar->bucket=(int *) RUNCALLOC(sizeof(unsigned int)*size);
+ thisvar->bucket=(unsigned INTPTR *) RUNCALLOC(sizeof(unsigned INTPTR)*size);
//Set data counts
return thisvar;
}
// Rehash code
unsigned int hashkey = (data>>GC_SHIFT_BITS)&thisvar->mask;
- int * ptr = &thisvar->bucket[hashkey];
- int ptrval= *ptr;
+ unsigned INTPTR * ptr = &thisvar->bucket[hashkey];
+ unsigned INTPTR ptrval= *ptr;
if (ptrval == 0) {
*ptr=data;
return 1;
thisvar=(struct MGCHash *)RUNMALLOC_I(sizeof(struct MGCHash));
thisvar->mask = ((size>>1)-1)<<1;
thisvar->size = size;
- thisvar->bucket=(int *) RUNCALLOC_I(sizeof(int)*size);
+ thisvar->bucket=(unsigned INTPTR *) RUNCALLOC_I(sizeof(unsigned INTPTR)*size);
return thisvar;
}
// Rehash code
unsigned int hashkey = (data>>GC_SHIFT_BITS)&thisvar->mask;
- int * ptr = &thisvar->bucket[hashkey];
+ unsigned INTPTR * ptr = &thisvar->bucket[hashkey];
if (*ptr==data) {
return 1;
+#include "mem.h"
#include "gcqueue.h"
struct pointerblock *gchead=NULL;
#ifndef GCQUEUE_H
#define GCQUEUE_H
#include "stdio.h"
+#include "multicore.h"
#ifdef MGC
#include "interrupt.h"
extern int gclobjtailindex;
extern struct lobjpointerblock *gclobjspare;
-static void gc_queueinit() {
+INLINE static void gc_queueinit() {
// initialize queue
if (gchead==NULL) {
gcheadindex=gctailindex=0;
////////////////////////////////////////////////////////////////////
// functions that should be invoked with interrupts off
////////////////////////////////////////////////////////////////////
-static void gc_enqueue_I(void * ptr) {
+INLINE static void gc_enqueue_I(void * ptr) {
if (gcheadindex==NUMPTRS) {
struct pointerblock * tmp;
if (gcspare!=NULL) {
}
// dequeue and destroy the queue
-static void * gc_dequeue_I() {
+INLINE static void * gc_dequeue_I() {
if (gctailindex==NUMPTRS) {
struct pointerblock *tmp=gctail;
gctail=gctail->next;
return gctail->ptrs[gctailindex++];
}
-static int gc_moreItems_I() {
+INLINE static int gc_moreItems_I() {
return !((gchead==gctail)&&(gctailindex==gcheadindex));
}
// should be invoked with interruption closed
// enqueue a large obj: start addr & length
-static void gc_lobjenqueue_I(void * ptr,
+INLINE static void gc_lobjenqueue_I(void * ptr,
unsigned int length,
unsigned int host) {
if (gclobjheadindex==NUMLOBJPTRS) {
}
// dequeue and destroy the queue
-static void * gc_lobjdequeue_I(unsigned int * length,
+INLINE static void * gc_lobjdequeue_I(unsigned int * length,
unsigned int * host) {
if (gclobjtailindex==NUMLOBJPTRS) {
struct lobjpointerblock *tmp=gclobjtail;
return gclobjtail->lobjs[gclobjtailindex++];
}
-static int gc_lobjmoreItems_I() {
+INLINE static int gc_lobjmoreItems_I() {
return !((gclobjhead==gclobjtail)&&(gclobjtailindex==gclobjheadindex));
}
////////////////////////////////////////////////////////////////////
// functions that can be invoked in normal places
////////////////////////////////////////////////////////////////////
-static void gc_enqueue(void * ptr) {
+INLINE static void gc_enqueue(void * ptr) {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
if (gcheadindex==NUMPTRS) {
struct pointerblock * tmp;
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
}
-static void * gc_dequeue() {
+INLINE static void * gc_dequeue() {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
if (gctailindex==NUMPTRS) {
struct pointerblock *tmp=gctail;
return r;
}
-static int gc_moreItems() {
+INLINE static int gc_moreItems() {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
int r = !((gchead==gctail)&&(gctailindex==gcheadindex));
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return r;
}
-static void gc_lobjenqueue(void * ptr,
+INLINE static void gc_lobjenqueue(void * ptr,
unsigned int length,
unsigned int host) {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-#include "runtime.h"
+#include "multicoreruntime.h"
#include "multicoremem.h"
#include "multicoregarbage.h"
#include "markbit.h"
}
#endif
+bool gc_checkCoreStatus() {
+ for(int i = 0; i < NUMCORES4GC; i++) {
+ if(gccorestatus[i]) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void gc_resetCoreStatus() {
+ for(int i = 0; i < NUMCORES4GC; i++) {
+ gccorestatus[i] = 1;
+ }
+}
+
+
void initmulticoregcdata() {
bamboo_smem_zero_top = NULL;
gcflag = false;
void master_mark(struct garbagelist *stackptr) {
GC_PRINTF("Start mark phase \n");
- GC_SEND_MSG_1_TO_CLIENT(GCSTART);
gc_status_info.gcphase = MARKPHASE;
+ GC_SEND_MSG_1_TO_CLIENT(GCSTART);
// mark phase
mark(stackptr);
}
void gc_master(struct garbagelist * stackptr) {
- //tprintf("start GC!\n");
+ tprintf("start GC!\n");
gc_status_info.gcprocessing = true;
gc_status_info.gcphase = INITPHASE;
tprintf("%u. used=%u free=%u corenum=%u status=%u, base=%x, ptr=%x\n", i, record->usedspace, record->freespace, record->corenum, record->status, gcbaseva+OFFSET2BASEVA(i), (gcbaseva+OFFSET2BASEVA(i)+record->usedspace));
}
#endif
+
master_finish();
//tprintf("finish GC ! %d \n",gcflag);
#include "multicorehelper.h" // for mappings between core # and block #
#include "structdefs.h"
#include "multicoregcprofile.h"
+#include "gctypes.h"
#ifdef GC_DEBUG
#define GC_PRINTF tprintf
// let each gc core to have one big block, this is very important
// for the computation of NUMBLOCKS(s, n), DO NOT change this!
-typedef int block_t;
-
typedef enum {
INITPHASE = 0x0, // 0x0
MARKPHASE, // 0x1
void * gcbaseva; // base va for shared memory without reserved sblocks
-static bool gc_checkCoreStatus() {
- for(int i = 0; i < NUMCORES4GC; i++) {
- if(gccorestatus[i]) {
- return false;
- }
- }
- return true;
-}
+bool gc_checkCoreStatus();
+
+void gc_resetCoreStatus();
-static void gc_resetCoreStatus() {
- for(int i = 0; i < NUMCORES4GC; i++) {
- gccorestatus[i] = 1;
- }
-}
/* Structure to keep track of free space in block */
#ifdef MULTICORE_GC
+#include "structdefs.h"
#include "multicoregccompact.h"
#include "runtime_arch.h"
#include "multicoreruntime.h"
}
}
-void useReturnedMem(unsigned int corenum, block_t localblockindex) {
+void useReturnedMem(unsigned int retcorenum, block_t localblockindex) {
for(int i=0;i<NUMCORES4GC;i++) {
unsigned INTPTR requiredmem=gcrequiredmems[i];
if (requiredmem) {
for(block_t nextlocalblocknum=localblockindex;nextlocalblocknum<numblockspercore;nextlocalblocknum++) {
- unsigned INTPTR blocknum=BLOCKINDEX2(corenum, nextlocalblocknum);
+ unsigned INTPTR blocknum=BLOCKINDEX2(retcorenum, nextlocalblocknum);
struct blockrecord * nextblockrecord=&allocationinfo.blocktable[blocknum];
if (nextblockrecord->status==BS_FREE) {
unsigned INTPTR freespace=nextblockrecord->freespace&~BAMBOO_CACHE_LINE_MASK;
void getSpace(struct moveHelper *to, unsigned int minimumbytes) {
//need more space to compact into
- if (to->localblocknum < gcblock2fill) {
+ if ((to->localblocknum+1) < gcblock2fill) {
getSpaceLocally(to);
} else {
getSpaceRemotely(to, minimumbytes);
}
}
-void * checkNeighbors_I(int corenum, unsigned INTPTR requiredmem, unsigned INTPTR desiredmem) {
+void * checkNeighbors_I(int ncorenum, unsigned INTPTR requiredmem, unsigned INTPTR desiredmem) {
int minblockindex=allocationinfo.lowestfreeblock/NUMCORES4GC;
unsigned INTPTR threshold=(desiredmem<MINMEMORYCHUNKSIZE)? desiredmem: MINMEMORYCHUNKSIZE;
unsigned INTPTR memcheck=requiredmem>threshold?requiredmem:threshold;
for(block_t lblock=minblockindex;lblock<numblockspercore;lblock++) {
for(int i=0;i<NUM_CORES2TEST;i++) {
- int neighborcore=core2test[corenum][i];
+ int neighborcore=core2test[ncorenum][i];
if (neighborcore!=-1) {
block_t globalblockindex=BLOCKINDEX2(neighborcore, lblock);
struct blockrecord * block=&allocationinfo.blocktable[globalblockindex];
return length;
}
//good to move objects and update pointers
- //tprintf("Decided to compact obj %x to %x\n", origptr, toptr);
gcmappingtbl[OBJMAPPINGINDEX(origptr)]=toptr;
BAMBOO_ASSERT(COMPACTPHASE == gc_status_info.gcphase);
// initialize structs for compacting
- struct moveHelper orig={0,NULL,NULL,0,NULL,0,0,0,0};
- struct moveHelper to={0,NULL,NULL,0,NULL,0,0,0,0};
+ struct moveHelper orig;
+ struct moveHelper to;
initOrig_Dst(&orig, &to);
CACHEADAPT_SAMPLING_DATA_REVISE_INIT(&orig, &to);
while(!gc_checkCoreStatus())
;
+#ifdef GC_DEBUG
+ void *nextvalid=gcbaseva;
+ for(void *tmp=gcbaseva; tmp<gcbaseva+BAMBOO_SHARED_MEM_SIZE;tmp+=ALIGNMENTSIZE) {
+ unsigned int objlength=getMarkedLength(tmp);
+ void *forwarding=gcmappingtbl[OBJMAPPINGINDEX(tmp)];
+ if (tmp>=nextvalid&&((objlength!=0)!=(forwarding!=NULL))) {
+ tprintf("Maps disagree tmp=%x olength=%u forwarding=%x\n",tmp, objlength, forwarding);
+ }
+ if (tmp<nextvalid&&forwarding!=NULL) {
+ tprintf("Weird forwarding pointer\n");
+ }
+ if (tmp>=nextvalid&&(objlength!=0||forwarding!=NULL)) {
+ unsigned int length=ALIGNSIZETOBYTES(objlength);
+ unsigned int size;
+ unsigned int type;
+ nextvalid=tmp+length;
+ gettype_size(tmp, &type, &size);
+ size=((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE;
+ if (size!=length) {
+ tprintf("Bad size in bitmap: tmp=%x length=%u size=%u type=%u\n", tmp, length, size, type);
+ }
+ block_t blockindex;
+ BLOCKINDEX(blockindex, forwarding);
+ struct blockrecord * block=&allocationinfo.blocktable[blockindex];
+ void *blockptr=OFFSET2BASEVA(blockindex)+gcbaseva;
+
+ if (block->status==BS_FREE) {
+ if (forwarding>(blockptr+block->usedspace)) {
+ tprintf("Pointer references free space forwarding=%x tmp=%x length=%u type=%u blockindex=%u, baseptr=%x, usedspace=%u, status=%u\n", forwarding, tmp, length, type,blockindex, blockptr, block->usedspace, block->status);
+ }
+ }
+ }
+ }
+#endif
+
GCPROFILE_ITEM();
//just in case we didn't get blocks back...
#ifdef MULTICORE_GC
#include "multicore.h"
+#include "gctypes.h"
struct moveHelper {
unsigned int localblocknum; // local block num for heap
#endif
};
+int gc_countRunningCores();
void initOrig_Dst(struct moveHelper * orig,struct moveHelper * to);
+void getSpaceLocally(struct moveHelper *to);
+void handleReturnMem_I(unsigned int cnum, void *heaptop);
+void useReturnedMem(unsigned int corenum, block_t localblockindex);
+void handleReturnMem(unsigned int cnum, void *heaptop);
+void getSpaceRemotely(struct moveHelper *to, unsigned int minimumbytes);
+void getSpace(struct moveHelper *to, unsigned int minimumbytes);
+void * checkNeighbors_I(int corenum, unsigned INTPTR requiredmem, unsigned INTPTR desiredmem);
+void * globalSearch_I(unsigned int topblock, unsigned INTPTR requiredmem, unsigned INTPTR desiredmem);
+void handleOneMemoryRequest(int core, unsigned int lowestblock);
+void handleMemoryRequests_I();
+void * gcfindSpareMem_I(unsigned INTPTR requiredmem, unsigned INTPTR desiredmem,unsigned int requiredcore);
+void master_compact();
void compacthelper(struct moveHelper * orig,struct moveHelper * to);
void compact();
void compact_master(struct moveHelper * orig, struct moveHelper * to);
#ifdef MULTICORE_GC
+#include "multicoregccompact.h"
#include "multicoregcflush.h"
#include "multicoreruntime.h"
#include "ObjectHash.h"
// NOTE: the objptr should not be NULL and should not be non shared ptr
#define updateObj(objptr) gcmappingtbl[OBJMAPPINGINDEX(objptr)]
//#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);if (obj<gcbaseva) tprintf("BAD PTR %x to %x in %u\n", updatetmpptr, obj, __LINE__);}
-#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=updateObj(updatetmpptr);if (!ISVALIDPTR(obj)) tprintf("Mapping problem for object %x -> %x, mark=%u, line=%u\n", updatetmpptr, obj, getMarkedLength(updatetmpptr),__LINE__);}}
+#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=updateObj(updatetmpptr);}}
+//if (!ISVALIDPTR(obj)) tprintf("Mapping problem for object %x -> %x, mark=%u, line=%u\n", updatetmpptr, obj, getMarkedLength(updatetmpptr),__LINE__);}}
-#define UPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr); if (!ISVALIDPTR(obj)) tprintf("Mapping parameter for object %x -> %x, mark=%u, line=%u\n", updatetmpptr, obj, getMarkedLength(updatetmpptr),__LINE__);}
+#define UPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr);}
+// if (!ISVALIDPTR(obj)) tprintf("Mapping parameter for object %x -> %x, mark=%u, line=%u\n", updatetmpptr, obj, getMarkedLength(updatetmpptr),__LINE__);}
-INLINE void updategarbagelist(struct garbagelist *listptr) {
+void updategarbagelist(struct garbagelist *listptr) {
for(;listptr!=NULL; listptr=listptr->next) {
for(int i=0; i<listptr->size; i++) {
UPDATEOBJ(listptr->array[i]);
}
}
-INLINE void updateRuntimePtrs(struct garbagelist * stackptr) {
+void updateRuntimePtrs(struct garbagelist * stackptr) {
// update current stack
updategarbagelist(stackptr);
unsigned int start = *((unsigned int*)(bamboo_thread_queue+2));
for(int i = thread_counter; i > 0; i--) {
// the thread obj can not be NULL
- UPDATEOBJNONNULL(bamboo_thread_queue[4+start]);
+ UPDATEOBJNONNULL(*((void **)&bamboo_thread_queue[4+start]));
start = (start+1)&bamboo_max_thread_num_mask;
}
}
#endif
}
-INLINE void updatePtrsInObj(void * ptr) {
+void updatePtrsInObj(void * ptr) {
int type = ((int *)(ptr))[0];
// scan all pointers in ptr
unsigned int * pointer=pointerarray[type];
unsigned INTPTR origendoffset=ALIGNTOTABLEINDEX((unsigned INTPTR)(origbound-gcbaseva));
unsigned int objlength;
+
while(origptr<origbound) {
//Try to skip over stuff fast first
unsigned INTPTR offset=(unsigned INTPTR) (origptr-gcbaseva);
return dstptr;
}
+#ifdef GC_DEBUG
+ {
+ unsigned int size;
+ unsigned int type;
+ gettype_size(origptr, &type, &size);
+ size=((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE;
+ if (size!=length) {
+ tprintf("BAD SIZE %u!=%u t=%u %x->%x\n",size,length,type, origptr, dstptr);
+ tprintf("origbase=%x origbound=%x\n",orig->base, origbound);
+ tprintf("tobase=%x tobound=%x\n",tobase, tobound);
+ }
+ }
+
+ if (dstptr>origptr) {
+ tprintf("move up %x -> %x\n", origptr, dstptr);
+ }
+ if (tmplast>origptr) {
+ tprintf("Overlap with last object\n");
+ }
+
+ tmplast=dstptr+length;
+#endif
+
/* Move the object */
- if(origptr >= endtoptr||dstptr >= origptr+length) {
+ if(origptr < endtoptr&&dstptr < origptr+length) {
memmove(dstptr, origptr, length);
} else if (origptr!=dstptr) {
//no need to copy if the source & dest are equal....
memcpy(dstptr, origptr, length);
}
- //tprintf("Moving object %x to %x with length %u\n", origptr, dstptr, length);
-
/* Update the pointers in the object */
updatePtrsInObj(dstptr);
//need more memory to compact into
block_t blockindex;
BLOCKINDEX(blockindex, dstptr);
- unsigned int corenum;
- BLOCK2CORE(corenum, blockindex);
+ unsigned int blockcore;
+ BLOCK2CORE(blockcore, blockindex);
to->base=OFFSET2BASEVA(blockindex)+gcbaseva;
to->bound=BOUNDPTR(blockindex)+gcbaseva;
- if (corenum!=BAMBOO_NUM_OF_CORE) {
+ if (blockcore!=BAMBOO_NUM_OF_CORE) {
//we have someone elses memory...need to ask to use it
//first set flag to false
blockgranted=false;
- send_msg_3(corenum,GCREQBLOCK, BAMBOO_NUM_OF_CORE, to->bound);
+ send_msg_3(blockcore,GCREQBLOCK, BAMBOO_NUM_OF_CORE, to->bound);
//wait for permission
while(!blockgranted)
;
void updateheap() {
// initialize structs for compacting
- struct moveHelper orig={0,NULL,NULL,0,NULL,0,0,0,0};
- struct moveHelper to={0,NULL,NULL,0,NULL,0,0,0,0};
+ struct moveHelper orig;
+ struct moveHelper to;
initOrig_Dst(&orig, &to);
updatehelper(&orig, &to);
}
#include "multicore.h"
#include "runtime.h"
-void flush(struct garbagelist * stackptr);
+void update(struct garbagelist * stackptr);
#endif // MULTICORE_GC
#endif // BAMBOO_MULTICORE_GC_FLUSH_H
extern struct lockvector bamboo_threadlocks;
#endif
-INLINE void gettype_size(void * ptr, int * ttype, unsigned int * tsize) {
+void gettype_size(void * ptr, int * ttype, unsigned int * tsize) {
int type = ((int *)ptr)[0];
if(type < NUMCLASSES) {
// a normal object
}
}
-INLINE bool isLarge(void * ptr, int * ttype, unsigned int * tsize) {
+bool isLarge(void * ptr, int * ttype, unsigned int * tsize) {
// check if a pointer refers to a large object
gettype_size(ptr, ttype, tsize);
unsigned INTPTR blocksize = (((unsigned INTPTR)(ptr-gcbaseva)) < BAMBOO_LARGE_SMEM_BOUND)? BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
#endif
}
-INLINE void scanPtrsInObj(void * ptr, int type) {
+void scanPtrsInObj(void * ptr, int type) {
// scan all pointers in ptr
unsigned int * pointer = pointerarray[type];
if (pointer==0) {
unsigned int isize = 0;
gc_status_info.gcbusystatus = true;
-
// mark phase
while(MARKPHASE == gc_status_info.gcphase) {
int counter = 0;
#ifdef MULTICORE_GC
#include "multicore.h"
-INLINE void gettype_size(void * ptr, int * ttype, unsigned int * tsize);
-INLINE bool isLarge(void * ptr, int * ttype, unsigned int * tsize);
-INLINE void markgarbagelist(struct garbagelist * listptr);
-INLINE void tomark(struct garbagelist * stackptr);
-INLINE void scanPtrsInObj(void * ptr, int type);
+void gettype_size(void * ptr, int * ttype, unsigned int * tsize);
+bool isLarge(void * ptr, int * ttype, unsigned int * tsize);
+void markgarbagelist(struct garbagelist * listptr);
+void tomark(struct garbagelist * stackptr);
+void scanPtrsInObj(void * ptr, int type);
void markObj(void * objptr);
void mark(struct garbagelist * stackptr);
#ifdef MULTICORE_GC
#ifdef GC_PROFILE
#include "multicoregcprofile.h"
+#include "structdefs.h"
#include "runtime_arch.h"
#include "mem.h"
// NOTE: this file should be changed to be generated automatically
-
#ifndef BAMBOO_MULTICORE_HELPER_H
#define BAMBOO_MULTICORE_HELPER_H
+#include "structdefs.h"
-#ifdef GC_1
-// NUMCORES4GC = 1
-static unsigned int gc_core2block[2] = {0,1};
-
-static unsigned int gc_block2core[2] = { 0, 0};
-#elif defined GC_2
-// NUMCORES4GC = 2
-static unsigned int gc_core2block[4] = {
- 0,3,
- 1,2
-};
-
-static unsigned int gc_block2core[4] = {
- 0, 1,
- 1, 0
-};
-#elif defined GC_4
-// NUMCORES4GC = 4
-static unsigned int gc_core2block[8] = {
- 0,7, 3,4,
- 1,6, 2,5
-};
-
-static unsigned int gc_block2core[8] = {
- 0, 2, 3, 1,
- 1, 3, 2, 0
-};
-#elif defined GC_8
-// NUMCORES4GC = 8
-static unsigned int gc_core2block[16] = {
- 0,15, 3,12, 4,11, 7,8,
- 1,14, 2,13, 5,10, 6,9
-};
-
-static unsigned int gc_block2core[16] = {
- 0, 4, 5, 1, 2, 6, 7, 3,
- 3, 7, 6, 2, 1, 5, 4, 0
-};
-#elif defined GC_16
-// NUMCORES4GC = 16
-static unsigned int gc_core2block[32] = {
- 0,31, 7,24, 8,23, 15,16,
- 1,30, 6,25, 9,22, 14,17,
- 2,29, 5,26, 10,21, 13,18,
- 3,28, 4,27, 11,20, 12,19
-};
-
-static unsigned int gc_block2core[32] = {
- 0, 4, 8, 12, 13, 9, 5, 1,
- 2, 6, 10, 14, 15, 11, 7, 3,
- 3, 7, 11, 15, 14, 10, 6, 2,
- 1, 5, 9, 13, 12, 8, 4, 0
-};
-#elif defined GC_32
-// NUMCORES4GC = 32
-static unsigned int gc_core2block[64] = {
- 0,63, 15,48, 16,47, 31,32,
- 1,62, 14,49, 17,46, 30,33,
- 2,61, 13,50, 18,45, 29,34,
- 3,60, 12,51, 19,44, 28,35,
- 4,59, 11,52, 20,43, 27,36,
- 5,58, 10,53, 21,42, 26,37,
- 6,57, 9,54, 22,41, 25,38,
- 7,56, 8,55, 23,40, 24,39
-};
-
-static unsigned int gc_block2core[64] = {
- 0, 4, 8, 12, 16, 20, 24, 28, 29, 25, 21, 17, 13, 9, 5, 1,
- 2, 6, 10, 14, 18, 22, 26, 30, 31, 27, 23, 19, 15, 11, 7, 3,
- 3, 7, 11, 15, 19, 23, 27, 31, 30, 26, 22, 18, 14, 10, 6, 2,
- 1, 5, 9, 13, 17, 21, 25, 29, 28, 24, 20, 16, 12, 8, 4, 0
-};
-#elif defined GC_48
-// NUMCORES4GC = 50
-static unsigned int gc_core2block[96] = {
- 0,95, 15,80, 16,79, 31,64, 32,63, 47,48,
- 1,94, 14,81, 17,78, 30,65, 33,62, 46,49,
- 2,93, 13,82, 18,77, 29,66, 34,61, 45,50,
- 3,92, 12,83, 19,76, 28,67, 35,60, 44,51,
- 4,91, 11,84, 20,75, 27,68, 36,59, 43,52,
- 5,90, 10,85, 21,74, 26,69, 37,58, 42,53,
- 6,89, 9,86, 22,73, 25,70, 38,57, 41,54,
- 7,88, 8,87, 23,72, 24,71, 39,56, 40,55
-};
-
-static unsigned int gc_block2core[96] = {
- 0, 6, 12, 18, 24, 30, 36, 42, 43, 37, 31, 25, 19, 13, 7, 1,
- 2, 8, 14, 20, 26, 32, 38, 44, 45, 39, 33, 27, 21, 15, 9, 3,
- 4, 10, 16, 22, 28, 34, 40, 46, 47, 41, 35, 29, 23, 17, 11, 5,
- 5, 11, 17, 23, 29, 35, 41, 47, 46, 40, 34, 28, 22, 16, 10, 4,
- 3, 9, 15, 21, 27, 33, 39, 45, 44, 38, 32, 26, 20, 14, 8, 2,
- 1, 7, 13, 19, 25, 31, 37, 43, 42, 36, 30, 24, 18, 12, 6, 0
-};
-#elif defined GC_50
-// NUMCORES4GC = 50
-static unsigned int gc_core2block[100] = {
- 0,99, 15,84, 16,83, 31,68, 32,67, 47,52,
- 1,98, 14,85, 17,82, 30,69, 33,66, 46,53,
- 2,97, 13,86, 18,81, 29,70, 34,65, 45,54,
- 3,96, 12,87, 19,80, 28,71, 35,64, 44,55,
- 4,95, 11,88, 20,79, 27,72, 36,63, 43,56,
- 5,94, 10,89, 21,78, 26,73, 37,62, 42,57,
- 6,93, 9,90, 22,77, 25,74, 38,61, 41,58, 48,51,
- 7,92, 8,91, 23,76, 24,75, 39,60, 40,59, 49,50
-};
-
-static unsigned int gc_block2core[100] = {
- 0, 6, 12, 18, 24, 30, 36, 43, 44, 37, 31, 25, 19, 13, 7, 1,
- 2, 8, 14, 20, 26, 32, 38, 45, 46, 39, 33, 27, 21, 15, 9, 3,
- 4, 10, 16, 22, 28, 34, 40, 47, 48, 41, 35, 29, 23, 17, 11, 5,
- 42, 49, 49, 42,
- 5, 11, 17, 23, 29, 35, 41, 48, 47, 40, 34, 28, 22, 16, 10, 4,
- 3, 9, 15, 21, 27, 33, 39, 46, 45, 38, 32, 26, 20, 14, 8, 2,
- 1, 7, 13, 19, 25, 31, 37, 44, 43, 36, 30, 24, 18, 12, 6, 0
-};
-#elif defined GC_56
-// NUMCORES4GC = 56
-static unsigned int gc_core2block[112] = {
- 0,111, 15, 96, 16,95, 31,80, 32,79, 47,64, 48,63,
- 1,110, 14, 97, 17,94, 30,81, 33,78, 46,65, 49,62,
- 2,109, 13, 98, 18,93, 29,82, 34,77, 45,66, 50,61,
- 3,108, 12, 99, 19,92, 28,83, 35,76, 44,67, 51,60,
- 4,107, 11,100, 20,91, 27,84, 36,75, 43,68, 52,59,
- 5,106, 10,101, 21,90, 26,85, 37,74, 42,69, 53,58,
- 6,105, 9,102, 22,89, 25,86, 38,73, 41,70, 54,57,
- 7,104, 8,103, 23,88, 24,87, 39,72, 40,71, 55,56
-};
-
-static unsigned int gc_block2core[112] = {
- 0, 7, 14, 21, 28, 35, 42, 49, 50, 43, 36, 29, 22, 15, 8, 1,
- 2, 9, 16, 23, 30, 37, 44, 51, 52, 45, 38, 31, 24, 17, 10, 3,
- 4, 11, 18, 25, 32, 39, 46, 53, 54, 47, 40, 33, 26, 19, 12, 5,
- 6, 13, 20, 27, 34, 41, 48, 55, 55, 48, 41, 34, 27, 20, 13, 6,
- 5, 12, 19, 26, 33, 40, 47, 54, 53, 46, 39, 32, 25, 18, 11, 4,
- 3, 10, 17, 24, 31, 38, 45, 52, 51, 44, 37, 30, 23, 16, 9, 2,
- 1, 8, 15, 22, 29, 36, 43, 50, 49, 42, 35, 28, 21, 14, 7, 0
-};
-#elif defined GC_62
-// NUMCORES4GC = 62
-static unsigned 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,
- 3,120, 12,111, 19,104, 28,95, 35,88, 44,79, 50,73, 59,64,
- 4,119, 11,112, 20,103, 27,96, 36,87, 43,80, 51,72, 58,65,
- 5,118, 10,113, 21,102, 26,97, 37,86, 42,81, 52,71, 57,66,
- 6,117, 9,114, 22,101, 25,98, 38,85, 41,82, 53,70, 56,67,
- 7,116, 8,115, 23,100, 24,99, 39,84, 40,83, 54,69, 55,68
-};
+extern unsigned int gc_core2block[2*NUMCORES4GC];
+extern unsigned int gc_block2core[2*NUMCORES4GC];
-static unsigned int gc_block2core[124] = {
- 0, 6, 14, 22, 30, 38, 46, 54, 55, 47, 39, 31, 23, 15, 7, 1,
- 2, 8, 16, 24, 32, 40, 48, 56, 57, 49, 41, 33, 25, 17, 9, 3,
- 4, 10, 18, 26, 34, 42, 50, 58, 59, 51, 43, 35, 27, 19, 11, 5,
- 12, 20, 28, 36, 44, 52, 60, 61, 53, 45, 37, 29, 21, 13,
- 13, 21, 29, 37, 45, 53, 61, 60, 52, 44, 36, 28, 20, 12,
- 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 // BAMBOO_MULTICORE_HELPER_H
-#ifdef MULTICORE
+#if defined(MULTICORE)&&defined(MULTICORE_GC)
#include "runtime_arch.h"
#include "multicoreruntime.h"
-
-#ifdef MULTICORE_GC
#include "multicoregarbage.h"
#include "multicorehelper.h"
#include "multicoremem_helper.h"
// Only allocate local mem chunks to each core.
// If a core has used up its local shared memory, start gc.
-void * localmalloc_I(int coren,
- unsigned int memcheck,
- int * allocsize) {
+void * localmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize) {
for(block_t localblocknum=0;localblocknum<GCNUMLOCALBLOCK;localblocknum++) {
block_t searchblock=BLOCKINDEX2(coren, localblocknum);
if (searchblock>=GCNUMBLOCK)
// Allocate the local shared memory to each core with the highest priority,
// if a core has used up its local shared memory, try to allocate the
// shared memory that belong to its neighbours, if also failed, start gc.
-void * fixedmalloc_I(int coren,
- unsigned int memcheck,
- int * allocsize) {
+void * fixedmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize) {
//try locally first
void * mem=localmalloc_I(coren,memcheck,allocsize);
if (mem!=NULL)
int neighborcore=core2test[coren][i];
if (neighborcore!=-1) {
block_t globalblockindex=BLOCKINDEX2(neighborcore, lblock);
- if (globalblockindex>=GCNUMBLOCK)
+ if (globalblockindex>=GCNUMBLOCK||globalblockindex<0)
return NULL;
struct blockrecord * block=&allocationinfo.blocktable[globalblockindex];
if (block->status==BS_FREE) {
// current memory allocation rate, if it has already reached the threshold,
// start gc, otherwise, allocate the shared memory globally. If all the
// shared memory has been used up, start gc.
-void * mixedmalloc_I(int coren,
- int isize,
- int * allocsize) {
+void * mixedmalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize) {
void * mem=fixedmalloc_I(coren,isize,allocsize);
if (mem!=NULL)
return mem;
// Allocate all the memory chunks globally, do not consider the host cores
// When all the shared memory are used up, start gc.
-void * globalmalloc_I(int coren, unsigned INTPTR memcheck, int * allocsize) {
+void * globalmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize) {
block_t firstfree=NOFREEBLOCK;
block_t lowestblock=allocationinfo.lowestfreeblock;
for(block_t searchblock=lowestblock;searchblock<GCNUMBLOCK;searchblock++) {
return NULL;
}
-void * smemalloc(int coren, int isize, int * allocsize) {
+void * smemalloc(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize) {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
void *retval=smemalloc_I(coren, isize, allocsize);
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
}
// malloc from the shared memory
-void * smemalloc_I(int coren, int isize, int * allocsize) {
+void * smemalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize) {
#ifdef SMEML
void *mem = localmalloc_I(coren, isize, allocsize);
#elif defined(SMEMF)
GC_SEND_MSG_1_TO_CLIENT(GCSTARTPRE);
}
}
- return NULL;
}
return mem;
}
#else
// malloc from the shared memory
-void * smemalloc_I(int coren,
- int size,
- int * allocsize) {
+void * smemalloc_I(int coren, unsigned INTPTR size, unsigned INTPTR * allocsize) {
void * mem = NULL;
int toallocate = (size>(BAMBOO_SMEM_SIZE)) ? (size) : (BAMBOO_SMEM_SIZE);
if(toallocate > bamboo_free_smem_size) {
}
return mem;
}
-#endif // MULTICORE_GC
-
-#endif // MULTICORE
+#endif
#ifdef GC_LARGESHAREDHEAP
#define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(2+24)))
#elif defined MGC
-#define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(72))) // 72M per core
+#define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*72)) // 72M per core
#else
#define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(2+14)))
#endif
//Pointer to new block of memory after request
volatile void * bamboo_cur_msp;
//Number of bytes in new block of memory
-volatile int bamboo_smem_size;
+volatile unsigned INTPTR bamboo_smem_size;
+
+void * localmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
+void * fixedmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
+void * mixedmalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
+void * globalmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
+void * smemalloc(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
+void * smemalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
+
#endif // BAMBOO_MULTICORE_MEM_H
//bad coordinate
core2test[i][index]=-1;
} else {
- int corenum=BAMBOO_CORE(x,y);
- if (corenum<0||corenum>=NUMCORES4GC) {
+ int blockcorenum=BAMBOO_CORE(x,y);
+ if (blockcorenum<0||blockcorenum>=NUMCORES4GC) {
core2test[i][index]=-1;
} else {
- core2test[i][index]=corenum;
+ core2test[i][index]=blockcorenum;
}
}
index++;
-1 //MSGEND
};
-INLINE unsigned int checkMsgLength_I(unsigned int realtype) {
+unsigned int checkMsgLength_I(unsigned int realtype) {
#if (defined(TASK)||defined(MULTICORE_GC))
unsigned int type = realtype & 0xff;
#else
// either not doing GC or the master core has decided to stop GC but
// // still sending msgs to other cores to inform them to stop the GC
#endif
- int allocsize = 0;
+ unsigned INTPTR allocsize = 0;
void * mem = smemalloc_I(data2, data1, &allocsize);
if(mem != NULL) {
// send the start_va to request core, cache the msg first
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_3_I(data2,MEMRESPONSE,mem,allocsize);
+ cache_msg_3_I(data2,MEMRESPONSE,(unsigned INTPTR) mem,allocsize);
} else {
- send_msg_3_I(data2,MEMRESPONSE,mem,allocsize);
+ send_msg_3_I(data2,MEMRESPONSE,(unsigned INTPTR) mem,allocsize);
}
} //else if mem == NULL, the gcflag of the startup core has been set
// and all the other cores have been informed to start gc
}
void processmsg_memresponse_I() {
- void * memptr = msgdata[msgdataindex];
+ void * memptr =(void *) msgdata[msgdataindex];
MSG_INDEXINC_I();
unsigned int numbytes = msgdata[msgdataindex];
MSG_INDEXINC_I();
void processmsg_reqblock_I() {
int cnum=msgdata[msgdataindex];
MSG_INDEXINC_I();
- void * topptr=msgdata[msgdataindex];
+ void * topptr= (void *)msgdata[msgdataindex];
MSG_INDEXINC_I();
if (topptr<=update_origblockptr) {
//send message
void processmsg_gcfinishmark_I() {
- int data1 = msgdata[msgdataindex];
+ int cnum = msgdata[msgdataindex];
MSG_INDEXINC_I();
- int data2 = msgdata[msgdataindex];
+ int nsend = msgdata[msgdataindex];
MSG_INDEXINC_I();
- int data3 = msgdata[msgdataindex];
+ int nrecv = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a mark phase finish msg
BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
- BAMBOO_ASSERT(gc_status_info.gcphase = MARKPHASE);
+ BAMBOO_ASSERT(gc_status_info.gcphase == MARKPHASE);
// all cores should do mark
- if(data1 < NUMCORESACTIVE) {
- gccorestatus[data1] = 0;
+ if(cnum < NUMCORESACTIVE) {
+ gccorestatus[cnum] = 0;
int entry_index = 0;
if(waitconfirm) {
// phase 2
// phase 1
entry_index = gcnumsrobjs_index;
}
- gcnumsendobjs[entry_index][data1] = data2;
- gcnumreceiveobjs[entry_index][data1] = data3;
+ gcnumsendobjs[entry_index][cnum] = nsend;
+ gcnumreceiveobjs[entry_index][cnum] = nrecv;
}
}
void * startaddr=handlegcfinishcompact_I(cnum, bytesneeded, maxbytesneeded);
if (startaddr) {
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_2_I(cnum,GCMOVESTART,startaddr);
+ cache_msg_2_I(cnum,GCMOVESTART,(unsigned INTPTR)startaddr);
} else {
- send_msg_2_I(cnum,GCMOVESTART,startaddr);
+ send_msg_2_I(cnum,GCMOVESTART,(unsigned INTPTR)startaddr);
}
}
}
// large obj info here
for(int k = 3; k < msglength; k+=2) {
- int lobj = msgdata[msgdataindex];
+ void * lobj = (void *) msgdata[msgdataindex];
MSG_INDEXINC_I();
int length = msgdata[msgdataindex];
MSG_INDEXINC_I();
void transferObject(struct transObjInfo * transObj);
#endif
+
#ifdef MULTICORE_GC
void transferMarkResults();
+void processmsg_gcstartinit_I();
+void processmsg_gcstart_I();
+void processmsg_gcstartcompact_I();
+void processmsg_gcstartupdate_I();
+void processmsg_gcfinishpre_I();
+void processmsg_gcfinishinit_I();
+void processmsg_memrequest_I();
+void processmsg_memresponse_I();
+void processmsg_reqblock_I();
+void processmsg_grantblock_I();
+void processmsg_gcfinishmark_I();
+void processmsg_returnmem_I();
+void * handlegcfinishcompact_I(int cnum, unsigned int bytesneeded, unsigned int maxbytesneeded);
+void processmsg_gcfinishcompact_I();
+void processmsg_gcfinishupdate_I();
+void processmsg_gcfinish_I();
+void processmsg_gcmarkconfirm_I();
+void processmsg_gcmarkreport_I();
+void processmsg_gcmarkedobj_I();
+void processmsg_gcmovestart_I();
+void processmsg_gclobjinfo_I(unsigned int msglength);
+#else
+void processmsg_lockrequest_I();
+void processmsg_lockrequest_I();
+void processmsg_lockgrount_I();
+void processmsg_lockdeny_I();
+void processmsg_lockrelease_I();
+void processmsg_redirectlock_I();
+void processmsg_redirectgrount_I();
+void processmsg_redirectdeny_I();
+void processmsg_redirectrelease_I();
#endif
+unsigned int checkMsgLength_I(unsigned int realtype);
+void processmsg_transtall_I();
+void processmsg_statusconfirm_I();
+void processmsg_statusreport_I();
+void processmsg_terminate_I();
+void processmsg_req_notify_start();
+void processmsg_notify_start();
+int receiveObject_I();
+
+
+#ifdef GC_PROFILE
+void processmsg_gcprofiles_I();
+#endif
+
+#ifdef GC_CACHE_ADAPT
+void processmsg_gcstartcachepolicy_I();
+void processmsg_gcfinishcachepolicy_I();
+void processmsg_gcstartpref_I();
+void processmsg_gcfinishpref_I();
+#endif
+
+#ifdef PROFILE
+void processmsg_profileoutput_I();
+void processmsg_profilefinish_I();
+#endif
#endif // MULTICORE
#endif // BAMBOO_MULTICORE_MSG_H
#ifdef MULTICORE
-
#include "runtime.h"
#include "multicoreruntime.h"
#include "methodheaders.h"
#include "multicoregarbage.h"
+#include "multicore_arch.h"
+#include <stdio.h>
extern int classsize[];
extern int typearray[];
}
return num;
}
-#else
-int CALL12(___String______convertdoubletochar____D__AR_C,
- double ___val___,
- double ___val___,
- struct ArrayObject ___chararray___) {
- return 0;
-}
#endif
#ifdef D___System______deepArrayCopy____L___Object____L___Object___
}
#endif
+#ifdef D___System______setgcprofileflag____
void CALL00(___System______setgcprofileflag____) {
#ifdef GC_PROFILE
#ifdef MGC_SPEC
#endif
#endif
}
+#endif
+#ifdef D___System______resetgcprofileflag____
void CALL00(___System______resetgcprofileflag____) {
#ifdef GC_PROFILE
#ifdef MGC_SPEC
#endif
#endif
}
+#endif
+
+void CALL00(___System______gc____) {
+#ifdef MULTICORE_GC
+ if(BAMBOO_NUM_OF_CORE == STARTUPCORE) {
+ if(!gc_status_info.gcprocessing && !gcflag) {
+ gcflag = true;
+ gcprecheck = true;
+ for(int i = 0; i < NUMCORESACTIVE; i++) {
+ // reuse the gcnumsendobjs & gcnumreceiveobjs
+ gcnumsendobjs[0][i] = 0;
+ gcnumreceiveobjs[0][i] = 0;
+ }
+ for(int i = 0; i < NUMCORES4GC; i++) {
+ if(i != STARTUPCORE) {
+ send_msg_1_I(i,GCSTARTPRE);
+ }
+ }
+ }
+ } else {
+ // send msg to the startup core to start gc
+ send_msg_1(STARTUPCORE, GCINVOKE);
+ }
+#endif
+}
void CALL00(___System______gc____) {
#ifdef MULTICORE_GC
}
#ifdef D___System______printString____L___String___
-void CALL01(___System______printString____L___String___,
- struct ___String___ * ___s___) {
-#ifdef MGC
-#ifdef TILERA_BME
+void CALL01(___System______printString____L___String___, struct ___String___ * ___s___) {
+#if defined(MGC)&&defined(TILERA_BME)
struct ArrayObject * chararray=VAR(___s___)->___value___;
int i;
int offset=VAR(___s___)->___offset___;
((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset];
printf("%c", sc);
}
-#endif // TILERA_BME
#endif // MGC
}
#endif
return NULL;
}
v->___length___=length;
- initlock(v);
+ initlock((struct ___Object___ *)v);
#ifdef GC_PROFILE
extern unsigned int gc_num_obj;
gc_num_obj++;
v->lock = NULL;
#endif
v->___length___=length;
- initlock(v);
+ initlock((struct ___Object___ *) v);
return v;
}
#endif
#endif
}
-INLINE void initruntimedata() {
+void initruntimedata() {
// initialize the arrays
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
// startup core to initialize corestatus[]
INITTASKDATA();
}
-INLINE void disruntimedata() {
+void disruntimedata() {
DISMULTICOREGCDATA();
DISTASKDATA();
BAMBOO_LOCAL_MEM_CLOSE();
BAMBOO_SHARE_MEM_CLOSE();
}
-INLINE void recordtotalexetime() {
+void recordtotalexetime() {
#ifdef USEIO
totalexetime = BAMBOO_GET_EXE_TIME()-bamboo_start_time;
#else // USEIO
- BAMBOO_PRINT(BAMBOO_GET_EXE_TIME()-bamboo_start_time);
+ unsigned long long timediff=BAMBOO_GET_EXE_TIME()-bamboo_start_time;
+ BAMBOO_PRINT(timediff);
#ifndef BAMBOO_MEMPROF
BAMBOO_PRINT(0xbbbbbbbb);
#endif
#endif // USEIO
}
-INLINE void getprofiledata_I() {
+void getprofiledata_I() {
//profile mode, send msgs to other cores to request pouring out progiling data
#ifdef PROFILE
// use numconfirm to check if all cores have finished output task profiling
#endif
}
-INLINE void checkCoreStatus() {
+void checkCoreStatus() {
int i = 0;
int sumsendobj = 0;
if((!waitconfirm) ||
}
// main function for each core
-inline void run(int argc, char** argv) {
+void run(int argc, char** argv) {
bool sendStall = false;
bool isfirst = true;
bool tocontinue = false;
// these are functions should be implemented in //
// multicore runtime for any multicore processors //
////////////////////////////////////////////////////////////
-INLINE void initCommunication(void);
-INLINE void fakeExecution(void);
-INLINE void terminate(void);
-INLINE void initlock(struct ___Object___ * v);
+void initCommunication(void);
+void fakeExecution(void);
+void terminate(void);
+void initlock(struct ___Object___ * v);
#ifdef BAMBOO_MEMPROF
-INLINE void terminatememprof(void);
+void terminatememprof(void);
#endif // BAMBOO_MEMPROF
///////////////////////////////////////////////////////////
// stores to incoherent memory //
/////////////////////////////////////////////////////////////////////////////
+void handleReturnMem_I(unsigned int cnum, void *heaptop);
+void handleReturnMem(unsigned int cnum, void *heaptop);
+void run(int argc, char** argv);
+void checkCoreStatus();
+void getprofiledata_I();
+void recordtotalexetime();
+void disruntimedata();
+void initruntimedata();
#endif // #ifdef MULTICORE
#endif // BAMBOO_MULTICORE_RUNTIME_H