Merge demsky's SC analysis fixup
authorBrian Norris <banorris@uci.edu>
Fri, 3 May 2013 16:51:20 +0000 (09:51 -0700)
committerBrian Norris <banorris@uci.edu>
Fri, 3 May 2013 16:51:41 +0000 (09:51 -0700)
scanalysis.cc
test/sctest.c

index e6cbddc..98dd8eb 100644 (file)
@@ -30,7 +30,7 @@ void SCAnalysis::print_list(action_list_t *list) {
                                model_print("BRF ");
                        act->print();
                        if (badrfset.contains(act)) {
-                               model_print("Desired Rf: %u \n",badrfset.get(act)->get_seq_number());
+                               model_print("Desired Rf: %u \n", badrfset.get(act)->get_seq_number());
                        }
                }
                hash = hash ^ (hash << 3) ^ ((*it)->hash());
@@ -49,8 +49,8 @@ void SCAnalysis::check_rf(action_list_t *list) {
        for (action_list_t::iterator it = list->begin(); it != list->end(); it++) {
                const ModelAction *act = *it;
                if (act->is_read()) {
-                       if (act->get_reads_from()!=lastwrmap.get(act->get_location()))
-                               badrfset.put(act,lastwrmap.get(act->get_location()));
+                       if (act->get_reads_from() != lastwrmap.get(act->get_location()))
+                               badrfset.put(act, lastwrmap.get(act->get_location()));
                }
                if (act->is_write())
                        lastwrmap.put(act->get_location(), act);
@@ -58,11 +58,11 @@ void SCAnalysis::check_rf(action_list_t *list) {
 }
 
 bool SCAnalysis::merge(ClockVector *cv, const ModelAction *act, const ModelAction *act2) {
-       ClockVector * cv2=cvmap.get(act2);
-       if (cv2==NULL)
+       ClockVector *cv2 = cvmap.get(act2);
+       if (cv2 == NULL)
                return true;
        if (cv2->getClock(act->get_tid()) >= act->get_seq_number() && act->get_seq_number() != 0) {
-               cyclic=true;
+               cyclic = true;
                //refuse to introduce cycles into clock vectors
                return false;
        }
@@ -332,7 +332,7 @@ bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
                                 write -rf-> R =>
                                 write2 -sc-> write */
                        if (cv->synchronized_since(write2)) {
-                               changed |= writecv==NULL || merge(writecv, write, write2);
+                               changed |= writecv == NULL || merge(writecv, write, write2);
                                break;
                        }
                }
index 7aa4805..2ddb953 100644 (file)
@@ -8,6 +8,8 @@ atomic_int x;
 atomic_int y;
 atomic_int z;
 
+static int r1, r2, r3;
+
 static void a(void *obj)
 {
        atomic_store_explicit(&z, 1, memory_order_relaxed);
@@ -17,20 +19,20 @@ static void b(void *obj)
 {
        atomic_store_explicit(&x, 1, memory_order_relaxed);
        atomic_store_explicit(&y, 1, memory_order_relaxed);
-       int r1=atomic_load_explicit(&z, memory_order_relaxed);
+       r1=atomic_load_explicit(&z, memory_order_relaxed);
 }
 static void c(void *obj)
 {
        atomic_store_explicit(&z, 2, memory_order_relaxed);
        atomic_store_explicit(&x, 2, memory_order_relaxed);
-       int r2=atomic_load_explicit(&y, memory_order_relaxed);
+       r2=atomic_load_explicit(&y, memory_order_relaxed);
 }
 
 static void d(void *obj)
 {
        atomic_store_explicit(&z, 3, memory_order_relaxed);
        atomic_store_explicit(&y, 2, memory_order_relaxed);
-       int r3=atomic_load_explicit(&x, memory_order_relaxed);
+       r3=atomic_load_explicit(&x, memory_order_relaxed);
 }
 
 int user_main(int argc, char **argv)
@@ -51,5 +53,7 @@ int user_main(int argc, char **argv)
        thrd_join(t3);
        thrd_join(t4);
 
+       /* Check and/or print r1, r2, r3? */
+
        return 0;
 }