result for hashmap
authorPeizhao Ou <peizhaoo@uci.edu>
Sun, 22 Mar 2015 04:36:57 +0000 (21:36 -0700)
committerPeizhao Ou <peizhaoo@uci.edu>
Sun, 22 Mar 2015 04:36:57 +0000 (21:36 -0700)
concurrent-hashmap/Makefile
concurrent-hashmap/note.txt
concurrent-hashmap/result1.txt
concurrent-hashmap/result2.txt
concurrent-hashmap/testcase1.cc
concurrent-hashmap/testcase2.cc
concurrent-hashmap/testcase3.cc [deleted file]

index 89e5244b22dc7dfdafd062823ef34e595d88fe4a..4c0a7dccd2a8d247eb5e87046b8c4db5fa49f948 100644 (file)
@@ -1,7 +1,7 @@
 include ../benchmarks.mk
 
 BENCH := hashmap
-NORMAL_TESTS := testcase1 testcase2 testcase3
+NORMAL_TESTS := testcase1 testcase2 
 
 WILDCARD_TESTS := $(patsubst %, %_wildcard, $(NORMAL_TESTS))
 
index 0056dcdc89fe1d2f1b9ef8907fd46957fc2d26dd..f080a487b1ac8fd614dbafd071e060220e3c0450 100644 (file)
@@ -8,3 +8,10 @@ get(k2); // b                          get(k1); // d
 When b and d both read the old head of the list (and they later grab the lock,
 making it the interface SC), it's non-SC because neither reads the updated
 value.
+
+Run testcase1 to make the store and load of value slot to be seq_cst.
+
+Then run testcase2 with "-o annotation" to get store and load of key slot to be
+release/acquire.
+
+0m0.015s + 0m0.000 = 0m0.015s 
index 2425b57eb15af902d3159fd970673559b24e7bd6..a47e66db703da8e365f0936d7260f2cd3f8956c1 100644 (file)
@@ -1,9 +1,17 @@
+peizhaoo@dw-2:~/test/model-checker-priv/model-checker-priv$ time ./run.sh
+benchmarks/concurrent-hashmap/testcase1_wildcard -m2 -y -u3 -tSCFENCE -o weaken
+&> /scratch/a
+
+real   0m0.031s
+user   0m0.015s
+sys    0m0.000s
+
 Result 0:
 wildcard 1 -> memory_order_relaxed
 wildcard 2 -> memory_order_relaxed
-wildcard 3 -> memory_order_acquire
-wildcard 4 -> memory_order_relaxed
-wildcard 6 -> memory_order_relaxed
-wildcard 7 -> memory_order_relaxed
+wildcard 3 -> memory_order_relaxed
+wildcard 4 -> memory_order_seq_cst
 wildcard 9 -> memory_order_relaxed
-wildcard 13 -> memory_order_release
+wildcard 10 -> memory_order_relaxed
+wildcard 11 -> memory_order_seq_cst
+wildcard 13 -> memory_order_relaxed
index c09db095fc87c962af9c8a4400d66dad57c3489a..176baf34dd0bebcf186301c0f7ea075993a98441 100644 (file)
@@ -1,11 +1,21 @@
+peizhaoo@dw-2:~/test/model-checker-priv/model-checker-priv$ time ./run.sh
+benchmarks/concurrent-hashmap/testcase2_wildcard -m2 -y -u3 -tSCFENCE -o weaken
+-o fbenchmarks/concurrent-hashmap/result1.txt -o annotation  &> /scratch/a
+
+real   0m0.027s
+user   0m0.000s
+sys    0m0.014s
+
 Result 0:
 wildcard 1 -> memory_order_relaxed
 wildcard 2 -> memory_order_relaxed
 wildcard 3 -> memory_order_acquire
 wildcard 4 -> memory_order_seq_cst
+wildcard 5 -> memory_order_relaxed
 wildcard 6 -> memory_order_relaxed
-wildcard 7 -> memory_order_relaxed
+wildcard 8 -> memory_order_relaxed
 wildcard 9 -> memory_order_relaxed
 wildcard 10 -> memory_order_relaxed
 wildcard 11 -> memory_order_seq_cst
+wildcard 12 -> memory_order_relaxed
 wildcard 13 -> memory_order_release
index 939e250bee787a487e694b68acdc6c3f47508528..008eb6fe1689de3db99a1e70d220ed0d90e23060 100644 (file)
@@ -28,6 +28,8 @@ void printValue(Value *value) {
 // Key(3, 4, 5) & Key(1, 4, 3) are hashed to the same slot -> 5
 
 
+/** Making w4 & w11 seq_cst */
+
 void threadA(void *arg) {
        Key *k1 = new Key(3, 2, 6);
        Key *k2 = new Key(1, 1, 1);
@@ -51,8 +53,15 @@ void threadB(void *arg) {
 }
 
 int user_main(int argc, char *argv[]) {
+       
+       Key *k1 = new Key(3, 2, 6);
+       Key *k2 = new Key(1, 1, 1);
+       Value *v1 = new Value(111, 111, 111);
+       Value *v2 = new Value(222, 222, 222);
        thrd_t t1, t2;
        table = new HashMap;
+       table->put(k1, v1);
+       table->put(k2, v2);
 
        thrd_create(&t1, threadA, NULL);
        thrd_create(&t2, threadB, NULL);
index 17f79d8edcf1344fdb826b54602977d243778dfe..96a5bb296533c1d3d0d63e0f5f795abac8f704ed 100644 (file)
@@ -25,41 +25,45 @@ void printValue(Value *value) {
 // Key(3, 2, 6) & Key(1, 3, 3) are hashed to the same slot -> 4
 // Key(1, 1, 1) & Key(3, 2, 2) are hashed to the same slot -> 0
 // Key(2, 4, 1) & Key(3, 4, 2) are hashed to the same slot -> 3
-// Key(3, 4, 5) & Key(1, 4, 3) are hashed to the same slot -> 5
-
+// Key(3, 4, 5) & Key(1, 4, 3) & Key(1, 1, 6) are hashed to the same slot -> 5
+// Key(2, 4, 8) & Key(1, 3, 8) -> 9
+// Key(1, 4, 8) -> 10
+// Key(1, 3, 7) -> 8
+// Key(1, 2, 7) -> 7
+// Key(1, 2, 6) -> 6
 
 void threadA(void *arg) {
        Key *k1 = new Key(3, 2, 6);
-       Key *k2 = new Key(1, 1, 1);
-       Value *v1 = new Value(10, 10, 10);
-       Value *r1 = table->put(k1, v1);
+       Key *k2 = new Key(1, 3, 3);
+       Key *k3 = new Key(2, 4, 1);
+       Key *k4 = new Key(3, 4, 2);
+       Value *v2 = new Value(10, 10, 10);
+       Value *r1 = table->put(k2, v2);
        //printValue(r1);
-       Value *r2 = table->get(k2);
-       //printf("Thrd A:\n");
-       printValue(r2);
+       Value *r2 = table->get(k4);
+       //printValue(r2);
 }
 
 void threadB(void *arg) {
        Key *k1 = new Key(3, 2, 6);
-       Key *k2 = new Key(1, 1, 1);
-       Value *v2 = new Value(30, 40, 50);
-       Value *r3 = table->put(k2, v2);
-       //printValue(r3);
-       Value *r4 = table->get(k1);
-       printf("Thrd B:\n");
-       printValue(r4);
+       Key *k2 = new Key(1, 3, 3);
+       Key *k3 = new Key(2, 4, 1);
+       Key *k4 = new Key(3, 4, 2);
+       Value *v3 = new Value(30, 40, 50);
+       Value *r3 = table->put(k3, v3);
 }
 
 int user_main(int argc, char *argv[]) {
-       
        Key *k1 = new Key(3, 2, 6);
-       Key *k2 = new Key(1, 1, 1);
+       Key *k2 = new Key(1, 3, 3);
+       Key *k3 = new Key(2, 4, 1);
+       Key *k4 = new Key(3, 4, 2);
        Value *v1 = new Value(111, 111, 111);
        Value *v2 = new Value(222, 222, 222);
        thrd_t t1, t2;
        table = new HashMap;
        table->put(k1, v1);
-       table->put(k2, v2);
+       //table->put(k3, v2);
 
        thrd_create(&t1, threadA, NULL);
        thrd_create(&t2, threadB, NULL);
diff --git a/concurrent-hashmap/testcase3.cc b/concurrent-hashmap/testcase3.cc
deleted file mode 100644 (file)
index 5b54a16..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <threads.h>
-
-#ifdef WILDCARD
-#include "hashmap_wildcard.h"
-#else
-#include "hashmap.h"
-#endif
-
-HashMap *table;
-
-void printKey(Key *key) {
-       if (key)
-               printf("pos = (%d, %d, %d)\n", key->x, key->y, key->z);
-       else
-               printf("pos = NULL\n");
-}
-
-void printValue(Value *value) {
-       if (value)
-               printf("velocity = (%d, %d, %d)\n", value->vX, value->vY, value->vZ);
-       else
-               printf("velocity = NULL\n");
-}
-
-// Key(3, 2, 6) & Key(1, 3, 3) are hashed to the same slot -> 4
-// Key(1, 1, 1) & Key(3, 2, 2) are hashed to the same slot -> 0
-// Key(2, 4, 1) & Key(3, 4, 2) are hashed to the same slot -> 3
-// Key(3, 4, 5) & Key(1, 4, 3) & Key(1, 1, 6) are hashed to the same slot -> 5
-// Key(2, 4, 8) & Key(1, 3, 8) -> 9
-// Key(1, 4, 8) -> 10
-// Key(1, 3, 7) -> 8
-// Key(1, 2, 7) -> 7
-// Key(1, 2, 6) -> 6
-
-void threadA(void *arg) {
-       Key *k1 = new Key(3, 4, 5);
-       Key *k2 = new Key(1, 4, 3);
-       Key *k3 = new Key(1, 1, 6);
-       Value *v2 = new Value(10, 10, 10);
-       Value *r1 = table->put(k2, v2);
-       //printValue(r1);
-       Value *r2 = table->get(k3);
-       printf("k1 -> %d:\n", table->hashKey(k1) % table->capacity);
-       printf("k2 -> %d:\n", table->hashKey(k2) % table->capacity);
-       printf("k3 -> %d:\n", table->hashKey(k3) % table->capacity);
-       //printValue(r2);
-}
-
-void threadB(void *arg) {
-       Key *k1 = new Key(3, 4, 5);
-       Key *k2 = new Key(1, 4, 3);
-       Key *k3 = new Key(1, 1, 6);
-       Value *v3 = new Value(30, 40, 50);
-       Value *r3 = table->put(k3, v3);
-       //printValue(r3);
-       //Value *r4 = table->get(k1);
-       //printf("Thrd B:\n");
-       //printValue(r4);
-}
-
-int user_main(int argc, char *argv[]) {
-       Key *k1 = new Key(3, 4, 5);
-       Key *k2 = new Key(1, 4, 3);
-       Key *k3 = new Key(1, 1, 6);
-       //Key *k2 = new Key(1, 3, 3);
-       Value *v1 = new Value(111, 111, 111);
-       //Value *v2 = new Value(222, 222, 222);
-       thrd_t t1, t2;
-       table = new HashMap;
-       table->put(k1, v1);
-       //table->put(k2, v2);
-
-       thrd_create(&t1, threadA, NULL);
-       thrd_create(&t2, threadB, NULL);
-       thrd_join(t1);
-       thrd_join(t2);
-       
-       return 0;
-}
-
-