1 #ifndef HASHSTRUCTURE_H_
2 #define HASHSTRUCTURE_H_
4 #include "mlp_runtime.h"
5 //#include "WaitingQueue.h"
8 #define bitvt unsigned long long
10 //Note READEFFECT = READBIN and WRITEEFFECT=WRITEBIN. They mean the same thing
11 //but are named differently for clarity in code.
14 #define WAITINGQUEUENOTE 2
19 #define PARENTBIN 1ULL
22 #define READY 1 //Item is ready and we haven't seen this bin before
23 #define NOTREADY 0 //Item is not ready and we haven't seen this bin before
24 #define SPECREADY (SPEC|READY) //Item is ready and we've seen this bin before
25 #define SPECNOTREADY (SPEC|NOTREADY) //Item is not ready and we've seen this bin before
32 #define RNUMBINS 131072
34 #define RH_MASK (RNUMBINS)-1
36 //Note: put resolved things at the end and unresolved at the front.
37 typedef struct BinItem_rcr {
41 //TODO keep track of record ptr here
42 struct BinItem_rcr * next;
45 typedef struct BinElement_rcr {
50 typedef struct Hashtable_rcr {
51 BinElement_rcr array[RNUMBINS];
52 // WaitingQueueBin * waitingQueue;
54 // use a different memory queue for each
55 // bin item type because the difference in
57 MemPool* memPoolWrite;
61 //Todo this is a clone of REntry, remove data fields as necessary
62 typedef struct Entry_rcr {
67 typedef struct WriteBinItem_rcr {
74 typedef struct ReadBinItem_rcr {
76 TraverserData array[RNUMREAD];
77 //We don't need a head index since if the item before it was freed, then all these would be considered ready as well.
81 extern __thread HashStructure ** allHashStructures;
83 HashStructure ** rcr_createMasterHashTableArray(int maxSize); //temporary
84 HashStructure* rcr_createHashtable(int sizeofWaitingQueue);
85 WriteBinItem_rcr* rcr_createWriteBinItem( HashStructure* htable );
86 ReadBinItem_rcr* rcr_createReadBinItem( HashStructure* htable );
87 inline int rcr_generateKey(void * ptr);
89 //Method signatures are not in their final form since I have still not decided what is the optimum amount of data
90 //to store in each entry.
92 void RESOLVE(SESEcommon *record, bitvt mask);
93 int rcr_WRITEBINCASE(HashStructure *T, int key, SESEcommon *task, struct rcrRecord *rcrrec, int index);
94 int rcr_READBINCASE(HashStructure *T, int key, SESEcommon * task, struct rcrRecord *rcrrec, int index);
96 int rcr_WTWRITEBINCASE(HashStructure *T, int key, SESEcommon *task, struct rcrRecord *rcrrec, int index);
97 int rcr_WTREADBINCASE(HashStructure *T, int key, SESEcommon * task, struct rcrRecord *rcrrec, int index);
98 int rcr_TAILREADCASE(HashStructure *T, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, struct rcrRecord *rcrrec, int index);
99 void rcr_TAILWRITECASE(HashStructure *T, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, struct rcrRecord *rcrrec, int index);
100 void rcr_RETIREHASHTABLE(HashStructure *T, SESEcommon *task, int key, BinItem_rcr *b);