datarace/clockvector: switch 'clocks' to use 'unsigned int' (modelclock_t)
authorBrian Norris <banorris@uci.edu>
Fri, 6 Jul 2012 18:00:27 +0000 (11:00 -0700)
committerBrian Norris <banorris@uci.edu>
Fri, 6 Jul 2012 18:00:27 +0000 (11:00 -0700)
clockvector.cc
clockvector.h
datarace.cc
datarace.h

index 5a7c5349b3cd98ad446e0eb90189cd4b695dbbfa..e0ced522a14f88520f072248d54c7d3de9cee630 100644 (file)
@@ -88,7 +88,7 @@ bool ClockVector::synchronized_since(ModelAction *act) const
  * Gets the clock corresponding to a given thread id from the clock
  * vector. */
 
-int ClockVector::getClock(thread_id_t thread) {
+modelclock_t ClockVector::getClock(thread_id_t thread) {
        int threadid = id_to_int(thread);
 
        if (threadid < num_threads)
index f56d8d5089b28a86b368214b9b68ae5cf1feed59..82f1e3774608229f33f1379e9037e37fff5b87a2 100644 (file)
@@ -20,7 +20,7 @@ public:
        bool synchronized_since(ModelAction *act) const;
 
        void print() const;
-       int getClock(thread_id_t thread);
+       modelclock_t getClock(thread_id_t thread);
 
        MEMALLOC
 private:
index 832a220a3148796940cf2c84ba154bca5932fd9b..12a2e6bb1d60aa84a94d0e970617e703c324ecc3 100644 (file)
@@ -28,9 +28,9 @@ static uint64_t * lookupAddressEntry(void * address) {
 static void expandRecord(uint64_t * shadow) {
        uint64_t shadowval=*shadow;
 
-       int readClock = READVECTOR(shadowval);
+       modelclock_t readClock = READVECTOR(shadowval);
        thread_id_t readThread = int_to_id(RDTHREADID(shadowval));
-       int writeClock = WRITEVECTOR(shadowval);
+       modelclock_t writeClock = WRITEVECTOR(shadowval);
        thread_id_t writeThread = int_to_id(WRTHREADID(shadowval));
 
        struct RaceRecord * record=(struct RaceRecord *)calloc(1,sizeof(struct RaceRecord));
@@ -40,7 +40,7 @@ static void expandRecord(uint64_t * shadow) {
        if (readClock!=0) {
                record->capacity=INITCAPACITY;
                record->thread=(thread_id_t *) malloc(sizeof(thread_id_t)*record->capacity);
-               record->readClock=(int *) malloc(sizeof(int)*record->capacity);
+               record->readClock=(modelclock_t *) malloc(sizeof(modelclock_t)*record->capacity);
                record->numReads=1;
                record->thread[0]=readThread;
                record->readClock[0]=readClock;
@@ -58,7 +58,7 @@ void fullRaceCheckWrite(thread_id_t thread, uint64_t * shadow, ClockVector *curr
        /* Check for datarace against last read. */
 
        for(int i=0;i<record->numReads;i++) {
-               int readClock = record->readClock[i];
+               modelclock_t readClock = record->readClock[i];
                thread_id_t readThread = record->thread[i];
                
                if (readThread != thread && readClock != 0 && currClock->getClock(readThread) <= readClock) {
@@ -69,7 +69,7 @@ void fullRaceCheckWrite(thread_id_t thread, uint64_t * shadow, ClockVector *curr
        
        /* Check for datarace against last write. */
        
-       int writeClock = record->writeClock;
+       modelclock_t writeClock = record->writeClock;
        thread_id_t writeThread = record->writeThread;
        
        if (writeThread != thread && writeClock != 0 && currClock->getClock(writeThread) <= writeClock) {
@@ -79,7 +79,7 @@ void fullRaceCheckWrite(thread_id_t thread, uint64_t * shadow, ClockVector *curr
        
        record->numReads=0;
        record->writeThread=thread;
-       int ourClock = currClock->getClock(thread);
+       modelclock_t ourClock = currClock->getClock(thread);
        record->writeClock=ourClock;
 }
 
@@ -94,7 +94,7 @@ void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock)
        }
 
        int threadid = id_to_int(thread);
-       int ourClock = currClock->getClock(thread);
+       modelclock_t ourClock = currClock->getClock(thread);
        
        /* Thread ID is too large or clock is too large. */
        if (threadid > MAXTHREADID || ourClock > MAXWRITEVECTOR) {
@@ -105,7 +105,7 @@ void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock)
        
        /* Check for datarace against last read. */
 
-       int readClock = READVECTOR(shadowval);
+       modelclock_t readClock = READVECTOR(shadowval);
        thread_id_t readThread = int_to_id(RDTHREADID(shadowval));
 
        if (readThread != thread && readClock != 0 && currClock->getClock(readThread) <= readClock) {
@@ -115,7 +115,7 @@ void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock)
 
        /* Check for datarace against last write. */
 
-       int writeClock = WRITEVECTOR(shadowval);
+       modelclock_t writeClock = WRITEVECTOR(shadowval);
        thread_id_t writeThread = int_to_id(WRTHREADID(shadowval));
        
        if (writeThread != thread && writeClock != 0 && currClock->getClock(writeThread) <= writeClock) {
@@ -130,7 +130,7 @@ void fullRaceCheckRead(thread_id_t thread, uint64_t * shadow, ClockVector *currC
 
        /* Check for datarace against last write. */
        
-       int writeClock = record->writeClock;
+       modelclock_t writeClock = record->writeClock;
        thread_id_t writeThread = record->writeThread;
        
        if (writeThread != thread && writeClock != 0 && currClock->getClock(writeThread) <= writeClock) {
@@ -143,7 +143,7 @@ void fullRaceCheckRead(thread_id_t thread, uint64_t * shadow, ClockVector *currC
        int copytoindex=0;
 
        for(int i=0;i<record->numReads;i++) {
-               int readClock = record->readClock[i];
+               modelclock_t readClock = record->readClock[i];
                thread_id_t readThread = record->thread[i];
                
                if (readThread != thread && currClock->getClock(readThread) <= readClock) {
@@ -159,9 +159,9 @@ void fullRaceCheckRead(thread_id_t thread, uint64_t * shadow, ClockVector *currC
        if (copytoindex>=record->capacity) {
                int newCapacity=record->capacity*2;
                thread_id_t *newthread=(thread_id_t *) malloc(sizeof(thread_id_t)*newCapacity);
-               int * newreadClock=(int *) malloc(sizeof(int)*newCapacity);             
+               modelclock_t * newreadClock=(modelclock_t *) malloc(sizeof(modelclock_t)*newCapacity);
                std::memcpy(newthread, record->thread, record->capacity*sizeof(thread_id_t));
-               std::memcpy(newreadClock, record->readClock, record->capacity*sizeof(int));
+               std::memcpy(newreadClock, record->readClock, record->capacity*sizeof(modelclock_t));
                free(record->readClock);
                free(record->thread);
                record->readClock=newreadClock;
@@ -169,7 +169,7 @@ void fullRaceCheckRead(thread_id_t thread, uint64_t * shadow, ClockVector *currC
                record->capacity=newCapacity;
        }
 
-       int ourClock = currClock->getClock(thread);
+       modelclock_t ourClock = currClock->getClock(thread);
        
        record->thread[copytoindex]=thread;
        record->readClock[copytoindex]=ourClock;
@@ -187,7 +187,7 @@ void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock) {
        }
 
        int threadid = id_to_int(thread);
-       int ourClock = currClock->getClock(thread);
+       modelclock_t ourClock = currClock->getClock(thread);
        
        /* Thread ID is too large or clock is too large. */
        if (threadid > MAXTHREADID || ourClock > MAXWRITEVECTOR) {
@@ -198,7 +198,7 @@ void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock) {
 
        /* Check for datarace against last write. */
 
-       int writeClock = WRITEVECTOR(shadowval);
+       modelclock_t writeClock = WRITEVECTOR(shadowval);
        thread_id_t writeThread = int_to_id(WRTHREADID(shadowval));
        
        if (writeThread != thread && writeClock != 0 && currClock->getClock(writeThread) <= writeClock) {
@@ -206,7 +206,7 @@ void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock) {
                reportDataRace();
        }
        
-       int readClock = READVECTOR(shadowval);
+       modelclock_t readClock = READVECTOR(shadowval);
        thread_id_t readThread = int_to_id(RDTHREADID(shadowval));
 
        if (readThread != thread && readClock != 0 && currClock->getClock(readThread) <= readClock) {
index e3cab5d6612aeb7f5770122ad27201a5245435f1..ef1ef8ca4a256eeaede006d24c7c806fa5844103 100644 (file)
@@ -29,12 +29,12 @@ void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock);
  * next 23 bits are write clock vector.  */
 
 struct RaceRecord {
-       int *readClock;
+       modelclock_t *readClock;
        thread_id_t *thread;
        int capacity;
        int numReads;
        thread_id_t writeThread;
-       int writeClock;
+       modelclock_t writeClock;
 };
 
 #define INITCAPACITY 4