Changeset 3247


Ignore:
Timestamp:
May 31, 2013, 12:29:48 PM (6 years ago)
Author:
cameron
Message:

Simplify template to count matches without scanning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/output/pablo_template.cpp

    r3022 r3247  
    134134
    135135    @decl
    136         ForwardScanner<BitBlock, ScanWord> match_scanner;
    137         ForwardScanner<BitBlock, ScanWord> line_scanner;
    138136bool line_match_found=false;
    139137
    140 
     138BitBlock match_vector = simd<1>::constant<0>();
    141139        int match_count=0;
    142140    int block_base  = 0;
     
    189187//print_register2("Matches",output.matches,128);
    190188
    191 match_scanner.init(&output.matches);
    192 line_scanner.init(&lex.LF);
    193 match_scanner.scan_to_next();
    194 line_scanner.scan_to_next();
    195 while(!(match_scanner.is_done() || line_scanner.is_done())) {
    196         if (line_scanner.get_pos()<match_scanner.get_pos()-1) {
    197                 line_match_found=false;
    198                 line_scanner.scan_to_next();
    199         } else {
    200                 if (!line_match_found) {
    201                         match_count++;
    202                         //printf("Match7 at: %d\n",match_scanner.get_pos());
    203                         line_match_found=true;
    204                 }
    205                 match_scanner.scan_to_next();
    206         }
    207 
    208 }
    209 if (!line_scanner.is_done()) {
    210         line_match_found=false;
    211 } else if (!match_scanner.is_done()) {
    212         if (!line_match_found) {
    213                 match_count++;
    214                         //printf("Match8 at: %d\n",match_scanner.get_pos());
    215                 line_match_found=true;
    216         }
    217 
    218 }
     189          if (bitblock::any(output.matches)) {
     190            if (bitblock::any(simd_and(match_vector, output.matches))) {
     191              match_count += bitblock::popcount(match_vector);
     192              match_vector = output.matches;
     193            }
     194            else {
     195              match_vector = simd_or(match_vector, output.matches);
     196            }
     197          }
     198
     199
     200
    219201
    220202//print_register2("Matches",output.matches, 128);
     
    245227                                @block_stmts
    246228//print_register2("Matches",output.matches,128);
    247 match_scanner.init(&output.matches);
    248 line_scanner.init(&lex.LF);
    249 match_scanner.scan_to_next();
    250 line_scanner.scan_to_next();
    251 while(!(match_scanner.is_done() || line_scanner.is_done())) {
    252         if (line_scanner.get_pos()<match_scanner.get_pos()-1) {
    253                 line_match_found=false;
    254                 line_scanner.scan_to_next();
    255         } else {
    256                 if (!line_match_found) {
    257                         match_count++;
    258                         //printf("Match3 at: %d\n",match_scanner.get_pos());
    259                         line_match_found=true;
    260                 }
    261                 match_scanner.scan_to_next();
    262         }
    263 
    264 }
    265 if (!line_scanner.is_done()) {
    266         line_match_found=false;
    267 } else if (!match_scanner.is_done()) {
    268         if (!line_match_found) {
    269                 match_count++;
    270                         //printf("Match5 at: %d\n",match_scanner.get_pos());
    271                 line_match_found=true;
    272         }
    273 
    274 }
     229          if (bitblock::any(output.matches)) {
     230            if (bitblock::any(simd_and(match_vector, output.matches))) {
     231              match_count += bitblock::popcount(match_vector);
     232              match_vector = output.matches;
     233            }
     234            else {
     235              match_vector = simd_or(match_vector, output.matches);
     236            }
     237          }
    275238
    276239
     
    284247//    Partial Block or Any Carry
    285248//
    286 //    Eliminatinthe @anycarry test simplifies dependencies. - RDC Nov. 6, 2012
    287 //
    288 #ifdef USE_ANY_CARRY_TEST
    289    if (remaining > 0 || @any_carry) {
    290 #endif
    291249          EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-remaining));
    292250                                s2p_do_final_block((BytePack *) &src_buffer[block_pos], basis_bits, EOF_mask);
    293251          @final_block_stmts
    294252//print_register2("Matches",output.matches,128);
    295 match_scanner.init(&output.matches);
    296 line_scanner.init(&lex.LF);
    297 match_scanner.scan_to_next();
    298 line_scanner.scan_to_next();
    299 while(!(match_scanner.is_done() || line_scanner.is_done())) {
    300         if (line_scanner.get_pos()<match_scanner.get_pos()-1) {
    301                 line_match_found=false;
    302                 line_scanner.scan_to_next();
    303         } else {
    304                 if (!line_match_found) {
    305                         match_count++;
    306                         //printf("Match at: %d\n",match_scanner.get_pos());
    307                         line_match_found=true;
    308                 }
    309                 match_scanner.scan_to_next();
    310         }
    311 
    312 }
    313 if (!line_scanner.is_done()) {
    314         line_match_found=false;
    315 } else if (!match_scanner.is_done()) {
    316         if (!line_match_found) {
    317                 match_count++;
    318                         //printf("Match2 at: %d\n",match_scanner.get_pos());
    319                 line_match_found=true;
    320         }
    321 
    322 }
    323 
    324 //print_register2("Matches",output.matches,128);
    325 #ifdef USE_ANY_CARRY_TEST
    326    }
    327 #endif
     253          match_count += bitblock::popcount(match_vector);
     254          if (bitblock::any(output.matches)) {
     255            match_count += bitblock::popcount(output.matches);
     256          }
     257
     258//print_register2("Matches",output.matches,128);
    328259
    329260    buffer_pos += chars_avail;
Note: See TracChangeset for help on using the changeset viewer.