New strategy... If the prefetching thread gets behind us, we don't issue a prefetch.
authorbdemsky <bdemsky>
Wed, 6 Aug 2008 05:33:35 +0000 (05:33 +0000)
committerbdemsky <bdemsky>
Wed, 6 Aug 2008 05:33:35 +0000 (05:33 +0000)
Robust/src/Runtime/DSTM/interface/queue.c
Robust/src/Runtime/DSTM/interface/trans.c

index 9f2eb419b9ff96791c3e820838a70589182ce72e..9ff96430dbdcf305ef5f3072e62f0aed5a08378a 100644 (file)
@@ -25,17 +25,17 @@ void * getmemory(int size) {
   if (tmpoffset>QSIZE) {
     //Wait for tail to go past end
     tmpoffset=size+sizeof(int);
-    while(headoffset<tailoffset)
-      ;
+    if (headoffset<tailoffset)
+      return NULL;
     //Wait for tail to go past new start
-    while(tailoffset<=tmpoffset)
-      ;
+    if (tailoffset<=tmpoffset)
+      return NULL;
     *((int *)(memory+headoffset))=-1;//safe because we left space
     *((int*)memory)=size+sizeof(int);
     return memory+sizeof(int);
   } else {
-    while(headoffset<tailoffset&&tailoffset<=tmpoffset)
-      ;
+    if (headoffset<tailoffset&&tailoffset<=tmpoffset)
+      return NULL;
     *((int*)(memory+headoffset))=size+sizeof(int);
     return memory+headoffset+sizeof(int);
   }
index 242e6bce56d7a0b8d7038a880faad75012b8f59c..04dc63cef4a2e44d4056acacf1880460a6909391 100644 (file)
@@ -143,10 +143,13 @@ inline int findmax(int *array, int arraylength) {
 void prefetch(int siteid, int ntuples, unsigned int *oids, unsigned short *endoffsets, short *arrayfields) {
   /* Allocate for the queue node*/
   int qnodesize = 2*sizeof(int) + ntuples * (sizeof(unsigned short) + sizeof(unsigned int)) + endoffsets[ntuples - 1] * sizeof(short);
-  char * node= getmemory(qnodesize);
-  /* Set queue node values */
   int len;
+  char * node= getmemory(qnodesize);
   int top=endoffsets[ntuples-1];
+  
+  if (node==NULL) 
+    return;
+  /* Set queue node values */
 
   /* TODO: Remove this after testing */
   evalPrefetch[siteid].callcount++;