changes to copy remote objs read into prefetch cache
authoradash <adash>
Fri, 25 Sep 2009 08:36:55 +0000 (08:36 +0000)
committeradash <adash>
Fri, 25 Sep 2009 08:36:55 +0000 (08:36 +0000)
print transaction stat counters for remote machines

Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.c
Robust/src/Runtime/DSTM/interface/signal.c
Robust/src/Runtime/DSTM/interface/trans.c

index d97e0b92502d1914cc42a5a46b9a5caf51661c7e..d416090280a518620ef19b07b79ec30782331edf 100644 (file)
@@ -121,6 +121,7 @@ void cleanPCache() {
 int updatePrefetchCache(trans_req_data_t *tdata) {
   int retval;
   char oidType;
+  /*//TODO comment it for now because objects read are already in the prefetch cache
   oidType = 'R';
   if(tdata->f.numread > 0) {
     if((retval = copyToCache(tdata->f.numread, (unsigned int *)(tdata->objread), oidType)) != 0) {
@@ -128,6 +129,7 @@ int updatePrefetchCache(trans_req_data_t *tdata) {
       return -1;
     }
   }
+  */
   if(tdata->f.nummod > 0) {
     oidType = 'M';
     if((retval = copyToCache(tdata->f.nummod, tdata->oidmod, oidType)) != 0) {
@@ -142,13 +144,13 @@ int copyToCache(int numoid, unsigned int *oidarray, char oidType) {
   int i;
   for (i = 0; i < numoid; i++) {
     unsigned int oid;
-    if(oidType == 'R') {
-      char * objread = (char *) oidarray;
-      oid = *((unsigned int *)(objread+(sizeof(unsigned int)+
-                                        sizeof(unsigned short))*i));
-    } else {
+    //if(oidType == 'R') {
+    //  char * objread = (char *) oidarray;
+    //  oid = *((unsigned int *)(objread+(sizeof(unsigned int)+
+    //                                    sizeof(unsigned short))*i));
+    //} else {
       oid = oidarray[i];
-    }
+    //}
     pthread_mutex_lock(&prefetchcache_mutex);
     objheader_t * header;
     if((header = (objheader_t *) t_chashSearch(oid)) == NULL) {
index 85445905b5703e3c82ee26bd95c2f8bad391e4ec..2f9c1105a1775d305996557391b0d940e78113c7 100644 (file)
@@ -20,7 +20,6 @@ extern int sendRemoteReq;
 void handle();
 extern pfcstats_t *evalPrefetch;
 
-/*
 void transStatsHandler(int sig, siginfo_t* info, void *context) {
 #ifdef TRANSSTATS
   FILE *fp;
@@ -39,14 +38,16 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) {
   fprintf(fp, "bytesSent = %d\n", bytesSent);
   fprintf(fp, "bytesRecv = %d\n", bytesRecv);
   fprintf(fp, "totalObjSize= %d\n", totalObjSize);
+  fprintf(fp, "sendRemoteReq= %d\n", sendRemoteReq);
+  fprintf(fp, "getResponse= %d\n", getResponse);
   fprintf(fp, "**********************************\n");
   fflush(fp);
   fclose(fp);
   exit(0);
 #endif
 }
-*/
 
+/*
 void transStatsHandler(int sig, siginfo_t* info, void *context) {
 #ifdef TRANSSTATS
   printf("******  Transaction Stats   ******\n");
@@ -67,6 +68,7 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) {
   exit(0);
 #endif
 }
+*/
 
 void handle() {
 #ifdef TRANSSTATS
index 97acba76ffb392d6c8ce18315ef215e2ed09b974..b53e4bd57739ba010fc9203ded9c2ade23527f23 100644 (file)
@@ -641,6 +641,29 @@ __attribute__((pure)) objheader_t *transRead(unsigned int oid) {
       nRemoteSend++;
 #endif
 #ifdef COMPILER
+#ifdef CACHE
+      //Copy object to prefetch cache
+      pthread_mutex_lock(&prefetchcache_mutex);
+      objheader_t *headerObj;
+      int size;
+      GETSIZE(size, objcopy);
+      if((headerObj = prefetchobjstrAlloc(size + sizeof(objheader_t))) == NULL) {
+        printf("%s(): Error in getting memory from prefetch cache at %s, %d\n", __func__,
+            __FILE__, __LINE__);
+        pthread_mutex_unlock(&prefetchcache_mutex);
+        return NULL;
+      }
+      pthread_mutex_unlock(&prefetchcache_mutex);
+      memcpy(headerObj, objcopy, size+sizeof(objheader_t));
+      //make an entry in prefetch lookup hashtable
+      void *oldptr;
+      if((oldptr = prehashSearch(oid)) != NULL) {
+        prehashRemove(oid);
+        prehashInsert(oid, headerObj);
+      } else {
+        prehashInsert(oid, headerObj);
+      }
+#endif
       return &objcopy[1];
 #else
       return objcopy;
@@ -725,6 +748,30 @@ __attribute__((pure)) objheader_t *transRead2(unsigned int oid) {
       nRemoteSend++;
 #endif
 #ifdef COMPILER
+#ifdef CACHE
+      //Copy object to prefetch cache
+      pthread_mutex_lock(&prefetchcache_mutex);
+      objheader_t *headerObj;
+      int size;
+      GETSIZE(size, objcopy);
+      if((headerObj = prefetchobjstrAlloc(size + sizeof(objheader_t))) == NULL) {
+        printf("%s(): Error in getting memory from prefetch cache at %s, %d\n", __func__,
+            __FILE__, __LINE__);
+        pthread_mutex_unlock(&prefetchcache_mutex);
+        return NULL;
+      }
+      pthread_mutex_unlock(&prefetchcache_mutex);
+      memcpy(headerObj, objcopy, size+sizeof(objheader_t));
+      //make an entry in prefetch lookup hashtable
+      void *oldptr;
+      if((oldptr = prehashSearch(oid)) != NULL) {
+        prehashRemove(oid);
+        prehashInsert(oid, headerObj);
+      } else {
+        prehashInsert(oid, headerObj);
+      }
+#endif
+
       return &objcopy[1];
 #else
       return objcopy;