MapLinearizabilityTest now uses SimpleRelaxed map by default
authorJeff Preshing <filter-github@preshing.com>
Tue, 16 Feb 2016 20:37:33 +0000 (15:37 -0500)
committerJeff Preshing <filter-github@preshing.com>
Tue, 16 Feb 2016 20:37:33 +0000 (15:37 -0500)
Also fix incorrect classification of an IRIW history as non-linearizable

samples/MapLinearizabilityTest/CMakeLists.txt
samples/MapLinearizabilityTest/MapLinearizabilityTest.cpp
samples/MapLinearizabilityTest/junction_userconfig.h.in [new file with mode: 0644]

index e7774af78111cddce0864749b38869bd1238bc2c..62e00ce41d882ee03222379593e846f9b3a39aa3 100644 (file)
@@ -7,4 +7,5 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     project(${SAMPLE_NAME})
 endif()    
 
+set(JUNCTION_USERCONFIG "junction_userconfig.h.in" CACHE STRING "Custom config for ${SAMPLE_NAME}")
 include(../AddSample.cmake)
index a3e1a6577a97257feed266066a73457615a60f2a..4523ae92ed82e762364fe998b836ac4480c8807a 100644 (file)
@@ -44,10 +44,10 @@ public:
     void run(ureg threadIndex) {
         u32 x = X;
         u32 y = Y;
-        while ((g_random[threadIndex].next32() & 0x1ff) != 0) { // Random delay
+        while ((g_random[threadIndex].next32() & 0x7f) != 0) { // Random delay
         }
         if (threadIndex == 0) {
-            // We store 2 because 1 is reserved for the default Redirect value.
+            // We store 2 because Junction maps reserve 1 for the default Redirect value.
             // The default can be overridden, but this is easier.
             m_map.insert(x, (void*) 2);
             m_r1 = (uptr) m_map.get(y);
@@ -87,18 +87,18 @@ public:
         }
         switch (threadIndex) {
         case 0:
-            // We store 2 because 1 is reserved for the default Redirect value.
+            // We store 2 because Junction maps reserve 1 for the default Redirect value.
             // The default can be overridden, but this is easier.
             m_map.insert(x, (void*) 2);
             break;
             
         case 1:
-            m_r1 = (uptr) m_map.get(x);
-            m_r2 = (uptr) m_map.get(y);
+            m_map.insert(y, (void*) 2);
             break;
             
         case 2:
-            m_map.insert(y, (void*) 2);
+            m_r1 = (uptr) m_map.get(x);
+            m_r2 = (uptr) m_map.get(y);
             break;
             
         case 3:
@@ -111,31 +111,33 @@ public:
 
 int main() {
 #if 1
-    turf::extra::JobDispatcher dispatcher(4);
-    MapAdapter adapter(4);
+    // Run StoreBufferTest
+    turf::extra::JobDispatcher dispatcher(2);
+    MapAdapter adapter(2);
 
-    int nonLinearizable = 0;
-    for (int iterations = 0;; iterations++) {
-        IRIWTest test;
-        dispatcher.kick(&IRIWTest::run, test);
-//        printf("%d %d %d %d\n", test.m_r1, test.m_r2, test.m_r3, test.m_r4);
-        if ((test.m_r1 == 2 && test.m_r2 == 0 && test.m_r3 == 2 && test.m_r4 == 0)
-            || (test.m_r1 == 0 && test.m_r2 == 2 && test.m_r3 == 0 && test.m_r4 == 2))
+    u64 nonLinearizable = 0;
+    for (u64 iterations = 0;; iterations++) {
+        StoreBufferTest test;
+        dispatcher.kick(&StoreBufferTest::run, test);
+        if (test.m_r1 == 0 && test.m_r2 == 0) {
             nonLinearizable++;
+        }
         if (iterations % 10000 == 0) {
-            printf("%d non-linearizable histories after %d iterations\n", nonLinearizable, iterations);
+            printf("%" TURF_U64D " non-linearizable histories after %" TURF_U64D " iterations\n", nonLinearizable, iterations);
         }
     }
 #else
-    turf::extra::JobDispatcher dispatcher(2);
-    MapAdapter adapter(2);
+    // Run IRIWTest
+    turf::extra::JobDispatcher dispatcher(4);
+    MapAdapter adapter(4);
 
     u64 nonLinearizable = 0;
     for (u64 iterations = 0;; iterations++) {
-        StoreBufferTest test;
-        dispatcher.kick(&StoreBufferTest::run, test);
-        if (test.m_r1 == 0 && test.m_r2 == 0)
+        IRIWTest test;
+        dispatcher.kick(&IRIWTest::run, test);
+        if (test.m_r1 == 2 && test.m_r2 == 0 && test.m_r3 == 2 && test.m_r4 == 0) {
             nonLinearizable++;
+        }
         if (iterations % 10000 == 0) {
             printf("%" TURF_U64D " non-linearizable histories after %" TURF_U64D " iterations\n", nonLinearizable, iterations);
         }
diff --git a/samples/MapLinearizabilityTest/junction_userconfig.h.in b/samples/MapLinearizabilityTest/junction_userconfig.h.in
new file mode 100644 (file)
index 0000000..5c9739d
--- /dev/null
@@ -0,0 +1 @@
+#define JUNCTION_IMPL_MAPADAPTER_PATH "junction/extra/impl/MapAdapter_SimpleRelaxed.h"