Changeset 42 for trunk/src


Ignore:
Timestamp:
Feb 11, 2008, 7:53:48 AM (11 years ago)
Author:
cameron
Message:

lib_simd: refactored allocation, bitstream_scan

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bitlex.c

    r40 r42  
    88
    99#include "bitlex.h"
    10 
    11 #ifdef __i386
    12 #include "../lib/sse_simd.h"
    13 #endif
    14 #ifdef _ARCH_PPC
    15 #include "../lib/altivec_simd.h"
    16 #endif
    17 
    18 #if BYTE_ORDER == BIG_ENDIAN
    19 #define sisd_sfl(blk, n) sisd_srl(blk, n)
    20 #define sisd_sbl(blk, n) sisd_sll(blk, n)
    21 #define sisd_sfli(blk, n) sisd_srli(blk, n)
    22 #define sisd_sbli(blk, n) sisd_slli(blk, n)
    23 #endif
    24 #if BYTE_ORDER == LITTLE_ENDIAN
    25 #define sisd_sfl(blk, n) sisd_sll(blk, n)
    26 #define sisd_sbl(blk, n) sisd_srl(blk, n)
    27 #define sisd_sfli(blk, n) sisd_slli(blk, n)
    28 #define sisd_sbli(blk, n) sisd_srli(blk, n)
    29 #endif
     10#include "../lib/lib_simd.h"
    3011
    3112
     
    3314        xml_buf = b;
    3415        parsing_engine_data = l;
    35         posix_memalign((void **) &x8basis, sizeof(BitBlock), BUFFER_SIZE);
     16        x8basis = (BitBlockBasis *) simd_new(BUFFER_SIZE/PACKSIZE);
    3617};
    3718
     
    450431
    451432void UTF_8_Lexer::Do_CharsetValidation() {
    452         printf("UTF_8_Lexer::Do_CharsetValidation not yet implemented; assuming OK.\n");
     433        //printf("UTF_8_Lexer::Do_CharsetValidation not yet implemented; assuming OK.\n");
    453434};
    454435
  • trunk/src/engine.c

    r37 r42  
    7171        scanner_timer = init_BOM_timer(BUFFER_BLOCKS * BLOCKSIZE);
    7272#endif
    73 /*      buf = new LexicalStreamSet;*/
    74         posix_memalign((void **) &buf, sizeof(BitBlock), sizeof(LexicalStreamSet));
    75 #ifdef DEBUG
    76         printf("parser->buf addr = %x\n", (int) buf);
    77 #endif
     73        buf = (LexicalStreamSet *) simd_new(sizeof(LexicalStreamSet)/PACKSIZE);
    7874
    7975  /* Install sentinels for every lexical item stream*/
  • trunk/src/xmlbuffer.c

    r35 r42  
    1515#include "multiliteral.h"
    1616#include "bytelex.h"
    17 #ifdef __i386
    18 #include "../lib/sse_simd.h"
    19 #endif
    20 #ifdef _ARCH_PPC
    21 #include "../lib/altivec_simd.h"
    22 #endif
    2317
    2418XML_Buffer_Interface::XML_Buffer_Interface() {}
     
    5852                exit(-1);
    5953        }
    60         int byte_stream_size = total_blocks * BLOCKSIZE + LOOKAHEAD_POSITIONS;
    61         posix_memalign((void **) &x16hi, sizeof(BytePack), byte_stream_size);
    62         posix_memalign((void **) &x16lo, sizeof(BytePack), byte_stream_size);
    63 /*
    64         x16hi = new BytePack[8*total_blocks+LOOKAHEAD_PACKS];
    65         x16lo = new BytePack[8*total_blocks+LOOKAHEAD_PACKS];
    66 */
    67 #ifdef DEBUG
    68         printf("x16hi addr = %x\n", (int) x16hi);
    69         printf("x16lo addr = %x\n", (int) x16lo);
    70 #endif
     54        x16hi = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
     55        x16lo = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
    7156}
    7257
     
    8974                exit(-1);
    9075        }
    91         int byte_stream_size = total_blocks * BLOCKSIZE + LOOKAHEAD_POSITIONS;
    92         posix_memalign((void **) &x32hh, sizeof(BytePack), byte_stream_size);
    93         posix_memalign((void **) &x32hl, sizeof(BytePack), byte_stream_size);
    94         posix_memalign((void **) &x32lh, sizeof(BytePack), byte_stream_size);
    95         posix_memalign((void **) &x32ll, sizeof(BytePack), byte_stream_size);
    96 /*      x32hh = new BytePack[8*total_blocks+LOOKAHEAD_PACKS];
    97         x32hl = new BytePack[8*total_blocks+LOOKAHEAD_PACKS];
    98         x32lh = new BytePack[8*total_blocks+LOOKAHEAD_PACKS];
    99         x32ll = new BytePack[8*total_blocks+LOOKAHEAD_PACKS];
    100 */
    101 #ifdef DEBUG
    102         printf("x32hh addr = %x\n", (int) x32hh);
    103         printf("x32hl addr = %x\n", (int) x32hl);
    104         printf("x32lh addr = %x\n", (int) x32lh);
    105         printf("x32ll addr = %x\n", (int) x32ll);
    106 #endif
     76        x32hh = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
     77        x32hl = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
     78        x32lh = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
     79        x32ll = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
    10780}
    10881
     
    143116        int total_packs = 8*total_blocks + LOOKAHEAD_PACKS;
    144117        for (int pk = 0; pk < total_packs; pk++) {
    145 /*              BytePack s0 = sisd_load_unaligned(&src_data[2*pk]);
    146                 BytePack s1 = sisd_load_unaligned(&src_data[2*pk+1]);*/
    147118                BytePack s0 = src_data[2*pk];
    148119                BytePack s1 = src_data[2*pk+1];
     
    170141        int total_packs = 8*total_blocks + LOOKAHEAD_PACKS;
    171142        for (int pk = 0; pk < total_packs; pk++) {
    172 /*              BytePack s0 = sisd_load_unaligned(&src_data[4*pk]);
    173                 BytePack s1 = sisd_load_unaligned(&src_data[4*pk+1]);
    174                 BytePack s2 = sisd_load_unaligned(&src_data[4*pk+2]);
    175                 BytePack s3 = sisd_load_unaligned(&src_data[4*pk+3]);*/
    176143                BytePack s0 = src_data[4*pk];
    177144                BytePack s1 = src_data[4*pk+1];
     
    230197void U16_Buffer::PreparePseudoASCII_Stream() {
    231198        int total_packs = 8*(buffer_bytes/2 + BLOCKSIZE - 1)/BLOCKSIZE + LOOKAHEAD_PACKS;
    232         posix_memalign((void **) &x8data, sizeof(BytePack), total_packs * PACKSIZE);
    233 /*      x8data = new BytePack[total_packs];*/
     199        x8data = simd_new(total_packs);
    234200        for (int pk = 0; pk < total_packs; pk++) {
    235201                x8data[pk] = simd_or(x16lo[pk],
     
    241207void U32_Buffer::PreparePseudoASCII_Stream() {
    242208        int total_packs = 8*(buffer_bytes/2 + BLOCKSIZE - 1)/BLOCKSIZE + LOOKAHEAD_PACKS;
    243         posix_memalign((void **) &x8data, sizeof(BytePack), total_packs * PACKSIZE);
    244 /*      x8data = new BytePack[total_packs];*/
     209        x8data = simd_new(total_packs);
    245210        for (int pk = 0; pk < total_packs; pk++) {
    246211                BytePack hi = simd_or(simd_or(x32hh[pk], x32hl[pk]), x32lh[pk]);
     
    294259XML_Buffer_Interface * XML_Buffer_Interface::BufferFactory(char* filename) {
    295260        int chars_read;
    296         BytePack * src_data;
    297261        struct stat fileinfo;
    298262        stat(filename, &fileinfo);
    299         int buffer_size = fileinfo.st_size + BUFFER_PADDING;
    300         posix_memalign((void **) &src_data, sizeof(BytePack), buffer_size);
    301 /*      src_data = new BytePack [buffer_size/PACKSIZE+1];*/
    302 #ifdef DEBUG
    303         printf("__alignof(*src_data) = %i\n", __alignof(*src_data));
    304         printf("src_data addr = %x\n", (int) src_data);
    305 #endif
     263        int buffer_packs = (fileinfo.st_size + BUFFER_PADDING + PACKSIZE - 1)/PACKSIZE;
     264        BytePack * src_data = simd_new(buffer_packs);
    306265        unsigned char * bytedata = (unsigned char *) src_data;
    307266        FILE *infile;
  • trunk/src/xmlbuffer.h

    r35 r42  
    1010
    1111#include "xmlparam.h"
    12 
    13 #ifdef __i386
    14 #include "../lib/sse_simd.h"
    15 #endif
    16 #ifdef _ARCH_PPC
    17 #include "../lib/altivec_simd.h"
    18 #endif
    19 
     12#include "../lib/lib_simd.h"
    2013
    2114/* The BytePack and the BitBlock are the two fundamental
Note: See TracChangeset for help on using the changeset viewer.