 Timestamp:
 Sep 14, 2011, 7:46:42 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

proto/parabix2/pablo_template.cpp
r1445 r1448 18 18 #include "xmldecl.h" 19 19 #include "namechars.h" 20 21 //#include "xml_error.c"22 //#include "xmldecl.c"23 24 20 #include "../lib/perflib/perfsec.h" 25 21 #include "../lib/s2p.h" … … 48 44 int block_base=0; 49 45 int buffer_base=0; 50 int buffer_last;51 46 char * source; 52 47 … … 56 51 BitBlock EOF_mask = simd_const_1(1); 57 52 53 /* StreamScan & Post Process Declarations */ 58 54 // static inline int StreamScanToFirst(ScanBlock * stream, int blk_count, int ProcessPos(int), int * error_pos_in_block) 59 55 static inline int StreamScan(ScanBlock * stream, int blk_count, int ProcessPos(int), int * error_pos_in_block); 56 57 static inline int NameStrt_check(int pos); 58 static inline int Name_check(int pos); 59 static inline int PIName_check(int pos); 60 static inline int CD_check(int pos); 61 static inline int GenRef_check(int pos); 62 static inline int HexRef_check(int pos); 63 static inline int DecRef_check(int pos); 64 static inline int AttRef_check(int pos); 65 66 @global 67 68 static inline void s2p_do_block(BytePack U8[], Basis_bits & basis_bits) { 69 s2p(U8[0], U8[1], U8[2], U8[3], U8[4], U8[5], U8[6], U8[7], 70 basis_bits.bit_0, basis_bits.bit_1, basis_bits.bit_2, basis_bits.bit_3, basis_bits.bit_4, basis_bits.bit_5, basis_bits.bit_6, basis_bits.bit_7); 71 } 72 73 static inline void s2p_do_final_block(BytePack U8[], Basis_bits & basis_bits, BitBlock EOF_mask) { 74 s2p_do_block(U8, basis_bits); 75 basis_bits.bit_0 = simd_and(basis_bits.bit_0, EOF_mask); 76 basis_bits.bit_1 = simd_and(basis_bits.bit_1, EOF_mask); 77 basis_bits.bit_2 = simd_and(basis_bits.bit_2, EOF_mask); 78 basis_bits.bit_3 = simd_and(basis_bits.bit_3, EOF_mask); 79 basis_bits.bit_4 = simd_and(basis_bits.bit_4, EOF_mask); 80 basis_bits.bit_5 = simd_and(basis_bits.bit_5, EOF_mask); 81 basis_bits.bit_6 = simd_and(basis_bits.bit_6, EOF_mask); 82 basis_bits.bit_7 = simd_and(basis_bits.bit_7, EOF_mask); 83 } 84 85 static inline void postprocess_do_block(Lex & lex, CtCDPI_Callouts & ctCDPI_Callouts, Ref_Callouts & ref_Callouts, Check_streams & check_streams, int chars_avail); 86 87 void do_process(FILE *infile, FILE *outfile); 88 89 int main(int argc, char * argv[]) { 90 char * infilename, * outfilename; 91 FILE *infile, *outfile; 92 struct stat fileinfo; 93 94 if (argc < 2) { 95 printf("Usage: %s <filename> [<outputfile>]\n", argv[0]); 96 exit(1); 97 } 98 99 infilename = argv[1]; 100 stat(infilename, &fileinfo); 101 infile = fopen(infilename, "rb"); 102 if (!infile) { 103 fprintf(stderr, "Error: cannot open %s for input.\n", infilename); 104 exit(1); 105 } 106 107 if (argc < 3) outfile = stdout; 108 else { 109 outfilename = argv[2]; 110 outfile = fopen(outfilename, "wb"); 111 if (!outfile) { 112 fprintf(stderr, "Error: cannot open %s for writing.\n", outfilename); 113 exit(1); 114 } 115 } 116 117 // PERF_SEC_BIND(1); 118 119 PERF_SEC_INIT(parser_timer); 120 121 do_process(infile, outfile); 122 123 PERF_SEC_DUMP(parser_timer); 124 125 PERF_SEC_DESTROY(parser_timer); 126 127 fclose(infile); 128 fclose(outfile); 129 return(0); 130 } 131 132 /* StreamScan & Post Process Definitions */ 60 133 static inline int StreamScan(ScanBlock * stream, int blk_count, int ProcessPos(int), int * error_pos_in_block) { 61 134 … … 194 267 } 195 268 196 197 198 @global199 200 static inline void s2p_do_block(BytePack U8[], Basis_bits & basis_bits) {201 s2p(U8[0], U8[1], U8[2], U8[3], U8[4], U8[5], U8[6], U8[7],202 basis_bits.bit_0, basis_bits.bit_1, basis_bits.bit_2, basis_bits.bit_3, basis_bits.bit_4, basis_bits.bit_5, basis_bits.bit_6, basis_bits.bit_7);203 }204 205 static inline void s2p_do_final_block(BytePack U8[], Basis_bits & basis_bits, BitBlock EOF_mask) {206 s2p_do_block(U8, basis_bits);207 basis_bits.bit_0 = simd_and(basis_bits.bit_0, EOF_mask);208 basis_bits.bit_1 = simd_and(basis_bits.bit_1, EOF_mask);209 basis_bits.bit_2 = simd_and(basis_bits.bit_2, EOF_mask);210 basis_bits.bit_3 = simd_and(basis_bits.bit_3, EOF_mask);211 basis_bits.bit_4 = simd_and(basis_bits.bit_4, EOF_mask);212 basis_bits.bit_5 = simd_and(basis_bits.bit_5, EOF_mask);213 basis_bits.bit_6 = simd_and(basis_bits.bit_6, EOF_mask);214 basis_bits.bit_7 = simd_and(basis_bits.bit_7, EOF_mask);215 }216 217 269 static inline void postprocess_do_block(Lex & lex, CtCDPI_Callouts & ctCDPI_Callouts, Ref_Callouts & ref_Callouts, Check_streams & check_streams, int chars_avail){ 218 270 tracker.StoreNewlines(lex.LF); … … 370 422 s2p_do_block((BytePack *) &srcbuf[block_base], basis_bits); 371 423 @block_stmts 372 424 postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, chars_avail); 373 425 } 374 426 matcher.StreamScan(chars_avail); … … 376 428 tracker.Advance_buffer(); 377 429 PERF_SEC_END(parser_timer, chars_avail); 378 430 379 431 int bytes_left = chars_read  chars_avail; 380 432 memmove(srcbuf, &srcbuf[BUFFER_SIZE], bytes_left); … … 420 472 } 421 473 } 422 423 424 425 int426 main(int argc, char * argv[]) {427 char * infilename, * outfilename;428 FILE *infile, *outfile;429 struct stat fileinfo;430 431 if (argc < 2) {432 printf("Usage: %s <filename> [<outputfile>]\n", argv[0]);433 exit(1);434 }435 436 infilename = argv[1];437 stat(infilename, &fileinfo);438 infile = fopen(infilename, "rb");439 if (!infile) {440 fprintf(stderr, "Error: cannot open %s for input.\n", infilename);441 exit(1);442 }443 444 if (argc < 3) outfile = stdout;445 else {446 outfilename = argv[2];447 outfile = fopen(outfilename, "wb");448 if (!outfile) {449 fprintf(stderr, "Error: cannot open %s for writing.\n", outfilename);450 exit(1);451 }452 }453 454 // PERF_SEC_BIND(1);455 456 PERF_SEC_INIT(parser_timer);457 458 do_process(infile, outfile);459 460 PERF_SEC_DUMP(parser_timer);461 462 PERF_SEC_DESTROY(parser_timer);463 464 fclose(infile);465 fclose(outfile);466 return(0);467 }
Note: See TracChangeset
for help on using the changeset viewer.