2 * @brief Data race detection code.
8 #include "clockvector.h"
14 struct ShadowBaseTable {
15 uint64_t array[65536];
18 #define MASK16BIT 0xffff
20 void initRaceDetector();
21 void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock);
22 void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock);
26 /** Basic encoding idea:
28 * (1) points to a full record or
30 * (2) encodes the information in a 64 bit word. Encoding is as
31 * follows: lowest bit set to 1, next 8 bits are read thread id, next
32 * 23 bits are read clock vector, next 8 bites are write thread id,
33 * next 23 bits are write clock vector. */
36 modelclock_t *readClock;
40 thread_id_t writeThread;
41 modelclock_t writeClock;
44 #define INITCAPACITY 4
46 #define ISSHORTRECORD(x) ((x)&0x1)
48 #define THREADMASK 0xff
49 #define RDTHREADID(x) (((x)>>1)&THREADMASK)
50 #define READMASK 0x07fffff
51 #define READVECTOR(x) (((x)>>9)&READMASK)
53 #define WRTHREADID(x) (((x)>>32)&THREADMASK)
55 #define WRITEMASK READMASK
56 #define WRITEVECTOR(x) (((x)>>40)&WRITEMASK)
58 #define ENCODEOP(rdthread, rdtime, wrthread, wrtime) (0x1ULL | ((rdthread)<<1) | ((rdtime) << 9) | (((uint64_t)wrthread)<<32) | (((uint64_t)wrtime)<<40))
60 #define MAXTHREADID (THREADMASK-1)
61 #define MAXREADVECTOR (READMASK-1)
62 #define MAXWRITEVECTOR (WRITEMASK-1)