do a make tabbing
authoradash <adash>
Mon, 4 May 2009 19:21:12 +0000 (19:21 +0000)
committeradash <adash>
Mon, 4 May 2009 19:21:12 +0000 (19:21 +0000)
 protect stats insde bounds
 add function to stm for instrumentation ---- still working on locks

18 files changed:
Robust/src/ClassLibrary/Character.java
Robust/src/ClassLibrary/FileInputStream.java
Robust/src/ClassLibrary/HashMapIterator.java
Robust/src/ClassLibrary/Hashtable.java
Robust/src/ClassLibrary/Integer.java
Robust/src/ClassLibrary/Iterator.java
Robust/src/ClassLibrary/LinkedList.java
Robust/src/ClassLibrary/PushbackInputStream.java
Robust/src/ClassLibrary/SocketInputStream.java
Robust/src/ClassLibrary/String.java
Robust/src/ClassLibrary/System.java
Robust/src/ClassLibrary/Vector.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/STM/stmlookup.c
Robust/src/Runtime/STM/tm.h
Robust/src/Runtime/runtime.c
Robust/src/buildscript

index 521a174e6eb967a4707776876ca2ce78d6b4dad4..1febbc3c4458e2423cafdf1752b61c8b3480aff8 100644 (file)
@@ -16,12 +16,12 @@ public class Character {
   }
 
   char value;
-  
-  public Character( char c ) {
+
+  public Character(char c) {
     value = c;
   }
 
-  public Character( Character c ) {
+  public Character(Character c) {
     value = c.value;
   }
 
@@ -32,15 +32,14 @@ public class Character {
   public static boolean isWhitespace(char character) {
     boolean returnValue;
     if ( (character == '\t') ||
-        (character == '\n') || 
-        (character == ' ') || 
-        (character == '\u000C') || 
-        (character == '\u001C') || 
-        (character == '\u001D') || 
-        (character == '\u001E') || 
-        (character == '\u001F')) 
-    {
-      returnValue = true;     
+         (character == '\n') ||
+         (character == ' ') ||
+         (character == '\u000C') ||
+         (character == '\u001C') ||
+         (character == '\u001D') ||
+         (character == '\u001E') ||
+         (character == '\u001F')) {
+      returnValue = true;
     } else {
       returnValue = false;
     }
index eeda05dd57fad945f1f83b8922188f03b83dda6e..44d888923eb697d4d1c7b5fd2987511a0e9970e4 100644 (file)
@@ -43,11 +43,11 @@ public class FileInputStream extends InputStream {
   public String readLine() {
     String line = "";
     int c = read();
-    
+
     // if we're already at the end of the file
     // or there is an error, don't even return
     // the empty string
-    if( c <= 0 ) { 
+    if( c <= 0 ) {
       return null;
     }
 
@@ -57,7 +57,7 @@ public class FileInputStream extends InputStream {
       c = read();
     }
 
-    // peek and consume characters that are carriage 
+    // peek and consume characters that are carriage
     // returns or line feeds so the whole line is read
     // and returned, and none of the line-ending chars
     c = peek();
index e297cf5f948760ff8bee10b308fe11ceb52767fe..f540d335a78177e05d4f120048fa98d394893690 100644 (file)
@@ -45,7 +45,7 @@ class HashMapIterator extends Iterator {
   }
 
   public void remove() {
-    System.out.println( "HashMapIterator.remove() not implemented." );
-    System.exit( -1 );
+    System.out.println("HashMapIterator.remove() not implemented.");
+    System.exit(-1);
   }
 }
index a8043524d7186b21253ea1a5e5b2a3bf33d425cc..9ecbdadd7a3ce0ace511ea46279aeb373841bd84 100644 (file)
@@ -1,7 +1,7 @@
 public class Hashtable extends HashMap
 {
   public Hashtable() {
-    HashMap(16, 0.75f);    
+    HashMap(16, 0.75f);
   }
 
   public Hashtable(int initialCapacity) {
index 831e78f9bfbb939a6be0b51b2f09d2968c87d5e9..7bb38585a184dd55a6b76073a8950aece243e769 100644 (file)
@@ -77,8 +77,8 @@ public class Integer {
     return String.valueOf(value);
   }
 
-  public static String toString( int i ) {
-    Integer I = new Integer( i );
+  public static String toString(int i) {
+    Integer I = new Integer(i);
     return I.toString();
   }
 
index e88a4854755d958d760d0646e087812032150fe3..f80ed50dae000691c327f067ac8a544a55dead71 100644 (file)
@@ -1,16 +1,16 @@
 public class Iterator {
   boolean hasNext() {
-    System.out.println( "Iterator is an abstract class." );
+    System.out.println("Iterator is an abstract class.");
     System.exit(-1);
   }
 
   Object next() {
-    System.out.println( "Iterator is an abstract class." );
+    System.out.println("Iterator is an abstract class.");
     System.exit(-1);
   }
 
   void remove() {
-    System.out.println( "Iterator is an abstract class." );
+    System.out.println("Iterator is an abstract class.");
     System.exit(-1);
-  }    
+  }
 }
index 72f57dd24f55767b6aa936d1b747f0b3235aaca4..e2af01042c825712d82977ade321414459fa0d8f 100644 (file)
@@ -3,9 +3,9 @@ public class LinkedListElement {
   public LinkedListElement prev;
   public Object element;
 
-  public LinkedListElement( Object e,
-                           LinkedListElement n,
-                           LinkedListElement p ) {
+  public LinkedListElement(Object e,
+                           LinkedListElement n,
+                           LinkedListElement p) {
     element = e;
     next = n;
     prev = p;
@@ -21,32 +21,32 @@ public class LinkedList {
     clear();
   }
 
-  public add( Object o ) {
+  public add(Object o) {
     if( tail == null ) {
-      head = new LinkedListElement( o, null, null );
+      head = new LinkedListElement(o, null, null);
       tail = head;
 
     } else {
-      tail.next = new LinkedListElement( o, null, tail );
+      tail.next = new LinkedListElement(o, null, tail);
       tail = tail.next;
     }
     size++;
   }
 
-  public addFirst( Object o ) {
+  public addFirst(Object o) {
     if( head == null ) {
-      head = new LinkedListElement( o, null, null );
+      head = new LinkedListElement(o, null, null);
       tail = head;
 
     } else {
-      head.prev = new LinkedListElement( o, head, null );
+      head.prev = new LinkedListElement(o, head, null);
       head = head.prev;
     }
     size++;
   }
 
-  public addLast( Object o ) {
-    add( o );
+  public addLast(Object o) {
+    add(o);
   }
 
   public clear() {
@@ -64,26 +64,26 @@ public class LinkedList {
   }
 
   public Object clone() {
-    System.out.println( "LinkedList.clone() not implemented." );
+    System.out.println("LinkedList.clone() not implemented.");
     System.exit(-1);
   }
 
-  public boolean contains( Object o ) {
+  public boolean contains(Object o) {
     LinkedListElement e = head;
     if (o==null) {
       while(e!=null) {
        if (e.element==null) {
          return true;
-        }
-        e=e.next;
+       }
+       e=e.next;
       }
       return false;
     } else {
       while( e != null ) {
-        if (o.equals(e.element)) {
-          return true;
-        }
-        e = e.next;
+       if (o.equals(e.element)) {
+         return true;
+       }
+       e = e.next;
       }
     }
     return false;
@@ -100,7 +100,7 @@ public class LinkedList {
     if( tail == null ) {
       return null;
     }
-    return tail.element;    
+    return tail.element;
   }
 
   public Object element() {
@@ -121,7 +121,7 @@ public class LinkedList {
 
   public Object removeFirst() {
     if( head == null ) {
-      System.out.println( "LinkedList: illegal removeFirst()" );
+      System.out.println("LinkedList: illegal removeFirst()");
       System.exit(-1);
     }
     Object o = head.element;
@@ -137,7 +137,7 @@ public class LinkedList {
 
   public Object removeLast() {
     if( tail == null ) {
-      System.out.println( "LinkedList: illegal removeLast()" );
+      System.out.println("LinkedList: illegal removeLast()");
       System.exit(-1);
     }
     Object o = tail.element;
@@ -151,9 +151,9 @@ public class LinkedList {
     return o;
   }
 
-  public void remove( Object o ) {
+  public void remove(Object o) {
     if( head == null ) {
-      System.out.println( "LinkedList: illegal remove( Object o )" );
+      System.out.println("LinkedList: illegal remove( Object o )");
       System.exit(-1);
     }
     LinkedListElement e = head;
@@ -170,8 +170,8 @@ public class LinkedList {
       }
       e = e.next;
     }
-    System.out.println( "LinkedList: illegal remove( Object o ), "+o+" not found" );
-    System.exit(-1);    
+    System.out.println("LinkedList: illegal remove( Object o ), "+o+" not found");
+    System.exit(-1);
   }
 
   public Object pop() {
@@ -180,12 +180,12 @@ public class LinkedList {
     return o;
   }
 
-  public void push( Object o ) {
-    addFirst( o );
+  public void push(Object o) {
+    addFirst(o);
   }
 
   public Iterator iterator() {
-    return new LinkedListIterator( this );
+    return new LinkedListIterator(this);
   }
 }
 
@@ -193,8 +193,8 @@ public class LinkedListIterator extends Iterator {
   LinkedList ll;
   LinkedListElement itr;
   Object removeable;
-  
-  public LinkedListIterator( LinkedList ll ) {
+
+  public LinkedListIterator(LinkedList ll) {
     this.ll = ll;
     itr = ll.head;
     removeable = null;
@@ -206,7 +206,7 @@ public class LinkedListIterator extends Iterator {
 
   public Object next() {
     if( itr == null ) {
-      System.out.println( "LinkedListIterator: illegal next()" );
+      System.out.println("LinkedListIterator: illegal next()");
       System.exit(-1);
     }
     removeable = itr.element;
@@ -216,10 +216,10 @@ public class LinkedListIterator extends Iterator {
 
   public void remove() {
     if( removeable == null ) {
-      System.out.println( "LinkedListIterator: illegal remove()" );
+      System.out.println("LinkedListIterator: illegal remove()");
       System.exit(-1);
     }
-    ll.remove( removeable );
+    ll.remove(removeable);
     removeable = null;
   }
 }
index fb29b4160c18df77eea6273e3b3ce7ac0a7a3baa..3e3d52f1175a1acda41bbb404b082572d136aa91 100644 (file)
@@ -19,7 +19,7 @@ public class PushbackInputStream {
   private int bottom;
   private int[] stack;
 
-  
+
   public PushbackInputStream(FileInputStream fis) {
     in = fis;
     max = 1000;
@@ -32,7 +32,7 @@ public class PushbackInputStream {
     stack = new int[max];
   }
 
-  
+
   public int read() {
     int v;
 
@@ -47,11 +47,11 @@ public class PushbackInputStream {
 
     // put whatever it is in the ring buffer
     ring[index] = v;
-    
+
     // keep ring buffer index
-    ++index; 
-    if( index == max ) { 
-      index = 0; 
+    ++index;
+    if( index == max ) {
+      index = 0;
     }
 
     // user gets what they want
@@ -64,11 +64,11 @@ public class PushbackInputStream {
 
     // the unread stack can only get so high
     if( top == max ) {
-      System.printString( "PushbackInputStream: max reached" );
-      System.exit( -1 );
+      System.printString("PushbackInputStream: max reached");
+      System.exit(-1);
     }
 
     // put it on the unread stack
     stack[top] = ring[index];
-  }    
+  }
 }
\ No newline at end of file
index 97afc287737ac694adddbd63afff52b5f52716d9..807cab6df8408e8beb69a344ae84e48740c026e5 100644 (file)
@@ -17,21 +17,21 @@ public class SocketInputStream extends InputStream {
   }
 
   public int readAll(byte[] b) {
-      int offset=read(b);
-      if (offset<0)
-         return offset;
-      int toread=b.length-offset;
-      while(toread>0) {
-         byte[] t=new byte[toread];
-         int rd=read(t);
-         if (rd<0)
-             return rd;
-         for(int i=0;i<rd;i++)
-             b[i+offset]=t[i];
-         offset+=rd;
-         toread-=rd;
-      }
-      return b.length;
+    int offset=read(b);
+    if (offset<0)
+      return offset;
+    int toread=b.length-offset;
+    while(toread>0) {
+      byte[] t=new byte[toread];
+      int rd=read(t);
+      if (rd<0)
+       return rd;
+      for(int i=0; i<rd; i++)
+       b[i+offset]=t[i];
+      offset+=rd;
+      toread-=rd;
+    }
+    return b.length;
   }
 
   public void close() {
index 7076ebe691a5c0890d84f24661525b036d2987c8..b1ebb8fc23ab4ef165a0d32ca30e691c27ada790 100644 (file)
@@ -297,7 +297,7 @@ public class String {
     for(i = 0; decimal != nodecimal; i++) {
       long basePower = 1;
       for(int x=0; x<i; x++) {
-        basePower*= 10;
+       basePower*= 10;
       }
       nodecimal = (long) (val*basePower);
       decimal = val*basePower;
@@ -308,7 +308,7 @@ public class String {
     for(j = 0; decimal >= 0; j++) {
       long basePower = 1;
       for(int x=0; x<j; x++) {
-        basePower*= 10;
+       basePower*= 10;
       }
       nodecimal = (long) (valueA - basePower);
       decimal = (double) nodecimal;
@@ -319,13 +319,13 @@ public class String {
     decimal = 0;
 
     for(k = j; k > 0; k--) {
-      if(k == i) //if a decimal point was previously found
-      {      //insert it where its meant to be
-        output.append((char)46);
+      if(k == i) //if a decimal point was previously found
+       //insert it where its meant to be
+       output.append((char)46);
       }
       long basePower = 1;
       for(int x=0; x<(k-1); x++) {
-        basePower*= 10;
+       basePower*= 10;
       }
       nodecimal = ((long) (valueA - decimal) / basePower);
       decimal += nodecimal*basePower;
@@ -375,11 +375,11 @@ public class String {
     return new String(chararray);
   }
 
-  public int compareTo( String s ) {
+  public int compareTo(String s) {
     int lenDiff = this.length() - s.length();
     if( lenDiff != 0 ) {
       return lenDiff;
-    }    
+    }
     for( int i = 0; i < this.length(); ++i ) {
       int valDiff = this.charAt(i) - s.charAt(i);
       if( valDiff != 0 ) {
index 9e43bd40396a4f5a82ae084cf652b9f3ac7824f6..ef6caa03f8f05bfb2cd86f79280c6513c75b0c10 100644 (file)
@@ -11,7 +11,7 @@ public class System {
   public static void println(String s) {
     System.printString(s+"\n");
   }
-  
+
   public static void println(Object o) {
     System.printString(""+o+"\n");
   }
@@ -23,7 +23,7 @@ public class System {
   public static void println(double o) {
     System.printString(""+o+"\n");
   }
+
   public static void print(String s) {
     System.printString(s);
   }
@@ -39,7 +39,7 @@ public class System {
   public static void print(double o) {
     System.printString(""+o);
   }
-  
+
   public static void error() {
     System.printString("Error (Use Breakpoint on ___System______error method for more information!)\n");
   }
index f4d1f954d1172b50c8458a711719eca2d2ff837e..42ab24f9f60f1147bcc4680f78e4ada828a2d8b5 100644 (file)
@@ -9,7 +9,7 @@ public class Vector {
     array=new Object[10];
   }
 
-  public Vector( int size ) {
+  public Vector(int size) {
     capacityIncrement=0;
     this.size=0;
     array=new Object[size];
index 86a790b158356d0fd6239c2d7b371a7a4fb019eb..ea2363f0c2a80c0c4c9d2c1a37fe743b3043c820 100644 (file)
@@ -72,7 +72,7 @@ public class BuildCode {
     state=st;
     callgraph=new CallGraph(state);
     if (state.SINGLETM)
-       oidstr="___objlocation___";
+      oidstr="___objlocation___";
     this.temptovar=temptovar;
     paramstable=new Hashtable();
     tempstable=new Hashtable();
@@ -188,8 +188,8 @@ public class BuildCode {
       nonSESEpass = false;
       while( !setSESEtoGen.isEmpty() ) {
        FlatSESEEnterNode fsen = setSESEtoGen.iterator().next();
-       setSESEtoGen.remove( fsen );
-       generateMethodSESE( fsen, fsen.getEnclosingFlatMeth(), null, outmethod );
+       setSESEtoGen.remove(fsen);
+       generateMethodSESE(fsen, fsen.getEnclosingFlatMeth(), null, outmethod);
       }
     } else {
       assert setSESEtoGen.isEmpty();
@@ -235,16 +235,16 @@ public class BuildCode {
     outmethod.println("int main(int argc, const char *argv[]) {");
     outmethod.println("  int i;");
     if (state.DSM) {
-       outmethod.println("#ifdef TRANSSTATS \n");
-       outmethod.println("handle();\n");
-       outmethod.println("#endif\n");
+      outmethod.println("#ifdef TRANSSTATS \n");
+      outmethod.println("handle();\n");
+      outmethod.println("#endif\n");
     }
     if (state.THREAD||state.DSM||state.SINGLETM) {
       outmethod.println("initializethreads();");
-      outmethod.println("#ifdef STMSTATS \n");
-      outmethod.println(" for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {\n");
-      outmethod.println("   typesCausingAbort[i] = 0;\n");
-      outmethod.println(" }\n");
+      outmethod.println("#ifdef STMSTATS\n");
+      outmethod.println(" for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {");
+      outmethod.println("   typesCausingAbort[i] = 0;");
+      outmethod.println(" }");
       outmethod.println("#endif\n");
     }
     if (state.DSM) {
@@ -318,25 +318,27 @@ public class BuildCode {
       outmethod.println("printf(\"numTransCommit= %d\\n\", numTransCommit);");
       outmethod.println("printf(\"nSoftAbort= %d\\n\", nSoftAbort);");
       if (state.DSM) {
-         outmethod.println("printf(\"nchashSearch= %d\\n\", nchashSearch);");
-         outmethod.println("printf(\"nmhashSearch= %d\\n\", nmhashSearch);");
-         outmethod.println("printf(\"nprehashSearch= %d\\n\", nprehashSearch);");
-         outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);");
-         outmethod.println("printf(\"bytesSent= %d\\n\", bytesSent);");
-         outmethod.println("printf(\"bytesRecv= %d\\n\", bytesRecv);");
+       outmethod.println("printf(\"nchashSearch= %d\\n\", nchashSearch);");
+       outmethod.println("printf(\"nmhashSearch= %d\\n\", nmhashSearch);");
+       outmethod.println("printf(\"nprehashSearch= %d\\n\", nprehashSearch);");
+       outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);");
+       outmethod.println("printf(\"bytesSent= %d\\n\", bytesSent);");
+       outmethod.println("printf(\"bytesRecv= %d\\n\", bytesRecv);");
       } else if (state.SINGLETM) {
-         outmethod.println("printf(\"nSoftAbortAbort= %d\\n\", nSoftAbortAbort);");
-         outmethod.println("printf(\"nSoftAbortCommit= %d\\n\", nSoftAbortCommit);");
-      outmethod.println("for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {\n");
-      outmethod.println("  printf(\"typesCausingAbort[%d]= %d\\n\", i, typesCausingAbort[i]);\n");
-      outmethod.println("}\n");
-      outmethod.println("fflush(stdout);");
+       outmethod.println("printf(\"nSoftAbortAbort= %d\\n\", nSoftAbortAbort);");
+       outmethod.println("printf(\"nSoftAbortCommit= %d\\n\", nSoftAbortCommit);");
+       outmethod.println("#ifdef STMSTATS\n");
+       outmethod.println("for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {\n");
+       outmethod.println("  printf(\"typesCausingAbort[%d]= %d\\n\", i, typesCausingAbort[i]);\n");
+       outmethod.println("}\n");
+       outmethod.println("#endif\n");
+       outmethod.println("fflush(stdout);");
       }
       outmethod.println("#endif\n");
     }
 
     if (state.THREAD||state.SINGLETM)
-       outmethod.println("pthread_exit(NULL);");
+      outmethod.println("pthread_exit(NULL);");
 
     outmethod.println("}");
 
@@ -387,7 +389,7 @@ public class BuildCode {
       outmethod.println("#include \"localobjects.h\"");
     }
     if (state.FASTCHECK) {
-      outmethod.println("#include \"localobjects.h\"");      
+      outmethod.println("#include \"localobjects.h\"");
     }
     if(state.MULTICORE) {
       outmethod.println("#include \"task.h\"");
@@ -824,17 +826,19 @@ public class BuildCode {
     outclassdefs.print("extern int numTransCommit;\n");
     outclassdefs.print("extern int nSoftAbort;\n");
     if (state.DSM) {
-       outclassdefs.print("extern int nchashSearch;\n");
-       outclassdefs.print("extern int nmhashSearch;\n");
-       outclassdefs.print("extern int nprehashSearch;\n");
-       outclassdefs.print("extern int nRemoteSend;\n");
-       outclassdefs.print("extern int bytesSent;\n");
-       outclassdefs.print("extern int bytesRecv;\n");
-       outclassdefs.print("extern void handle();\n");
+      outclassdefs.print("extern int nchashSearch;\n");
+      outclassdefs.print("extern int nmhashSearch;\n");
+      outclassdefs.print("extern int nprehashSearch;\n");
+      outclassdefs.print("extern int nRemoteSend;\n");
+      outclassdefs.print("extern int bytesSent;\n");
+      outclassdefs.print("extern int bytesRecv;\n");
+      outclassdefs.print("extern void handle();\n");
     } else if (state.SINGLETM) {
-       outclassdefs.println("extern int nSoftAbortAbort;");
-       outclassdefs.println("extern int nSoftAbortCommit;");
-       outclassdefs.println("extern int typesCausingAbort[];");
+      outclassdefs.println("extern int nSoftAbortAbort;");
+      outclassdefs.println("extern int nSoftAbortCommit;");
+      outclassdefs.println("#ifdef STMSTATS\n");
+      outclassdefs.println("extern int typesCausingAbort[];");
+      outclassdefs.println("#endif\n");
     }
     outclassdefs.print("#endif\n");
     outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n");
@@ -853,7 +857,7 @@ public class BuildCode {
       outclassdefs.print("sizeof(struct "+cdarray[i].getSafeSymbol()+")");
       needcomma=true;
     }
-    
+
 
     arraytable=new TypeDescriptor[state.numArrays()];
 
@@ -877,10 +881,10 @@ public class BuildCode {
 
     outclassdefs.println("};");
 
-    ClassDescriptor objectclass=typeutil.getClass(TypeUtil.ObjectClass);    
+    ClassDescriptor objectclass=typeutil.getClass(TypeUtil.ObjectClass);
     needcomma=false;
     outclassdefs.print("int typearray[]={");
-    for(int i=0;i<state.numClasses();i++) {
+    for(int i=0; i<state.numClasses(); i++) {
       ClassDescriptor cd=cdarray[i];
       ClassDescriptor supercd=cd.getSuperDesc();
       if (needcomma)
@@ -892,7 +896,7 @@ public class BuildCode {
       needcomma=true;
     }
 
-    for(int i=0;i<state.numArrays();i++) {
+    for(int i=0; i<state.numArrays(); i++) {
       TypeDescriptor arraytd=arraytable[i];
       ClassDescriptor arraycd=arraytd.getClassDesc();
       if (arraycd==null) {
@@ -920,13 +924,13 @@ public class BuildCode {
       needcomma=true;
     }
 
-    outclassdefs.println("};");    
+    outclassdefs.println("};");
 
     needcomma=false;
 
 
     outclassdefs.print("int typearray2[]={");
-    for(int i=0;i<state.numArrays();i++) {
+    for(int i=0; i<state.numArrays(); i++) {
       TypeDescriptor arraytd=arraytable[i];
       ClassDescriptor arraycd=arraytd.getClassDesc();
       if (arraycd==null) {
@@ -939,7 +943,7 @@ public class BuildCode {
       ClassDescriptor cd=arraycd.getSuperDesc();
       int level=arraytd.getArrayCount()-1;
       int type=-1;
-      for(;level>0;level--) {
+      for(; level>0; level--) {
        TypeDescriptor supertd=new TypeDescriptor(objectclass);
        supertd.setArrayCount(level);
        type=state.getArrayNumber(supertd);
@@ -969,8 +973,7 @@ public class BuildCode {
     if (lb!=null) {
       paramstable.put(lb, objectparams);
       backuptable.put(lb, new Hashtable<TempDescriptor, TempDescriptor>());
-    }
-    else if (md!=null)
+    } else if (md!=null)
       paramstable.put(md, objectparams);
     else
       paramstable.put(task, objectparams);
@@ -1479,48 +1482,48 @@ public class BuildCode {
       }
     }
 
-    generateCode( fm.getNext(0), fm, lb, null, output );
+    generateCode(fm.getNext(0), fm, lb, null, output);
 
     output.println("}\n\n");
   }
 
 
-  protected void generateMethodSESE( FlatSESEEnterNode fsen,
-                                    FlatMethod fm, 
-                                    LocalityBinding lb,
-                                    PrintWriter output ) {
+  protected void generateMethodSESE(FlatSESEEnterNode fsen,
+                                    FlatMethod fm,
+                                    LocalityBinding lb,
+                                    PrintWriter output) {
 
     //output.println( "void _SESE"+fsen.getPrettyIdentifier()+
-      //" {\n" );
+    //" {\n" );
     //generateCode( fsen.getNext(0), fm, lb, fsen.getFlatExit(), output );
     //output.println( "}\n\n" );
 
     /*
-    output.println("struct sese"+faen.getPrettyIdentifier()+"in {");
-    Iterator<TempDescriptor> itr = faen.getInVarSet().iterator();
-    while( itr.hasNext() ) {
-      TempDescriptor td = itr.next();
-      output.println("  "+td+";");
-    }
-    output.println("}");
+       output.println("struct sese"+faen.getPrettyIdentifier()+"in {");
+       Iterator<TempDescriptor> itr = faen.getInVarSet().iterator();
+       while( itr.hasNext() ) {
+       TempDescriptor td = itr.next();
+       output.println("  "+td+";");
+       }
+       output.println("}");
 
-    output.println("struct sese"+faen.getPrettyIdentifier()+"out {");
-    itr = faen.getOutVarSet().iterator();
-    while( itr.hasNext() ) {
-      TempDescriptor td = itr.next();
-      output.println("  "+td+";");
-    }
-    output.println("}");
-    */
+       output.println("struct sese"+faen.getPrettyIdentifier()+"out {");
+       itr = faen.getOutVarSet().iterator();
+       while( itr.hasNext() ) {
+       TempDescriptor td = itr.next();
+       output.println("  "+td+";");
+       }
+       output.println("}");
+     */
 
   }
 
 
-  protected void generateCode( FlatNode first,
-                              FlatMethod fm, 
-                              LocalityBinding lb,
-                              FlatSESEExitNode stop,
-                              PrintWriter output ) {
+  protected void generateCode(FlatNode first,
+                              FlatMethod fm,
+                              LocalityBinding lb,
+                              FlatSESEExitNode stop,
+                              PrintWriter output) {
 
     /* Assign labels to FlatNode's if necessary.*/
     Hashtable<FlatNode, Integer> nodetolabel=assignLabels(first);
@@ -1534,10 +1537,12 @@ public class BuildCode {
       if (current_node==null) {
        current_node=(FlatNode)tovisit.iterator().next();
        tovisit.remove(current_node);
-      } else if (tovisit.contains(current_node)){
-         tovisit.remove(current_node);
+      } else if (tovisit.contains(current_node)) {
+       tovisit.remove(current_node);
+      }
+      if(current_node==stop) {
+       return;
       }
-      if(current_node==stop) { return; }
       visited.add(current_node);
       if (nodetolabel.containsKey(current_node))
        output.println("L"+nodetolabel.get(current_node)+":");
@@ -1565,7 +1570,7 @@ public class BuildCode {
          nextnode=fsen.getFlatExit().getNext(0);
        } else {
          output.print("   ");
-         generateFlatNode(fm, lb, current_node, output);       
+         generateFlatNode(fm, lb, current_node, output);
          nextnode=current_node.getNext(0);
        }
        if (visited.contains(nextnode)) {
@@ -1726,7 +1731,7 @@ public class BuildCode {
        if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) {
          output.println("if (needtocollect) checkcollect2(&"+localsprefix+");");
        } else
-       output.println("if (needtocollect) checkcollect(&"+localsprefix+");");
+         output.println("if (needtocollect) checkcollect(&"+localsprefix+");");
       } else
        output.println("/* nop */");
       return;
@@ -1929,11 +1934,11 @@ public class BuildCode {
       return;
     /* Have to generate flat globalconv */
     if (fgcn.getMakePtr()) {
-       if (state.DSM) {
-           output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", (unsigned int) "+generateTemp(fm, fgcn.getSrc(),lb)+");");
-       } else {
-           output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", "+generateTemp(fm, fgcn.getSrc(),lb)+");");
-       }
+      if (state.DSM) {
+       output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", (unsigned int) "+generateTemp(fm, fgcn.getSrc(),lb)+");");
+      } else {
+       output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", "+generateTemp(fm, fgcn.getSrc(),lb)+");");
+      }
     } else {
       /* Need to convert to OID */
       if (fgcn.doConvert()) {
@@ -1951,7 +1956,7 @@ public class BuildCode {
     } else {
       type=fion.getType().getClassDesc().getId();
     }
-    
+
     if (fion.getType().getSymbol().equals(TypeUtil.ObjectClass))
       output.println(generateTemp(fm, fion.getDst(), lb)+"=1;");
     else
@@ -1967,7 +1972,7 @@ public class BuildCode {
       TempDescriptor tmp=tmpit.next();
       output.println(generateTemp(fm, backuptable.get(lb).get(tmp),lb)+"="+generateTemp(fm,tmp,lb)+";");
     }
-    
+
     output.println("goto transstart"+faen.getIdentifier()+";");
 
     /******* Print code to retry aborted transaction *******/
@@ -1982,7 +1987,7 @@ public class BuildCode {
     if (state.DSM) {
       /********* Need to revert local object store ********/
       String revertptr=generateTemp(fm, reverttable.get(lb),lb);
-      
+
       output.println("while ("+revertptr+") {");
       output.println("struct ___Object___ * tmpptr;");
       output.println("tmpptr="+revertptr+"->"+nextobjstr+";");
@@ -1994,7 +1999,7 @@ public class BuildCode {
 
     output.println("transstart"+faen.getIdentifier()+":");
     output.println("transStart();");
-    
+
     if (state.ABORTREADERS) {
       output.println("if (_setjmp(aborttrans)) {");
       output.println("  goto transretry"+faen.getIdentifier()+"; }");
@@ -2016,7 +2021,7 @@ public class BuildCode {
     output.println("goto transretry"+faen.getAtomicEnter().getIdentifier()+";");
     if (state.DSM) {
       output.println("} else {");
-    /* Need to commit local object store */
+      /* Need to commit local object store */
       output.println("while ("+revertptr+") {");
       output.println("struct ___Object___ * tmpptr;");
       output.println("tmpptr="+revertptr+"->"+nextobjstr+";");
@@ -2029,7 +2034,7 @@ public class BuildCode {
 
 
   public void generateSESE(FlatMethod fm, LocalityBinding lb, FlatSESEEnterNode faen, PrintWriter output) {
-    
+
   }
 
 
@@ -2219,8 +2224,8 @@ public class BuildCode {
 
       output.println(dst+"="+ src +"->"+field+ ";");
       if (ffn.getField().getType().isPtr()&&locality.getAtomic(lb).get(ffn).intValue()>0&&
-         ((dc==null)||dc.getNeedTrans(lb, ffn))&&
-         locality.getNodePreTempInfo(lb, ffn).get(ffn.getSrc())!=LocalityAnalysis.SCRATCH) {
+          ((dc==null)||dc.getNeedTrans(lb, ffn))&&
+          locality.getNodePreTempInfo(lb, ffn).get(ffn.getSrc())!=LocalityAnalysis.SCRATCH) {
        output.println("TRANSREAD("+dst+", "+dst+");");
       }
     } else if (state.DSM) {
@@ -2289,14 +2294,14 @@ public class BuildCode {
       if (srcptr&&!fsfn.getSrc().getType().isNull()) {
        output.println("{");
        if ((dc==null)||dc.getNeedSrcTrans(lb, fsfn)&&
-         locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getSrc())!=LocalityAnalysis.SCRATCH) {
+           locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getSrc())!=LocalityAnalysis.SCRATCH) {
          output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);");
        } else {
          output.println("INTPTR srcoid=(INTPTR)"+src+";");
        }
       }
       if (wb.needBarrier(fsfn)&&
-         locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getDst())!=LocalityAnalysis.SCRATCH) {
+          locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getDst())!=LocalityAnalysis.SCRATCH) {
        output.println("*((unsigned int *)&("+dst+"->___objstatus___))|=DIRTY;");
       }
       if (srcptr&!fsfn.getSrc().getType().isNull()) {
@@ -2390,8 +2395,8 @@ public class BuildCode {
       output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
 
       if (elementtype.isPtr()&&locality.getAtomic(lb).get(fen).intValue()>0&&
-         ((dc==null)||dc.getNeedTrans(lb, fen))&&
-         locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())!=LocalityAnalysis.SCRATCH) {
+          ((dc==null)||dc.getNeedTrans(lb, fen))&&
+          locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())!=LocalityAnalysis.SCRATCH) {
        output.println("TRANSREAD("+dst+", "+dst+");");
       }
     } else if (state.DSM) {
@@ -2442,7 +2447,7 @@ public class BuildCode {
     if (state.SINGLETM && locality.getAtomic(lb).get(fsen).intValue()>0) {
       //Transaction set element case
       if (wb.needBarrier(fsen)&&
-           locality.getNodePreTempInfo(lb, fsen).get(fsen.getDst())!=LocalityAnalysis.SCRATCH) {
+          locality.getNodePreTempInfo(lb, fsen).get(fsen.getDst())!=LocalityAnalysis.SCRATCH) {
        output.println("*((unsigned int *)&("+generateTemp(fm,fsen.getDst(),lb)+"->___objstatus___))|=DIRTY;");
       }
       if (fsen.getSrc().getType().isPtr()&&!fsen.getSrc().getType().isNull()) {
index 2d92cbd2bb5dbfc9245d5f84c5a4e62a19359b71..ed87d172a5397da1b5775faba9b6c42c24d3a854 100644 (file)
@@ -1,10 +1,10 @@
 /* ============================================================
- * singleTMCommit.c 
+ * singleTMCommit.c
  * - single thread commit on local machine
  * =============================================================
  * Copyright (c) 2009, University of California, Irvine, USA.
  * All rights reserved.
- * Author: Alokika Dash 
+ * Author: Alokika Dash
  *         adash@uci.edu
  * =============================================================
  *
@@ -23,14 +23,14 @@ int numTransAbort = 0;
 int nSoftAbort = 0;
 int nSoftAbortCommit = 0;
 int nSoftAbortAbort = 0;
-int typesCausingAbort[TOTALNUMCLASSANDARRAY];
 #endif
 
 #ifdef STMSTATS
+int typesCausingAbort[TOTALNUMCLASSANDARRAY];
 /******Keep track of objects and types causing aborts******/
 #define DEBUGSTMSTAT(args...) { \
-  printf(args); \
-  fflush(stdout); \
+    printf(args); \
+    fflush(stdout); \
 }
 #else
 #define DEBUGSTMSTAT(args...)
@@ -45,7 +45,7 @@ int typesCausingAbort[TOTALNUMCLASSANDARRAY];
 
 /* ==================================================
  * stmStartup
- * This function starts up the transaction runtime. 
+ * This function starts up the transaction runtime.
  * ==================================================
  */
 int stmStartup() {
@@ -92,7 +92,7 @@ void objstrDelete(objstr_t *store) {
 
 /* =================================================
  * transStart
- * This function initializes things required in the 
+ * This function initializes things required in the
  * transaction start
  * =================================================
  */
@@ -102,7 +102,7 @@ void transStart() {
 
 /* =======================================================
  * transCreateObj
- * This function creates objects in the transaction record 
+ * This function creates objects in the transaction record
  * =======================================================
  */
 objheader_t *transCreateObj(void * ptr, unsigned int size) {
@@ -151,7 +151,7 @@ void *objstrAlloc(unsigned int size) {
     size+=(8-(size&7));
   }
 
-  for(;i<2;i++) {
+  for(; i<2; i++) {
     if (OSFREE(store)>=size) {
       tmp=store->top;
       store->top +=size;
@@ -162,7 +162,7 @@ void *objstrAlloc(unsigned int size) {
   }
 
   {
-    unsigned int newsize=size>DEFAULT_OBJ_STORE_SIZE?size:DEFAULT_OBJ_STORE_SIZE;
+    unsigned int newsize=size>DEFAULT_OBJ_STORE_SIZE ? size : DEFAULT_OBJ_STORE_SIZE;
     objstr_t **otmp=&t_reserve;
     objstr_t *ptr;
     while((ptr=*otmp)!=NULL) {
@@ -175,7 +175,7 @@ void *objstrAlloc(unsigned int size) {
        return &ptr[1];
       }
     }
-    
+
     objstr_t *os=(objstr_t *)calloc(1,(sizeof(objstr_t) + newsize));
     void *nptr=&os[1];
     os->next=t_cache;
@@ -199,7 +199,7 @@ __attribute__((pure)) void *transRead(void * oid) {
 
   /* Read from the main heap */
   //No lock for now
-  objheader_t *header = (objheader_t *)(((char *)oid) - sizeof(objheader_t)); 
+  objheader_t *header = (objheader_t *)(((char *)oid) - sizeof(objheader_t));
   GETSIZE(size, header);
   size += sizeof(objheader_t);
   objcopy = (objheader_t *) objstrAlloc(size);
@@ -228,7 +228,7 @@ void freenewobjs() {
  * transCommit
  * - This function initiates the transaction commit process
  * - goes through the transaction cache and decides
- * - a final response 
+ * - a final response
  * ================================================================
  */
 int transCommit() {
@@ -271,7 +271,7 @@ int transCommit() {
 #endif
       softaborted++;
       if (softaborted>4) {
-       //retry if to many soft aborts
+       //retry if too many soft aborts
        freenewobjs();
        objstrReset();
        t_chashreset();
@@ -322,26 +322,27 @@ int traverseCache() {
     while(curr != NULL) {
       //if the first bin in hash table is empty
       if(curr->key == NULL)
-        break;
+       break;
       objheader_t * headeraddr=&((objheader_t *) curr->val)[-1];
-      objheader_t *header=(objheader_t *) (((char *)curr->key)-sizeof(objheader_t));
+      objheader_t *header=(objheader_t *)(((char *)curr->key)-sizeof(objheader_t));
       unsigned int version = headeraddr->version;
-      
+
       if(STATUS(headeraddr) & DIRTY) {
        /* Read from the main heap  and compare versions */
        if(write_trylock(&header->lock)) { //can aquire write lock
-         if (version == header->version) {/* versions match */
+         if (version == header->version) { /* versions match */
            /* Keep track of objects locked */
            oidwrlocked[numoidwrlocked++] = OID(header);
-         } else { 
+         } else {
            oidwrlocked[numoidwrlocked++] = OID(header);
            transAbortProcess(oidwrlocked, numoidwrlocked);
 #ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
+           header->abortCount++;
+           (typesCausingAbort[TYPE(header)])++;
+           getTotalAbortCount(i+1, size, (void *)(curr->next), NULL, 'w');
 #endif
            DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-        DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+           DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
            if (c_numelements>=200) {
              free(oidrdlocked);
              free(oidrdversion);
@@ -350,17 +351,18 @@ int traverseCache() {
            return TRANS_ABORT;
          }
        } else { /* cannot aquire lock */
-#ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
-#endif
          if(version == header->version) {
            /* versions match */
            softabort=1;
          } else {
            transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+           header->abortCount++;
+           (typesCausingAbort[TYPE(header)])++;
+           getTotalAbortCount(i+1, size, (void *)(curr->next), NULL, 'w');
+#endif
            DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-        DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+           DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
            if (c_numelements>=200) {
              free(oidrdlocked);
              free(oidrdversion);
@@ -379,20 +381,21 @@ int traverseCache() {
 
   //THIS IS THE SERIALIZATION POINT *****
 
-  for(i=0;i<numoidrdlocked;i++) {
+  for(i=0; i<numoidrdlocked; i++) {
     /* Read from the main heap  and compare versions */
     objheader_t *header=oidrdlocked[i];
     unsigned int version=oidrdversion[i];
     if(header->lock>0) { //not write locked
-      if(version != header->version) {/* versions do not match */
+      if(version != header->version) { /* versions do not match */
        oidrdlocked[numoidrdlocked++] = OID(header);
        transAbortProcess(oidwrlocked, numoidwrlocked);
 #ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
+       header->abortCount++;
+       (typesCausingAbort[TYPE(header)])++;
+       getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *) oidrdversion, 'r');
 #endif
        DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-    DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+       DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
        if (c_numelements>=200) {
          free(oidrdlocked);
          free(oidrdversion);
@@ -401,17 +404,18 @@ int traverseCache() {
        return TRANS_ABORT;
       }
     } else { /* cannot aquire lock */
-#ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
-#endif
       //do increment as we didn't get lock
       if(version == header->version) {
        softabort=1;
       } else {
        transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+       header->abortCount++;
+       (typesCausingAbort[TYPE(header)])++;
+       getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *) oidrdversion, 'r');
+#endif
        DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-    DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+       DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
        if (c_numelements>=200) {
          free(oidrdlocked);
          free(oidrdversion);
@@ -421,7 +425,7 @@ int traverseCache() {
       }
     }
   }
-  
+
   /* Decide the final response */
   if (softabort) {
     transAbortProcess(oidwrlocked, numoidwrlocked);
@@ -477,24 +481,25 @@ int alttraverseCache() {
   while(curr != NULL) {
     //if the first bin in hash table is empty
     objheader_t * headeraddr=&((objheader_t *) curr->val)[-1];
-    objheader_t *header=(objheader_t *) (((char *)curr->key)-sizeof(objheader_t));
+    objheader_t *header=(objheader_t *)(((char *)curr->key)-sizeof(objheader_t));
     unsigned int version = headeraddr->version;
-    
+
     if(STATUS(headeraddr) & DIRTY) {
       /* Read from the main heap  and compare versions */
       if(write_trylock(&header->lock)) { //can aquire write lock
-       if (version == header->version) {/* versions match */
+       if (version == header->version) { /* versions match */
          /* Keep track of objects locked */
          oidwrlocked[numoidwrlocked++] = OID(header);
-       } else { 
+       } else {
          oidwrlocked[numoidwrlocked++] = OID(header);
          transAbortProcess(oidwrlocked, numoidwrlocked);
 #ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
+         header->abortCount++;
+         (typesCausingAbort[TYPE(header)])++;
+         getTotalAbortCount(0, 1, (void *) curr->next, NULL, 'w');
 #endif
          DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-      DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+         DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
          if (c_numelements>=200) {
            free(oidrdlocked);
            free(oidrdversion);
@@ -509,11 +514,12 @@ int alttraverseCache() {
        } else {
          transAbortProcess(oidwrlocked, numoidwrlocked);
 #ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
+         header->abortCount++;
+         (typesCausingAbort[TYPE(header)])++;
+         getTotalAbortCount(0, 1, (void *) curr->next, NULL, 'w');
 #endif
          DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-      DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+         DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
          if (c_numelements>=200) {
            free(oidrdlocked);
            free(oidrdversion);
@@ -530,18 +536,19 @@ int alttraverseCache() {
     curr = curr->lnext;
   }
   //THIS IS THE SERIALIZATION POINT *****
-  for(i=0;i<numoidrdlocked;i++) {
+  for(i=0; i<numoidrdlocked; i++) {
     objheader_t * header = oidrdlocked[i];
     unsigned int version=oidrdversion[i];
     if(header->lock>=0) {
       if(version != header->version) {
        transAbortProcess(oidwrlocked, numoidwrlocked);
 #ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
+       header->abortCount++;
+       (typesCausingAbort[TYPE(header)])++;
+       getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *)oidrdversion, 'r');
 #endif
        DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-    DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+       DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
        if (c_numelements>=200) {
          free(oidrdlocked);
          free(oidrdversion);
@@ -550,16 +557,17 @@ int alttraverseCache() {
        return TRANS_ABORT;
       }
     } else { /* cannot aquire lock */
-#ifdef STMSTATS
-        header->abortCount++;
-        (typesCausingAbort[TYPE(header)])++;
-#endif
       if(version == header->version) {
        softabort=1;
       } else {
        transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+       header->abortCount++;
+       (typesCausingAbort[TYPE(header)])++;
+       getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *)oidrdversion, 'r');
+#endif
        DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
-    DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
+       DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
        if (c_numelements>=200) {
          free(oidrdlocked);
          free(oidrdversion);
@@ -569,7 +577,7 @@ int alttraverseCache() {
       }
     }
   }
-  
+
   /* Decide the final response */
   if (softabort) {
     transAbortProcess(oidwrlocked, numoidwrlocked);
@@ -623,16 +631,16 @@ int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) {
   struct objlist *ptr=newobjs;
   while(ptr!=NULL) {
     int max=ptr->offset;
-    for(i=0;i<max;i++) {
+    for(i=0; i<max; i++) {
       //clear the new flag
       ((struct ___Object___ *)ptr->objs[i])->___objstatus___=0;
     }
     ptr=ptr->next;
   }
-  
+
   /* Copy from transaction cache -> main object store */
   for (i = 0; i < numoidwrlocked; i++) {
-    /* Read from the main heap */ 
+    /* Read from the main heap */
     header = (objheader_t *)(((char *)(oidwrlocked[i])) - sizeof(objheader_t));
     int tmpsize;
     GETSIZE(tmpsize, header);
@@ -643,12 +651,64 @@ int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) {
     memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
     header->version += 1;
   }
-  
+
   /* Release write locks */
   for(i=0; i< numoidwrlocked; i++) {
-    header = (objheader_t *)(((char *)(oidwrlocked[i])) - sizeof(objheader_t)); 
+    header = (objheader_t *)(((char *)(oidwrlocked[i])) - sizeof(objheader_t));
     write_unlock(&header->lock);
   }
   return 0;
 }
 
+/** ========================================================================================
+ * getTotalAbortCount
+ * params : start: start index of the loop
+ *        : stop: stop index of the loop
+ *        : startptr: pointer that points to where to start looking in the array/ linked list
+ *          'r'/'w' if found when visiting objects read/ objects modified
+ * =========================================================================================
+ **/
+#ifdef STMSTATS
+void getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, char type) {
+  printf("Inside %s()\n", __func__);
+  int i;
+  if(type == 'w') {
+    int isFirstTime = 0;
+    chashlistnode_t *curr = (chashlistnode_t *) startptr;
+    chashlistnode_t *ptr = c_table;
+    for(i = start; i < stop; i++) {
+      if(!isFirstTime)
+       curr = &ptr[i];
+      /* Inner loop to traverse the linked list of the cache lookupTable */
+      while(curr != NULL) {
+       if(curr->key == NULL)
+         break;
+       objheader_t * headeraddr=&((objheader_t *) curr->val)[-1];
+       objheader_t *header=(objheader_t *)(((char *)curr->key)-sizeof(objheader_t));
+       unsigned int version = headeraddr->version;
+       /* versions do not match */
+       if(version != header->version) {
+         header->abortCount++;
+         (typesCausingAbort[TYPE(header)])++;
+       }
+       curr = curr->next;
+      }
+      isFirstTime = 1;
+    }
+  } else {
+    /* Go through oids read that are locked */
+    for(i = start; i < stop; i++) {
+      objheader_t *header = ((void **)startptr)[i];
+      unsigned int version = ((int *)checkptr)[i];
+      if(version != header->version) { /* versions do not match */
+       header->abortCount++;
+       (typesCausingAbort[TYPE(header)])++;
+      }
+    }
+  }
+}
+#else
+void getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, char type) {
+  return;
+}
+#endif
index 024e39de687ca226491efe3a08f53333bd2af39b..f770c77999f91fb659018a0cab6eaf80a415574b 100644 (file)
@@ -16,7 +16,7 @@ void t_chashCreate(unsigned int size, double loadfactor) {
   int i;
 
   // Allocate space for the hash table
-  
+
 
   c_table = calloc(size, sizeof(chashlistnode_t));
   c_loadfactor = loadfactor;
@@ -119,7 +119,7 @@ unsigned int t_chashResize(unsigned int newsize) {
   int isfirst;    // Keeps track of the first element in the chashlistnode_t for each bin in hashtable
   unsigned int i,index;
   unsigned int mask;
-  
+
   ptr = c_table;
   oldsize = c_size;
   c_list=NULL;
@@ -140,7 +140,7 @@ unsigned int t_chashResize(unsigned int newsize) {
     do {                      //Inner loop to go through linked lists
       void * key;
       chashlistnode_t *tmp,*next;
-      
+
       if ((key=curr->key) == 0) {             //Exit inner loop if there the first element is 0
        break;                  //key = val =0 for element if not present within the hash table
       }
@@ -153,16 +153,16 @@ unsigned int t_chashResize(unsigned int newsize) {
        tmp->val = curr->val;
        tmp->lnext=c_list;
        c_list=tmp;
-      }/*
-        NOTE:  Add this case if you change this...
-        This case currently never happens because of the way things rehash....
-        else if (isfirst) {
-       chashlistnode_t *newnode= calloc(1, sizeof(chashlistnode_t));
-       newnode->key = curr->key;
-       newnode->val = curr->val;
-       newnode->next = tmp->next;
-       tmp->next=newnode;
-       } */
+      } /*
+          NOTE:  Add this case if you change this...
+          This case currently never happens because of the way things rehash....
+          else if (isfirst) {
+          chashlistnode_t *newnode= calloc(1, sizeof(chashlistnode_t));
+          newnode->key = curr->key;
+          newnode->val = curr->val;
+          newnode->next = tmp->next;
+          tmp->next=newnode;
+          } */
       else {
        curr->next=tmp->next;
        tmp->next=curr;
index 8579375e11c7b436a59ccfce4d065692df0cffdf..1fe0380cdf8ff9d74abd53dcb32c37c9b2d51c0d 100644 (file)
@@ -5,14 +5,9 @@
  * Control Messages
  * ==================
  */
-#define TRANS_AGREE         10
-#define TRANS_DISAGREE      11
 #define TRANS_SOFT_ABORT    12
 #define TRANS_ABORT         13
 #define TRANS_COMMIT        14
-#define READ_OBJ            15
-#define THREAD_NOTIFY       16
-#define THREAD_RESPONSE     17
 
 
 /* ========================
 #include <pthread.h>
 #include <sys/time.h>
 #include <errno.h>
-#include "threadnotify.h"
+//#include "threadnotify.h"
 #include "stmlookup.h"
 #include "dsmlock.h"
 
 /* ==================================
  * Bit designation for status field
- * of object header 
+ * of object header
  * ==================================
  */
 #define DIRTY 0x01
@@ -88,20 +83,20 @@ typedef struct objheader {
 #define OSUSED(x) (((unsigned INTPTR)(x)->top)-((unsigned INTPTR) (x+1)))
 #define OSFREE(x) ((x)->size-OSUSED(x))
 #define TRANSREAD(x,y) { \
-  void * inputvalue;\
-if ((inputvalue=y)==NULL) x=NULL;\
-else { \
-chashlistnode_t * cnodetmp=&c_table[(((unsigned INTPTR)inputvalue)&c_mask)>>4];        \
-do { \
-  if (cnodetmp->key==inputvalue) {x=cnodetmp->val;break;} \
-cnodetmp=cnodetmp->next;\
if (cnodetmp==NULL) {if (((struct ___Object___*)inputvalue)->___objstatus___&NEW) {x=inputvalue;break;} else \
-{x=transRead(inputvalue); asm volatile("":"=m"(c_table),"=m"(c_mask));break;}} \
-} while(1);\
-}}
+    void * inputvalue; \
+    if ((inputvalue=y)==NULL) x=NULL;\
+         else { \
+           chashlistnode_t * cnodetmp=&c_table[(((unsigned INTPTR)inputvalue)&c_mask)>>4]; \
+           do { \
+             if (cnodetmp->key==inputvalue) {x=cnodetmp->val; break;} \
+             cnodetmp=cnodetmp->next; \
            if (cnodetmp==NULL) {if (((struct ___Object___*)inputvalue)->___objstatus___&NEW) {x=inputvalue; break;} else \
+                                  {x=transRead(inputvalue); asm volatile ("" : "=m" (c_table),"=m" (c_mask)); break;}} \
+          } while(1); \
+        }}
 
 /* =================================
- * Data structures 
+ * Data structures
  * =================================
  */
 typedef struct objstr {
@@ -122,18 +117,22 @@ extern __thread objstr_t *t_cache;
 extern __thread objstr_t *t_reserve;
 
 
-#ifdef TRANSSTATS
 /***********************************
  * Global Variables for statistics
  **********************************/
+#ifdef TRANSSTATS
 extern int numTransCommit;
 extern int numTransAbort;
 extern int nSoftAbort;
 extern int nSoftAbortAbort;
 extern int nSoftAbortCommit;
+#endif
+
+#ifdef STMSTATS
 extern int typesCausingAbort[];
 #endif
 
+
 /* ================================
  * Functions used
  * ================================
@@ -153,5 +152,6 @@ int alttraverseCache();
 int transAbortProcess(void **, int);
 int transCommmitProcess(void **, int);
 void randomdelay(int);
+void getTotalAbortCount(int, int, void *, void *, char);
 
 #endif
index abbac360de0ab4cf569ef9d0d8d10436720a7c06..af5a49b5c62df4583a8efede72efb0df938e7c9a 100644 (file)
@@ -16,7 +16,7 @@
 #include "tm.h"
 #include <pthread.h>
 /* Global barrier for STM */
-pthread_barrier_t barrier; 
+pthread_barrier_t barrier;
 pthread_barrierattr_t attr;
 #endif
 #include <string.h>
@@ -113,11 +113,13 @@ void CALL11(___System______exit____I,int ___status___, int ___status___) {
 #ifdef STM
   printf("nSoftAbortCommit = %d\n", nSoftAbortCommit);
   printf("nSoftAbortAbort = %d\n", nSoftAbortAbort);
+#ifdef STMSTATS
   int i;
   for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {
     printf("typesCausingAbort[%d]= %d\n", i, typesCausingAbort[i]);
   }
 #endif
+#endif
 #endif
   exit(___status___);
 }
@@ -195,7 +197,7 @@ void CALL11(___Barrier______setBarrier____I, int nthreads, int nthreads) {
   struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
 #endif
   // Barrier initialization
-  int ret; 
+  int ret;
   if((ret = pthread_barrier_init(&barrier, NULL, nthreads)) != 0) {
     printf("%s() Could not create a barrier: numthreads = 0 in %s\n", __func__, __FILE__);
     exit(-1);
@@ -203,7 +205,7 @@ void CALL11(___Barrier______setBarrier____I, int nthreads, int nthreads) {
 #ifdef PRECISE_GC
   restartaftergc(tmp);
 #endif
-} 
+}
 #endif
 
 #ifdef D___Barrier______enterBarrier____
index 60545a12b166ab16c1f81d18b1ddc2a7bd7498bb..a23e2eb1c3e65ebb0b2a27bc0ecfd88f8b1a19f7 100755 (executable)
@@ -5,6 +5,7 @@ echo -robustroot set up the ROBUSTROOT to directory other than default one
 echo -dsm distributed shared memory
 echo -singleTM single machine committing transactions
 echo -stmdebug STM debug
+echo "-stmstats prints single machine commit (stm) statistics for the benchmark"
 echo -abortreaders abort readers immediately
 echo -trueprob double - probabiltiy of true branch
 echo -dsmcaching -enable caching in dsm runtime