from cloned git
[predictor-hash.git] / predictorhash2.h
blobc66fc7314fef55fedf78e4b63e6cf93bd65bda7f
1 /*****************************************************/
2 /***** Same as predictorhash.h, but table is param ***/
3 /***** etrizable here ***/
4 /*****************************************************/
7 #ifndef PREDICTORHASH_H
8 #define PREDICTORHASH_H
12 #define PREDICT_TABLE_SIZE 0x1000 // 256 entry table
13 #define INDEX_MASK 0x00000FFF // 8 bit index in a 256 entry table
14 #define TAG_MASK 0x00003000 // next 6 bits for tag
15 #define TAG_SHIFT 12 // shift to bring the tag down for comparison.
16 #define HASH_SHIFT 5 // shift the prev_hash by this many bits before ORing with last_hash
18 struct predict_table_entry{
19 /*Phase prediction paper says that their predictor has
20 256 entries encompassing less than 500 bytes. This should make each entry of
21 2 bytes (a little less). How to divide this between tag and predicted id ?
23 On-line simpoint says that they have a signature table of 1024 entries. Thus
24 the phase_id can go up to 10 bits. This leaves only 6 bits for Tag ? Or did
25 they use larger table entries ?
28 // limit the size in the light of above discussion?
29 unsigned int *tag;
30 unsigned int *phase_id;
33 struct PredictorHash {
35 // how much in future we have to predict
36 unsigned int pred_future_len;
37 unsigned int kept_futur_len;
38 unsigned int kept_tag_len_bits; // in bits
39 unsigned int kept_tag_var_len; // var len. 1 ftm
40 unsigned int table_size; // in powers of two
42 // based on table size
43 unsigned int index_mask;
44 unsigned int tag_mask;
45 unsigned int tag_shift;
48 unsigned short * history;
49 unsigned int hist_head;
50 unsigned int hist_tail;
52 unsigned int *temp_kept_futur;
53 /*it shows only the num-entries. size of history = hist_len*2*2 bytes
54 * if short */
55 unsigned int history_length;
56 int largest_center;
59 // prediction table
60 // see the size : shall we limit the size ??
61 struct predict_table_entry *predict_table;
62 unsigned int prev_hash; // contains the id and num_occr of
63 // prev (before the last) phase hashed
65 unsigned int last_phase_predictions; //stats
66 unsigned int new_phase_predictions;
70 struct PredictorHash * predictor_create(
71 unsigned int hist_size
72 ,unsigned int pred_futur_len
73 ,unsigned int kept_futur_len
74 ,unsigned int kept_tag_len
75 ,unsigned int table_size
78 unsigned int calc_index_mask( unsigned int table_size);
79 unsigned int calc_tag_mask( unsigned int table_size);
80 unsigned int calc_tag_shift( unsigned int table_size);
82 unsigned int compare_two_arrays( unsigned int *a1, unsigned int *a2
83 , int len, float success_measure );
84 #endif //PREDICTORHASH_H