From 4630a1fe23100f30cb2284120346cf9bf271bca1 Mon Sep 17 00:00:00 2001 From: adash Date: Fri, 13 Feb 2009 06:38:26 +0000 Subject: [PATCH] bug fixes --- .../src/Runtime/DSTM/interface/dstmserver.c | 13 +++-- Robust/src/Runtime/DSTM/interface/prefetch.c | 51 +++++++++++-------- Robust/src/Runtime/DSTM/interface/prefetch.h | 1 + 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index f2e5f161..d3f0931f 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -7,6 +7,7 @@ #include "llookup.h" #include "threadnotify.h" #include "prefetch.h" +#include #ifdef COMPILER #include "thread.h" #endif @@ -142,9 +143,11 @@ void *dstmAccept(void *acceptfd) { case READ_REQUEST: /* Read oid requested and search if available */ recv_data((int)acceptfd, &oid, sizeof(unsigned int)); - if((srcObj = mhashSearch(oid)) == NULL) { - printf("Error: Object 0x%x is not found in Main Object Store %s, %d\n", oid, __FILE__, __LINE__); - break; + while((srcObj = mhashSearch(oid)) == NULL) { + int ret; + if((ret = sched_yield()) != 0) { + printf("%s(): error no %d in thread yield\n", __func__, errno); + } } h = (objheader_t *) srcObj; GETSIZE(size, h); @@ -685,7 +688,7 @@ int transCommitProcess(void *modptr, unsigned int *oidmod, unsigned int *oidlock return 1; } GETSIZE(tmpsize,header); - + { struct ___Object___ *dst=(struct ___Object___*)((char*)header+sizeof(objheader_t)); struct ___Object___ *src=(struct ___Object___*)((char*)modptr+sizeof(objheader_t)+offset); @@ -832,7 +835,7 @@ int prefetchReq(int acceptfd) { } //end of for } } //end of while - //Release socket + //Release socket if (mid!=-1) freeSockWithLock(transPResponseSocketPool, mid, sd); diff --git a/Robust/src/Runtime/DSTM/interface/prefetch.c b/Robust/src/Runtime/DSTM/interface/prefetch.c index 2bd0af4d..9e36671a 100644 --- a/Robust/src/Runtime/DSTM/interface/prefetch.c +++ b/Robust/src/Runtime/DSTM/interface/prefetch.c @@ -121,8 +121,7 @@ labelL1: objheader_t *header; header = searchObj(dfsList[prev]); if(header == NULL) { - printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__); - return NULL; + dfsList[top] = 0; } else { //if Array if(TYPE(header) > NUMCLASSES) { @@ -130,8 +129,8 @@ labelL1: } else { //linked list dfsList[top] = getNextPointerOid(offsetarray, dfsList, &top, &depth); } - goto labelL1; } + goto labelL1; } else { // increment and go down the tree //Increment top top += 2; @@ -157,8 +156,7 @@ labelL1: objheader_t * header; header = searchObj(dfsList[prev]); if(header == NULL) { - printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__); - return NULL; + dfsList[top] = 0; } else { //if Array if(TYPE(header) > NUMCLASSES) { @@ -166,8 +164,8 @@ labelL1: } else { //linked list dfsList[top] = getNextPointerOid(offsetarray, dfsList, &top, &depth); } - goto labelL1; } + goto labelL1; } else continue; } @@ -183,7 +181,7 @@ objheader_t *searchObj(unsigned int oid) { } else if ((header = (objheader_t *) prehashSearch(oid)) != NULL) { return header; } else { - //printf("Error: Cannot find header %s, %d\n", __func__, __LINE__); + ; } return NULL; } @@ -350,12 +348,12 @@ int getRangePrefetchResponse(int sd) { } else { prehashInsert(oid, ptr); } + objheader_t *head = prehashSearch(oid); pthread_mutex_lock(&pflookup.lock); pthread_cond_broadcast(&pflookup.cond); pthread_mutex_unlock(&pflookup.lock); } else if(control == OBJECT_NOT_FOUND) { oid = *((unsigned int *)(recvbuffer + sizeof(char))); - //printf("%s() Error: OBJ NOT FOUND.. THIS SHOULD NOT HAPPEN\n", __func__); } else { printf("%s() Error: in Decoding the control value %d, %s\n", __func__, __LINE__, __FILE__); } @@ -402,6 +400,7 @@ int dfsOffsetTree(unsigned int baseoid, short * offsetarray, int sd, int numoffs oidAtDepth_t odep; /* Initialize */ + perMcPrefetchList_t *head = NULL; odep.oid = 0; odep.depth = 0; int i; @@ -427,6 +426,9 @@ labelL1: printf("%s() Error in sendOidNotFound() at line %d in %s()\n", __func__, __LINE__, __FILE__); return -1; } + //If not found forward request + forwardRequest(dfsList, &top, &depth, &numoffset, offsetarray); + //go up the tree while((dfsList[top+1] == *(offsetarray + depth + 1)) && (depth >= 0)) { if(top == depth) { @@ -446,9 +448,7 @@ labelL1: objheader_t *header; header = searchObj(dfsList[prev]); if(header == NULL) { - printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__); - return -1; - //return 0; + dfsList[top] = 0; } else { //if Array if(TYPE(header) > NUMCLASSES) { @@ -488,9 +488,7 @@ labelL1: objheader_t * header; header = searchObj(dfsList[prev]); if(header == NULL) { - printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__); - return -1; - //return 0; + dfsList[top] = 0; } else { //if Array if(TYPE(header) > NUMCLASSES) { @@ -498,8 +496,8 @@ labelL1: } else { //linked list dfsList[top] = getNextPointerOid(offsetarray, dfsList, &top, &depth); } - goto labelL1; } + goto labelL1; } else continue; } @@ -575,7 +573,6 @@ unsigned int getNextArrayOid(short *offsetarray, unsigned int *dfsList, int *top } objheader_t *header = searchObj(oid); if(header == NULL) { - printf("%s() Error: Object not found at %s , %d\n", __func__, __FILE__, __LINE__); return 0; } else { short stride = GET_STRIDE(*(offsetarray+(*depth) + 1)); @@ -605,7 +602,7 @@ unsigned int getNextArrayOid(short *offsetarray, unsigned int *dfsList, int *top unsigned int getNextPointerOid(short *offsetarray, unsigned int *dfsList, int *top, int* depth) { int prev; if(*(dfsList + *top + 1) > 1) { //tells which offset to calculate the oid from - //(if range > 1 then use available oid to compute next oid else go to previous oid) + //(if range > 1 then use available oid to compute next oid else go to previous oid) prev = *top; } else { prev = *top - 2; @@ -616,7 +613,6 @@ unsigned int getNextPointerOid(short *offsetarray, unsigned int *dfsList, int *t } objheader_t *header = searchObj(oid); if(header == NULL) { - printf("%s() Error: Object not found at %s , %d\n", __func__, __FILE__, __LINE__); return 0; } else { int startelement = *(offsetarray + *depth); @@ -633,8 +629,7 @@ int sendOidFound(unsigned int oid, int sd) { } else if((header = (objheader_t *) prehashSearch(oid))!=NULL) { ; } else { - printf("%s() Error: THIS SHOULD NOT HAPPEN at line %d in %s()\n", __func__, __LINE__, __FILE__); - return -1; + return 0; } int incr = 0; @@ -665,3 +660,19 @@ int sendOidNotFound(unsigned int oid, int sd) { sendPrefetchResponse(sd, &control, sendbuffer, &size); return 0; } + +void forwardRequest(unsigned int * dfsList, int *top, int *depth, int *numoffset, short * offsetarray) { + perMcPrefetchList_t *head = NULL; + unsigned int machinenum = lhashSearch(*(dfsList + *top)); + insertPrefetch(machinenum, *(dfsList + *top), (*numoffset)-(*depth), &offsetarray[*depth], &head); + + if(head!=NULL) { + // Get sock from shared pool + int sd = getSock2(transPrefetchSockPool, machinenum); + /* Send Prefetch Request */ + sendRangePrefetchReq(head, sd); + /* Deallocated pilehead */ + proPrefetchQDealloc(head); + } + return; +} diff --git a/Robust/src/Runtime/DSTM/interface/prefetch.h b/Robust/src/Runtime/DSTM/interface/prefetch.h index a6a2c101..1ec456ed 100644 --- a/Robust/src/Runtime/DSTM/interface/prefetch.h +++ b/Robust/src/Runtime/DSTM/interface/prefetch.h @@ -58,6 +58,7 @@ int findOidinStride(short *, struct ArrayObject *, int, int, int, int, int, int int processLinkedListOids(short *, objheader_t *, int *, int); int getRangePrefetchResponse(int sd); objheader_t *searchObj(unsigned int); +void forwardRequest(unsigned int *, int*, int*, int*, short*); /*********** Functions for computation at the participant end **********/ int getNextOid(short *, unsigned int*, int*, int*, oidAtDepth_t *, unsigned int); -- 2.34.1