source: trunk/symtab/id_symbol_table.hpp @ 1893

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

Updated hash function tests. Renamed hash_util.hpp header.

File size: 7.2 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: A contract on length groups contract exists between C++ code and generated Pablo code. */
23static const uint32_t LGTH_GROUPS = 17;
24
25/* Forward Decls */
26//struct Markers;
27//struct Hash;
28//struct Groups;
29
30//template<class HASH_TABLE>
31//void do_block(HASH_TABLE h_table, Groups gr & ends, uint32_t segment_size) {
32
33//    uint8_t * raw_bytes;
34//    cout << HASH_TABLE::reflect() << endl;
35
36//    BitStreamIterator iter(ends,segment_size);
37
38//    while(*iter>0) {
39//      iter++;
40//      cout << *iter << endl;
41
42//    }
43
44
45
46//}
47
48template<class ALLOCATOR>
49class id_symbol_table: public symbol_table {
50public:
51    id_symbol_table() {
52
53        for(int lgth=1;lgth<LGTH_GROUPS;lgth++) {
54            has_pending[lgth] = false;
55        }
56
57    }
58
59    ~id_symbol_table() {}
60
61        // Groups & groups
62        void resolve(BitBlock * buffer, Markers * markers, Hash * hash, Groups * groups, uint32_t segment_size, AoS_symbol * symbol_ary, const uint32_t symbol_ary_size) {
63
64            /* TODO - Migrate 'do_segment to 'hash table' class. */
65    //  do_segment<hash_table<identity_strategy_t<uint8_t,1>, hash_strategy_t<1>, ALLOCATOR> >(h1, groups.starts, groups.ends_1, segment_size);
66    //  do_segment<hash_table<identity_strategy_t<uint16_t,2>, hash_strategy_t<2>, ALLOCATOR> >(h2, groups.starts, groups.ends_2, segment_size);
67    //  do_segment<hash_table<identity_strategy_t<uint16_t,3>, hash_strategy_t<3>, ALLOCATOR> >(h3, groups.starts, groups.ends_3, segment_size);
68    //  do_segment<hash_table<identity_strategy_t<uint32_t,4>, hash_strategy_t<4>, ALLOCATOR> >(h4, groups.starts, groups.ends_4, segment_size);
69    //  do_segment<hash_table<identity_strategy_t<uint32_t,5>, hash_strategy_t<5>, ALLOCATOR> >(h5, groups.starts, groups.ends_5, segment_size);
70
71    // TODO - GO FROM HERE - HMMM - AoS - Representation Boo!
72
73    segment_size = 1;
74    cout << "eh" << endl;
75    for(uint32_t blk = 0; blk<segment_size; blk++) {
76
77        ForwardScanner<BitBlock, scanword_t> scanner;
78
79        print_register<BitBlock>("ends_16",groups[blk].ends_16);
80
81        //if ( bitblock::any(groups[blk].ends_16) )
82        //{
83            scanner.init(&groups[blk].ends_16);
84            scanner.scan_to_next();
85            int pos = scanner.get_pos();
86            while(pos != -1) {
87                cout << pos << endl;
88                pos = scanner.scan_to_next();
89
90            }
91//      }
92    }
93    //  do_segment<hash_table<identity_strategy_t<uint32_t,6>, hash_strategy_t<6>, ALLOCATOR> >(h6, groups.starts, groups.ends_6, segment_size);
94    //  do_segment<hash_table<identity_strategy_t<uint32_t,7>, hash_strategy_t<7>, ALLOCATOR> >(h7, groups.starts, groups.ends_7, segment_size);
95    //  do_segment<hash_table<identity_strategy_t<uint32_t,8>, hash_strategy_t<8>, ALLOCATOR> >(h8, groups.starts, groups.ends_8, segment_size);
96    //  do_segment<hash_table<identity_strategy_t<uint32_t,9>, hash_strategy_t<9>, ALLOCATOR> >(h9, groups.starts, groups.ends_9, segment_size);
97    //  do_segment<hash_table<identity_strategy_t<uint32_t,10>, hash_strategy_t<10>, ALLOCATOR> >(h10, groups.starts, groups.ends_10, segment_size);
98
99    //  do_segment<hash_table<identity_strategy_t<uint32_t,11>, hash_strategy_t<11>, ALLOCATOR> >(h11, groups.starts, groups.ends_11, segment_size);
100    //  do_segment<hash_table<identity_strategy_t<uint32_t,12>, hash_strategy_t<12>, ALLOCATOR> >(h12, groups.starts, groups.ends_12, segment_size);
101    //  do_segment<hash_table<identity_strategy_t<uint32_t,13>, hash_strategy_t<13>, ALLOCATOR> >(h13, groups.starts, groups.ends_13, segment_size);
102    //  do_segment<hash_table<identity_strategy_t<uint32_t,14>, hash_strategy_t<14>, ALLOCATOR> >(h14, groups.starts, groups.ends_14, segment_size);
103    //  do_segment<hash_table<identity_strategy_t<uint32_t,15>, hash_strategy_t<15>, ALLOCATOR> >(h15, groups.starts, groups.ends_15, segment_size);
104
105    //  do_segment<hash_table<identity_strategy_t<BitBlock,16>, hash_strategy_t<16>, ALLOCATOR> >(h16, starts, groups.ends_16, segment_size);
106    //  do_segment<hash_table<identity_strategy_d, hash_strategy_d, ALLOCATOR> >(hgte_17, starts, groups.ends_gte_17, segment_size);
107
108
109    }
110
111    // void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, BitBlock * hash_values, SoA_symbol & symbols) {}
112private:
113
114    hash_table<identity_strategy_t<uint8_t,1>, hash_strategy_t<1>, ALLOCATOR> h1;
115    hash_table<identity_strategy_t<uint16_t,2>, hash_strategy_t<2>, ALLOCATOR> h2;
116    hash_table<identity_strategy_t<uint16_t,3>, hash_strategy_t<3>, ALLOCATOR> h3;
117    hash_table<identity_strategy_t<uint32_t,4>, hash_strategy_t<4>, ALLOCATOR> h4;
118    hash_table<identity_strategy_t<uint32_t,5>, hash_strategy_t<5>, ALLOCATOR> h5;
119
120    hash_table<identity_strategy_t<uint32_t,6>, hash_strategy_t<6>, ALLOCATOR> h6;
121    hash_table<identity_strategy_t<uint32_t,7>, hash_strategy_t<7>, ALLOCATOR> h7;
122    hash_table<identity_strategy_t<uint32_t,8>, hash_strategy_t<8>, ALLOCATOR> h8;
123    hash_table<identity_strategy_t<uint32_t,9>, hash_strategy_t<9>, ALLOCATOR> h9;
124    hash_table<identity_strategy_t<uint32_t,10>, hash_strategy_t<10>, ALLOCATOR> h10;
125
126    hash_table<identity_strategy_t<uint32_t,11>, hash_strategy_t<11>, ALLOCATOR> h11;
127    hash_table<identity_strategy_t<uint32_t,12>, hash_strategy_t<12>, ALLOCATOR> h12;
128    hash_table<identity_strategy_t<uint32_t,13>, hash_strategy_t<13>, ALLOCATOR> h13;
129    hash_table<identity_strategy_t<uint32_t,14>, hash_strategy_t<14>, ALLOCATOR> h14;
130    hash_table<identity_strategy_t<uint32_t,15>, hash_strategy_t<15>, ALLOCATOR> h15;
131
132    hash_table<identity_strategy_t<BitBlock,16>, hash_strategy_t<16>, ALLOCATOR> h16;
133
134    hash_table<identity_strategy_d, hash_strategy_d, ALLOCATOR> hgte_17;
135
136    bool has_pending[LGTH_GROUPS+1]; /* lgth indexed array, 1,2,.. */
137};
138
139#endif // ID_SYMBOL_TABLE_TEMPLATE_HPP
140
141/* Thesis Questions
142
1431. How do we stitch together C code and Pablo generated code.
144- Variables, starts, ends
145- Length groups
146- EOF mask
147
148*/
149
150/*
151template<class SYMBOL, class ALLOCATOR>
152class div2: public symbol_table_strategy<SYMBOL, ALLOCATOR> {
153
154public:
155    div2() {}
156    ~div2() {}
157
158    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) {
159        cout << "div2 Strategy" << endl;
160    }
161    //void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, SoA_symbol & symbols);
162};
163
164template<class SYMBOL, class ALLOCATOR>
165class log2: public symbol_table_strategy<SYMBOL, ALLOCATOR> {
166
167public:
168    log2() {}
169    ~log2() {}
170
171    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) {
172        cout << "log2 Strategy" << endl;
173    }
174    //void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, SoA_symbol & symbols);
175};
176*/
177
Note: See TracBrowser for help on using the repository browser.