new files for dynamic prefetch enabling
authoradash <adash>
Thu, 31 Jul 2008 02:27:50 +0000 (02:27 +0000)
committeradash <adash>
Thu, 31 Jul 2008 02:27:50 +0000 (02:27 +0000)
and signal file for getting new stats

Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.c [new file with mode: 0644]
Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.h [new file with mode: 0644]
Robust/src/Runtime/DSTM/interface/signal.c [new file with mode: 0644]

diff --git a/Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.c b/Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.c
new file mode 100644 (file)
index 0000000..ef7d7aa
--- /dev/null
@@ -0,0 +1,49 @@
+#include "dstm.h"
+#include "addPrefetchEnhance.h"
+
+extern int numprefetchsites;
+//pfcstats_t evalPrefetch[numprefetchsites]; //Global array for all prefetch sites in the executable
+extern pfcstats_t *evalPrefetch;
+
+pfcstats_t *initPrefetchStats() {
+  pfcstats_t *ptr;
+  if((ptr = calloc(numprefetchsites, sizeof(pfcstats_t))) == NULL) {
+    printf("%s() Calloc error in %s at line %d\n", __func__, __FILE__, __LINE__);
+    return NULL;
+  }
+  int i;
+  /* Enable prefetching at the beginning */
+  for(i=0; i<numprefetchsites; i++) {
+    ptr[i].operMode = 1;
+    ptr[i].callcount = 0;
+    ptr[i].retrycount = RETRYINTERVAL; //N
+    ptr[i].uselesscount = SHUTDOWNINTERVAL; //M
+  }
+  return ptr;
+}
+
+int getRetryCount(int siteid) {
+  return evalPrefetch[siteid].retrycount;
+}
+
+int getUselessCount(int siteid) {
+  return evalPrefetch[siteid].uselesscount;
+}
+
+char getOperationMode(int siteid) {
+  return evalPrefetch[siteid].operMode;
+}
+
+void handleDynPrefetching(int numLocal, int ntuples, int siteid) {
+  if(numLocal < ntuples) {
+    /* prefetch not found locally(miss in cache) */
+    evalPrefetch[siteid].operMode = 1;
+    evalPrefetch[siteid].uselesscount = SHUTDOWNINTERVAL;
+  } else {
+    if(getOperationMode(siteid) != 0) {
+      evalPrefetch[siteid].uselesscount--;
+      if(evalPrefetch[siteid].uselesscount <= 0)
+        evalPrefetch[siteid].operMode = 0;
+    }
+  }
+}
diff --git a/Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.h b/Robust/src/Runtime/DSTM/interface/addPrefetchEnhance.h
new file mode 100644 (file)
index 0000000..e33e376
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _ADDPREFETCHENHANCE_H_
+#define _ADDPREFETCHENHANCE_H_
+
+typedef struct prefetchCountStats {
+  int retrycount;    /* keeps track of when to retry and check if we can turn on this prefetch site */ 
+  int uselesscount; /* keeps track of how long was the prefetching at site useles */ 
+  char operMode; /* 1 = on , 0 = off */
+  int callcount;
+} pfcstats_t;
+
+pfcstats_t *initPrefetchStats();
+int getRetryCount(int siteid);
+int getUselessCount(int siteid);
+char getOperationMode(int);
+void handleDynPrefetching(int, int, int);
+
+#endif
diff --git a/Robust/src/Runtime/DSTM/interface/signal.c b/Robust/src/Runtime/DSTM/interface/signal.c
new file mode 100644 (file)
index 0000000..062e8a0
--- /dev/null
@@ -0,0 +1,33 @@
+#include "dstm.h"
+#include <signal.h>
+
+extern int numTransAbort;
+extern int numTransCommit;
+extern int numprefetchsites;
+void handle();
+extern pfcstats_t *evalPrefetch;
+
+void transStatsHandler(int sig, siginfo_t* info, void *context) {
+#ifdef TRANSSTATS
+  printf("******  Transaction Stats   ******\n");
+  printf("numTransAbort = %d\n", numTransAbort);
+  printf("numTransCommit = %d\n", numTransCommit);
+  int i;
+  for(i=0; i<numprefetchsites; i++) {
+    printf("siteid = %d,  callCount = %d\n", i, evalPrefetch[i].callcount);
+  }
+  exit(0);
+#endif
+}
+
+void handle() {
+#ifdef TRANSSTATS
+  struct sigaction siga;
+  siga.sa_handler = NULL;
+  siga.sa_flags = SA_SIGINFO;
+  siga.sa_flags = 0;
+  siga.sa_sigaction = &transStatsHandler;
+  sigemptyset(&siga.sa_mask);
+  sigaction(SIGUSR1, &siga, 0);
+#endif
+}