check in completely clean java version
authorbdemsky <bdemsky>
Sat, 14 Nov 2009 23:45:57 +0000 (23:45 +0000)
committerbdemsky <bdemsky>
Sat, 14 Nov 2009 23:45:57 +0000 (23:45 +0000)
18 files changed:
Robust/src/Benchmarks/SingleTM/Yada/java/Barrier.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/List_Node.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/List_t.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/Node.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/Queue_t.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/RBTree.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/Random.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/Vector_t.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/avltree.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/bytereader.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/coordinate.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/edge.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/element.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/global_arg.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/heap.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/mesh.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/region.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Yada/java/yada.java [new file with mode: 0644]

diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/Barrier.java b/Robust/src/Benchmarks/SingleTM/Yada/java/Barrier.java
new file mode 100644 (file)
index 0000000..98e07cf
--- /dev/null
@@ -0,0 +1,7 @@
+public class Barrier {
+  public static void enterBarrier() {
+  }
+  public static void setBarrier(int x) {
+  }
+
+}
\ No newline at end of file
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/List_Node.java b/Robust/src/Benchmarks/SingleTM/Yada/java/List_Node.java
new file mode 100644 (file)
index 0000000..806baa1
--- /dev/null
@@ -0,0 +1,10 @@
+
+public class List_Node {
+    Object dataPtr;
+    List_Node nextPtr;
+
+    public List_Node() {
+        dataPtr = null;
+        nextPtr = null;
+    }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/List_t.java b/Robust/src/Benchmarks/SingleTM/Yada/java/List_t.java
new file mode 100644 (file)
index 0000000..cc6577a
--- /dev/null
@@ -0,0 +1,292 @@
+/* =============================================================================
+ *
+ * List_t.java
+ * -- Sorted singly linked list
+ * -- Options: duplicate allowed  
+ *    (DLIST_NO_DUPLICATES) is no implemented yet (default: allow duplicates)
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006.  All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * Unless otherwise noted, the following license applies to STAMP files:
+ * 
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ * 
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ * 
+ *     * Neither the name of Stanford University nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+
+public class List_t {
+
+  public List_Node head;
+  int size;
+  int mode;
+
+    public List_t() {
+        head = new List_Node();
+    }
+
+
+    /* =======================================================================
+     * allocNode
+     * -- Returns null on failure
+     * =======================================================================
+     */
+    private List_Node allocNode(Object dataPtr) 
+    {
+        List_Node nodePtr = new List_Node();
+
+        nodePtr.dataPtr = dataPtr;
+        nodePtr.nextPtr = null;
+
+        return nodePtr;
+    }
+        
+    
+/* =============================================================================
+ * list_alloc
+ * -- If NULL passed for 'compare' function, will compare data pointer addresses
+ * -- Returns NULL on failure
+ * =============================================================================
+ * list_t* list_alloc (long (*compare)(const void*, const void*));
+ *
+ *
+ */
+
+  //mode 0 = element_list_compare
+  //mode 1 = element_list_compareedge
+
+  public List_t(int mode) {
+    head = new List_Node();
+    this.mode=mode;
+    head.dataPtr = null;
+    head.nextPtr = null;
+    size = 0;
+  }
+    
+/* =============================================================================
+ * list_isEmpty
+ * -- Return TRUE if list is empty, else FALSE
+ * =============================================================================
+ * bool_t list_isEmpty (list_t* listPtr);
+ */
+    public boolean isEmpty() 
+    {
+        return (head.nextPtr == null);
+    }
+
+/* =============================================================================
+ * list_getSize
+ * -- Returns size of list
+ * =============================================================================
+ * long list_getSize (list_t* listPtr);
+ */
+    public int getSize() {
+        return size;
+    }
+
+/* =============================================================================
+ * findPrevious
+ * =============================================================================
+ * void* list_find (list_t* listPtr, void* dataPtr);
+ */                                                                             
+    private List_Node findPrevious(Object dataPtr) 
+    {
+        List_Node prevPtr = head;
+        List_Node nodePtr = prevPtr.nextPtr;
+
+        for(; nodePtr != null; nodePtr = nodePtr.nextPtr) {
+            if (compare(nodePtr.dataPtr,dataPtr) >= 0) {
+                return prevPtr;
+            }
+            prevPtr = nodePtr;
+        }
+
+        return prevPtr;
+    }
+
+    /* =============================================================================
+     * list_find
+     * -- Returns NULL if not found, else returns pointer to data
+     * =============================================================================
+     * void* list_find (list_t* listPtr, void* dataPtr);
+     */
+  public Object find(Object dataPtr) {
+    List_Node nodePtr;
+    List_Node prevPtr = findPrevious(dataPtr);
+    
+    nodePtr = prevPtr.nextPtr;
+    
+    if((nodePtr == null) ||
+       (compare(nodePtr.dataPtr,dataPtr) != 0)) {
+      return null;
+    }
+    
+    return nodePtr.dataPtr;
+  }
+
+  //mode 0 = element_list_compare
+  //mode 1 = element_list_compareedge
+
+  public int compare(Object obj1,Object obj2) {
+    if (mode==0) {
+      return element.element_compare((element)obj1, (element)obj2);
+    } else {
+      return element.compareEdge((edge)obj1, (edge) obj2);
+    }
+  }
+
+/* =============================================================================
+ * list_insert
+ * -- Return TRUE on success, else FALSE
+ * =============================================================================
+ * bool_t list_insert (list_t* listPtr, void* dataPtr);
+ */
+    public boolean insert(Object dataPtr) {
+        List_Node prevPtr;
+        List_Node nodePtr;
+        List_Node currPtr;
+
+        prevPtr = findPrevious(dataPtr);
+        currPtr = prevPtr.nextPtr;
+
+       if((currPtr!=null)&&compare(currPtr.dataPtr, dataPtr)==0) {
+         return false;
+       }
+
+        nodePtr = allocNode(dataPtr);
+        if (nodePtr == null) {
+            return false;
+        }
+
+        nodePtr.nextPtr = currPtr;
+        prevPtr.nextPtr = nodePtr;
+        size++;
+
+        return true;
+    }
+        
+    
+/* =============================================================================
+ * list_remove
+ * -- Returns TRUE if successful, else FALSE
+ * =============================================================================
+ * bool_t list_remove (list_t* listPtr, void* dataPtr);
+ */
+    public boolean remove(Object dataPtr) 
+    {
+        List_Node prevPtr;
+        List_Node nodePtr;
+
+        prevPtr = findPrevious(dataPtr);
+
+        nodePtr = prevPtr.nextPtr;
+
+        if((nodePtr != null) &&
+            (compare(nodePtr.dataPtr,dataPtr) == 0))
+        {
+            prevPtr.nextPtr = nodePtr.nextPtr;
+            nodePtr.nextPtr = null;
+            size--;
+
+            return true;
+        }
+    
+        return false;
+    }
+
+    int compareObject(Object obj1,Object obj2) {
+        return 1;
+    }
+    
+
+/* =============================================================================
+ * list_clear
+ * -- Removes all elements
+ * =============================================================================
+ * void list_clear (list_t* listPtr);
+ */
+    public void clear() {
+        head = new List_Node();
+        size = 0;    
+    }
+
+/* =============================================================================
+ *
+ * End of list.java
+ *
+ * =============================================================================
+ */
+
+ /* Test list */
+
+ public static void main(String[] argv) {
+     List_t listPtr;
+     int[] data1 = new int[5];
+     int[] data2 = new int[6];
+
+     int i;
+
+     System.out.println("Starting...");
+ }
+
+}
+
+
+     
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/Node.java b/Robust/src/Benchmarks/SingleTM/Yada/java/Node.java
new file mode 100644 (file)
index 0000000..f9387bb
--- /dev/null
@@ -0,0 +1,13 @@
+
+
+public class Node {
+    Object k;      // key
+    Object v;   // val
+    Node p;     // parent
+    Node l;     // left
+    Node r;     // right
+    int c;      // color
+
+    public Node() {}
+
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/Queue_t.java b/Robust/src/Benchmarks/SingleTM/Yada/java/Queue_t.java
new file mode 100644 (file)
index 0000000..197969d
--- /dev/null
@@ -0,0 +1,75 @@
+public class Queue_t {
+  int pop;
+  int push;
+  int capacity;
+  Object[] elements;
+  public Queue_t(int initCapacity) {
+    int capacity = ((initCapacity < 2) ? 2 : initCapacity);
+    elements = new Object[capacity];
+    pop = capacity - 1;
+    push = 0;
+    this.capacity = capacity;
+  }
+  public boolean queue_isEmpty () {
+    return ((pop + 1) % capacity) == push;
+  }
+  public void queue_clear () {
+    pop = capacity - 1;
+    push = 0;
+  }
+  public void queue_shuffle(Random randomPtr) {
+    int numElement;
+    if (pop < push) {
+      numElement = push - (pop + 1);
+    } else {
+      numElement = capacity - (pop - push + 1);
+    }
+    int base = pop + 1;
+    for (int i = 0; i < numElement; i++) {
+      int r1 = (int) (randomPtr.random_generate() % numElement);
+      int r2 = (int) (randomPtr.random_generate() % numElement);
+      int i1 = (base + r1) % capacity;
+      int i2 = (base + r2) % capacity;
+      Object tmp = elements[i1];
+      elements[i1] = elements[i2];
+      elements[i2] = tmp;
+    }
+  }
+  public boolean queue_push (Object dataPtr) {
+    int newPush = (push + 1) % capacity;
+    if (newPush == pop) {
+      int newCapacity = capacity * 2;
+      Object[] newElements = new Object[newCapacity];
+      int dst = 0;
+      if (pop < push) {
+ for (int src = (pop + 1); src < push; src++, dst++) {
+   newElements[dst] = elements[src];
+ }
+      } else {
+ for (int src = (pop + 1); src < capacity; src++, dst++) {
+   newElements[dst] = elements[src];
+ }
+ for (int src = 0; src < push; src++, dst++) {
+   newElements[dst] = elements[src];
+ }
+      }
+      elements = newElements;
+      pop = newCapacity - 1;
+      capacity = newCapacity;
+      push = dst;
+      newPush = push + 1;
+    }
+    elements[push] = dataPtr;
+    push = newPush;
+    return true;
+  }
+  public Object queue_pop() {
+    int newPop = (pop + 1) % capacity;
+    if (newPop == push) {
+      return null;
+    }
+    Object dataPtr = elements[newPop];
+    pop = newPop;
+    return dataPtr;
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/RBTree.java b/Robust/src/Benchmarks/SingleTM/Yada/java/RBTree.java
new file mode 100644 (file)
index 0000000..c98f05a
--- /dev/null
@@ -0,0 +1,422 @@
+public class RBTree {
+    Node root;
+    int compID;
+    public RBTree() {}
+  private Node lookup(Object k)
+    {
+        Node p = root;
+        while(p != null) {
+            int cmp = compare(k,p.k);
+            if(cmp == 0) {
+                return p;
+            }
+            p = (cmp < 0) ? p.l : p.r;
+        }
+        return null;
+    }
+    private void rotateLeft(Node x)
+    {
+        Node r = x.r;
+        Node rl = r.l;
+        x.r = rl;
+        if(rl != null) {
+            rl.p = x;
+        }
+        Node xp = x.p;
+        r.p = xp;
+        if (xp == null) {
+            root = r;
+        } else if (xp.l == x) {
+            xp.l = r;
+        } else {
+            xp.r = r;
+        }
+        r.l = x;
+        x.p = r;
+    }
+    private void rotateRight(Node x)
+    {
+        Node l = x.l;
+        Node lr = l.r;
+        x.l = lr;
+        if (lr != null) {
+            lr.p = x;
+        }
+        Node xp = x.p;
+        l.p = xp;
+        if (xp == null) {
+            root = l;
+        } else if (xp.r == x) {
+            xp.r = l;
+        } else {
+            xp.l = l;
+        }
+        l.r = x;
+        x.p = l;
+    }
+    private void fixAfterInsertion(Node x)
+    {
+        x.c = 0;
+        while (x != null && x != root) {
+            Node xp = x.p;
+            if(xp.c != 0) {
+                break;
+            }
+            if((x!=null? x.p : null) == (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null? ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).l : null)) {
+                Node y = (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null? ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).r : null);
+                if((y!=null? y.c : 1) == 0) {
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=1;;
+                    if (y!=null) y.c=1;;
+                    if (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null) ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).c=0;;
+                    x = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null);
+                } else {
+                    if ( x== ((x!=null? x.p : null)!=null? (x!=null? x.p : null).r : null)) {
+                        x = (x!=null? x.p : null);
+                        rotateLeft(x);
+                    }
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=1;;
+                    if (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null) ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).c=0;;
+                    if(((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null) != null) {
+                        rotateRight(((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null));
+                    }
+                }
+            } else {
+                Node y = (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null? ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).l : null);
+                if((y!=null? y.c : 1) == 0) {
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=1;;
+                    if (y!=null) y.c=1;;
+                    if (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null) ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).c=0;;
+                    x = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null);
+                } else {
+                    if (x == ((x!=null? x.p : null)!=null? (x!=null? x.p : null).l : null)) {
+                        x = (x!=null? x.p : null);
+                        rotateRight(x);
+                    }
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=1;;
+                    if (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null)!=null) ((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null).c=0;;
+                    if (((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null) != null) {
+                        rotateLeft(((x!=null? x.p : null)!=null? (x!=null? x.p : null).p : null));
+                    }
+                }
+            }
+        }
+        Node ro = root;
+        if(ro.c != 1) {
+            ro.c = 1;
+        }
+    }
+    private Node insert(Object k,Object v,Node n)
+    {
+        Node t = root;
+        if (t== null) {
+            if (n == null) {
+                return null;
+            }
+            n.l = null;
+            n.r = null;
+            n.p = null;
+            n.k = k;
+            n.v = v;
+            n.c = 1;
+            root = n;
+            return null;
+        }
+        while(true) {
+            int cmp = compare(k,t.k);
+            if (cmp == 0) {
+                return t;
+            } else if (cmp < 0) {
+                Node tl = t.l;
+                if (tl != null) {
+                    t = tl;
+                } else {
+                    n.l = null;
+                    n.r = null;
+                    n.k = k;
+                    n.v = v;
+                    n.p = t;
+                    t.l = n;
+                    fixAfterInsertion(n);
+                    return null;
+                }
+            } else {
+                Node tr = t.r;
+                if (tr != null) {
+                    t = tr;
+                } else {
+                    n.l = null;
+                    n.r = null;
+                    n.k = k;
+                    n.v = v;
+                    n.p = t;
+                    t.r = n;
+                    fixAfterInsertion(n);
+                    return null;
+                }
+            }
+        }
+    }
+    private Node successor(Node t)
+    {
+        if ( t == null) {
+            return null;
+        } else if( t.r != null) {
+            Node p = t.r;
+            while (p.l != null) {
+                p = p.l;
+            }
+            return p;
+        } else {
+            Node p = t.p;
+            Node ch = t;
+            while (p != null && ch == p.r) {
+                ch = p;
+                p = p.p;
+            }
+            return p;
+        }
+    }
+    private void fixAfterDeletion(Node x)
+    {
+        while (x != root && (x!=null? x.c : 1) == 1) {
+            if ( x == ((x!=null? x.p : null)!=null? (x!=null? x.p : null).l : null)) {
+                Node sib = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).r : null);
+                if ((sib!=null? sib.c : 1) == 0) {
+                    if (sib!=null) sib.c=1;;
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=0;;
+                    rotateLeft((x!=null? x.p : null));
+                    sib = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).r : null);
+                }
+                if(((sib!=null? sib.l : null)!=null? (sib!=null? sib.l : null).c : 1) == 1 &&
+                        ((sib!=null? sib.r : null)!=null? (sib!=null? sib.r : null).c : 1) == 1) {
+                    if (sib!=null) sib.c=0;;
+                    x = (x!=null? x.p : null);
+                } else {
+                    if(((sib!=null? sib.r : null)!=null? (sib!=null? sib.r : null).c : 1) == 1) {
+                        if ((sib!=null? sib.l : null)!=null) (sib!=null? sib.l : null).c=1;;
+                        if (sib!=null) sib.c=0;;
+                        rotateRight(sib);
+                        sib = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).r : null);
+                    }
+                    if (sib!=null) sib.c=((x!=null? x.p : null)!=null? (x!=null? x.p : null).c : 1);;
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=1;;
+                    if ((sib!=null? sib.r : null)!=null) (sib!=null? sib.r : null).c=1;;
+                    rotateLeft((x!=null? x.p : null));
+                    x = root;
+                }
+            } else {
+                Node sib = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).l : null);
+                if((sib!=null? sib.c : 1) == 0) {
+                    if (sib!=null) sib.c=1;;
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=0;;
+                    rotateRight((x!=null? x.p : null));
+                    sib = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).l : null);
+                }
+                if (((sib!=null? sib.r : null)!=null? (sib!=null? sib.r : null).c : 1) == 1 &&
+                        ((sib!=null? sib.l : null)!=null? (sib!=null? sib.l : null).c : 1) == 1) {
+                    if (sib!=null) sib.c=0;;
+                    x = (x!=null? x.p : null);
+                } else {
+                    if(((sib!=null? sib.l : null)!=null? (sib!=null? sib.l : null).c : 1) == 1) {
+                        if ((sib!=null? sib.r : null)!=null) (sib!=null? sib.r : null).c=1;;
+                        if (sib!=null) sib.c=0;;
+                        rotateLeft(sib);
+                        sib = ((x!=null? x.p : null)!=null? (x!=null? x.p : null).l : null);
+                    }
+                    if (sib!=null) sib.c=((x!=null? x.p : null)!=null? (x!=null? x.p : null).c : 1);;
+                    if ((x!=null? x.p : null)!=null) (x!=null? x.p : null).c=1;;
+                    if ((sib!=null? sib.l : null)!=null) (sib!=null? sib.l : null).c=1;;
+                    rotateRight((x!=null? x.p : null));
+                    x = root;
+                }
+            }
+        }
+        if (x != null && x.c != 1) {
+            x.c = 1;
+        }
+    }
+    private Node deleteNode(Node p) {
+        if(p.l != null && p.r != null) {
+            Node s = successor(p);
+            p.k = s.k;
+            p.v = s.v;
+            p = s;
+        }
+        Node replacement = (p.l != null)? p.l : p.r;
+        if (replacement != null) {
+            replacement.p = p.p;
+            Node pp = p.p;
+            if(pp == null) {
+                root = replacement;
+            } else if( p == pp.l) {
+                pp.l = replacement;
+            } else {
+                pp.r = replacement;
+            }
+            p.l = null;
+            p.r = null;
+            p.p = null;
+            if(p.c == 1) {
+                fixAfterDeletion(replacement);
+            }
+        } else if(p.p == null) {
+            root = null;
+        } else {
+            if (p.c == 1) {
+                fixAfterDeletion(p);
+            }
+            Node pp = p.p;
+            if(pp != null) {
+                if( p == pp.l) {
+                    pp.l = null;
+                } else if( p == pp.r) {
+                    pp.r = null;
+                }
+                p.p = null;
+            }
+        }
+        return p;
+    }
+    private Node firstEntry()
+    {
+        Node p = root;
+        if( p != null) {
+            while ( p.l != null) {
+                p = p.l;
+            }
+        }
+        return p;
+    }
+    private int verifyRedBlack(Node root,int depth)
+    {
+        int height_left;
+        int height_right;
+        if ( root == null) {
+            return 1;
+        }
+        height_left = verifyRedBlack(root.l,depth+1);
+        height_right = verifyRedBlack(root.r,depth+1);
+        if(height_left == 0 || height_right == 0) {
+            return 0;
+        }
+        if (height_left != height_right) {
+            System.out.println(" Imbalace @depth = " + depth + " : " + height_left + " " + height_right);
+        }
+        if (root.l != null && root.l.p != root) {
+            System.out.println(" lineage");
+        }
+        if (root.r != null && root.r.p != root) {
+            System.out.println(" lineage");
+        }
+        if (root.c == 0) {
+            if (root.l != null && root.l.c != 1) {
+                System.out.println("VERIFY in verifyRedBlack");
+                return 0;
+             }
+            if (root.r != null && root.r.c != 1) {
+                 System.out.println("VERIFY in verifyRedBlack");
+                 return 0;
+            }
+            return height_left;
+        }
+        if(root.c != 1) {
+                System.out.println("VERIFY in verifyRedBlack");
+                return 0;
+        }
+        return (height_left + 1);
+    }
+    private int compare(Object a,Object b)
+    {
+        if(compID == 0)
+   return element.compareEdge((edge)a,(edge)b);
+       return 0;
+    }
+    public int verify(int verbose)
+    {
+        if ( root == null) {
+            return 1;
+        }
+        if(verbose != 0) {
+            System.out.println("Integrity check: ");
+        }
+        if (root.p != null) {
+            System.out.println("  (WARNING) root = " + root + " parent = " + root.p);
+            return -1;
+        }
+        if (root.c != 1) {
+            System.out.println("  (WARNING) root = " + root + " color = " + root.c);
+        }
+        int ctr = 0;
+        Node its = firstEntry();
+        while (its != null) {
+            ctr++;
+            Node child = its.l;
+            if ( child != null && child.p != its) {
+                System.out.println("bad parent");
+            }
+            child = its.r;
+            if ( child != null && child.p != its) {
+                System.out.println("Bad parent");
+            }
+            Node nxt = successor(its);
+            if (nxt == null) {
+                break;
+            }
+            if( compare(its.k,nxt.k) >= 0) {
+                System.out.println("Key order " + its + " ("+its.k+" "+its.v+") "
+                                                + nxt + " ("+nxt.k+" "+nxt.v+") ");
+                return -3;
+            }
+            its = nxt;
+        }
+        int vfy = verifyRedBlack(root, 0);
+        if(verbose != 0) {
+            System.out.println(" Nodes = " + ctr + " Depth = " + vfy);
+        }
+        return vfy;
+    }
+  public RBTree(int compID) {
+    this.compID = compID;
+    this.root = null;
+  }
+  public boolean insert(Object key,Object val) {
+    Node node = new Node();
+    Node ex = insert(key,val,node);
+    if ( ex != null) {
+      node = null;
+    }
+    return ((ex == null) ? true : false);
+  }
+  public boolean deleteObjNode(Object key) {
+        Node node = null;
+        node = lookup(key);
+        if(node != null) {
+            node = deleteNode(node);
+        }
+        if(node != null) {
+        }
+        return ((node != null) ? true : false);
+    }
+  public boolean update(Object key,Object val) {
+    Node nn = new Node();
+    Node ex = insert(key,val,nn);
+    if (ex != null) {
+      ex.v = val;
+      nn = null;
+      return true;
+    }
+    return false;
+  }
+  public Object get(Object key) {
+    Node n = lookup(key);
+    if (n != null) {
+      Object val = n.v;
+      return val;
+    }
+    return null;
+  }
+  public boolean contains(Object key) {
+    Node n = lookup(key);
+    return (n != null);
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/Random.java b/Robust/src/Benchmarks/SingleTM/Yada/java/Random.java
new file mode 100644 (file)
index 0000000..1862c3b
--- /dev/null
@@ -0,0 +1,87 @@
+public class Random {
+  long[] mt; 
+  int mti;
+  int RANDOM_DEFAULT_SEED;
+  /* period parameter */
+
+
+  public Random() {
+    RANDOM_DEFAULT_SEED = 0;
+    mt = new long[624];
+  }
+
+  public void random_alloc() {
+    init_genrand(this.RANDOM_DEFAULT_SEED);
+  }
+
+  /* initializes mt[N] with a seed */
+  public void init_genrand(int s) {
+    mt[0]= ((long)s) & 0xFFFFFFFFL;
+    for (int mti=1; mti<624; mti++) {
+      mt[mti] = (1812433253L * (mt[mti-1] ^ (mt[mti-1] >> 30)) + ((long)mti));
+      /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+      /* In the previous versions, MSBs of the seed affect   */
+      /* only MSBs of the array mt[].                        */
+      /* 2002/01/09 modified by Makoto Matsumoto             */
+      mt[mti] &= 0xFFFFFFFFL;
+      /* for >32 bit machines */
+    }
+    this.mti=624;
+  }
+
+  public void random_seed(int seed) {
+    init_genrand(seed);
+  }
+
+  public long random_generate() {
+    long x= genrand_int32()&0xFFFFFFFFL;
+    return x;
+  }
+
+  public long posrandom_generate() {
+    long r=genrand_int32();
+    if (r>0)
+      return r;
+    else 
+      return -r;
+  }
+
+  public long genrand_int32() {
+    long y;
+    int mti = this.mti;
+    long[] mt = this.mt;
+
+    if (mti >= 624) { /* generate N words at one time */
+      int kk;
+
+      if (mti == 624+1) {  /* if init_genrand() has not been called, */
+        init_genrand(5489); /* a default initial seed is used */
+       mti=this.mti;
+      }
+      for (kk=0;kk<(624-397);kk++) {
+        y = (mt[kk]&0x80000000L)|(mt[kk+1]&0x7fffffffL);
+        mt[kk] = mt[kk+397] ^ (y >> 1) ^ ((y & 0x1)==0 ? 0L:0x9908b0dfL);
+      }
+      for (;kk<(624-1);kk++) {
+        y = (mt[kk]&0x80000000L)|(mt[kk+1]&0x7fffffffL);
+        mt[kk] = mt[kk+(397-624)] ^ (y >> 1) ^ ((y & 0x1)==0 ? 0L:0x9908b0dfL);
+      }
+      y = (mt[624-1]&0x80000000L)|(mt[0]&0x7fffffffL);
+      mt[624-1] = mt[397-1] ^ (y >> 1) ^ ((y & 0x1)==0 ? 0L:0x9908b0dfL);
+
+      mti = 0;
+    }
+
+    y = mt[mti++];
+
+    /* Tempering */
+    y ^= (y >> 11);
+    y ^= (y << 7) & 0x9d2c5680L;
+    y ^= (y << 15) & 0xefc60000L;
+    y ^= (y >> 18);
+
+    this.mti = mti;
+
+    return y;
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/Vector_t.java b/Robust/src/Benchmarks/SingleTM/Yada/java/Vector_t.java
new file mode 100644 (file)
index 0000000..08442a7
--- /dev/null
@@ -0,0 +1,123 @@
+import java.lang.Math;
+public class Vector_t {
+  int size;
+  int capacity;
+  Object[] elements;
+//  QuickSort qsort;
+
+  public Vector_t() {
+//    qsort = new QuickSort();
+  }
+
+  /* =============================================================================
+   * Vector_alloc
+   * -- Returns null if failed
+   * =============================================================================
+   */
+  public Vector_t(int initCapacity) {
+    int capacity = Math.max(initCapacity, 1);
+    size=0;
+    this.capacity = capacity;
+    this.elements = new Object[capacity];
+  }
+
+  /* =============================================================================
+   * Vector_at
+   * -- Returns null if failed
+   * =============================================================================
+   */
+  public Object vector_at(int i) {
+    if ((i < 0) || (i >= size)) {
+      System.out.println("Illegal Vector.element\n");
+      return null;
+    }
+    return elements[i];
+  }
+
+
+  /* =============================================================================
+   * Vector_pushBack
+   * -- Returns false if fail, else true
+   * =============================================================================
+   */
+  public boolean vector_pushBack(Object dataPtr) {
+    if (size == capacity) {
+      int newCapacity = capacity * 2;
+      Object[] newElements = new Object[newCapacity];
+
+      capacity = newCapacity;
+      for (int i = 0; i < size; i++) {
+        newElements[i] = elements[i];
+      }
+      elements = null;
+      elements = newElements;
+    }
+
+    elements[size++] = dataPtr;
+
+    return true;
+  }
+
+  /* =============================================================================
+   * Vector_popBack
+   * -- Returns null if fail, else returns last element
+   * =============================================================================
+   */
+  public Object vector_popBack() {
+    if (size < 1) {
+      return null;
+    }
+    
+    return elements[--size];
+  }
+
+  /* =============================================================================
+   * Vector_getSize
+   * =============================================================================
+   */
+  public int vector_getSize() {
+    return size;
+  }
+
+  /* =============================================================================
+   * Vector_clear
+   * =============================================================================
+   */
+  public void vector_clear() {
+    size = 0;
+  }
+  
+  /* =============================================================================
+   * Vector_sort
+   * =============================================================================
+   *
+  public void
+    vector_sort ()
+    {
+      //qsort.sort(elements, 0, (elements.length - 1));
+      qsort.sort(elements);
+      //qsort(elements, size, 4, compare);
+    }
+
+  * =============================================================================
+   * Vector_copy
+   * =============================================================================
+   */
+  public static boolean vector_copy (Vector_t dstVectorPtr, Vector_t srcVectorPtr) {
+    int dstCapacity = dstVectorPtr.capacity;
+    int srcSize = srcVectorPtr.size;
+    if (dstCapacity < srcSize) {
+      int srcCapacity = srcVectorPtr.capacity;
+      Object[] elements = new Object[srcCapacity];
+      dstVectorPtr.elements = null;
+      dstVectorPtr.elements = elements;
+      dstVectorPtr.capacity = srcCapacity;
+    }
+    for(int i = 0; i< srcSize; i++) {
+      dstVectorPtr.elements[i] = srcVectorPtr.elements[i];
+    }
+    
+    dstVectorPtr.size = srcSize;
+    return true;
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/avltree.java b/Robust/src/Benchmarks/SingleTM/Yada/java/avltree.java
new file mode 100644 (file)
index 0000000..06393df
--- /dev/null
@@ -0,0 +1,226 @@
+class avlnode {
+  int balance;
+  Object data;
+  avlnode link[];
+  avlnode() {
+    link=new avlnode[2];
+  }
+  avlnode(avltree tree, Object data) {
+    this.data = data;
+    link=new avlnode[2];
+  }
+}
+class avltrav {
+  avltree tree;
+  avlnode it;
+  avlnode path[];
+  int top;
+  avltrav() {
+    path=new avlnode[64];
+  }
+  Object start(avltree tree, int dir) {
+    this.tree = tree;
+    it = tree.root;
+    top = 0;
+    if ( it != null ) {
+      while ( it.link[dir] != null ) {
+ path[top++] = it;
+ it = it.link[dir];
+      }
+    }
+    return it == null? null: it.data;
+  }
+  Object move(int dir) {
+    if (it.link[dir] != null) {
+      path[top++] = it;
+      it = it.link[dir];
+      while (it.link[1-dir] != null ) {
+ path[top++] = it;
+ it = it.link[1-dir];
+      }
+    } else {
+      avlnode last;
+      do {
+ if (top == 0 ) {
+   it = null;
+   break;
+ }
+ last = it;
+ it = path[--top];
+      } while ( last == it.link[dir] );
+    }
+    return it==null? null: it.data;
+  }
+  Object avltfirst(avltree tree ) {
+    return start(tree, 0 );
+  }
+  Object avltlast (avltree tree ) {
+    return start(tree, 1 );
+  }
+  Object avltnext() {
+    return move(1);
+  }
+  Object avltprev() {
+    return move(0);
+  }
+}
+public class avltree {
+  avlnode root;
+  int size;
+  int mode;
+  public avltree(int mode) {
+    size = 0;
+    this.mode=mode;
+  }
+  int cmp(Object a, Object b) {
+    if (mode==0) {
+      return element.element_mapCompareEdge((edge)a, (edge)b);
+    } else if (mode==1) {
+      return element.element_mapCompare((edge)a, (edge)b);
+    }
+    return 0;
+  }
+  boolean contains(Object key) {
+    boolean success = false;
+    edge searchPair=new edge();
+    searchPair.firstPtr = key;
+    if (avlfind(searchPair) != null) {
+      success = true;
+    }
+    return success;
+  }
+  Object find(Object key) {
+    Object dataPtr = null;
+    edge searchPair=new edge();
+    searchPair.firstPtr = key;
+    edge pairPtr = (edge)avlfind(searchPair);
+    if (pairPtr != null) {
+      dataPtr = pairPtr.secondPtr;
+    }
+    return dataPtr;
+  }
+  boolean insert(Object key, Object data) {
+    boolean success = false;
+    edge insertPtr = new edge(key, data);
+    if (avlinsert(insertPtr)) {
+      success = true;
+    }
+    return success;
+  }
+  boolean remove(Object key) {
+    boolean success = false;
+    edge searchPair=new edge();
+    searchPair.firstPtr = key;
+    edge pairPtr = (edge) avlfind(searchPair);
+    if (avlerase(searchPair)) {
+      success=true;
+    }
+    return success;
+  }
+  Object avlfind(Object data ) {
+    avlnode it = root;
+    while ( it != null ) {
+      int cmp =cmp(it.data, data );
+      if ( cmp == 0 )
+ break;
+      it = it.link[(cmp < 0)?1:0];
+    }
+    return it == null ? null : it.data;
+  }
+  boolean avlinsert(Object data ) {
+    if ( root == null ) {
+      root = new avlnode(this,data);
+    } else {
+      avlnode head =new avlnode();
+      avlnode s, t;
+      avlnode p, q;
+      int dir;
+      t = head;
+      t.link[1] = root;
+      for ( s = p = t.link[1]; true ; p=q ) {
+ dir = (cmp ( p.data, data ) < 0)?1:0;
+ q = p.link[dir];
+ if ( q == null )
+   break;
+ if ( q.balance != 0 ) {
+   t = p;
+   s = q;
+ }
+      }
+      p.link[dir] = q = new avlnode(this, data);
+      if (q==null)
+ return false;
+      for ( p = s; p != q; p = p.link[dir] ) {
+ dir = (cmp ( p.data, data ) < 0)?1:0;
+ p.balance += (dir == 0) ? -1 : +1;
+      }
+      q = s;
+      if ((s.balance<0?-s.balance:s.balance)>1) {
+ dir =(cmp(s.data,data) < 0)?1:0;
+ do { avlnode ni = s.link[dir]; int bal = dir == 0 ? -1 : +1; if ( ni.balance == bal ) { s.balance = ni.balance = 0; do { avlnode save = s.link[1-(1-dir)]; s.link[1-(1-dir)] = save.link[(1-dir)]; save.link[(1-dir)] = s; s = save; } while (false); } else { do { avlnode n = s.link[dir]; avlnode nn = n.link[1-dir]; if ( nn.balance == 0 ) s.balance = n.balance = 0; else if ( nn.balance == bal ) { s.balance = -bal; n.balance = 0; } else { s.balance = 0; n.balance = bal; } nn.balance = 0; } while (false); do { avlnode save = s.link[1-(1-dir)].link[(1-dir)]; s.link[1-(1-dir)].link[(1-dir)] = save.link[1-(1-dir)]; save.link[1-(1-dir)] = s.link[1-(1-dir)]; s.link[1-(1-dir)] = save; save = s.link[1-(1-dir)]; s.link[1-(1-dir)] = save.link[(1-dir)]; save.link[(1-dir)] = s; s = save; } while (false); } } while (false);
+      }
+      if ( q == head.link[1] )
+ root = s;
+      else
+ t.link[(q == t.link[1])?1:0] = s;
+    }
+    size++;
+    return true;
+  }
+  boolean avlerase (Object data) {
+    if (root != null) {
+      avlnode it;
+      avlnode up[]=new avlnode[64];
+      int upd[]=new int[64];
+      int top = 0;
+      int done = 0;
+      it = root;
+      for ( ; true ; ) {
+ if ( it == null )
+   return false;
+ else if ( cmp ( it.data, data ) == 0 )
+   break;
+ upd[top] = (cmp ( it.data, data ) < 0)?1:0;
+ up[top++] = it;
+ it = it.link[upd[top - 1]];
+      }
+      if ( it.link[0] == null || it.link[1] == null ) {
+ int dir = (it.link[0] == null)?1:0;
+ if (top != 0)
+   up[top-1].link[upd[top - 1]] = it.link[dir];
+ else
+   root = it.link[dir];
+      } else {
+ avlnode heir = it.link[1];
+ upd[top] = 1;
+ up[top++] = it;
+ while ( heir.link[0] != null ) {
+   upd[top] = 0;
+   up[top++] = heir;
+   heir = heir.link[0];
+ }
+ Object save = it.data;
+ it.data = heir.data;
+ heir.data = save;
+ up[top-1].link[(up[top - 1] == it)?1:0] = heir.link[1];
+    }
+      while ( --top >= 0 && (done==0) ) {
+ up[top].balance += upd[top] != 0 ? -1 : +1;
+ if (up[top].balance == 1 || up[top].balance==-1 )
+   break;
+ else if ( up[top].balance > 1 ||up[top].balance < -1) {
+   do { avlnode nr = up[top].link[1-upd[top]]; int bal = upd[top] == 0 ? -1 : +1; if ( nr.balance == -bal ) { up[top].balance = nr.balance = 0; do { avlnode save = up[top].link[1-upd[top]]; up[top].link[1-upd[top]] = save.link[upd[top]]; save.link[upd[top]] = up[top]; up[top] = save; } while (false); } else if ( nr.balance == bal ) { do { avlnode n = up[top].link[(1-upd[top])]; avlnode nn = n.link[1-(1-upd[top])]; if ( nn.balance == 0 ) up[top].balance = n.balance = 0; else if ( nn.balance == -bal ) { up[top].balance = - -bal; n.balance = 0; } else { up[top].balance = 0; n.balance = -bal; } nn.balance = 0; } while (false); do { avlnode save = up[top].link[1-upd[top]].link[upd[top]]; up[top].link[1-upd[top]].link[upd[top]] = save.link[1-upd[top]]; save.link[1-upd[top]] = up[top].link[1-upd[top]]; up[top].link[1-upd[top]] = save; save = up[top].link[1-upd[top]]; up[top].link[1-upd[top]] = save.link[upd[top]]; save.link[upd[top]] = up[top]; up[top] = save; } while (false); } else { up[top].balance = -bal; nr.balance = bal; do { avlnode save = up[top].link[1-upd[top]]; up[top].link[1-upd[top]] = save.link[upd[top]]; save.link[upd[top]] = up[top]; up[top] = save; } while (false); done = 1; } } while (false);
+   if ( top != 0 )
+     up[top - 1].link[upd[top - 1]] = up[top];
+   else
+     root = up[0];
+ }
+      }
+    }
+    size--;
+    return true;
+  }
+  int avlsize() {
+    return size;
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/bytereader.java b/Robust/src/Benchmarks/SingleTM/Yada/java/bytereader.java
new file mode 100644 (file)
index 0000000..55d455b
--- /dev/null
@@ -0,0 +1,116 @@
+import java.io.*;
+public class bytereader {
+  FileInputStream fis;
+  byte[] buffer;
+  int lastlocation;
+  int pos;
+  byte[] tmp;
+
+  public bytereader(FileInputStream fis) {
+    this.fis=fis;
+    this.buffer=new byte[1024];
+    this.tmp=new byte[200];
+    lastlocation=0;
+    pos=0;
+  }
+  
+  public void jumptonextline() {
+    while(true) {
+      for(;pos<lastlocation;pos++) {
+       if (buffer[pos]=='\n') {
+         pos++;
+         return;
+       }
+      }
+      if (pos==lastlocation) {
+       readnewdata();
+      }
+    }
+  }
+
+  private void readnewdata() {
+    pos=0;
+    try {
+    lastlocation=fis.read(buffer);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  byte[] curbuffer;
+  int start;
+  int end;
+
+  private void skipline() {
+    if (pos>=lastlocation)
+      readnewdata();
+    if (pos<lastlocation&&buffer[pos]=='#')
+      jumptonextline();
+  }
+
+  public int getInt() {
+    getBytes();
+    int value=0;
+    boolean negative=false;
+    for(;start<end;start++) {
+      if (curbuffer[start]>='0'&&curbuffer[start]<='9')
+       value=value*10+(curbuffer[start]-'0');
+      else if (curbuffer[start]=='-')
+       negative=true;
+    }
+    if (negative)
+      value=-value;
+    return value;
+  }
+
+  public double getDouble() {
+    getBytes();
+    boolean negative=false;
+    String s=new String(curbuffer, start, end-start);
+    double value=Double.parseDouble(s);
+    return value;
+  }
+
+  private void getBytes() {
+    boolean searching=true;
+    while(searching) {
+      for(;pos<lastlocation;pos++) {
+       if (buffer[pos]=='#') {
+         jumptonextline();
+       } else if (buffer[pos]!=' '&&buffer[pos]!='\n'&&buffer[pos]!='\t') {
+         searching=false;
+         break;
+       }
+      }
+      if (searching) {
+       readnewdata();
+      }
+    }
+    start=pos;
+    for(;pos<lastlocation;pos++) {
+      if (buffer[pos]==' '||
+         buffer[pos]=='\n') {
+       end=pos;
+       pos++;
+       curbuffer=buffer;
+       return;
+      }
+    }
+    curbuffer=tmp;
+    for(int i=start;i<lastlocation;i++) {
+      tmp[i-start]=buffer[i];
+    }
+    start=lastlocation-start;
+    readnewdata();
+    for(;pos<lastlocation;pos++) {
+      if (buffer[pos]==' '||
+         buffer[pos]=='\n') {
+       end=pos+start;
+       start=0;
+       pos++;
+       return;
+      }
+      tmp[pos+start]=buffer[pos];
+    }
+  }
+}
\ No newline at end of file
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/coordinate.java b/Robust/src/Benchmarks/SingleTM/Yada/java/coordinate.java
new file mode 100644 (file)
index 0000000..90ddb93
--- /dev/null
@@ -0,0 +1,157 @@
+/* =============================================================================
+ *
+ * coordinate.c
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006.  All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * Unless otherwise noted, the following license applies to STAMP files:
+ * 
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ * 
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ * 
+ *     * Neither the name of Stanford University nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+public class coordinate {
+  double x;
+  double y;
+
+  public coordinate() {
+  }
+
+  static int coordinate_compare (coordinate aPtr, coordinate bPtr) {
+    if (aPtr.x < bPtr.x) {
+      return -1;
+    } else if (aPtr.x > bPtr.x) {
+      return 1;
+    } else if (aPtr.y < bPtr.y) {
+      return -1;
+    } else if (aPtr.y > bPtr.y) {
+      return 1;
+    }
+    return 0;
+  }
+
+
+/* =============================================================================
+ * coordinate_distance
+ * =============================================================================
+ */
+  static double coordinate_distance (coordinate coordinatePtr, coordinate aPtr) {
+    double delta_x = coordinatePtr.x - aPtr.x;
+    double delta_y = coordinatePtr.y - aPtr.y;
+
+    return Math.sqrt((delta_x * delta_x) + (delta_y * delta_y));
+  }
+
+
+/* =============================================================================
+ * coordinate_angle
+ *
+ *           (b - a) .* (c - a)
+ * cos a = ---------------------
+ *         ||b - a|| * ||c - a||
+ *
+ * =============================================================================
+ */
+  static double coordinate_angle(coordinate aPtr, coordinate bPtr, coordinate cPtr) {
+    double delta_b_x;
+    double delta_b_y;
+    double delta_c_x;
+    double delta_c_y;
+    double distance_b;
+    double distance_c;
+    double numerator;
+    double denominator;
+    double cosine;
+    double radian;
+
+    delta_b_x = bPtr.x - aPtr.x;
+    delta_b_y = bPtr.y - aPtr.y;
+
+    delta_c_x = cPtr.x - aPtr.x;
+    delta_c_y = cPtr.y - aPtr.y;
+
+    numerator = (delta_b_x * delta_c_x) + (delta_b_y * delta_c_y);
+
+    distance_b = coordinate_distance(aPtr, bPtr);
+    distance_c = coordinate_distance(aPtr, cPtr);
+    denominator = distance_b * distance_c;
+
+    cosine = numerator / denominator;
+    radian = Math.acos(cosine);
+
+    return (180.0 * radian / 3.141592653589793238462643);
+}
+
+
+/* =============================================================================
+ * coordinate_print
+ * =============================================================================
+ */
+  void coordinate_print() {
+    System.out.print("("+x+", "+y+")");
+  }
+}
+/* =============================================================================
+ *
+ * End of coordinate.c
+ *
+ * =============================================================================
+ */
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/edge.java b/Robust/src/Benchmarks/SingleTM/Yada/java/edge.java
new file mode 100644 (file)
index 0000000..709a519
--- /dev/null
@@ -0,0 +1,117 @@
+/* =============================================================================
+ *
+ * Pair.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006.  All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * Ported to Java
+ *  
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ * 
+ * ------------------------------------------------------------------------
+ * 
+ * Unless otherwise noted, the following license applies to STAMP files:
+ * 
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ * 
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ * 
+ *     * Neither the name of Stanford University nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+import java.util.*;
+
+public class edge {
+  public Object firstPtr;
+  public Object secondPtr;
+  
+  public edge() {
+    firstPtr = null;
+    secondPtr = null;
+  }
+  
+
+  /* =============================================================================
+   * 
+   * pair constructor
+   * 
+   * pair_t* pair_alloc(void* firstPtr, void* secondPtr);
+   * =============================================================================
+   */
+  public edge(Object first,Object second) {
+    this.firstPtr = first;
+    this.secondPtr = second;
+  }
+
+
+  /* =============================================================================
+   * pair_swap
+   * -- Exchange 'firstPtr' and 'secondPtr'
+   * =============================================================================
+   * void pair_swap (pair_t* pairPtr);
+   */
+  public void swap() {
+    Object tmpPtr = firstPtr;
+    firstPtr=secondPtr;
+    secondPtr=tmpPtr;
+  }
+}    
+
+/* =============================================================================
+ *
+ * End of pair.java
+ *
+ * =============================================================================
+ */
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/element.java b/Robust/src/Benchmarks/SingleTM/Yada/java/element.java
new file mode 100644 (file)
index 0000000..c1f1451
--- /dev/null
@@ -0,0 +1,305 @@
+public class element {
+  coordinate coordinates[];
+  int numCoordinate;
+  coordinate circumCenter;
+  double circumRadius;
+  double minAngle;
+  edge edges[];
+  int numEdge;
+  coordinate midpoints[];
+  double radii[];
+  edge encroachedEdgePtr;
+  boolean isSkinny;
+  List_t neighborListPtr;
+  boolean isGarbage;
+  boolean isReferenced;
+  void minimizeCoordinates() {
+    int minPosition = 0;
+    for (int i = 1; i < numCoordinate; i++) {
+      if (coordinate.coordinate_compare(coordinates[i], coordinates[minPosition]) < 0) {
+ minPosition = i;
+      }
+    }
+    while(minPosition != 0) {
+      coordinate tmp = coordinates[0];
+      for (int j = 0; j < (numCoordinate - 1); j++) {
+ coordinates[j] = coordinates[j+1];
+      }
+      coordinates[numCoordinate-1] = tmp;
+      minPosition--;
+    }
+  }
+  void checkAngles() {
+    minAngle = 180.0;
+    ;
+    isReferenced = false;
+    isSkinny = false;
+    encroachedEdgePtr = null;
+    if (numCoordinate == 3) {
+      for (int i = 0; i < 3; i++) {
+ double angle = coordinate.coordinate_angle(coordinates[i],
+         coordinates[(i + 1) % 3],
+         coordinates[(i + 2) % 3]);
+ ;
+ ;
+ if (angle > 90.0) {
+   encroachedEdgePtr = edges[(i + 1) % 3];
+ }
+ if (angle < angleConstraint) {
+   isSkinny = true;
+ }
+ if (angle < minAngle) {
+   minAngle = angle;
+ }
+      }
+      ;
+    }
+  }
+  void calculateCircumCircle() {
+    coordinate circumCenterPtr = this.circumCenter;
+    ;
+    if (numCoordinate == 2) {
+      circumCenterPtr.x = (coordinates[0].x + coordinates[1].x) / 2.0;
+      circumCenterPtr.y = (coordinates[0].y + coordinates[1].y) / 2.0;
+    } else {
+      double ax = coordinates[0].x;
+      double ay = coordinates[0].y;
+      double bx = coordinates[1].x;
+      double by = coordinates[1].y;
+      double cx = coordinates[2].x;
+      double cy = coordinates[2].y;
+      double bxDelta = bx - ax;
+      double byDelta = by - ay;
+      double cxDelta = cx - ax;
+      double cyDelta = cy - ay;
+      double bDistance2 = (bxDelta * bxDelta) + (byDelta * byDelta);
+      double cDistance2 = (cxDelta * cxDelta) + (cyDelta * cyDelta);
+      double xNumerator = (byDelta * cDistance2) - (cyDelta * bDistance2);
+      double yNumerator = (bxDelta * cDistance2) - (cxDelta * bDistance2);
+      double denominator = 2 * ((bxDelta * cyDelta) - (cxDelta * byDelta));
+      double rx = ax - (xNumerator / denominator);
+      double ry = ay + (yNumerator / denominator);
+      ;
+      circumCenterPtr.x = rx;
+      circumCenterPtr.y = ry;
+    }
+    circumRadius = coordinate.coordinate_distance(circumCenterPtr,
+        coordinates[0]);
+  }
+  public void setEdge(int i) {
+    coordinate firstPtr = coordinates[i];
+    coordinate secondPtr = coordinates[(i + 1) % numCoordinate];
+    edge edgePtr = edges[i];
+    int cmp = coordinate.coordinate_compare(firstPtr, secondPtr);
+    ;
+    if (cmp < 0) {
+      edgePtr.firstPtr = firstPtr;
+      edgePtr.secondPtr = secondPtr;
+    } else {
+      edgePtr.firstPtr = secondPtr;
+      edgePtr.secondPtr = firstPtr;
+    }
+    coordinate midpointPtr = midpoints[i];
+    midpointPtr.x = (firstPtr.x + secondPtr.x) / 2.0;
+    midpointPtr.y = (firstPtr.y + secondPtr.y) / 2.0;
+    radii[i] = coordinate.coordinate_distance(firstPtr, midpointPtr);
+  }
+  void initEdges(coordinate[] coordinates, int numCoordinate) {
+    numEdge = ((numCoordinate * (numCoordinate - 1)) / 2);
+    for (int e = 0; e < numEdge; e++) {
+      setEdge(e);
+    }
+  }
+static int element_compare (element aElementPtr, element bElementPtr) {
+  int aNumCoordinate = aElementPtr.numCoordinate;
+  int bNumCoordinate = bElementPtr.numCoordinate;
+  coordinate aCoordinates[] = aElementPtr.coordinates;
+  coordinate bCoordinates[] = bElementPtr.coordinates;
+  if (aNumCoordinate < bNumCoordinate) {
+    return -1;
+  } else if (aNumCoordinate > bNumCoordinate) {
+    return 1;
+  }
+  for (int i = 0; i < aNumCoordinate; i++) {
+    int compareCoordinate =
+      coordinate.coordinate_compare(aCoordinates[i], bCoordinates[i]);
+    if (compareCoordinate != 0) {
+      return compareCoordinate;
+    }
+  }
+  return 0;
+}
+  int element_listCompare (Object aPtr, Object bPtr) {
+    element aElementPtr = (element)aPtr;
+    element bElementPtr = (element)bPtr;
+    return element_compare(aElementPtr, bElementPtr);
+  }
+  static int element_mapCompare(Object aPtr, Object bPtr) {
+    element aElementPtr = (element)(((edge)aPtr).firstPtr);
+    element bElementPtr = (element)(((edge)bPtr).firstPtr);
+    return element_compare(aElementPtr, bElementPtr);
+  }
+  double angleConstraint;
+  public element(coordinate[] coordinates, int numCoordinate, double angle) {
+    this.circumCenter=new coordinate();
+    this.coordinates=new coordinate[3];
+    this.midpoints=new coordinate[3];
+    this.radii=new double[3];
+    this.edges=new edge[3];
+    for (int i = 0; i < 3; i++) {
+      this.midpoints[i] = new coordinate();
+      this.edges[i]=new edge();
+    }
+    for (int i = 0; i < numCoordinate; i++) {
+      this.coordinates[i] = coordinates[i];
+    }
+    this.numCoordinate = numCoordinate;
+    this.angleConstraint=angle;
+    minimizeCoordinates();
+    checkAngles();
+    calculateCircumCircle();
+    initEdges(coordinates, numCoordinate);
+    neighborListPtr = new List_t(0);
+    isGarbage = false;
+    isReferenced = false;
+  }
+  int element_getNumEdge() {
+    return numEdge;
+  }
+  edge element_getEdge(int i) {
+    if (i < 0 || i > numEdge)
+      return null;
+    return edges[i];
+  }
+  static int compareEdge(edge aEdgePtr, edge bEdgePtr) {
+    int diffFirst = coordinate.coordinate_compare((coordinate)aEdgePtr.firstPtr,
+                                        (coordinate)bEdgePtr.firstPtr);
+    return ((diffFirst != 0) ?
+            (diffFirst) :
+            (coordinate.coordinate_compare((coordinate)aEdgePtr.secondPtr,
+                                (coordinate)bEdgePtr.secondPtr)));
+  }
+  int element_listCompareEdge (Object aPtr, Object bPtr) {
+    edge aEdgePtr = (edge)(aPtr);
+    edge bEdgePtr = (edge)(bPtr);
+    return compareEdge(aEdgePtr, bEdgePtr);
+  }
+  static int element_mapCompareEdge (edge aPtr, edge bPtr) {
+    edge aEdgePtr = (edge)(aPtr.firstPtr);
+    edge bEdgePtr = (edge)(bPtr.firstPtr);
+    return compareEdge(aEdgePtr, bEdgePtr);
+  }
+  int element_heapCompare (Object aPtr, Object bPtr) {
+    element aElementPtr = (element)aPtr;
+    element bElementPtr = (element)bPtr;
+    if (aElementPtr.encroachedEdgePtr!=null) {
+      if (bElementPtr.encroachedEdgePtr!=null) {
+ return 0;
+      } else {
+ return 1;
+      }
+    }
+    if (bElementPtr.encroachedEdgePtr!=null) {
+      return -1;
+    }
+    return 0;
+  }
+  boolean element_isInCircumCircle(coordinate coordinatePtr) {
+    double distance = coordinate.coordinate_distance(coordinatePtr, circumCenter);
+    return distance <= circumRadius;
+  }
+  boolean isEncroached() {
+    return encroachedEdgePtr!=null;
+  }
+  void element_clearEncroached() {
+    encroachedEdgePtr = null;
+  }
+  edge element_getEncroachedPtr() {
+    return encroachedEdgePtr;
+  }
+  boolean element_isSkinny() {
+    return isSkinny;
+  }
+  boolean element_isBad() {
+    return (isEncroached() || element_isSkinny());
+  }
+  boolean element_isReferenced () {
+    return isReferenced;
+  }
+  void element_setIsReferenced(boolean status) {
+    isReferenced= status;
+  }
+  public boolean element_isGarbage() {
+    return isGarbage;
+  }
+  void element_setIsGarbage(boolean status) {
+    isGarbage=status;
+  }
+  void element_addNeighbor(element neighborPtr) {
+    neighborListPtr.insert(neighborPtr);
+  }
+  List_t element_getNeighborListPtr () {
+    return neighborListPtr;
+  }
+  static edge element_getCommonEdge (element aElementPtr, element bElementPtr) {
+    edge aEdges[] = aElementPtr.edges;
+    edge bEdges[] = bElementPtr.edges;
+    int aNumEdge = aElementPtr.numEdge;
+    int bNumEdge = bElementPtr.numEdge;
+    for (int a = 0; a < aNumEdge; a++) {
+      edge aEdgePtr = aEdges[a];
+      for (int b = 0; b < bNumEdge; b++) {
+ edge bEdgePtr = bEdges[b];
+ if (compareEdge(aEdgePtr, bEdgePtr) == 0) {
+   return aEdgePtr;
+ }
+      }
+    }
+    return null;
+  }
+  coordinate element_getNewPoint() {
+    if (encroachedEdgePtr!=null) {
+      for (int e = 0; e < numEdge; e++) {
+ if (compareEdge(encroachedEdgePtr, edges[e]) == 0) {
+   return midpoints[e];
+ }
+      }
+      ;
+    }
+    return circumCenter;
+  }
+  boolean element_checkAngles() {
+    if (numCoordinate == 3) {
+      for (int i = 0; i < 3; i++) {
+ double angle = coordinate.coordinate_angle(coordinates[i],
+     coordinates[(i + 1) % 3],
+     coordinates[(i + 2) % 3]);
+ if (angle < angleConstraint) {
+   return false;
+ }
+      }
+    }
+    return true;
+  }
+  void element_print() {
+    for (int c = 0; c < numCoordinate; c++) {
+      coordinates[c].coordinate_print();
+      System.out.print(" ");
+    }
+  }
+  void element_printEdge (edge edgePtr) {
+    ((coordinate)edgePtr.firstPtr).coordinate_print();
+    System.out.println(" -> ");
+    ((coordinate)edgePtr.secondPtr).coordinate_print();
+  }
+  void element_printAngles() {
+    if (numCoordinate == 3) {
+      for (int i = 0; i < 3; i++) {
+ double angle = coordinate.coordinate_angle(coordinates[i],
+     coordinates[(i + 1) % 3],
+     coordinates[(i + 2) % 3]);
+ System.out.println(angle);
+      }
+    }
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/global_arg.java b/Robust/src/Benchmarks/SingleTM/Yada/java/global_arg.java
new file mode 100644 (file)
index 0000000..0a481e9
--- /dev/null
@@ -0,0 +1,7 @@
+public class global_arg {
+  public global_arg() {
+  }
+
+  int global_totalNumAdded;
+  int global_numProcess;
+}
\ No newline at end of file
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/heap.java b/Robust/src/Benchmarks/SingleTM/Yada/java/heap.java
new file mode 100644 (file)
index 0000000..6e5828f
--- /dev/null
@@ -0,0 +1,107 @@
+public class heap {
+  Object [] elements;
+  int size;
+  int capacity;
+  public heap(int initCapacity) {
+    int capacity = ((initCapacity > 0) ? (initCapacity) : (1));
+    elements = new Object[capacity];
+    size=0;
+    this.capacity = capacity;
+  }
+  public void siftUp(int startIndex) {
+    int index = startIndex;
+    while ((index > 1)) {
+      int parentIndex = ((index) / 2);
+      Object parentPtr = elements[parentIndex];
+      Object thisPtr = elements[index];
+      if (compare(parentPtr, thisPtr) >= 0) {
+ break;
+      }
+      Object tmpPtr = parentPtr;
+      elements[parentIndex] = thisPtr;
+      elements[index] = tmpPtr;
+      index = parentIndex;
+    }
+  }
+  public boolean heap_insert(Object dataPtr) {
+    if ((size + 1) >= capacity) {
+      int newCapacity = capacity * 2;
+      Object newElements[] = new Object[newCapacity];
+      this.capacity = newCapacity;
+      for (int i = 0; i <= size; i++) {
+ newElements[i] = elements[i];
+      }
+      this.elements = newElements;
+    }
+    size++;
+    elements[size] = dataPtr;
+    siftUp(size);
+    return true;
+  }
+  public void heapify(int startIndex) {
+    int index = startIndex;
+    while (true) {
+      int leftIndex = (2*index);
+      int rightIndex = (2*(index) + 1);
+      int maxIndex = -1;
+      if ((leftIndex <= size) &&
+   (compare(elements[leftIndex], elements[index]) > 0)) {
+ maxIndex = leftIndex;
+      } else {
+ maxIndex = index;
+      }
+      if ((rightIndex <= size) &&
+   (compare(elements[rightIndex], elements[maxIndex]) > 0)) {
+ maxIndex = rightIndex;
+      }
+      if (maxIndex == index) {
+ break;
+      } else {
+ Object tmpPtr = elements[index];
+ elements[index] = elements[maxIndex];
+ elements[maxIndex] = tmpPtr;
+ index = maxIndex;
+      }
+    }
+  }
+  Object heap_remove() {
+    if (size < 1) {
+      return null;
+    }
+    Object dataPtr = elements[1];
+    elements[1] = elements[size];
+    size--;
+    heapify(1);
+    return dataPtr;
+  }
+  boolean heap_isValid() {
+    for (int i = 1; i < size; i++) {
+      if (compare(elements[i+1], elements[((i+1) / 2)]) > 0) {
+ return false;
+      }
+    }
+    return true;
+  }
+  private static int compare(Object aPtr, Object bPtr) {
+    element aElementPtr = (element)aPtr;
+    element bElementPtr = (element)bPtr;
+    if (aElementPtr.encroachedEdgePtr!=null) {
+      if (bElementPtr.encroachedEdgePtr!=null) {
+        return 0;
+      } else {
+        return 1;
+      }
+    }
+    if (bElementPtr.encroachedEdgePtr!=null) {
+      return -1;
+    }
+    return 0;
+  }
+  public void printHeap() {
+    System.out.println("[");
+    for (int i = 0; i < size; i++) {
+      System.out.print(elements[i+1]+" ");
+    }
+    System.out.println("]");
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/mesh.java b/Robust/src/Benchmarks/SingleTM/Yada/java/mesh.java
new file mode 100644 (file)
index 0000000..ed59209
--- /dev/null
@@ -0,0 +1,210 @@
+import java.io.*;
+public class mesh {
+  element rootElementPtr;
+  Queue_t initBadQueuePtr;
+  int size;
+  RBTree boundarySetPtr;
+  double angle;
+  public mesh(double angle) {
+    this.angle=angle;
+    rootElementPtr = null;
+    initBadQueuePtr = new Queue_t(-1);
+    size = 0;
+    boundarySetPtr = new RBTree(0);
+  }
+  void TMmesh_insert (element elementPtr, avltree edgeMapPtr) {
+    if (rootElementPtr==null) {
+      rootElementPtr=elementPtr;
+    }
+    int numEdge = elementPtr.element_getNumEdge();
+    for (int i = 0; i < numEdge; i++) {
+      edge edgePtr = elementPtr.element_getEdge(i);
+      if (!edgeMapPtr.contains(edgePtr)) {
+ boolean isSuccess = edgeMapPtr.insert(edgePtr, elementPtr);
+ ;
+      } else {
+ element sharerPtr = (element)edgeMapPtr.find(edgePtr);
+ ;
+ elementPtr.element_addNeighbor(sharerPtr);
+ sharerPtr.element_addNeighbor(elementPtr);
+ boolean isSuccess = edgeMapPtr.remove(edgePtr);
+ ;
+ isSuccess = edgeMapPtr.insert(edgePtr, null);
+ ;
+      }
+    }
+    edge encroachedPtr = elementPtr.element_getEncroachedPtr();
+    if (encroachedPtr!=null) {
+      if (!boundarySetPtr.contains(encroachedPtr)) {
+ elementPtr.element_clearEncroached();
+      }
+    }
+  }
+public void TMmesh_remove(element elementPtr) {
+  ;
+  if (rootElementPtr == elementPtr) {
+    rootElementPtr=null;
+  }
+  List_t neighborListPtr = elementPtr.element_getNeighborListPtr();
+  List_Node it=neighborListPtr.head;
+  while (it.nextPtr!=null) {
+    it=it.nextPtr;
+    element neighborPtr = (element)it.dataPtr;
+    List_t neighborNeighborListPtr = neighborPtr.element_getNeighborListPtr();
+    boolean status = neighborNeighborListPtr.remove(elementPtr);
+    ;
+  }
+  elementPtr.element_setIsGarbage(true);
+}
+boolean TMmesh_insertBoundary(edge boundaryPtr) {
+  return boundarySetPtr.insert(boundaryPtr,null);
+}
+boolean TMmesh_removeBoundary(edge boundaryPtr) {
+  return boundarySetPtr.deleteObjNode(boundaryPtr);
+}
+  void createElement(coordinate[] coordinates, int numCoordinate,
+      avltree edgeMapPtr) {
+  element elementPtr = new element(coordinates, numCoordinate, angle);
+  if (numCoordinate == 2) {
+    edge boundaryPtr = elementPtr.element_getEdge(0);
+    boolean status = boundarySetPtr.insert(boundaryPtr, null);
+    ;
+  }
+  TMmesh_insert(elementPtr, edgeMapPtr);
+  if (elementPtr.element_isBad()) {
+    boolean status = initBadQueuePtr.queue_push(elementPtr);
+    ;
+  }
+}
+int mesh_read(String fileNamePrefix) throws Exception {
+    int i;
+    int numElement = 0;
+    avltree edgeMapPtr = new avltree(0);
+    String fileName=fileNamePrefix+".node";
+    FileInputStream inputFile = new FileInputStream(fileName);
+    bytereader br=new bytereader(inputFile);
+    int numEntry=br.getInt();
+    int numDimension=br.getInt();
+    br.jumptonextline();
+    ;
+    int numCoordinate = numEntry + 1;
+    coordinate coordinates[] = new coordinate[numCoordinate];
+    for(i=0;i<numCoordinate;i++)
+      coordinates[i]=new coordinate();
+    for (i = 0; i < numEntry; i++) {
+      int id;
+      double x;
+      double y;
+      id=br.getInt();
+      x=br.getDouble();
+      y=br.getDouble();
+      br.jumptonextline();
+      coordinates[id].x = x;
+      coordinates[id].y = y;
+    }
+    ;
+    inputFile.close();
+    fileName=fileNamePrefix+".poly";
+    inputFile = new FileInputStream(fileName);
+    br=new bytereader(inputFile);
+    numEntry=br.getInt();
+    numDimension=br.getInt();
+    br.jumptonextline();
+    ;
+    ;
+    numEntry=br.getInt();
+    br.jumptonextline();
+    for (i = 0; i < numEntry; i++) {
+      int id;
+      int a;
+      int b;
+      coordinate insertCoordinates[]=new coordinate[2];
+      id=br.getInt();
+      a=br.getInt();
+      b=br.getInt();
+      br.jumptonextline();
+      ;
+      ;
+      insertCoordinates[0] = coordinates[a];
+      insertCoordinates[1] = coordinates[b];
+      createElement(insertCoordinates, 2, edgeMapPtr);
+    }
+    ;
+    numElement += numEntry;
+    inputFile.close();
+    fileName=fileNamePrefix+".ele";
+    inputFile = new FileInputStream(fileName);
+    br=new bytereader(inputFile);
+    numEntry=br.getInt();
+    numDimension=br.getInt();
+    br.jumptonextline();
+    ;
+    for (i = 0; i < numEntry; i++) {
+      int id;
+      int a;
+      int b;
+      int c;
+      coordinate insertCoordinates[]=new coordinate[3];
+      id=br.getInt();
+      a=br.getInt();
+      b=br.getInt();
+      c=br.getInt();
+      ;
+      ;
+      ;
+      insertCoordinates[0] = coordinates[a];
+      insertCoordinates[1] = coordinates[b];
+      insertCoordinates[2] = coordinates[c];
+      createElement(insertCoordinates, 3, edgeMapPtr);
+    }
+    ;
+    numElement += numEntry;
+    inputFile.close();
+    return numElement;
+}
+element mesh_getBad() {
+  return (element)initBadQueuePtr.queue_pop();
+}
+void mesh_shuffleBad (Random randomPtr) {
+  initBadQueuePtr.queue_shuffle(randomPtr);
+}
+boolean mesh_check(int expectedNumElement) {
+    int numBadTriangle = 0;
+    int numFalseNeighbor = 0;
+    int numElement = 0;
+    System.out.println("Checking final mesh:");
+    Queue_t searchQueuePtr = new Queue_t(-1);
+    avltree visitedMapPtr = new avltree(1);
+    ;
+    searchQueuePtr.queue_push(rootElementPtr);
+    while (!searchQueuePtr.queue_isEmpty()) {
+        List_t neighborListPtr;
+        element currentElementPtr = (element)searchQueuePtr.queue_pop();
+        if (visitedMapPtr.contains(currentElementPtr)) {
+            continue;
+        }
+        boolean isSuccess = visitedMapPtr.insert(currentElementPtr, null);
+ ;
+        if (!currentElementPtr.element_checkAngles()) {
+            numBadTriangle++;
+        }
+        neighborListPtr = currentElementPtr.element_getNeighborListPtr();
+        List_Node it=neighborListPtr.head;
+        while (it.nextPtr!=null) {
+   it=it.nextPtr;
+   element neighborElementPtr =
+     (element)it.dataPtr;
+   if (!visitedMapPtr.contains(neighborElementPtr)) {
+     isSuccess = searchQueuePtr.queue_push(neighborElementPtr);
+     ;
+   }
+        }
+        numElement++;
+    }
+    System.out.println("Number of elements      = "+ numElement);
+    System.out.println("Number of bad triangles = "+ numBadTriangle);
+    return (!(numBadTriangle > 0 ||
+       numFalseNeighbor > 0 ||
+       numElement != expectedNumElement));
+}
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/region.java b/Robust/src/Benchmarks/SingleTM/Yada/java/region.java
new file mode 100644 (file)
index 0000000..469729d
--- /dev/null
@@ -0,0 +1,163 @@
+public class region {
+  coordinate centerCoordinate;
+  Queue_t expandQueuePtr;
+  List_t beforeListPtr;
+  List_t borderListPtr;
+  Vector_t badVectorPtr;
+  public region() {
+    expandQueuePtr = new Queue_t(-1);
+    beforeListPtr = new List_t(0);
+    borderListPtr = new List_t(1);
+    badVectorPtr = new Vector_t(1);
+  }
+  public static void TMaddToBadVector(Vector_t badVectorPtr, element badElementPtr) {
+    boolean status = badVectorPtr.vector_pushBack(badElementPtr);
+    ;
+    badElementPtr.element_setIsReferenced(true);
+  }
+  public static int TMretriangulate (element elementPtr,
+         region regionPtr,
+         mesh meshPtr,
+         avltree edgeMapPtr, double angle) {
+    Vector_t badVectorPtr = regionPtr.badVectorPtr;
+    List_t beforeListPtr = regionPtr.beforeListPtr;
+    List_t borderListPtr = regionPtr.borderListPtr;
+    int numDelta = 0;
+    ;
+    coordinate centerCoordinate = elementPtr.element_getNewPoint();
+    List_Node it=beforeListPtr.head;
+    while (it.nextPtr!=null) {
+      it=it.nextPtr;
+      element beforeElementPtr = (element)it.dataPtr;
+      meshPtr.TMmesh_remove(beforeElementPtr);
+    }
+    numDelta -= beforeListPtr.getSize();
+    if (elementPtr.element_getNumEdge() == 1) {
+      coordinate coordinates[]=new coordinate[2];
+      edge edgePtr = elementPtr.element_getEdge(0);
+      coordinates[0] = centerCoordinate;
+      coordinates[1] = (coordinate)(edgePtr.firstPtr);
+      element aElementPtr = new element(coordinates, 2, angle);
+      meshPtr.TMmesh_insert(aElementPtr, edgeMapPtr);
+      coordinates[1] = (coordinate)edgePtr.secondPtr;
+      element bElementPtr = new element(coordinates, 2, angle);
+      meshPtr.TMmesh_insert(bElementPtr, edgeMapPtr);
+      boolean status = meshPtr.TMmesh_removeBoundary(elementPtr.element_getEdge(0));
+      ;
+      status = meshPtr.TMmesh_insertBoundary(aElementPtr.element_getEdge(0));
+      ;
+      status = meshPtr.TMmesh_insertBoundary(bElementPtr.element_getEdge(0));
+      ;
+      numDelta += 2;
+    }
+    it=borderListPtr.head;
+    while (it.nextPtr!=null) {
+      coordinate coordinates[]=new coordinate[3];
+      it=it.nextPtr;
+      edge borderEdgePtr = (edge)it.dataPtr;
+      ;
+      coordinates[0] = centerCoordinate;
+      coordinates[1] = (coordinate)(borderEdgePtr.firstPtr);
+      coordinates[2] = (coordinate)(borderEdgePtr.secondPtr);
+      element afterElementPtr = new element(coordinates, 3, angle);
+      meshPtr.TMmesh_insert(afterElementPtr, edgeMapPtr);
+      if (afterElementPtr.element_isBad()) {
+ TMaddToBadVector(badVectorPtr, afterElementPtr);
+      }
+    }
+    numDelta += borderListPtr.getSize();
+    return numDelta;
+  }
+  element TMgrowRegion(element centerElementPtr,
+         region regionPtr,
+         mesh meshPtr,
+         avltree edgeMapPtr) {
+    boolean isBoundary = false;
+    if(centerElementPtr.element_getNumEdge() == 1) {
+      isBoundary = true;
+    }
+    List_t beforeListPtr = regionPtr.beforeListPtr;
+    List_t borderListPtr = regionPtr.borderListPtr;
+    Queue_t expandQueuePtr = regionPtr.expandQueuePtr;
+    beforeListPtr.clear();
+    borderListPtr.clear();
+    expandQueuePtr.queue_clear();
+    coordinate centerCoordinatePtr = centerElementPtr.element_getNewPoint();
+    expandQueuePtr.queue_push(centerElementPtr);
+    while (!expandQueuePtr.queue_isEmpty()) {
+      element currentElementPtr = (element) expandQueuePtr.queue_pop();
+      beforeListPtr.insert(currentElementPtr);
+      List_t neighborListPtr = currentElementPtr.element_getNeighborListPtr();
+      List_Node it=neighborListPtr.head;
+      while (it.nextPtr!=null) {
+ it=it.nextPtr;
+ element neighborElementPtr = (element)it.dataPtr;
+ neighborElementPtr.element_isGarbage();
+ if (beforeListPtr.find(neighborElementPtr)==null) {
+   if (neighborElementPtr.element_isInCircumCircle(centerCoordinatePtr)) {
+     if (!isBoundary && (neighborElementPtr.element_getNumEdge() == 1)) {
+       return neighborElementPtr;
+     } else {
+       boolean isSuccess = expandQueuePtr.queue_push(neighborElementPtr);
+       ;
+     }
+   } else {
+     edge borderEdgePtr = element.element_getCommonEdge(neighborElementPtr, currentElementPtr);
+     if (borderEdgePtr==null) {
+       System.out.println("Abort case");
+     }
+     borderListPtr.insert(borderEdgePtr);
+     if (!edgeMapPtr.contains(borderEdgePtr)) {
+       edgeMapPtr.insert(borderEdgePtr, neighborElementPtr);
+     }
+   }
+ }
+      }
+    }
+    return null;
+  }
+  int TMregion_refine(element elementPtr, mesh meshPtr, double angle) {
+    int numDelta = 0;
+    avltree edgeMapPtr = null;
+    element encroachElementPtr = null;
+    elementPtr.element_isGarbage();
+    while (true) {
+      edgeMapPtr = new avltree(0);
+      encroachElementPtr = TMgrowRegion(elementPtr,
+     this,
+     meshPtr,
+     edgeMapPtr);
+      if (encroachElementPtr!=null) {
+ encroachElementPtr.element_setIsReferenced(true);
+ numDelta += TMregion_refine(encroachElementPtr,
+        meshPtr, angle);
+ if (elementPtr.element_isGarbage()) {
+   break;
+ }
+      } else {
+ break;
+      }
+    }
+    if (!elementPtr.element_isGarbage()) {
+      numDelta += TMretriangulate(elementPtr,
+      this,
+      meshPtr,
+      edgeMapPtr, angle);
+    }
+    return numDelta;
+  }
+  void region_clearBad () {
+    badVectorPtr.vector_clear();
+  }
+  void region_transferBad(heap workHeapPtr) {
+    int numBad = badVectorPtr.vector_getSize();
+    for (int i = 0; i < numBad; i++) {
+      element badElementPtr = (element)badVectorPtr.vector_at(i);
+      if (badElementPtr.element_isGarbage()) {
+      } else {
+ boolean status = workHeapPtr.heap_insert(badElementPtr);
+ ;
+      }
+    }
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Yada/java/yada.java b/Robust/src/Benchmarks/SingleTM/Yada/java/yada.java
new file mode 100644 (file)
index 0000000..af576d9
--- /dev/null
@@ -0,0 +1,153 @@
+public class yada extends Thread {
+  String global_inputPrefix;
+  int global_numThread;
+  double global_angleConstraint;
+  mesh global_meshPtr;
+  heap global_workHeapPtr;
+  int global_totalNumAdded;
+  int global_numProcess;
+  global_arg globalvar;
+  public yada() {
+    global_inputPrefix = "";
+    global_numThread = 1;
+    global_angleConstraint = 20.0;
+    global_totalNumAdded = 0;
+    global_numProcess = 0;
+  }
+  public yada(mesh meshptr, heap heapptr, double angle, global_arg g) {
+    global_meshPtr=meshptr;
+    global_workHeapPtr=heapptr;
+    global_angleConstraint=angle;
+    globalvar=g;
+  }
+  public static void displayUsage () {
+    System.out.println("Usage: Yada [options]");
+    System.out.println("Options:                              (defaults)");
+    System.out.println("    a <FLT>   Min [a]ngle constraint  (20.0)");
+    System.out.println("    i <STR>   [i]nput name prefix     (\"\")");
+    System.out.println("    t <UINT>  Number of [t]hreads     (1L)");
+    System.exit(1);
+  }
+  public void parseArgs (String argv[]) {
+    for(int index=0;index<argv.length;index++) {
+      if (argv[index].equals("-a")) {
+ index++;
+ global_angleConstraint=Double.parseDouble(argv[index]);
+      } else if (argv[index].equals("-i")) {
+ index++;
+ global_inputPrefix=argv[index];
+      } else if (argv[index].equals("-t")) {
+ index++;
+ global_numThread=Integer.parseInt(argv[index]);
+      } else {
+ displayUsage();
+ System.exit(-1);
+      }
+    }
+}
+  public static int initializeWork (heap workHeapPtr, mesh meshPtr) {
+    Random randomPtr = new Random();
+    randomPtr.random_seed(0);
+    meshPtr.mesh_shuffleBad(randomPtr);
+    int numBad = 0;
+    while(true) {
+      element elementPtr = meshPtr.mesh_getBad();
+      if (elementPtr==null) {
+ break;
+      }
+      numBad++;
+      boolean status = workHeapPtr.heap_insert(elementPtr);
+      ;
+      elementPtr.element_setIsReferenced(true);
+    }
+    return numBad;
+  }
+  public static void Assert(boolean status) {
+    if (!status) {
+      System.out.println("Failed assert");
+      int [] x=new int[1];
+      x[0]=3/0;
+    }
+  }
+  public void process() {
+    heap workHeapPtr = global_workHeapPtr;
+    mesh meshPtr = global_meshPtr;
+    int totalNumAdded = 0;
+    int numProcess = 0;
+    region regionPtr = new region();
+    while (true) {
+        element elementPtr;
+        {
+   elementPtr = (element) workHeapPtr.heap_remove();
+        }
+        if (elementPtr == null) {
+   break;
+        }
+        boolean isGarbage;
+        {
+   isGarbage = elementPtr.element_isGarbage();
+        }
+        if (isGarbage) {
+            continue;
+        }
+        int numAdded;
+        {
+   regionPtr.region_clearBad();
+   numAdded = regionPtr.TMregion_refine(elementPtr, meshPtr, global_angleConstraint);
+        }
+        {
+   elementPtr.element_setIsReferenced(false);
+   isGarbage = elementPtr.element_isGarbage();
+        }
+        totalNumAdded += numAdded;
+        {
+   regionPtr.region_transferBad(workHeapPtr);
+        }
+        numProcess++;
+    }
+    {
+      globalvar.global_totalNumAdded=globalvar.global_totalNumAdded + totalNumAdded;
+      globalvar.global_numProcess=globalvar.global_numProcess + numProcess;
+    }
+  }
+  public void run() {
+    Barrier.enterBarrier();
+    process();
+    Barrier.enterBarrier();
+  }
+  public static void main(String[] argv) {
+    yada y=new yada();
+    global_arg g=new global_arg();
+    y.globalvar=g;
+    y.parseArgs(argv);
+    Barrier.setBarrier(y.global_numThread);
+    y.global_meshPtr = new mesh(y.global_angleConstraint);
+    System.out.println("Angle constraint = "+ y.global_angleConstraint);
+    System.out.println("Reading input... ");
+    int initNumElement=0;
+    try {
+      initNumElement = y.global_meshPtr.mesh_read(y.global_inputPrefix);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    System.out.println("done.");
+    y.global_workHeapPtr = new heap(1);
+    for(int i=1;i<y.global_numThread;i++) {
+      yada ychild=new yada(y.global_meshPtr, y.global_workHeapPtr, y.global_angleConstraint, g);
+      ychild.start();
+    }
+    int initNumBadElement = initializeWork(y.global_workHeapPtr,y.global_meshPtr);
+    System.out.println("Initial number of mesh elements = "+ initNumElement);
+    System.out.println("Initial number of bad elements  = "+ initNumBadElement);
+    System.out.println("Starting triangulation...");
+    long start=System.currentTimeMillis();
+    y.run();
+    long stop=System.currentTimeMillis();
+    long diff=stop-start;
+    System.out.println("TIME="+diff);
+    System.out.println(" done.");
+    int finalNumElement = initNumElement + y.globalvar.global_totalNumAdded;
+    System.out.println("Final mesh size                 = "+ finalNumElement);
+    System.out.println("Number of elements processed    = "+ y.globalvar.global_numProcess);
+  }
+}