more implementation of scanalysis...
authorBrian Demsky <bdemsky@uci.edu>
Fri, 12 Apr 2013 08:33:34 +0000 (01:33 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Sat, 13 Apr 2013 21:03:03 +0000 (14:03 -0700)
implementation of scanalysis and printout code...  should work now

scanalysis.cc
scanalysis.h

index 6391e58..83a8227 100644 (file)
@@ -5,11 +5,13 @@
 
 SCAnalysis::SCAnalysis() {
        cvmap=new HashTable<const ModelAction *, ClockVector *, uintptr_t, 4>();
+       cycleset=new HashTable<const ModelAction *, const ModelAction *, uintptr_t, 4>();
        threadlists=new SnapVector<action_list_t>(1);
 }
 
 SCAnalysis::~SCAnalysis() {
        delete cvmap;
+       delete cycleset;
        delete threadlists;
 }
 
@@ -22,8 +24,11 @@ void SCAnalysis::print_list(action_list_t *list) {
 
        for (it = list->begin(); it != list->end(); it++) {
                const ModelAction *act = *it;
-               if (act->get_seq_number() > 0)
+               if (act->get_seq_number() > 0) {
+                       if (cycleset->contains(act))
+                               model_print("CYC");
                        act->print();
+               }
                hash = hash^(hash<<3)^((*it)->hash());
        }
        model_print("HASH %u\n", hash);
@@ -37,6 +42,13 @@ void SCAnalysis::analyze(action_list_t * actions) {
        print_list(list);
 }
 
+bool SCAnalysis::merge(ClockVector * cv, const ModelAction * act, ClockVector *cv2) {
+       if (cv2->getClock(act->get_tid())>=act->get_seq_number() && act->get_seq_number() != 0) {
+               cycleset->put(act, act);
+       }
+       return cv->merge(cv2);
+}
+
 ModelAction * SCAnalysis::getNextAction() {
        ModelAction *act=NULL;
        for(int i=0;i<=maxthreads;i++) {
@@ -107,7 +119,7 @@ bool SCAnalysis::updateConstraints(ModelAction *act) {
                                break;
                        if (write->get_location() == act->get_location()) {
                                //write is sc after act
-                               writecv->merge(actcv);
+                               merge(writecv, write, actcv);
                                changed=true;
                                break;
                        }
@@ -122,7 +134,7 @@ bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
        /* Merge in the clock vector from the write */
        const ModelAction *write=read->get_reads_from();
        ClockVector *writecv=cvmap->get(write);
-       changed|= ( writecv == NULL || cv->merge(writecv) && (*read < *write));
+       changed|= ( writecv == NULL || merge(cv, read, writecv) && (*read < *write));
 
        for(int i=0;i<=maxthreads;i++) {
                thread_id_t tid=int_to_id(i);
@@ -146,7 +158,7 @@ bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
                                 write -rf-> R =>
                                 R -sc-> write2 */
                        if (write2cv->synchronized_since(write)) {
-                               changed |= write2cv->merge(cv);
+                               changed |= merge(write2cv, write2, cv);
                        }
                
                        //looking for earliest write2 in iteration to satisfy this
@@ -154,7 +166,7 @@ bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
                                 write -rf-> R =>
                                 write2 -sc-> write */
                        if (cv->synchronized_since(write2)) {
-                               changed |= writecv == NULL || writecv->merge(write2cv);
+                               changed |= writecv == NULL || merge(writecv, write, write2cv);
                                break;
                        }
                }
@@ -183,7 +195,13 @@ void SCAnalysis::computeCV(action_list_t *list) {
                                cv = new ClockVector(lastcv, act);
                                cvmap->put(act, cv);
                        } else if ( lastcv != NULL ) {
-                                       cv->merge(lastcv);
+                               merge(cv, act, lastcv);
+                       }
+                       if (act->is_thread_join()) {
+                               Thread *joinedthr = act->get_thread_operand();
+                               ModelAction *finish = model->get_last_action(joinedthr->get_id());
+                               ClockVector *finishcv = cvmap->get(finish);
+                               changed |= (finishcv == NULL) || merge(cv, act, finishcv);
                        }
                        if (act->is_thread_join()) {
                                Thread *joinedthr = act->get_thread_operand();
index 79f78f1..f9db2db 100644 (file)
@@ -18,8 +18,10 @@ class SCAnalysis : public Trace_Analysis {
        action_list_t * generateSC(action_list_t *);
        bool processRead(ModelAction *read, ClockVector *cv);
        ModelAction * getNextAction();
+       bool merge(ClockVector * cv, const ModelAction * act, ClockVector *cv2);
        int maxthreads;
        HashTable<const ModelAction *,ClockVector *, uintptr_t, 4 > * cvmap;
+       HashTable<const ModelAction *,const ModelAction *, uintptr_t, 4 > * cycleset;
        SnapVector<action_list_t> * threadlists;
 };
 #endif