source: trunk/symtab/id_symbol_table.hpp @ 3028

Last change on this file since 3028 was 1929, checked in by ksherdy, 7 years ago

Updated identity symbol table.

File size: 7.6 KB
Line 
1/*
2 * id_symbol_table.hpp - Identity Symbol Table Pablo Template
3 * Created on: 18-December-2011
4 * Author: Ken Herdy
5 *
6 * BitBlock type arguments must adhere to the 'full-block invariant'
7 * and mask partial block with null bytes.
8 *
9 * Number of length groups MUST coincide with the
10 * number compiler generated length groups.
11 *
12 */
13#ifndef ID_SYMBOL_TABLE_TEMPLATE_HPP
14#define ID_SYMBOL_TABLE_TEMPLATE_HPP
15
16#include "symbol_table.hpp"
17#include "hash_table.hpp"
18#include "../lib/carryQ.hpp"
19#include "../lib/bitblock_iterator.hpp"
20#include "../lib/bitblock_scan.hpp"
21
22/* NOTE: C++ template code and Pablo generated length groups must coincide. */
23static const uint32_t LGTH_GROUPS = 17;
24
25template<class HASH_TABLE>
26IDISA_ALWAYS_INLINE void do_block(HASH_TABLE h_table, uint32_t lgth, uint8_t * raw_buffer, BitBlock * ends, uint8_t * h0, uint8_t * h1) {
27
28    int32_t spos, epos;
29    ForwardScanner<BitBlock, scanword_t> scanner(ends);
30    scanner.scan_to_next();
31    epos = scanner.get_pos();
32
33//    if(first segment block) {
34//      Buffer management ensures contiguous memory.
35//    }
36
37    uint32_t bucket;
38
39    while(epos != -1) {
40        spos = (epos - lgth);
41        bucket = h_table.get_bucket(h0, h1, spos, lgth);
42
43        cout << "Value:" << string((char *)&(raw_buffer[spos]), lgth) << endl;
44        cout << "Hash:" << bucket << endl;
45        cout << "GID:" << h_table.lookup_or_insert(bucket,&raw_buffer[spos],lgth) << endl;
46
47        epos = scanner.scan_to_next();
48    }
49
50}
51
52template<class ALLOCATOR>
53class id_symbol_table: public symbol_table {
54public:
55    id_symbol_table():h4(4096) {
56
57//      for(int lgth=1;lgth<LGTH_GROUPS;lgth++) {
58//          zero_partial(partial_offset[lgth]);
59//          //partial_offset[lgth] =0;
60//      }
61
62    }
63
64    ~id_symbol_table() {}
65
66        // Groups & groups
67        void resolve(uint8_t raw_buffer [], Markers markers [], Groups groups [], Hash hash [], uint32_t blocks, AoS_symbol symbol_ary [], const uint32_t symbols) {
68
69           // segment_size = 1;
70
71            for(uint32_t k=0;k<blocks;k++) {
72
73                /* TODO - Migrate 'do_segment to 'hash table' class. */
74        //      do_segment<hash_table<identity_strategy_t<uint8_t,1>, hash_strategy_t<1>, ALLOCATOR> >(h1, groups.starts, groups.ends_1, segment_size);
75        //      do_segment<hash_table<identity_strategy_t<uint16_t,2>, hash_strategy_t<2>, ALLOCATOR> >(h2, groups.starts, groups.ends_2, segment_size);
76        //      do_segment<hash_table<identity_strategy_t<uint16_t,3>, hash_strategy_t<3>, ALLOCATOR> >(h3, groups.starts, groups.ends_3, segment_size);
77        //      do_segment<hash_table<identity_strategy_t<uint32_t,4>, hash_strategy_t<4>, ALLOCATOR> >(h4, groups.starts, groups.ends_4, segment_size);
78
79                do_block<hash_table <identity_strategy_t<uint32_t,4>, hash_strategy_t<4>, ALLOCATOR> >(h4, 4, &raw_buffer[k*BLOCK_SIZE], &groups[k].ends_4, &raw_buffer[k*BLOCK_SIZE], &raw_buffer[k*BLOCK_SIZE]);
80
81        //      do_block<hash_table<identity_strategy_t<uint32_t,5>, hash_strategy_d, ALLOCATOR> >(h5, 5, (uint8_t *)&buffer[k], (uint8_t *)&groups[k].ends_5, (uint8_t *)&buffer[k], (uint8_t *)&buffer[k]);
82        //      do_block<hash_table<identity_strategy_t<uint32_t,5>, hash_strategy_t<5>, ALLOCATOR> >(h5, groups[k].starts, groups[k].ends_5);
83        //      do_segment<hash_table<identity_strategy_t<uint32_t,6>, hash_strategy_t<6>, ALLOCATOR> >(h6, groups.starts, groups.ends_6, segment_size);
84        //      do_segment<hash_table<identity_strategy_t<uint32_t,7>, hash_strategy_t<7>, ALLOCATOR> >(h7, groups.starts, groups.ends_7, segment_size);
85        //      do_segment<hash_table<identity_strategy_t<uint32_t,8>, hash_strategy_t<8>, ALLOCATOR> >(h8, groups.starts, groups.ends_8, segment_size);
86        //      do_segment<hash_table<identity_strategy_t<uint32_t,9>, hash_strategy_t<9>, ALLOCATOR> >(h9, groups.starts, groups.ends_9, segment_size);
87        //      do_segment<hash_table<identity_strategy_t<uint32_t,10>, hash_strategy_t<10>, ALLOCATOR> >(h10, groups.starts, groups.ends_10, segment_size);
88
89        //      do_segment<hash_table<identity_strategy_t<uint32_t,11>, hash_strategy_t<11>, ALLOCATOR> >(h11, groups.starts, groups.ends_11, segment_size);
90        //      do_segment<hash_table<identity_strategy_t<uint32_t,12>, hash_strategy_t<12>, ALLOCATOR> >(h12, groups.starts, groups.ends_12, segment_size);
91        //      do_segment<hash_table<identity_strategy_t<uint32_t,13>, hash_strategy_t<13>, ALLOCATOR> >(h13, groups.starts, groups.ends_13, segment_size);
92        //      do_segment<hash_table<identity_strategy_t<uint32_t,14>, hash_strategy_t<14>, ALLOCATOR> >(h14, groups.starts, groups.ends_14, segment_size);
93        //      do_segment<hash_table<identity_strategy_t<uint32_t,15>, hash_strategy_t<15>, ALLOCATOR> >(h15, groups.starts, groups.ends_15, segment_size);
94
95        //      do_segment<hash_table<identity_strategy_t<BitBlock,16>, hash_strategy_t<16>, ALLOCATOR> >(h16, starts, groups.ends_16, segment_size);
96        //      do_segment<hash_table<identity_strategy_d, hash_strategy_d, ALLOCATOR> >(hgte_17, starts, groups.ends_gte_17, segment_size);
97
98            }
99
100            /* Final Block */
101    }
102
103    // void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, BitBlock * hash_values, SoA_symbol & symbols) {}
104private:
105    /*
106    hash_table<1, identity_strategy_t<uint8_t,1>, hash_strategy_t<1>, ALLOCATOR> h1;
107    hash_table<2, identity_strategy_t<uint16_t,2>, hash_strategy_t<2>, ALLOCATOR> h2;
108    hash_table<3, identity_strategy_t<uint16_t,3>, hash_strategy_t<3>, ALLOCATOR> h3;
109    */
110    hash_table<identity_strategy_t<uint32_t,4>, hash_strategy_t<4>, ALLOCATOR> h4;
111
112    //hash_table<identity_strategy_t<uint32_t,5>, hash_strategy_d, ALLOCATOR> h5;
113    /*
114    hash_table<6, identity_strategy_t<uint32_t,6>, hash_strategy_d, ALLOCATOR> h6;
115    hash_table<7, identity_strategy_t<uint32_t,7>, hash_strategy_d, ALLOCATOR> h7;
116    hash_table<8, identity_strategy_t<uint32_t,8>, hash_strategy_d, ALLOCATOR> h8;
117    hash_table<9, identity_strategy_t<uint32_t,9>, hash_strategy_d, ALLOCATOR> h9;
118    hash_table<10, identity_strategy_t<uint32_t,10>, hash_strategy_d, ALLOCATOR> h10;
119
120    hash_table<11, identity_strategy_t<uint32_t,11>, hash_strategy_t<11>, ALLOCATOR> h11;
121    hash_table<12, identity_strategy_t<uint32_t,12>, hash_strategy_t<12>, ALLOCATOR> h12;
122    hash_table<13, identity_strategy_t<uint32_t,13>, hash_strategy_t<13>, ALLOCATOR> h13;
123    hash_table<14, identity_strategy_t<uint32_t,14>, hash_strategy_t<14>, ALLOCATOR> h14;
124    hash_table<15, identity_strategy_t<uint32_t,15>, hash_strategy_t<15>, ALLOCATOR> h15;
125
126    hash_table<16, identity_strategy_t<BitBlock,16>, hash_strategy_t<16>, ALLOCATOR> h16;
127    */
128    /*Default */
129    /*
130    hash_table<0, identity_strategy_d, hash_strategy_d, ALLOCATOR> hgte_17;
131    */
132
133    //int32_t partial_offset[LGTH_GROUPS+1]; /* lgth indexed array, 1,2,.. */
134};
135
136#endif // ID_SYMBOL_TABLE_TEMPLATE_HPP
137
138/*
139
1401. How do we stitch together C code and Pablo generated code.
141- Variables, starts, ends
142- Length groups
143- EOF mask
144
145*/
146
147/*
148template<class SYMBOL, class ALLOCATOR>
149class div2: public symbol_table_strategy<SYMBOL, ALLOCATOR> {
150
151public:
152    div2() {}
153    ~div2() {}
154
155    void resolve(BitBlock * buffer, BitBlock * starts, BitBlock * ends, BitBlock * hash_basis_0, BitBlock * hash_basis_1, uint32_t segment_size, AoS_symbol * symbol_ary, const uint32_t symbol_ary_size) {
156        cout << "div2 Strategy" << endl;
157    }
158    //void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, SoA_symbol & symbols);
159};
160
161template<class SYMBOL, class ALLOCATOR>
162class log2: public symbol_table_strategy<SYMBOL, ALLOCATOR> {
163
164public:
165    log2() {}
166    ~log2() {}
167
168    void resolve(BitBlock * buffer, BitBlock * starts, BitBlock * ends, BitBlock * hash_basis_0, BitBlock * hash_basis_1, uint32_t segment_size, AoS_symbol * symbol_ary, const uint32_t symbol_ary_size) {
169        cout << "log2 Strategy" << endl;
170    }
171    //void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, SoA_symbol & symbols);
172};
173*/
174
Note: See TracBrowser for help on using the repository browser.