From 2c5801c48c7e42477a9d33af80e0abb9d732faca Mon Sep 17 00:00:00 2001 From: adash Date: Wed, 13 Aug 2008 01:31:32 +0000 Subject: [PATCH] changes to enable no caching and no prefetching by adding DCACHE flag to buildscript. Tested on Em3d --- .../src/Benchmarks/Prefetch/Em3d/dsm/makefile | 22 +-- Robust/src/Benchmarks/Prefetch/bm.txt | 8 +- .../Runtime/DSTM/interface/addUdpEnhance.h | 1 + .../src/Runtime/DSTM/interface/dstmserver.c | 16 +-- Robust/src/Runtime/DSTM/interface/prelookup.c | 2 + Robust/src/Runtime/DSTM/interface/signal.c | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 129 ++++++++---------- Robust/src/buildscript | 7 +- 8 files changed, 90 insertions(+), 97 deletions(-) diff --git a/Robust/src/Benchmarks/Prefetch/Em3d/dsm/makefile b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/makefile index ca304c77..f0304c52 100644 --- a/Robust/src/Benchmarks/Prefetch/Em3d/dsm/makefile +++ b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/makefile @@ -14,22 +14,28 @@ SRC3=${MAINCLASS}2.java \ EVector.java FLAGS=-dsm -prefetch -optimize -excprefetch Em3d.main -excprefetch BiGraph.create -excprefetch Node.Node -excprefetch Node.fillTable -excprefetch Node.makeUniqueNeighbors -excprefetch Node.makeFromNodes -excprefetch Node.updateFromNodes -debug -mainclass ${MAINCLASS} -trueprob 0.91 -FLAGS1=-dsm -prefetch -optimize -excprefetch Node.makeUniqueNeighbors -excprefetch EVector.ensureCapacity -excprefetch EVector.addElement -excprefetch BiGraph.makeFromNodes -excprefetch EVector.elementAt -excprefetch BiGraph.initializeNodes -excprefetch BiGraph.allocateNodes -mainclass ${MAINCLASS} -trueprob 0.91 -FLAGS2=-dsm -optimize -mainclass ${MAINCLASS} +FLAGS1=-dsm -prefetch -dsmcaching -optimize -excprefetch Node.makeUniqueNeighbors -excprefetch EVector.ensureCapacity -excprefetch EVector.addElement -excprefetch BiGraph.makeFromNodes -excprefetch EVector.elementAt -excprefetch BiGraph.initializeNodes -excprefetch BiGraph.allocateNodes -mainclass ${MAINCLASS} -trueprob 0.91 +FLAGS2=-dsm -dsmcaching -optimize -excprefetch Node.makeUniqueNeighbors -excprefetch EVector.ensureCapacity -excprefetch EVector.addElement -excprefetch BiGraph.makeFromNodes -excprefetch EVector.elementAt -excprefetch BiGraph.initializeNodes -excprefetch BiGraph.allocateNodes -mainclass ${MAINCLASS} -trueprob 0.91 +FLAGS3=-dsm -optimize -mainclass ${MAINCLASS} default: # ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC} # ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC} - ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NNP ${SRC3} + ../../../../buildscript ${FLAGS3} -o ${MAINCLASS}NPNC ${SRC3} + ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC3} ../../../../buildscript ${FLAGS1} -o ${MAINCLASS}N ${SRC3} - cp ${MAINCLASS}NNP.bin ${MAINCLASS}1NP.bin + cp ${MAINCLASS}NPNC.bin ${MAINCLASS}1NPNC.bin + cp ${MAINCLASS}NP.bin ${MAINCLASS}1NP.bin cp ${MAINCLASS}N.bin ${MAINCLASS}1.bin - cp ${MAINCLASS}NNP.bin ${MAINCLASS}2NP.bin + cp ${MAINCLASS}NPNC.bin ${MAINCLASS}2NPNC.bin + cp ${MAINCLASS}NP.bin ${MAINCLASS}2NP.bin cp ${MAINCLASS}N.bin ${MAINCLASS}2.bin - cp ${MAINCLASS}NNP.bin ${MAINCLASS}3NP.bin + cp ${MAINCLASS}NPNC.bin ${MAINCLASS}3NPNC.bin + cp ${MAINCLASS}NP.bin ${MAINCLASS}3NP.bin + cp ${MAINCLASS}N.bin ${MAINCLASS}3.bin + cp ${MAINCLASS}NPNC.bin ${MAINCLASS}3NPNC.bin + cp ${MAINCLASS}NP.bin ${MAINCLASS}3NP.bin cp ${MAINCLASS}N.bin ${MAINCLASS}3.bin - cp ${MAINCLASS}NNP.bin ${MAINCLASS}4NP.bin - cp ${MAINCLASS}N.bin ${MAINCLASS}4.bin clean: rm -rf tmpbuilddirectory diff --git a/Robust/src/Benchmarks/Prefetch/bm.txt b/Robust/src/Benchmarks/Prefetch/bm.txt index 31331325..fbee3cee 100644 --- a/Robust/src/Benchmarks/Prefetch/bm.txt +++ b/Robust/src/Benchmarks/Prefetch/bm.txt @@ -1,7 +1,11 @@ -JGFSORBenchSizeA:SOR/dsm::2:3:4:sorverA -JGFLUFactBenchSizeA:LUFact/dsm::2:4:lufactverA +JGFSORBenchSizeA:SOR/dsm:1:2:3:4:sorverA +JGFSORBenchSizeC:SOR/dsm:1:2:3:4:sorverC +JGFSORBenchSizeD:SOR/dsm:1:2:3:4:sorverD +JGFMolDynBenchSizeA:Moldyn/dsm:1:2:3:4:moldynverA +JGFLUFactBenchSizeA:LUFact/dsm:1:2:3:4:lufactverA MatrixMultiply:MatrixMultiply:1 200 30:2 200 30:3 200 30:4 200 30:mmver200 MatrixMultiply:MatrixMultiply:1 600:2 600:3 600:4 600:mmver600 Em3d:Em3d/dsm:-T 1 -N 4000 -d 130 -p -i 3:-T 2 -N 4000 -d 130 -p -i 3:-T 3 -N 4000 -d 130 -p -i 3:-T 4 -N 4000 -d 130 -p -i 3:em3dver40001303 +Em3d:Em3d/dsm:-T 1 -N 4000 -d 130 -p -i 100000:-T 2 -N 4000 -d 130 -p -i 100000:-T 3 -N 4000 -d 130 -p -i 100000:-T 4 -N 4000 -d 130 -p -i 100000:em3dver4000130100000 Chase:Chase:::::chase Array:Array:::::array diff --git a/Robust/src/Runtime/DSTM/interface/addUdpEnhance.h b/Robust/src/Runtime/DSTM/interface/addUdpEnhance.h index f68e5ca0..1691473d 100644 --- a/Robust/src/Runtime/DSTM/interface/addUdpEnhance.h +++ b/Robust/src/Runtime/DSTM/interface/addUdpEnhance.h @@ -2,6 +2,7 @@ #define _ADDUDPENHANCE_H #include "dstm.h" +#include "mlookup.h" /******************************* diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index 0928321c..e5a2beed 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -469,12 +469,6 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne numBytes += size; /* Send TRANS_DISAGREE to Coordinator */ control = TRANS_DISAGREE; -#ifdef CHECKTA - char b[] = "version mismatch"; - char c[] = "object type"; - TABORT3(__func__, b, c, TYPE(mobj)); -#endif - } } else {/* If Obj is not locked then lock object */ /* Save all object oids that are locked on this machine during this transaction request call */ @@ -491,12 +485,6 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne size += sizeof(objheader_t); numBytes += size; control = TRANS_DISAGREE; - -#ifdef CHECKTA - char b[] = "version mismatch"; - char c[] = "object type"; - TABORT3(__func__, b, c, TYPE(mobj)); -#endif } } } @@ -504,6 +492,7 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne /* send TRANS_DISAGREE and objs*/ if(v_nomatch > 0) { +#ifdef CACHE char *objs = calloc(1, numBytes); int j, offset = 0; for(j = 0; j 0) { for(j = 0; j < objlocked; j++) { if((headptr = mhashSearch(oidlocked[j])) == NULL) { @@ -525,12 +515,14 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne free(oidlocked); } send_data(acceptfd, &control, sizeof(char)); +#ifdef CACHE send_data(acceptfd, &numBytes, sizeof(int)); send_data(acceptfd, objs, numBytes); transinfo->objvernotmatch = oidvernotmatch; transinfo->numvernotmatch = objvernotmatch; free(objs); free(transinfo->objvernotmatch); +#endif return control; } diff --git a/Robust/src/Runtime/DSTM/interface/prelookup.c b/Robust/src/Runtime/DSTM/interface/prelookup.c index 7e81d5f3..f003e0f1 100644 --- a/Robust/src/Runtime/DSTM/interface/prelookup.c +++ b/Robust/src/Runtime/DSTM/interface/prelookup.c @@ -191,6 +191,7 @@ unsigned int prehashResize(unsigned int newsize) { //Note: This is based on the implementation of the inserting a key in the first position of the hashtable void prehashClear() { +#ifdef CACHE int i, isFirstBin; prehashlistnode_t *ptr, *prev, *curr; @@ -220,5 +221,6 @@ void prehashClear() { } pflookup.hack2=pflookup.hack; pflookup.hack=oldcache; +#endif } diff --git a/Robust/src/Runtime/DSTM/interface/signal.c b/Robust/src/Runtime/DSTM/interface/signal.c index 942c8320..b670548a 100644 --- a/Robust/src/Runtime/DSTM/interface/signal.c +++ b/Robust/src/Runtime/DSTM/interface/signal.c @@ -21,9 +21,9 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) { printf("nmhashSearch = %d\n", nmhashSearch); printf("nprehashSearch = %d\n", nprehashSearch); printf("nRemoteReadSend = %d\n", nRemoteSend); - int i; //TODO Remove later /* + int i; for(i=0; icache, size); - memcpy(objcopy, tmp, size); - /* Insert into cache's lookup table */ - chashInsert(record->lookupTable, OID(tmp), objcopy); + /* Look up in prefetch cache */ + GETSIZE(size, tmp); + size+=sizeof(objheader_t); + objcopy = (objheader_t *) objstrAlloc(record->cache, size); + memcpy(objcopy, tmp, size); + /* Insert into cache's lookup table */ + chashInsert(record->lookupTable, OID(tmp), objcopy); #ifdef COMPILER - return &objcopy[1]; + return &objcopy[1]; #else - return objcopy; + return objcopy; +#endif + } #endif - } else { /* Get the object from the remote location */ if((machinenumber = lhashSearch(oid)) == 0) { printf("Error: %s() No machine found for oid =% %s,%dx\n",__func__, machinenumber, __FILE__, __LINE__); return NULL; } objcopy = getRemoteObj(record, machinenumber, oid); - + if(objcopy == NULL) { printf("Error: Object not found in Remote location %s, %d\n", __FILE__, __LINE__); return NULL; } else { #ifdef TRANSSTATS - nRemoteSend++; -#endif -#ifdef CHECKTA - printf("Remote read, oid = %x, oidtype =%d\n", oid, TYPE(objcopy)); - fflush(stdout); + nRemoteSend++; #endif STATUS(objcopy)=0; #ifdef COMPILER @@ -629,10 +630,6 @@ int transCommit(transrecord_t *record) { if(treplyctrl == TRANS_ABORT) { #ifdef TRANSSTATS numTransAbort++; -#endif -#ifdef CHECKTA - char a[] = "Aborting"; - TABORT1(a); #endif /* Free Resources */ objstrDelete(record->cache); @@ -644,10 +641,6 @@ int transCommit(transrecord_t *record) { } else if(treplyctrl == TRANS_COMMIT) { #ifdef TRANSSTATS numTransCommit++; -#endif -#ifdef CHECKTA - char a[] = "Commiting"; - TABORT1(a); #endif /* Free Resources */ objstrDelete(record->cache); @@ -713,6 +706,7 @@ void *transRequest(void *threadarg) { /* Read control message from Participant */ recv_data(sd, &control, sizeof(char)); /* Recv Objects if participant sends TRANS_DISAGREE */ +#ifdef CACHE if(control == TRANS_DISAGREE) { int length; recv_data(sd, &length, sizeof(int)); @@ -730,11 +724,6 @@ void *transRequest(void *threadarg) { objheader_t * header; header = (objheader_t *) (((char *)newAddr) + offset); oidToPrefetch = OID(header); -#ifdef CHECKTA - printf("Trans disagree for oid = %x: ", OID(header)); - char a[] = "object type"; - TABORT8(__func__, a, TYPE(header)); -#endif int size = 0; GETSIZE(size, header); size += sizeof(objheader_t); @@ -750,6 +739,7 @@ void *transRequest(void *threadarg) { offset += size; } } +#endif recvcontrol = control; /* Update common data structure and increment count */ @@ -793,6 +783,7 @@ void *transRequest(void *threadarg) { } */ +#ifdef CACHE if(*(tdata->replyctrl) == TRANS_COMMIT) { int retval; /* Update prefetch cache */ @@ -809,6 +800,7 @@ void *transRequest(void *threadarg) { } } } +#endif /* Send the final response such as TRANS_COMMIT or TRANS_ABORT * to all participants in their respective socket */ @@ -861,8 +853,10 @@ void decideResponse(thread_data_array_t *tdata) { /* Send Abort */ *(tdata->replyctrl) = TRANS_ABORT; *(tdata->replyretry) = 0; +#ifdef CACHE /* clear objects from prefetch cache */ cleanPCache(tdata); +#endif } else if(transagree == tdata->buffer->f.mcount){ /* Send Commit */ *(tdata->replyctrl) = TRANS_COMMIT; @@ -998,19 +992,6 @@ void *handleLocalReq(void *threadarg) { v_nomatch++; /* Send TRANS_DISAGREE to Coordinator */ localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_DISAGREE; -#ifdef CHECKTA - printf("Trans disagree for oid = %x: ", OID(mobj)); - char a[] = "object type"; - TABORT8(__func__, a, TYPE(mobj)); -#endif - -#ifdef CHECKTA - //char a[] = "mid"; - //char b[] = "version mismatch"; - //char c[] = "object type"; - //char d[] = "oid"; - //TABORT9(__func__, b, a, c, d, localtdata->tdata->mid, TYPE(mobj), OID(mobj)); -#endif break; } } else { @@ -1024,18 +1005,6 @@ void *handleLocalReq(void *threadarg) { v_nomatch++; /* Send TRANS_DISAGREE to Coordinator */ localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_DISAGREE; -#ifdef CHECKTA - printf("Trans disagree for oid = %x: ", OID(mobj)); - char a[] = "object type"; - TABORT8(__func__, a, TYPE(mobj)); -#endif -#ifdef CHECKTA - //char a[] = "mid"; - //char b[] = "version mismatch"; - //char c[] = "object type"; - //char d[] = "oid"; - //TABORT9(__func__, b, a, c, d, localtdata->tdata->mid, TYPE(mobj), OID(mobj)); -#endif break; } } @@ -1047,13 +1016,6 @@ void *handleLocalReq(void *threadarg) { } /* Condition to send TRANS_SOFT_ABORT */ if((v_matchlock > 0 && v_nomatch == 0) || (numoidnotfound > 0 && v_nomatch == 0)) { -#ifdef CHECKTA - //char a[] = "mid"; - //char b[] = "version mismatch"; - //char c[] = "object type"; - //TABORT7(__func__, b, a, c, localtdata->tdata->mid, TYPE(mobj)); - printf("%s() Soft abort\n", __func__); -#endif localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_SOFT_ABORT; } @@ -1084,6 +1046,7 @@ void *handleLocalReq(void *threadarg) { pthread_exit(NULL); } } else if(*(localtdata->tdata->replyctrl) == TRANS_COMMIT) { +#ifdef CACHE /* Invalidate objects in other machine cache */ if(localtdata->tdata->buffer->f.nummod > 0) { int retval; @@ -1092,6 +1055,7 @@ void *handleLocalReq(void *threadarg) { return; } } +#endif if(transComProcess(localtdata) != 0) { printf("Error in transComProcess() %s,%d\n", __FILE__, __LINE__); fflush(stdout); @@ -1432,7 +1396,9 @@ unsigned short getObjType(unsigned int oid) { short fieldoffset[] ={}; if ((objheader = (objheader_t *) mhashSearch(oid)) == NULL) { +#ifdef CACHE if ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) { +#endif unsigned int mid = lhashSearch(oid); int sd = getSock2(transReadSockPool, mid); char remotereadrequest[sizeof(char)+sizeof(unsigned int)]; @@ -1452,6 +1418,7 @@ unsigned short getObjType(unsigned int oid) { /* Read object if found into local cache */ int size; recv_data(sd, &size, sizeof(int)); +#ifdef CACHE pthread_mutex_lock(&prefetchcache_mutex); if ((objheader = prefetchobjstrAlloc(size)) == NULL) { printf("Error: %s() objstrAlloc error for copying into prefetch cache %s, %d\n", __func__, __FILE__, __LINE__); @@ -1460,8 +1427,24 @@ unsigned short getObjType(unsigned int oid) { pthread_mutex_unlock(&prefetchcache_mutex); recv_data(sd, objheader, size); prehashInsert(oid, objheader); + return TYPE(objheader); +#else + char *buffer; + if((buffer = calloc(1, size)) == NULL) { + printf("%s() Calloc Error %s at line %d\n", __func__, __FILE__, __LINE__); + fflush(stdout); + return 0; + } + recv_data(sd, buffer, size); + objheader = (objheader_t *)buffer; + unsigned short type = TYPE(objheader); + free(buffer); + return type; +#endif } +#ifdef CACHE } +#endif } return TYPE(objheader); } @@ -1741,10 +1724,12 @@ void threadNotify(unsigned int oid, unsigned short version, unsigned int tid) { printf("threadNotify(): New version %d has not changed since last version for oid = %d, %s, %d\n", version, oid, __FILE__, __LINE__); return; } else { +#ifdef CACHE /* Clear from prefetch cache and free thread related data structure */ if((ptr = prehashSearch(oid)) != NULL) { prehashRemove(oid); } +#endif pthread_cond_signal(&(ndata->threadcond)); } } diff --git a/Robust/src/buildscript b/Robust/src/buildscript index a9bea668..a257d8ea 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -4,6 +4,7 @@ printhelp() { echo -robustroot set up the ROBUSTROOT to directory other than default one echo -dsm distributed shared memory echo -trueprob double - probabiltiy of true branch +echo -dsmcaching -enable caching in dsm runtime echo -mac distributed shared memory mac support echo -check generate check code echo -dmalloc link in dmalloc @@ -190,8 +191,10 @@ RAWDEBUGFLAG=true EXTRAOPTIONS="$EXTRAOPTIONS -g" elif [[ $1 = '-runtimedebug' ]] then -#EXTRAOPTIONS="$EXTRAOPTIONS -DDEBUG" -EXTRAOPTIONS="$EXTRAOPTIONS -DCHECKTB" +EXTRAOPTIONS="$EXTRAOPTIONS -DCHECKTA" +elif [[ $1 = '-dsmcaching' ]] +then +EXTRAOPTIONS="$EXTRAOPTIONS -DCACHE" elif [[ $1 = '-nooptimize' ]] then EXTRAOPTIONS="$EXTRAOPTIONS -O0" -- 2.34.1