Ignore:
Timestamp:
Feb 3, 2013, 5:09:09 PM (6 years ago)
Author:
lindanl
Message:

Name Parsing using Lookahead

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/PDF/cb_template.cpp

    r2859 r2896  
    1717#include "../../simd-lib/perflib/perfsec.h"
    1818
    19 #define BUFSIZE 1000000
     19
    2020
    2121#ifdef BUFFER_PROFILING
     
    4747static inline void s2p_do_final_block(BytePack U8[], Basis_bits & basis_bits, BitBlock EOF_mask);
    4848
    49 void do_process(FILE *infile, FILE *outfile);
     49void do_process(FILE *infile, FILE *outfile, int filesize);
     50
     51
    5052
    5153int main(int argc, char * argv[]) {
     
    8284        PERF_SEC_INIT(parser_timer);
    8385
    84         do_process(infile, outfile);
     86        do_process(infile, outfile, fileinfo.st_size+1);
    8587
    8688        PERF_SEC_DUMP(parser_timer);
     
    212214}
    213215
    214 void do_process(FILE *infile, FILE *outfile) {
    215 
    216 @decl
     216void do_process(FILE *infile, FILE *outfile, int filesize) {
     217 
     218  int BLOCKS = filesize/BLOCK_SIZE+1;
     219
     220  struct Basis_bits * basis_bits = (struct Basis_bits *)malloc(sizeof(struct Basis_bits)*BLOCKS);
     221
     222  struct Lex * lex = (struct Lex *)malloc(sizeof(struct Lex)*BLOCKS);
     223 
     224  struct Parity parity;
     225
     226  struct Escape_Callouts escape_Callouts;
     227
     228  struct Out_Callouts out_Callouts;
     229
     230  struct Marker marker;
    217231
    218232  int block_base = 0;
    219233  int chars_read = 0;
    220234  int chars_avail = 0;
    221   char srcbuf[BUFSIZE];
    222   char content_buf[BUFSIZE];
     235  char * srcbuf = (char*)malloc(filesize);
     236  char * content_buf = (char*)malloc(filesize);
    223237  char * content_buf_ptr =  content_buf;
    224238
     
    227241 
    228242
    229   chars_read = fread((void *)srcbuf, 1, BUFSIZE, infile);
     243  chars_read = fread((void *)srcbuf, 1, filesize, infile);
    230244  chars_avail = chars_read;
    231245
     
    234248
    235249    PERF_SEC_START(parser_timer);
    236 
    237 /* Full Blocks */
     250   
     251    for (int i = 0; i < BLOCKS; i++){
     252      s2p_do_block((BytePack *) &srcbuf[i*BLOCK_SIZE], basis_bits[i]);
     253      classify_bytes.do_block(basis_bits[i], lex[i]);
     254    }
     255   
     256    for (int i = 0; i < BLOCKS-1; i++){
     257      parse_Escaped.do_block(lex[i], parity, escape_Callouts, out_Callouts);
     258      parse_HexStrings.do_block(lex[i], marker, out_Callouts);
     259      parse_Names.do_block(lex[i], marker, out_Callouts,lex[i+1]);
     260      prepare_content_buffer.do_block(basis_bits[i], lex[i], escape_Callouts, out_Callouts);
     261      Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
     262    }
     263    /*final block*/
     264    EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-chars_avail));
     265    parse_Escaped.do_final_block(lex[BLOCKS-1], parity, escape_Callouts, out_Callouts, EOF_mask);
     266    parse_HexStrings.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
     267    parse_Names.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
     268    prepare_content_buffer.do_final_block(basis_bits[BLOCKS-1], lex[BLOCKS-1], escape_Callouts, out_Callouts, EOF_mask);
     269    out_Callouts.delmask |= ~EOF_mask;         
     270    Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
     271/*
     272
    238273    while (chars_avail >= BLOCK_SIZE) {
    239274          s2p_do_block((BytePack *) &srcbuf[block_base], basis_bits);
     
    243278          chars_avail -= BLOCK_SIZE;
    244279    }
    245 /*Partial Blocks*/
     280
    246281    if (chars_avail > 0 || @any_carry) {
    247282          EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-chars_avail));
     
    251286          Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
    252287    }
    253    
     288*/   
    254289    PERF_SEC_END(parser_timer, chars_read);
    255290   
Note: See TracChangeset for help on using the changeset viewer.