#include "multicoremsg.h"
#include "multicoregcprofile.h"
+void cacheadapt_finish_compact(void *toptr) {
+ unsigned int dstpage=(toptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
+ unsigned int * newtable=&gccachesamplingtbl_r[dstpage*NUMCORESACTIVE];
+
+ for(int core = 0; core < NUMCORESACTIVE; core++) {
+ (*newtable)=(*newtable)>>6;
+ newtable++;
+ }
+}
+
void cacheadapt_finish_src_page(void *srcptr, void *tostart, void *tofinish) {
unsigned int srcpage=(srcptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
- unsigned int dstpage=(tostart-gcbase)>>BAMBOO_PAGE_SIZE_BITS;
+ unsigned int dstpage=(tostart-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
unsigned int numbytes=tofinish-tostart;
unsigned int * oldtable=&gccachesamplingtbl[srcpage*NUMCORESACTIVE];
}
}
+/* Bytes needed equal to zero is a special case... It means that we should finish the dst page */
+
void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsigned int bytesneeded) {
unsigned int numbytes=toptr-tostart;
- void *tobound=(tostart&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
- void *origbound=(origstart&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
+ void *tobound=(void *)((((unsigned INTPTR)toptr-1)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE);
+ void *origbound=(void *)((((unsigned INTPTR)origptr)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE);
- unsigned int topage=(tostart-gcbase)>>BAMBOO_PAGE_SIZE_BITS;
+ unsigned int topage=(toptr-1-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
unsigned int origpage=(origptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
unsigned int * totable=&gccachesamplingtbl_r[topage*NUMCORESACTIVE];
unsigned int * origtable=&gccachesamplingtbl[origpage*NUMCORESACTIVE];
- unsigned int remaintobytes=tobound-toptr;
+ //handler
+ unsigned int remaintobytes=(bytesneeded==0)?0:(tobound-toptr);
unsigned int remainorigbytes=origbound-origptr;
do {
topage++;//to page is definitely done
tobound+=BAMBOO_PAGE_SIZE;
origpage=(origptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;//handle exact match case
- origbound=(origptr&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
+ origbound=(void *) ((((unsigned INTPTR)origptr)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE);
} else {
//Finishing off orig page
printf("%x, %d, %d, ",(int)page_sva,page_index,coren);
unsigned int * local_tbl = &gccachesamplingtbl[page_index*NUMCORESACTIVE];
for(int i = 0; i < NUMCORESACTIVE; i++) {
- int freq = *local_tbl;
+ unsigned int freq = *local_tbl;
local_tbl++;
- printf("%d, ", freq);
+ printf("%u, ", freq);
}
printf("\n");
}
int accesscore = 0; // TODO
unsigned int * local_tbl = &gccachesamplingtbl_r[page_index*NUMCORESACTIVE];
for(int i = 0; i < NUMCORESACTIVE; i++) {
- int freq = *local_tbl;
+ unsigned int freq = *local_tbl;
//printf("%d, ", freq);
if(freq != 0) {
accesscore++;// TODO
printf("%x, %d, %d, ",(int)page_sva,page_index,coren);
unsigned int * local_tbl = &gccachesamplingtbl_r[page_index*NUMCORESACTIVE];
for(int i = 0; i < NUMCORESACTIVE; i++) {
- int freq = *local_tbl;
- printf("%d, ", freq);
+ unsigned int freq = *local_tbl;
+ printf("%u, ", freq);
sumdata[accesscore-1][i]+=freq;
local_tbl++;
}
for(int i = 0; i < NUMCORESACTIVE; i++) {
printf("%d ", i);
for(int j = 0; j < NUMCORESACTIVE; j++) {
- printf(" %d ", sumdata[j][i]);
+ printf(" %u ", sumdata[j][i]);
}
printf("\n");
}
#define BAMBOO_CACHE_MODE_NONE 3 // no caching
#define BAMBOO_CACHE_MODE_COORDS 4 // cached on a specific core
+void cacheadapt_finish_compact(void *toptr);
void cacheadapt_finish_src_page(void *srcptr, void *tostart, void *tofinish);
void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsigned int bytesneeded);
void cacheAdapt_gc(bool isgccachestage);
#define CACHEADAPT_FINISH_SRC_PAGE(a,b,c) cacheadapt_finish_src_page(a,b,c);
#define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d) cacheadapt_finish_dst_page(a,b,c,d);
+#define CACHEADAPT_FINISH_COMPACT(a) cacheadapt_finish_compact(a);
#define CACHEADAPT_GC(b) cacheAdapt_gc(b)
#define CACHEADAPT_MASTER() cacheAdapt_master()
#define CACHEADAPT_SAMPING_RESET()
#define CACHEADAPT_FINISH_SRC_PAGE(a,b,c)
#define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d)
+#define CACHEADAPT_FINISH_COMPACT(a)
#define CACHEADAPT_GC(b)
#define CACHEADAPT_MASTER()
#define CACHEADAPT_PHASE_CLIENT()
#ifdef GC_CACHE_ADAPT
orig->pagebound=orig->base+BAMBOO_PAGE_SIZE;
#endif
- if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE)
+ if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE) {
+ CACHEADAPT_FINISH_COMPACT(to->ptr);
break;
+ }
}
if (minimumbytes!=0) {
getSpace(to, minimumbytes);
return minimumbytes;
} else {
CACHEADAPT_FINISH_DST_PAGE(orig->ptr, tmpto, to->ptr, minimumbytes);
- to->pagebound=((endtoptr-1)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
+ to->pagebound=((((unsigned INTPTR)endtoptr)-1)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
//update pointers to avoid double counting the stuff we already added in
tmporig=orig->ptr+minimumbytes;
tmpto=to->ptr+minimumbytes;
struct moveHelper to;
initOrig_Dst(&orig, &to);
- CACHEADAPT_SAMPLING_DATA_REVISE_INIT(&orig, &to);
compacthelper(&orig, &to);
}