Ignore:
Timestamp:
Nov 15, 2011, 1:19:24 AM (8 years ago)
Author:
vla24
Message:

SymbolTable?: updated templates implementation to use BitBlockForwardIterator?. Fixed block boundary case handling for div2 grouping strategy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/SymbolTable/dictionary_pbgs_log_template.cpp

    r1666 r1684  
    2222int buffer_last;
    2323char * source;
    24 LineColTracker tracker;
    25 TagMatcher matcher;
    2624BitBlock EOF_mask = simd<1>::constant<1>();
    27 ErrorTracker error_tracker;
    28 
    2925BitBlock elem_starts;
    3026int previous_block_last_elem_start;
     
    3430PBGSLogSymbolTable pbgs_symbol_table;
    3531
    36 /* StreamScan & Post Process Declarations */
    37 //      static inline int StreamScanToFirst(ScanBlock * stream, int blk_count, int ProcessPos(int), int * error_pos_in_block)
    38 static inline int StreamScan(ScanBlock * stream, int blk_count, int ProcessPos(int), int * error_pos_in_block);
    39 
    4032@global
    4133
     
    4335static inline void s2p_do_final_block(BytePack U8[], Basis_bits & basis_bits, BitBlock EOF_mask);
    4436static inline void postprocess_do_block(Dictionary& dictionary, Hash_data hash_data);
     37
     38void do_process(FILE *infile, FILE *outfile);
     39
     40template <int L> static inline void validate_block_length_grouping(BitBlockForwardIterator & start, int block_base);
     41
    4542static inline int ScanBackwardPos(BitBlock * block, int pos);
    4643static inline int compute_hash_value (int lgth, int start);
    4744template <int L> static inline int ElemEnd_grouping(int pos, int length);
    4845template <int L> static inline int StreamScanLengthGrouping(ScanBlock * stream, int blk_count);
    49 
    50 void do_process(FILE *infile, FILE *outfile);
    5146
    5247int main(int argc, char * argv[]) {
     
    251246//    else
    252247    {
    253         gid = pbgs_symbol_table.Lookup_or_Insert_Name(source + start, hashvalue, lgth);
     248        gid = pbgs_symbol_table.Lookup_or_Insert_Name(source + start, hashvalue, lgth);
    254249    }
    255250    gids.push_back(gid);
     
    268263// L = 17, pass in bitstream for symbols length longer than 16
    269264template <int L>
    270 static inline int StreamScanLengthGrouping(ScanBlock * stream, int blk_count) {
    271     int blk;
    272     int block_pos = 0;
    273     for (blk = 0; blk < blk_count; blk++) {
    274         ScanBlock s = stream[blk];
    275         while(s) {
    276             int end_pos = cfzl(s) + block_pos;
    277             int start_pos = ScanBackwardPos (&elem_starts, end_pos);
    278             int length = end_pos - start_pos;
    279             ElemEnd_grouping<L>(start_pos, length);
    280             s = s & (s-1);  // clear rightmost bit.
    281         }
    282         block_pos += 8 * sizeof(ScanBlock);
    283     }
    284     return 0;
     265static inline void validate_block_length_grouping(BitBlockForwardIterator & start, int block_base) {
     266
     267    BitBlockForwardIterator end;
     268    int end_pos, start_pos, length;
     269
     270    while(start != end) {
     271        end_pos = /*block_base + */*start;
     272        start_pos = ScanBackwardPos (&elem_starts, end_pos);
     273        length = end_pos - start_pos;
     274        ElemEnd_grouping<L>(start_pos, length);
     275        start++;
     276    }
    285277}
    286278
    287279// pass in bitstream for symbols length 1
    288280template <>
    289 inline int StreamScanLengthGrouping<1>(ScanBlock * stream, int blk_count) {
    290     int blk;
    291     int block_pos = 0;
    292     for (blk = 0; blk < blk_count; blk++) {
    293         ScanBlock s = stream[blk];
    294         while(s) {
    295             int end_pos = cfzl(s) + block_pos;
    296             ElemEnd_grouping<1>(end_pos, 1);
    297             s = s & (s-1);  // clear rightmost bit.
    298         }
    299         block_pos += 8 * sizeof(ScanBlock);
    300     }
    301     return 0;
     281inline void validate_block_length_grouping<1>(BitBlockForwardIterator & start, int block_base) {
     282
     283    BitBlockForwardIterator end;
     284    int end_pos, start_pos, length;
     285
     286    while(start != end) {
     287        end_pos = /*block_base + */*start;
     288        start_pos = ScanBackwardPos (&elem_starts, end_pos);
     289        length = end_pos - start_pos;
     290        ElemEnd_grouping<1>(end_pos, 1);
     291        start++;
     292    }
    302293}
    303294
    304295// pass in bitstream for symbols length 2
    305296template <>
    306 inline int StreamScanLengthGrouping<2>(ScanBlock * stream, int blk_count) {
    307     int blk;
    308     int block_pos = 0;
    309     for (blk = 0; blk < blk_count; blk++) {
    310         ScanBlock s = stream[blk];
    311         while(s) {
    312             int end_pos = cfzl(s) + block_pos;
    313             ElemEnd_grouping<2>(end_pos, 2);
    314             s = s & (s-1);  // clear rightmost bit.
    315         }
    316         block_pos += 8 * sizeof(ScanBlock);
    317     }
    318     return 0;
     297inline void validate_block_length_grouping<2>(BitBlockForwardIterator & start, int block_base) {
     298
     299    BitBlockForwardIterator end;
     300    int end_pos, start_pos, length;
     301
     302    while(start != end) {
     303        end_pos = /*block_base + */*start;
     304        start_pos = ScanBackwardPos (&elem_starts, end_pos);
     305        length = end_pos - start_pos;
     306        ElemEnd_grouping<2>(end_pos, 2);
     307        start++;
     308    }
    319309}
    320310
     
    326316    if ( bitblock_has_bit(dictionary.Word_ends_1) )
    327317    {
    328         StreamScanLengthGrouping<1>((ScanBlock *) &dictionary.Word_ends_1, sizeof(BitBlock)/sizeof(ScanBlock));
     318        BitBlockForwardIterator iter_length_grouping_1(&dictionary.Word_ends_1);
     319        validate_block_length_grouping<1>(iter_length_grouping_1, block_base);
    329320    }
    330321
    331322    if ( bitblock_has_bit(dictionary.Word_ends_2) )
    332323    {
    333         StreamScanLengthGrouping<2>((ScanBlock *) &dictionary.Word_ends_2, sizeof(BitBlock)/sizeof(ScanBlock));
     324        BitBlockForwardIterator iter_length_grouping_2(&dictionary.Word_ends_2);
     325        validate_block_length_grouping<2>(iter_length_grouping_2, block_base);
    334326    }
    335327
    336328    if ( bitblock_has_bit(dictionary.Word_ends_3_to_4) )
    337329    {
    338         StreamScanLengthGrouping<4>((ScanBlock *) &dictionary.Word_ends_3_to_4, sizeof(BitBlock)/sizeof(ScanBlock));
     330        BitBlockForwardIterator iter_length_grouping_4(&dictionary.Word_ends_3_to_4);
     331        validate_block_length_grouping<4>(iter_length_grouping_4, block_base);
    339332    }
    340333
    341334    if ( bitblock_has_bit(dictionary.Word_ends_5_to_8) )
    342335    {
    343         StreamScanLengthGrouping<8>((ScanBlock *) &dictionary.Word_ends_5_to_8, sizeof(BitBlock)/sizeof(ScanBlock));
     336        BitBlockForwardIterator iter_length_grouping_8(&dictionary.Word_ends_5_to_8);
     337        validate_block_length_grouping<8>(iter_length_grouping_8, block_base);
    344338    }
    345339
    346340    if ( bitblock_has_bit(dictionary.Word_ends_9_to_16) )
    347341    {
    348         StreamScanLengthGrouping<16>((ScanBlock *) &dictionary.Word_ends_9_to_16, sizeof(BitBlock)/sizeof(ScanBlock));
     342        BitBlockForwardIterator iter_length_grouping_16(&dictionary.Word_ends_9_to_16);
     343        validate_block_length_grouping<16>(iter_length_grouping_16, block_base);
    349344    }
    350345
    351346    if ( bitblock_has_bit(dictionary.Word_ends_17_and_longer) )
    352347    {
    353         StreamScanLengthGrouping<17>((ScanBlock *) &dictionary.Word_ends_17_and_longer, sizeof(BitBlock)/sizeof(ScanBlock));
     348        BitBlockForwardIterator iter_length_grouping_remaining(&dictionary.Word_ends_17_and_longer);
     349        validate_block_length_grouping<17>(iter_length_grouping_remaining, block_base);
    354350    }
    355351
Note: See TracChangeset for help on using the changeset viewer.