Ignore:
Timestamp:
Aug 20, 2014, 12:21:30 AM (5 years ago)
Author:
ksherdy
Message:

Added example s2k output file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/s2k/trunk/demo/grep/src/grep.cpp

    r4053 r4054  
    1 /*
     1/*
     2 * \s2k{} push model template.
     3 *
    24 * grep exact-string search C++ in \s2k{}.
    35 *
     
    7274// Runtime libraries
    7375#include <simd-lib/bitblock.hpp>
     76#include <simd-lib/bitblock_iterator.hpp>
    7477#include <simd-lib/runtime.hpp>
    7578#include <simd-lib/pabloSupport.hpp>
    76 #include <simd-lib/bitblock_iterator.hpp>
    7779#include <simd-lib/transpose.hpp>
     80#include <simd-lib/mmalloc.hpp>
    7881
    7982// C/C++ libraries
     
    8285#include <string>
    8386#include <iostream>
     87#include <sys/stat.h>
     88#include <sys/mman.h>
     89#include <fcntl.h>
    8490using namespace std;
    8591
     
    100106        BitBlock line_starts;
    101107        BitBlock line_ends;
    102 };
    103  
    104 struct Source
    105 {
    106         Source()
    107         {
    108         }
    109        
    110         IDISA_INLINE void do_block()
    111         {
    112                 carry_set_0.carryAdjust(0);
    113         }
    114        
    115         IDISA_INLINE void do_final_block(BitBlock & EOF_mask)
    116         {
    117                 carry_set_0.carryAdjust(0);
    118         }
    119        
    120         IDISA_INLINE void clear()
    121         {
    122                
    123         }
    124        
    125         DeclareRuntimeInfoSet(carry_set_0, 0, 0);
    126108};
    127109 
     
    413395};
    414396 
    415 struct Read
     397struct Bind
    416398{
    417         Read()
    418         {
    419         }
    420        
    421         IDISA_INLINE void do_block(struct Output & output)
     399        Bind()
     400        {
     401        }
     402       
     403        IDISA_INLINE void do_block()
    422404        {
    423405                carry_set_0.carryAdjust(0);
    424406        }
    425407       
    426         IDISA_INLINE void do_final_block(struct Output & output, BitBlock & EOF_mask)
     408        IDISA_INLINE void do_final_block(BitBlock & EOF_mask)
    427409        {
    428410                carry_set_0.carryAdjust(0);
     
    437419};
    438420 
    439 struct Write
    440 {
    441         Write()
    442         {
    443         }
    444        
    445         IDISA_INLINE void do_block(struct Output & output)
    446         {
    447                 carry_set_0.carryAdjust(0);
    448         }
    449        
    450         IDISA_INLINE void do_final_block(struct Output & output, BitBlock & EOF_mask)
    451         {
    452                 carry_set_0.carryAdjust(0);
    453         }
    454        
    455         IDISA_INLINE void clear()
    456         {
    457                
    458         }
    459        
    460         DeclareRuntimeInfoSet(carry_set_0, 0, 0);
     421
     422
     423// S2K Bind
     424char * buffer;
     425BitBlock * line_starts;
     426BitBlock * line_ends;
     427BitBlock * match_follows;
     428
     429struct pipeline {
     430 
     431  public:
     432 
     433  pipeline() { }
     434  ~pipeline() { }
     435
     436  void process()
     437  {
     438    int bytes_remaining = s2k::BUFFER_SIZE;
     439    int block_index     = 0;
     440     
     441      // \s2k{} bind.
     442      char * byte_data;
     443
     444      // Process blocks.
     445      while (bytes_remaining >= BLOCK_SIZE) {
     446       
     447        // \s2k{} bind.
     448        byte_data = &buffer[block_index * BLOCK_SIZE];
     449       
     450        // \s2k{} 'do_block()' calls.
     451        transpose.do_block(byte_data, basis_bits);
     452classifyBytes.do_block(basis_bits, lex);
     453match.do_block(lex, output);
     454matchLines.do_block(lex, output);
     455
     456 
     457        // \s2k{} write.
     458        match_follows[block_index]  = output.match_follows;
     459        line_starts[block_index]    = output.line_starts;
     460        line_ends[block_index]      = output.line_ends;
     461         
     462        bytes_remaining -= BLOCK_SIZE;
     463        block_index++;
     464      }   
     465
     466      // Process a partial block.
     467      BitBlock EOF_mask = bitblock::srl(simd<1>::constant<1>(),
     468                                        convert(BLOCK_SIZE - bytes_remaining));
     469
     470      // \s2k{} bind.
     471      byte_data = &buffer[block_index * BLOCK_SIZE];
     472         
     473      // \s2k{} 'do_final_block()' calls.
     474      transpose.do_final_block(byte_data, basis_bits, EOF_mask);
     475classifyBytes.do_final_block(basis_bits, lex, EOF_mask);
     476match.do_final_block(lex, output, EOF_mask);
     477matchLines.do_final_block(lex, output, EOF_mask);
     478
     479     
     480      // \s2k{} write.
     481      match_follows[block_index]  = output.match_follows & EOF_mask;
     482      line_starts[block_index]    = output.line_starts & EOF_mask;
     483      line_ends[block_index]      = output.line_ends & EOF_mask;
     484  }
     485 
     486  private:
     487
     488// S2K Generated
     489struct Basis_bits basis_bits;
     490struct Lex lex;
     491struct Output output;
     492
     493
     494// S2K Generated
     495struct Bind bind;
     496struct Transpose transpose;
     497struct ClassifyBytes classifyBytes;
     498struct Match match;
     499struct MatchLines matchLines;
     500   
     501
    461502};
    462  
    463 
    464 
    465 // Segment-at-a-time buffered stream processing parameters.
    466 const int SCANBLOCK_SIZE     = sizeof(ScanWord) * 8;
    467 const int SCANFIELD_SIZE     = sizeof(ScanWord) * 8;
    468 const int SEGMENT_BLOCKS     = SCANBLOCK_SIZE * SCANFIELD_SIZE / BLOCK_SIZE;
    469 const int SEGMENT_SIZE       = SEGMENT_BLOCKS * BLOCK_SIZE;
    470 
    471 const char * fixed_pattern   = "apple";
    472 const int pattern_size       = strlen(fixed_pattern);
     503
     504struct grep {
     505
     506  public:
     507
     508  grep():infile(NULL), outfile(stdout),
     509         pattern_size(sizeof("apple")-1),
     510         byte_offset(0),
     511         pattern_only_matching(0),
     512         line_matching(1) {
     513  }
     514 
     515  ~grep() {
     516    destroy();
     517  }
     518 
     519  void open_infile(char * infilename) {
     520
     521    fdSrc = open(infilename, O_RDONLY);
     522    if (fdSrc == -1) {
     523      fprintf(stderr, "Error: cannot open %s for processing.\n", infilename);
     524      exit(-1);
     525    }
     526   
     527    if (fstat(fdSrc, &infile_sb) == -1) {
     528      fprintf(stderr, "Error: cannot stat %s for processing.\n", infilename);
     529      exit(-1);
     530    }
     531
     532    buffer = (char *) mmap(NULL, infile_sb.st_size, PROT_READ, MAP_PRIVATE, fdSrc, 0);
     533    if (buffer == MAP_FAILED) {
     534      fprintf(stderr, "Error: mmap of %s failure.\n", infilename);
     535      exit(-1);
     536    }
     537  }
     538 
     539  void read_infile() {
     540    if((s2k::BUFFER_SIZE = infile_sb.st_size) > 0 ) {
     541      allocate();
     542    };
     543  }
     544 
     545  void open_outfile(char * outfilename) {
     546    outfile = fopen(outfilename, "wb");
     547    if (!outfile) {
     548      fprintf(stderr, "Error: cannot open %s.\n", outfilename);
     549      exit(-1);
     550    } 
     551  }
     552
     553  void close_infile() {
     554    if(infile)  { close(fdSrc); infile=NULL; }
     555  }
     556
     557  void close_outfile() {
     558    if(outfile) { fclose(outfile); outfile=NULL;}
     559  }
     560 
     561  void do_byte_offset() {
     562    byte_offset = 1;
     563  }
     564 
     565  void do_line_matching() {
     566    pattern_only_matching = 0;
     567    line_matching         = 1;
     568  }
     569 
     570  void do_pattern_only_matching() {
     571    pattern_only_matching = 1;
     572    line_matching         = 0;
     573  }
     574 
     575  void process() {
     576   
     577    // Segment-at-a-time variables
     578    int bytes_remaining = s2k::BUFFER_SIZE;
     579    int block_index     = 0;
     580    int block_base      = 0;
     581    int block_count     = ((bytes_remaining % BLOCK_SIZE) == 0)
     582                          ? (bytes_remaining/BLOCK_SIZE)
     583                          : (bytes_remaining/BLOCK_SIZE) + 1;
     584   
     585    BitBlockStreamScanner<BitBlock,ScanWord> matches_scanner;
     586    BitBlockStreamScanner<BitBlock,ScanWord> line_starts_scanner;
     587    BitBlockStreamScanner<BitBlock,ScanWord> line_ends_scanner;
     588   
     589    matches_scanner.init(match_follows, block_count);
     590    line_starts_scanner.init(line_starts, block_count);
     591    line_ends_scanner.init(line_ends, block_count);
     592     
     593    if(pattern_only_matching) {
     594      int match_offset = 0;
     595      while((match_offset = matches_scanner.scan_to_next()) > -1) {
     596        match_offset -= pattern_size;
     597        if(byte_offset) {
     598          int match_stream_offset = block_base + match_offset;
     599          fprintf(outfile, "%d:", match_stream_offset);
     600        }
     601
     602        fwrite(&buffer[match_offset], 1, pattern_size, outfile); // lookahead
     603        fprintf(outfile, "\n");
     604      }
     605    } 
     606
     607    if(line_matching) {
     608      int line_start_offset = 0;
     609      int line_end_offset = 0;
     610
     611      while( ((line_start_offset = line_starts_scanner.scan_to_next()) > -1) &&
     612             ((line_end_offset = line_ends_scanner.scan_to_next()) > -1)) {
     613
     614        if(byte_offset) {
     615          fprintf(outfile, "%d:", block_base + line_start_offset,
     616          block_base + line_end_offset);
     617        }
     618
     619        fwrite(&buffer[line_start_offset], 1,
     620               line_end_offset - line_start_offset + 1, outfile);
     621        }
     622     }
     623  }
     624 
     625  private:
     626
     627  // helpers
     628  void allocate() {
     629    int size      = (s2k::BUFFER_SIZE + BLOCK_SIZE) / BLOCK_SIZE; 
     630    line_starts   = simd_malloc<BitBlock>(size);
     631    line_ends     = simd_malloc<BitBlock>(size);
     632    match_follows = simd_malloc<BitBlock>(size);
     633  }
     634 
     635  void destroy() {
     636    simd_free<BitBlock>(line_starts);
     637    simd_free<BitBlock>(line_ends);
     638    simd_free<BitBlock>(match_follows);
     639  }
     640
     641  // members
     642  int fdSrc;
     643  struct stat infile_sb;
     644  FILE *infile, * outfile;
     645 
     646  int pattern_size;
     647  int byte_offset;
     648  int pattern_only_matching;
     649  int line_matching;
     650
     651};
    473652
    474653int main(int argc, char * argv[]) {
    475654
    476   char * infilename, * outfilename;
    477   FILE * infile, * outfile;
     655  struct pipeline pipeline;
     656  struct grep grep;
    478657
    479658  int opt_code;
    480   int byte_offset             = 0;
    481   int pattern_only_matching   = 0;
    482   int line_matching           = 1;   
    483 
    484659  while ((opt_code = getopt(argc, argv, "bo?")) != -1) {
    485660    switch (opt_code) {
    486661      case 'b':
    487         byte_offset = 1;
     662        grep.do_byte_offset();
    488663        break;
    489664      case 'o':
    490         pattern_only_matching = 1;
    491         line_matching = 0;
     665        grep.do_pattern_only_matching();
    492666        break;
    493667      case '?':
     
    497671        printf("\t-b,\tprint the byte offset with output lines\n");
    498672        printf("\t-o,\tshow only the part of a line matching PATTERN\n");
    499         printf("\t-V,\tprint version information and exit");           
     673        printf("\t-V,\tprint version information and exit");
    500674        exit(-1);
    501675    }
     
    504678  if (optind >= argc) {
    505679    printf ("Too few arguments\n");
    506     printf("Usage: %s [-c] [-v] <regex> <inputfile> [<outputfile>]\n", argv[0]);
     680    printf("Usage: %s [-b] [-o] <inputfile> [<outputfile>]\n", argv[0]);
    507681    exit(-1);
    508682  }
    509683
    510   infilename = argv[optind++];
    511   infile = fopen(infilename, "rb");
    512   if (!infile) {
    513     fprintf(stderr, "Error: cannot open %s.\n", infilename);
    514     exit(-1);
    515   }
    516 
    517   if(optind >= argc) {
    518       outfile = stdout;
    519   } else {
    520     outfilename = argv[optind++];
     684  char * infilename = argv[optind++];
     685  grep.open_infile(infilename);
     686
     687  if(!(optind >= argc)) {
     688    char * outfilename = argv[optind++];
     689    grep.open_outfile(outfilename);
     690    /*
    521691    if (optind != argc) {
    522692      printf ("Too many arguments\n");
     
    524694      exit(-1);
    525695    }
    526     outfile = fopen(outfilename, "wb");
    527     if (!outfile) {
    528       fprintf(stderr, "Error: cannot open %s.\n", outfilename);
    529       exit(-1);
    530     }
    531   }
    532 
    533   // { // ___loop_preheader___
    534 
    535 
    536 // S2K Generated
    537 struct Basis_bits basis_bits;
    538 struct Lex lex;
    539 struct Output output;
    540 
    541 
    542 // Initialize struct members
    543 basis_bits.bit_7 = simd<1>::constant<0>();
    544 basis_bits.bit_6 = simd<1>::constant<0>();
    545 basis_bits.bit_5 = simd<1>::constant<0>();
    546 basis_bits.bit_4 = simd<1>::constant<0>();
    547 basis_bits.bit_3 = simd<1>::constant<0>();
    548 basis_bits.bit_2 = simd<1>::constant<0>();
    549 basis_bits.bit_1 = simd<1>::constant<0>();
    550 basis_bits.bit_0 = simd<1>::constant<0>();
    551 
    552 lex.a = simd<1>::constant<0>();
    553 lex.p = simd<1>::constant<0>();
    554 lex.l = simd<1>::constant<0>();
    555 lex.e = simd<1>::constant<0>();
    556 lex.LF = simd<1>::constant<0>();
    557 
    558 lex.a = simd<1>::constant<0>();
    559 lex.p = simd<1>::constant<0>();
    560 lex.l = simd<1>::constant<0>();
    561 lex.e = simd<1>::constant<0>();
    562 lex.LF = simd<1>::constant<0>();
    563 
    564 output.match_follows = simd<1>::constant<0>();
    565 output.lines= simd<1>::constant<0>();
    566 output.line_starts= simd<1>::constant<0>();
    567 output.line_ends= simd<1>::constant<0>();
    568 
    569 // S2K Generated
    570 struct Transpose transpose;
    571 struct ClassifyBytes classifyBytes;
    572 struct Match match;
    573 struct MatchLines matchLines;
    574 
    575 
    576   // \s2k{} transpose.do_block() / transpose.do_final_block()
    577   // bind to `char * byte_data' and `struct Basis_bits 'basis' argument names.
    578   ATTRIBUTE_SIMD_ALIGN char buffer[SEGMENT_SIZE];
    579   char * byte_data = buffer;
    580 
    581   // Iterators
    582   BitStreamScanner<BitBlock, ScanWord, ScanWord, SEGMENT_BLOCKS> matches_scanner;
    583   BitStreamScanner<BitBlock, ScanWord, ScanWord, SEGMENT_BLOCKS> line_starts_scanner;
    584   BitStreamScanner<BitBlock, ScanWord, ScanWord, SEGMENT_BLOCKS> line_ends_scanner;
    585 
    586   // Segment-at-a-time variables
    587   int bytes_read              = 0;
    588   int bytes_avail             = 0;
    589   int bytes_remaining         = 0;
    590 
    591   int copy_back_size          = 0;
    592   int copy_back_offset        = 0;
    593 
    594   // Segment-at-a-time offset
    595   int block_index             = 0;
    596   int segment_base            = 0;
    597 
    598   // Iterator offset
    599   int match_offset            = 0;
    600   int line_start_offset       = 0;
    601   int line_end_offset         = 0;
    602 
    603   int line_final_start_offset = 0;
    604   int line_final_end_offset   = 0;
    605 
    606   // { // ___loop_preheader___
    607 
    608 
    609   while(!feof(infile)) {
    610  
    611     // __loop_header__ {
    612     block_index = 0;
    613 
    614     // initialize scanners
    615     matches_scanner.init();
    616     line_starts_scanner.init();
    617     line_ends_scanner.init(); 
    618  
    619     bytes_read      = fread(buffer + copy_back_size, 1,
    620                         SEGMENT_SIZE - copy_back_size, infile);
    621     bytes_avail     = bytes_read + copy_back_size;
    622     bytes_remaining = bytes_avail;
    623 
    624     if(ferror(infile)) { perror( "io error" ); exit(1); }
    625     // } __loop_header__
    626 
    627 
    628     // __loop_body__ {
    629    
    630     // Process full segment
    631     if (bytes_remaining == SEGMENT_SIZE) {
    632 
    633       for(block_index = 0; block_index < SEGMENT_BLOCKS; block_index++) {
    634 
    635         byte_data = &buffer[block_index * BLOCK_SIZE];
    636        
    637         // S2K Generated
    638         transpose.do_block(byte_data, basis_bits);
    639 classifyBytes.do_block(basis_bits, lex);
    640 match.do_block(lex, output);
    641 matchLines.do_block(lex, output);
    642 
    643 
    644         if(pattern_only_matching) {
    645           matches_scanner.load_block(output.match_follows, block_index);
    646         }
    647 
    648         if(line_matching) {
    649           line_starts_scanner.load_block(output.line_starts, block_index);
    650           line_ends_scanner.load_block(output.line_ends, block_index);
    651         }
    652       }
    653 
    654       if(pattern_only_matching) {
    655         while(matches_scanner.has_next()) {
    656           match_offset = matches_scanner.scan_to_next() - pattern_size;
    657           if(byte_offset) {
    658             int match_stream_offset = segment_base + match_offset;
    659             fprintf(outfile, "%d:", match_stream_offset);
    660           }
    661 
    662           fwrite(&buffer[match_offset], 1, pattern_size, outfile); // lookahead
    663           //fprintf(outfile, "%s\n", fixed_pattern);
    664           fprintf(outfile, "\n");
    665         }
    666 
    667         copy_back_size      = pattern_size + 1;
    668         copy_back_offset    = bytes_avail - copy_back_size;
    669       }
    670  
    671       if(line_matching) {
    672 
    673         assert(("Input line length exceeds segment size.",
    674           line_ends_scanner.has_next() && line_starts_scanner.has_next()));
    675         line_final_start_offset = line_starts_scanner.get_final_pos();
    676         line_final_end_offset = line_ends_scanner.get_final_pos();
    677 
    678         while(line_starts_scanner.has_next() && line_ends_scanner.has_next()) {
    679 
    680           line_start_offset  = line_starts_scanner.scan_to_next();
    681           line_end_offset    = line_ends_scanner.scan_to_next();
    682 
    683           if(byte_offset) {
    684             fprintf(outfile, "%d:", segment_base + line_start_offset);
    685           }
    686 
    687           fwrite(&buffer[line_start_offset], 1,
    688             line_end_offset - line_start_offset + 1, outfile);
    689         }
    690 
    691         copy_back_offset = (line_final_start_offset > line_final_end_offset)
    692                          ? line_final_start_offset : (line_final_end_offset + 1);
    693         copy_back_size   = bytes_avail - copy_back_offset;
    694 
    695         assert(("copy_back_offset", (copy_back_offset >= 0)));
    696         assert(("copy_back_offset", (copy_back_offset <= bytes_avail)));
    697         assert(("copy_back_size", (copy_back_size >= 0)));
    698         assert(("copy_back_size", (copy_back_size < SEGMENT_SIZE)));
    699       }
    700      
    701       bytes_remaining -= SEGMENT_SIZE;
    702     }
    703    
    704     // Process a partial segment.
    705     if(bytes_remaining > 0) {
    706 
    707       while (bytes_remaining >= BLOCK_SIZE) {
    708         byte_data = &buffer[block_index * BLOCK_SIZE];
    709        
    710         // Compiler 'do_block()' calls.
    711         transpose.do_block(byte_data, basis_bits);
    712 classifyBytes.do_block(basis_bits, lex);
    713 match.do_block(lex, output);
    714 matchLines.do_block(lex, output);
    715 
    716  
    717         if(pattern_only_matching) {
    718           matches_scanner.load_block(output.match_follows, block_index);
    719         }       
    720        
    721         if(line_matching) {
    722           line_starts_scanner.load_block(output.line_starts, block_index);
    723           line_ends_scanner.load_block(output.line_ends, block_index);
    724         }
    725  
    726         bytes_remaining -= BLOCK_SIZE;
    727         block_index++;
    728        }   
    729 
    730        // Process a partial block.
    731        BitBlock EOF_mask = bitblock::srl(simd<1>::constant<1>(),
    732                                         convert(BLOCK_SIZE - bytes_remaining));
    733        byte_data = &buffer[block_index * BLOCK_SIZE];
    734          
    735        // Compiler 'do_final_block()' calls.
    736        transpose.do_final_block(byte_data, basis_bits, EOF_mask);
    737 classifyBytes.do_final_block(basis_bits, lex, EOF_mask);
    738 match.do_final_block(lex, output, EOF_mask);
    739 matchLines.do_final_block(lex, output, EOF_mask);
    740 
    741        
    742        if(pattern_only_matching) {
    743           matches_scanner.load_block(output.match_follows & EOF_mask, block_index);
    744        }
    745 
    746        if(line_matching) {   
    747          line_starts_scanner.load_block(output.line_starts & EOF_mask, block_index);
    748          line_ends_scanner.load_block(output.line_ends & EOF_mask, block_index);           
    749        }
    750  
    751        if(pattern_only_matching) {
    752          while(matches_scanner.has_next()) {
    753            match_offset = matches_scanner.scan_to_next() - pattern_size;
    754            if(byte_offset) {
    755              int match_stream_offset = segment_base + match_offset;
    756              fprintf(outfile, "%d:", match_stream_offset);
    757            }
    758 
    759            fwrite(&buffer[match_offset], 1, pattern_size, outfile); // lookahead
    760            fprintf(outfile, "\n");
    761          }
    762    
    763           copy_back_size      = pattern_size + 1;
    764           copy_back_offset    = bytes_avail - copy_back_size;
    765        }
    766        
    767        if(line_matching) {
    768          assert(("Input line exceeds segment size.",
    769                   line_ends_scanner.has_next() &&
    770                   line_starts_scanner.has_next()));
    771          line_final_start_offset = line_starts_scanner.get_final_pos();
    772          line_final_end_offset = line_ends_scanner.get_final_pos();
    773        
    774         while(line_starts_scanner.has_next() && line_ends_scanner.has_next()) {
    775           line_start_offset  = line_starts_scanner.scan_to_next();
    776           line_end_offset    = line_ends_scanner.scan_to_next();
    777    
    778           if(byte_offset) {
    779             fprintf(outfile, "%d:", segment_base + line_start_offset,
    780                      segment_base + line_end_offset);
    781           }
    782    
    783           fwrite(&buffer[line_start_offset], 1,
    784                  line_end_offset - line_start_offset + 1, outfile);
    785         }
    786    
    787         copy_back_offset   = (line_final_start_offset > line_final_end_offset)
    788                               ? line_final_start_offset
    789                               : (line_final_end_offset + 1);
    790                              
    791         copy_back_size     = bytes_avail - copy_back_offset;
    792    
    793         assert(("copy_back_offset", (copy_back_offset >= 0)));
    794         assert(("copy_back_offset", (copy_back_offset <= bytes_avail)));
    795         assert(("copy_back_size", (copy_back_size >= 0)));
    796         assert(("copy_back_size", (copy_back_size < SEGMENT_SIZE)));           
    797       }
    798     }
    799 
    800 
    801     // __loop_tail__ {
    802     // S2K Generated 'clear()' calls.
    803     transpose.clear();
    804 classifyBytes.clear();
    805 match.clear();
    806 matchLines.clear();
    807 
    808 
    809     memmove(&buffer[0], &buffer[copy_back_offset], copy_back_size);
    810 
    811     // segment_base()
    812     segment_base += bytes_avail;
    813     segment_base -= copy_back_size;
    814     // } __loop_tail__
    815 
    816 
    817   }
    818 
    819 
    820   // __loop_exit__ {
    821   if(infile) { fclose(infile); infile=NULL;}
    822   if(outfile) { fclose(outfile); outfile=NULL;}
    823   // } __loop_exit__
    824 
    825 
     696    */
     697  }
     698
     699  grep.read_infile();
     700  pipeline.process();
     701  grep.process();
     702  grep.close_infile();
     703  grep.close_outfile();
     704 
    826705  return 0;
    827706}
    828 
    829 
    830 
    831 
    832 
    833 
    834 
    835 
    836 
    837 
    838 
    839 
    840 
    841 
    842 
    843 
    844 
    845 
    846 
    847 
    848 
    849 
    850 
    851 
    852 
    853 
    854 
    855 
    856 
    857 /*
    858  * Segment-at-a-time Processing Issues:
    859  *
    860  * 1. Start-of-stream or equivalently start-of-segment clear()...
    861  *    The ScanTo and EOF_mask processing ensure a 'fence post' at the
    862  *    end of each segment as well as at the end of file.
    863  *
    864  * 'grep.py' and 'grep_template.cpp' are tightly coupled on a number of variables:
    865  *
    866  * 1. Tranpose.do_block expects 'byte_data' and 'basis_bits'.
    867  * 2. All StreamFunction.do_final_block methods expect 'EOF_mask'.
    868  * 3. Sequential iterators (scanners) expect 'output.matches'.
    869  * 4. Sequential iterators (scanners) expect 'lex.LF'.
    870  *
    871  */
Note: See TracChangeset for help on using the changeset viewer.