From d3542d89b537c7a0fd5ddb9848e461d4278baca3 Mon Sep 17 00:00:00 2001 From: adash Date: Mon, 21 Dec 2009 21:58:16 +0000 Subject: [PATCH] manual prefetching changes --- Robust/src/Runtime/DSTM/interface/prefetch.c | 106 ++++++++++++++----- Robust/src/Runtime/DSTM/interface/prefetch.h | 6 +- 2 files changed, 85 insertions(+), 27 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/prefetch.c b/Robust/src/Runtime/DSTM/interface/prefetch.c index 2464b48e..fc65a716 100644 --- a/Robust/src/Runtime/DSTM/interface/prefetch.c +++ b/Robust/src/Runtime/DSTM/interface/prefetch.c @@ -9,6 +9,27 @@ extern sockPoolHashTable_t *transPResponseSocketPool; extern pthread_mutex_t prefetchcache_mutex; extern prehashtable_t pflookup; +#define LOGTIMES +#ifdef LOGTIMES +extern char bigarray1[6*1024*1024]; +extern unsigned int bigarray2[6*1024*1024]; +extern unsigned int bigarray3[6*1024*1024]; +extern long long bigarray4[6*1024*1024]; +extern int bigarray5[6*1024*1024]; +extern int bigindex1; +#define LOGTIME(x,y,z,a,b) {\ + int tmp=bigindex1; \ + bigarray1[tmp]=x; \ + bigarray2[tmp]=y; \ + bigarray3[tmp]=z; \ + bigarray4[tmp]=a; \ + bigarray5[tmp]=b; \ + bigindex1++; \ +} +#else +#define LOGTIME(x,y,z,a,b) +//log(eventname, oid, type, time, unqiue id) +#endif // Function for new prefetch call void rangePrefetch(unsigned int oid, short numoffset, short *offsets) { @@ -21,6 +42,7 @@ void rangePrefetch(unsigned int oid, short numoffset, short *offsets) { ((unsigned int *)node)[0] = oid; index = index + (sizeof(unsigned int)); *((short *)(node+index)) = numoffset; + LOGTIME('R',oid,numoffset,0,0); index = index + (sizeof(short)); memcpy(node+index, offsets, numoffset * sizeof(short)); movehead(qnodesize); @@ -33,7 +55,9 @@ void *transPrefetchNew() { int count = numavailable(); /* Check tuples if they are found locally */ + LOGTIME('Z',0,0,0,0); perMcPrefetchList_t* pilehead = processLocal(node,count); + LOGTIME('Y',0,0,0,0); if (pilehead!=NULL) { @@ -52,7 +76,6 @@ void *transPrefetchNew() { // Deallocate the prefetch queue pile node incmulttail(count); - //inctail(); } } @@ -69,9 +92,12 @@ perMcPrefetchList_t *processLocal(char *ptr, int numprefetches) { unsigned int dfsList[numoffset]; int offstop=numoffset-2; + int countInvalidObj=0; - objheader_t * header = searchObj(oid); + objheader_t * header = searchObj(oid, &countInvalidObj); + //printf("%u %x\n", oid, header); if (header==NULL) { + LOGTIME('b',oid,0,0,countInvalidObj); //forward prefetch int machinenum = lhashSearch(oid); insertPrefetch(machinenum, oid, numoffset, offsetarray, &head); @@ -80,17 +106,21 @@ perMcPrefetchList_t *processLocal(char *ptr, int numprefetches) { dfsList[0]=oid; dfsList[1]=0; + LOGTIME('B',oid,TYPE(header),0,countInvalidObj); //Start searching the dfsList for(top=0; top>=0;) { - oid=getNextOid(header, offsetarray, dfsList, top); + oid=getNextOid(header, offsetarray, dfsList, top, &countInvalidObj); + LOGTIME('O',oid,0,0,countInvalidObj); + int isLastOffset=0; if (oid&1) { int oldisField=TYPE(header) < NUMCLASSES; top+=2; dfsList[top]=oid; dfsList[top+1]=0; - header=searchObj(oid); + header=searchObj(oid, &countInvalidObj); if (header==NULL) { + LOGTIME('c',oid,top,0,countInvalidObj); //forward prefetch int machinenum = lhashSearch(oid); @@ -98,10 +128,13 @@ perMcPrefetchList_t *processLocal(char *ptr, int numprefetches) { insertPrefetch(machinenum, oid, 2+numoffset-top, &offsetarray[top-2], &head); else insertPrefetch(machinenum, oid, numoffset-top, &offsetarray[top], &head); - } else if (top=0;) { - oid=getNextOid(header, offsetarray, dfsList, top); + oid=getNextOid(header, offsetarray, dfsList, top, &countInvalidObj); if (oid&1) { int oldisField=TYPE(header) < NUMCLASSES; top+=2; dfsList[top]=oid; dfsList[top+1]=0; - header=searchObj(oid); + header=searchObj(oid,&countInvalidObj); if (header==NULL) { + LOGTIME('h',oid,top,0,countInvalidObj); //forward prefetch - int machinenum = lhashSearch(oid); - if (oldisField&&(dfsList[top-1]!=GET_RANGE(offsetarray[top+1]))) - insertPrefetch(machinenum, oid, 2+numoffset-top, &offsetarray[top-2], &head); - else - insertPrefetch(machinenum, oid, numoffset-top, &offsetarray[top], &head); + //int machinenum = lhashSearch(oid); + //if (oldisField&&(dfsList[top-1]!=GET_RANGE(offsetarray[top+1]))) + // insertPrefetch(machinenum, oid, 2+numoffset-top, &offsetarray[top-2], &head); + //else + // insertPrefetch(machinenum, oid, numoffset-top, &offsetarray[top], &head); } else { sendOidFound(header, oid, sd, buffer, &bufoffset); + LOGTIME('H',oid,TYPE(header),0,top); if (top 1) { + return NULL; + } + } + } + return header; + } } /* Delete perMcPrefetchList_t and everything it points to */ @@ -464,7 +519,8 @@ int rangePrefetchReq(int acceptfd, struct readstruct * readbuffer) { } -unsigned int getNextOid(objheader_t * header, short * offsetarray, unsigned int *dfsList, int top) { +unsigned int getNextOid(objheader_t * header, short * offsetarray, unsigned int *dfsList, int top, int *countInvalidObj) +{ int startindex= offsetarray[top+2]; int currcount = dfsList[top+1]; int range = GET_RANGE(offsetarray[top + 3]); @@ -504,7 +560,7 @@ unsigned int getNextOid(objheader_t * header, short * offsetarray, unsigned int if(currcount!=0 & range != 0) { //go to the next offset - header=searchObj(dfsList[top+2]); + header=searchObj(dfsList[top+2],countInvalidObj); if (header==NULL) return 2; } diff --git a/Robust/src/Runtime/DSTM/interface/prefetch.h b/Robust/src/Runtime/DSTM/interface/prefetch.h index 62b9703e..ee537c9a 100644 --- a/Robust/src/Runtime/DSTM/interface/prefetch.h +++ b/Robust/src/Runtime/DSTM/interface/prefetch.h @@ -62,11 +62,13 @@ void sendRangePrefetchReq(perMcPrefetchList_t *, int sd, unsigned int mid); int rangePrefetchReq(int acceptfd, struct readstruct * readbuffer); int processOidFound(objheader_t *, short *, int, int, int); int getRangePrefetchResponse(int sd, struct readstruct *); -INLINE objheader_t *searchObj(unsigned int); +//INLINE objheader_t *searchObj(unsigned int); +INLINE objheader_t *searchObj(unsigned int, int*); /*********** Functions for computation at the participant end **********/ -unsigned int getNextOid(objheader_t * header, short * offsetarray, unsigned int *dfsList, int top); +//unsigned int getNextOid(objheader_t * header, short * offsetarray, unsigned int *dfsList, int top); +unsigned int getNextOid(objheader_t * header, short * offsetarray, unsigned int *dfsList, int top, int *); int sendOidFound(objheader_t *, unsigned int, int, char *buffer, int *bufoffset); int sendOidNotFound(unsigned int oid, int sd); void flushResponses(int sd, char * buffer, int * bufoffset); -- 2.34.1