Changeset 2615


Ignore:
Timestamp:
Nov 6, 2012, 2:00:21 PM (6 years ago)
Author:
ksherdy
Message:

Updated template/Makefile for STL memory aligned vector.

Location:
proto/parabix2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/Makefile

    r2612 r2615  
    1010PABLO_TEMPLATE_LSST=pablo_template_lsst.cpp
    1111PABLO_COMPILER=../Compiler/pablomain.py
    12 PABLO_ADD_DEBUG = #-a -b
     12PABLO_ADD_DEBUG = # -a -b
    1313
    1414# LSST
     
    3535TEMP=t.tmp
    3636
    37 avx:    $(PABLO_SRC)
    38         python $(PABLO_COMPILER) $(PABLO_SRC) -t pablo_template_avx.cpp -o $(OUTFILE)
     37all: xmlwf id div2 logbase2 div2_logbase2 bit_byte
    3938
    40 all: pablo id div2 logbase2 div2_logbase2 bit_byte
    41 
    42 pablo:  $(PABLO_SRC)
    43         python $(PABLO_COMPILER) $(PABLO_SRC) -t $(PABLO_TEMPLATE) -o $(OUTFILE)
     39xmlwf:  $(PABLO_SRC)
     40        python $(PABLO_COMPILER) $(PABLO_SRC) -t $(PABLO_TEMPLATE) -o $(OUTFILE) $(PABLO_ADD_DEBUG)
    4441
    4542experimental:   $(PABLO_SRC)
    4643        python $(PABLO_COMPILER) $(PABLO_SRC) -X -t $(PABLO_TEMPLATE) -o $(OUTFILE)
    47 
    4844
    4945id: template
     
    7066#       python $(PABLO_COMPILER) $(PABLO_SRC) parabix2_pablo2.py -t pablo_template_multithreads.cpp -o $(OUTFILE)
    7167
     68avx:    $(PABLO_SRC)
     69        python $(PABLO_COMPILER) $(PABLO_SRC) -t pablo_template_avx.cpp -o $(OUTFILE)
     70
    7271pablo_help:
    7372        python  $(PABLO_COMPILER) -h
  • proto/parabix2/pablo_template.cpp

    r2613 r2615  
    44#include <sys/types.h>
    55#include <sys/stat.h>
     6
     7//#define STL_ALIGNED_VECTOR
     8#ifdef STL_ALIGNED_VECTOR // experimental, comment out TagMatcher code to use STL aligned memory vector
     9#warning "Compiling experimental STL_ALIGNED_VECTOR."
     10#include <vector>
     11#include "../lib/simd-lib/stl_aligned_allocator.hpp"
     12#endif
    613
    714#define LocalCarryDeclare(name, count)\
     
    1421#include "../lib/simd-lib/s2p.hpp"
    1522#include "../lib/simd-lib/perflib/perfsec.h"
     23#include "../lib/simd-lib/buffer.hpp"
    1624
    1725#include <xmldecl.h>
    1826#include <namechars.h>
     27#ifndef STL_ALIGNED_VECTOR
    1928#include <TagMatcher.hpp>
     29#endif
    2030#include <LineColTracker.hpp>
    2131#include <ErrorUtil.h>
     
    116126
    117127    LineColTracker tracker;
    118         TagMatcher<SEGMENT_SIZE,LOOKAHEAD_SIZE> matcher;
    119 
    120     int block_base=0;
    121         int block_pos = 0;
    122     int buffer_base=0;
    123     int buffer_pos = 0;
     128                #ifndef STL_ALIGNED_VECTOR
     129                        TagMatcher<SEGMENT_SIZE,LOOKAHEAD_SIZE> matcher;
     130                #endif
     131
     132    int block_base  = 0;
     133                int block_pos   = 0;
     134    int buffer_base = 0;
     135    int buffer_pos  = 0;
    124136    int chars_avail = 0;
    125         int chars_read = 0;
     137                int chars_read = 0;
    126138
    127139    //////////////////////////////////////////////////////////////////////////////////////////
    128140    // Buffer Management
    129141    //////////////////////////////////////////////////////////////////////////////////////////
    130         //      BitBlock buf[(BUFFER_SIZE)/sizeof(BitBlock)];
    131         //      uint8_t * src_buffer = (uint8_t *)buf + COPYBACK_SIZE;
    132 
    133         #include "../lib/simd-lib/buffer.hpp"
    134         uint8_t * COPYBACK;
    135         uint8_t * src_buffer;
    136         ALLOC_STATIC_ALIGNED_BYTE_BUFFER_WITH_COPYBACK(COPYBACK, src_buffer);
     142                //      BitBlock buf[(BUFFER_SIZE)/sizeof(BitBlock)];
     143                //      uint8_t * src_buffer = (uint8_t *)buf + COPYBACK_SIZE;
     144
     145                #ifdef STL_ALIGNED_VECTOR
     146                        std::vector<uint8_t, AAllocator<uint8_t> > src_buffer;
     147                        src_buffer.reserve(BUFFER_SIZE);
     148                #else
     149                        uint8_t * COPYBACK;
     150                        uint8_t * src_buffer;
     151                        ALLOC_STATIC_ALIGNED_BYTE_BUFFER_WITH_COPYBACK(COPYBACK, src_buffer);
     152                #endif
    137153       
    138154    //////////////////////////////////////////////////////////////////////////////////////////
    139155    // XML Validation / Content Model
    140156    //////////////////////////////////////////////////////////////////////////////////////////
    141         chars_read = fread((void *)src_buffer, 1, SEGMENT_SIZE, infile);
    142         chars_avail = chars_read;
    143         if (chars_avail >= SEGMENT_SIZE) chars_avail = SEGMENT_SIZE;
     157                chars_read = fread((void *)&src_buffer[0], 1, SEGMENT_SIZE, infile);
     158                chars_avail = chars_read;
     159                if (chars_avail >= SEGMENT_SIZE) chars_avail = SEGMENT_SIZE;
    144160
    145161    if(chars_read<4){
     
    149165
    150166    Entity_Info * e = new Entity_Info;
    151         e->AnalyzeSignature((unsigned char *)src_buffer);
     167                e->AnalyzeSignature((unsigned char *)&src_buffer[0]);
    152168
    153169    if (e->code_unit_base == ASCII) {
    154170
    155                 XML_Decl_Parser<ASCII> decl_parser((unsigned char *)src_buffer);
     171                XML_Decl_Parser<ASCII> decl_parser((unsigned char *)&src_buffer[0]);
    156172
    157173                decl_parser.ReadXMLInfo(*e);
     
    190206    // Full Segments
    191207    //////////////////////////////////////////////////////////////////////////////////////////
    192         matcher.setSrc((char *)src_buffer);
     208        #ifndef STL_ALIGNED_VECTOR
     209        matcher.setSrc((char *)&src_buffer[0]);
     210        #endif
    193211        while (chars_avail >= SEGMENT_SIZE) {
    194212      PERF_SEC_START(parser_timer);
     
    200218
    201219          tracker.StoreNewlines(lex.LF);
    202                   postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, (char *)src_buffer, buffer_base, block_base, chars_avail, tracker);
     220                  postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, (char *)&src_buffer[0], buffer_base, block_base, chars_avail, tracker);
     221                                        #ifndef STL_ALIGNED_VECTOR
    203222          matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
     223                                        #endif
    204224          tracker.AdvanceBlock();
    205225      }
     226                        #ifndef STL_ALIGNED_VECTOR
    206227      matcher.StreamScan(chars_avail);
    207228      matcher.Advance_buffer();
     229                        #endif                 
    208230      PERF_SEC_END(parser_timer, chars_avail);
    209231
    210           memmove(src_buffer, &src_buffer[SEGMENT_SIZE], LOOKAHEAD_SIZE); // CopyBack Trailing Padding
    211 
    212           // memmove(src_base, &src_buf[SEGMENT_SIZE-COPYBACK_SIZE], COPYBACK_SIZE); // Symbol Table CopyBack
     232          memmove(&src_buffer[0], &src_buffer[SEGMENT_SIZE], LOOKAHEAD_SIZE); // CopyBack Trailing Padding
     233
    213234          chars_read = fread(&src_buffer[LOOKAHEAD_SIZE], 1, SEGMENT_SIZE, infile) + LOOKAHEAD_SIZE;
    214235          chars_avail = chars_read;
     
    229250    while (remaining >= BLOCK_SIZE) {
    230251          block_base = block_pos;
    231                   s2p_do_block((BytePack *) &src_buffer[block_pos], basis_bits);
     252                                s2p_do_block((BytePack *) &src_buffer[block_pos], basis_bits);
    232253          @block_stmts
    233254          tracker.StoreNewlines(lex.LF);
    234                   postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, (char *)src_buffer, buffer_base, block_base, chars_avail, tracker);
    235                   matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
     255                                postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, (char *)&src_buffer[0], buffer_base, block_base, chars_avail, tracker);
     256                                        #ifndef STL_ALIGNED_VECTOR
     257                                                matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
     258                                        #endif
    236259          tracker.AdvanceBlock();
    237260          block_pos += BLOCK_SIZE;
     
    248271#endif
    249272          EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-remaining));
    250                   s2p_do_final_block((BytePack *) &src_buffer[block_pos], basis_bits, EOF_mask);
     273                                s2p_do_final_block((BytePack *) &src_buffer[block_pos], basis_bits, EOF_mask);
    251274          @final_block_stmts
    252275          tracker.StoreNewlines(lex.LF);
    253                   postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, (char *)src_buffer, buffer_base, block_base, chars_avail, tracker);
     276                                postprocess_do_block(lex, ctCDPI_Callouts, ref_Callouts, check_streams, (char *)&src_buffer[0], buffer_base, block_base, chars_avail, tracker);
     277                                        #ifndef STL_ALIGNED_VECTOR
    254278          matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
     279                                        #endif
    255280          tracker.AdvanceBlock();
    256281
     
    261286    buffer_pos += chars_avail;
    262287    buffer_base = buffer_pos;
    263 
     288                #ifndef STL_ALIGNED_VECTOR
    264289    matcher.StreamScan(chars_avail);
    265290    matcher.Advance_buffer();
     
    269294      exit(-1);
    270295    }
    271         PERF_SEC_END(parser_timer, chars_avail);
     296                #endif
     297                PERF_SEC_END(parser_timer, chars_avail);
    272298}
    273299
  • proto/parabix2/src/perf_script.py

    r2591 r2615  
    77testfile_home = "../../../trunk/QA/TD/"
    88#programs = ['xmlwf','expat','Xerces_SAX','Xerces_DOM']
    9 programs = ['xmlwf','id','div2','logbase2','div2_logbase2','bit_byte']
     9programs = ['xmlwf'] #,'id','div2','logbase2','div2_logbase2','bit_byte']
    1010#programs = ['xmlwf', 'id','logbase2']
    1111#programs = ['xmlwf']
Note: See TracChangeset for help on using the changeset viewer.