From: Jeff Preshing Date: Tue, 16 Feb 2016 20:37:33 +0000 (-0500) Subject: MapLinearizabilityTest now uses SimpleRelaxed map by default X-Git-Url: http://plrg.eecs.uci.edu/git/?p=junction.git;a=commitdiff_plain;h=779ccbad0699d6e6614e14802b52fb4982f290c5;hp=3ef92edd2bdb5084e12483b746a925ddc7e5fcc8 MapLinearizabilityTest now uses SimpleRelaxed map by default Also fix incorrect classification of an IRIW history as non-linearizable --- diff --git a/samples/MapLinearizabilityTest/CMakeLists.txt b/samples/MapLinearizabilityTest/CMakeLists.txt index e7774af..62e00ce 100644 --- a/samples/MapLinearizabilityTest/CMakeLists.txt +++ b/samples/MapLinearizabilityTest/CMakeLists.txt @@ -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) diff --git a/samples/MapLinearizabilityTest/MapLinearizabilityTest.cpp b/samples/MapLinearizabilityTest/MapLinearizabilityTest.cpp index a3e1a65..4523ae9 100644 --- a/samples/MapLinearizabilityTest/MapLinearizabilityTest.cpp +++ b/samples/MapLinearizabilityTest/MapLinearizabilityTest.cpp @@ -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 index 0000000..5c9739d --- /dev/null +++ b/samples/MapLinearizabilityTest/junction_userconfig.h.in @@ -0,0 +1 @@ +#define JUNCTION_IMPL_MAPADAPTER_PATH "junction/extra/impl/MapAdapter_SimpleRelaxed.h"