Changeset 1929 for trunk


Ignore:
Timestamp:
Feb 14, 2012, 4:30:27 PM (7 years ago)
Author:
ksherdy
Message:

Updated identity symbol table.

Location:
trunk/symtab
Files:
19 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/symtab/id_symbol_table.hpp

    r1893 r1929  
    2020#include "../lib/bitblock_scan.hpp"
    2121
    22 /* NOTE: A contract on length groups contract exists between C++ code and generated Pablo code. */
     22/* NOTE: C++ template code and Pablo generated length groups must coincide. */
    2323static const uint32_t LGTH_GROUPS = 17;
    2424
    25 /* Forward Decls */
    26 //struct Markers;
    27 //struct Hash;
    28 //struct Groups;
     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) {
    2927
    30 //template<class HASH_TABLE>
    31 //void do_block(HASH_TABLE h_table, Groups gr & ends, uint32_t segment_size) {
     28    int32_t spos, epos;
     29    ForwardScanner<BitBlock, scanword_t> scanner(ends);
     30    scanner.scan_to_next();
     31    epos = scanner.get_pos();
    3232
    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 
     33//    if(first segment block) {
     34//      Buffer management ensures contiguous memory.
    4235//    }
    4336
     37    uint32_t bucket;
    4438
     39    while(epos != -1) {
     40        spos = (epos - lgth);
     41        bucket = h_table.get_bucket(h0, h1, spos, lgth);
    4542
    46 //}
     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}
    4751
    4852template<class ALLOCATOR>
    4953class id_symbol_table: public symbol_table {
    5054public:
    51     id_symbol_table() {
     55    id_symbol_table():h4(4096) {
    5256
    53         for(int lgth=1;lgth<LGTH_GROUPS;lgth++) {
    54             has_pending[lgth] = false;
    55         }
     57//      for(int lgth=1;lgth<LGTH_GROUPS;lgth++) {
     58//          zero_partial(partial_offset[lgth]);
     59//          //partial_offset[lgth] =0;
     60//      }
    5661
    5762    }
     
    6065
    6166        // 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) {
     67        void resolve(uint8_t raw_buffer [], Markers markers [], Groups groups [], Hash hash [], uint32_t blocks, AoS_symbol symbol_ary [], const uint32_t symbols) {
    6368
    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);
     69           // segment_size = 1;
    7070
    71     // TODO - GO FROM HERE - HMMM - AoS - Representation Boo!
     71            for(uint32_t k=0;k<blocks;k++) {
    7272
    73     segment_size = 1;
    74     cout << "eh" << endl;
    75     for(uint32_t blk = 0; blk<segment_size; blk++) {
     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);
    7678
    77         ForwardScanner<BitBlock, scanword_t> scanner;
     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]);
    7880
    79         print_register<BitBlock>("ends_16",groups[blk].ends_16);
     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);
    8088
    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        //      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);
    8997
    9098            }
    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);
    9899
    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 
     100            /* Final Block */
    109101    }
    110102
    111103    // void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, BitBlock * hash_values, SoA_symbol & symbols) {}
    112104private:
     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;
    113111
    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;
     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;
    119119
    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;
     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;
    125125
    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;
     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    */
    131132
    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,.. */
     133    //int32_t partial_offset[LGTH_GROUPS+1]; /* lgth indexed array, 1,2,.. */
    137134};
    138135
    139136#endif // ID_SYMBOL_TABLE_TEMPLATE_HPP
    140137
    141 /* Thesis Questions
     138/*
    142139
    1431401. How do we stitch together C code and Pablo generated code.
Note: See TracChangeset for help on using the changeset viewer.