edits
authorPeizhao Ou <peizhaoo@uci.edu>
Wed, 9 Sep 2015 18:47:28 +0000 (11:47 -0700)
committerPeizhao Ou <peizhaoo@uci.edu>
Wed, 9 Sep 2015 18:47:28 +0000 (11:47 -0700)
scfence/scfence.cc
test/iriw.cc [new file with mode: 0644]
test/iriw_wildcard.cc [new file with mode: 0644]

index 63408cbf1c06c4fe96fab70961930b01eba4c914..130dc3b16dfc83f09bc563a4a97089d7b82c5ac4 100644 (file)
@@ -35,7 +35,7 @@ void SCFence::setExecution(ModelExecution * execution) {
 }
 
 const char * SCFence::name() {
-       const char * name = "SCFENCE";
+       const char * name = "AUTOMO";
        return name;
 }
 
diff --git a/test/iriw.cc b/test/iriw.cc
new file mode 100644 (file)
index 0000000..fddbf1a
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+ * @file iriw.cc
+ * @brief Independent read and independent write test
+ */
+
+#include <atomic>
+#include <threads.h>
+#include <stdio.h>
+
+#include "wildcard.h"
+#include "model-assert.h"
+
+using namespace std;
+
+atomic_int x, y;
+int r1, r2, r3, r4; /* "local" variables */
+
+static void a(void *obj)
+{
+       x.store(1, memory_order_seq_cst);
+}
+
+static void b(void *obj)
+{
+       y.store(1, memory_order_seq_cst);
+}
+
+static void c(void *obj)
+{
+       r1 = x.load(memory_order_acquire);
+       r2 = y.load(memory_order_seq_cst);
+}
+
+static void d(void *obj)
+{
+       r3 = y.load(memory_order_acquire);
+       r4 = x.load(memory_order_seq_cst);
+}
+
+
+int user_main(int argc, char **argv)
+{
+       thrd_t t1, t2, t3, t4;
+
+       atomic_init(&x, 0);
+       atomic_init(&y, 0);
+
+       printf("Main thread: creating 4 threads\n");
+       thrd_create(&t1, (thrd_start_t)&a, NULL);
+       thrd_create(&t2, (thrd_start_t)&b, NULL);
+       thrd_create(&t3, (thrd_start_t)&c, NULL);
+       thrd_create(&t4, (thrd_start_t)&d, NULL);
+
+       thrd_join(t1);
+       thrd_join(t2);
+       thrd_join(t3);
+       thrd_join(t4);
+       printf("Main thread is finished\n");
+
+       /*
+        * This condition should not be hit if the execution is SC */
+       bool sc = (r1 == 1 && r2 == 0 && r3 == 1 && r4 == 0);
+       printf("r1 = %d, r2 = %d, r3 = %d and r4 = %d\n", r1, r2, r3, r4);
+       MODEL_ASSERT(!sc);
+       return 0;
+}
diff --git a/test/iriw_wildcard.cc b/test/iriw_wildcard.cc
new file mode 100644 (file)
index 0000000..5c52455
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+ * @file iriw.cc
+ * @brief Independent read and independent write test
+ */
+
+#include <atomic>
+#include <threads.h>
+#include <stdio.h>
+
+#include "wildcard.h"
+#include "model-assert.h"
+
+using namespace std;
+
+atomic_int x, y;
+int r1, r2, r3, r4; /* "local" variables */
+
+static void a(void *obj)
+{
+       x.store(1, wildcard(1));
+}
+
+static void b(void *obj)
+{
+       y.store(1, wildcard(2));
+}
+
+static void c(void *obj)
+{
+       r1 = x.load(wildcard(3));
+       r2 = y.load(wildcard(4));
+}
+
+static void d(void *obj)
+{
+       r3 = y.load(wildcard(5));
+       r4 = x.load(wildcard(6));
+}
+
+
+int user_main(int argc, char **argv)
+{
+       thrd_t t1, t2, t3, t4;
+
+       atomic_init(&x, 0);
+       atomic_init(&y, 0);
+
+       printf("Main thread: creating 4 threads\n");
+       thrd_create(&t1, (thrd_start_t)&a, NULL);
+       thrd_create(&t2, (thrd_start_t)&b, NULL);
+       thrd_create(&t3, (thrd_start_t)&c, NULL);
+       thrd_create(&t4, (thrd_start_t)&d, NULL);
+
+       thrd_join(t1);
+       thrd_join(t2);
+       thrd_join(t3);
+       thrd_join(t4);
+       printf("Main thread is finished\n");
+
+       /*
+        * This condition should not be hit if the execution is SC */
+       bool sc = (r1 == 1 && r2 == 0 && r3 == 1 && r4 == 0);
+       //MODEL_ASSERT(!sc);
+
+       return 0;
+}