Ignore:
Timestamp:
Feb 23, 2016, 9:07:05 AM (3 years ago)
Author:
lindanl
Message:

new version using the kernels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/do_grep.h

    r4904 r4939  
    99#include <string>
    1010#include <stdint.h>
    11 #include "basis_bits.h"
    12 #include "include/simd-lib/bitblock.hpp"
    13 #include "include/simd-lib/transpose.hpp"
    14 #include "include/simd-lib/bitblock_iterator.hpp"
    1511#include <re/re_cc.h>
    1612
    17 struct Output {
    18     BitBlock matches;
    19     BitBlock LF;
    20 };
    2113
    22 #if (BLOCK_SIZE == 128)
    23 #define SEGMENT_BLOCKS 7
    24 #endif
    25 
    26 #if (BLOCK_SIZE == 256)
    27 #define SEGMENT_BLOCKS 15
    28 #endif
    29 
    30 #define SEGMENT_SIZE (BLOCK_SIZE * SEGMENT_BLOCKS)
    31 
    32 
    33 #if (BLOCK_SIZE == 256)
    34 typedef BitStreamScanner<BitBlock, uint64_t, uint64_t, SEGMENT_BLOCKS> ScannerT;
    35 #endif
    36 
    37 #if (BLOCK_SIZE == 128)
    38 typedef BitStreamScanner<BitBlock, uint32_t, uint32_t, SEGMENT_BLOCKS> ScannerT;
    39 #endif
    40 
    41 typedef void (*transpose_fcn_T)(BytePack * byte_data, Basis_bits & basis_bits);
    42 typedef void (*process_block_initialize_carries_fcn)();
    43 typedef void (*process_block_fcn)(const Basis_bits & basis_bits, Output & output);
     14typedef void (*main_fcn_T)(char * byte_data, int filesize, const char* filename, uint64_t finalLineUnterminated);
    4415
    4516namespace llvm { class raw_ostream; }
     
    4819public:
    4920
    50     GrepExecutor(void * process_block_initialize_carries, void * process_block)
    51     : mCountOnlyOption(false)
    52     , mGetCodePointsOption(false)
    53     , mShowFileNameOption(false)
    54     , mShowLineNumberingOption(false)
    55     , mParsedCodePointSet(nullptr)
    56     , mTransposeFcn(reinterpret_cast<transpose_fcn_T>(&s2p_do_block))
    57     , mInitializeCarriesFcn(reinterpret_cast<process_block_initialize_carries_fcn>(process_block_initialize_carries))
    58     , mProcessBlockFcn(reinterpret_cast<process_block_fcn>(process_block)) {
     21    GrepExecutor(void * main_fnptr)
     22    : mMainFcn(reinterpret_cast<main_fcn_T>(main_fnptr)) {
    5923       
    6024    }
    61     GrepExecutor(void * s2p_fnptr, void * process_block_initialize_carries, void * process_block)
    62     : mCountOnlyOption(false)
    63     , mGetCodePointsOption(false)
    64     , mShowFileNameOption(false)
    65     , mShowLineNumberingOption(false)
    66     , mParsedCodePointSet(nullptr)
    67     , mTransposeFcn(reinterpret_cast<transpose_fcn_T>(s2p_fnptr))
    68     , mInitializeCarriesFcn(reinterpret_cast<process_block_initialize_carries_fcn>(process_block_initialize_carries))
    69     , mProcessBlockFcn(reinterpret_cast<process_block_fcn>(process_block)) {
    70        
    71     }
    72    
    73     void setCountOnlyOption(bool doCount = true) {mCountOnlyOption = doCount;}
    74     void setParseCodepointsOption() {
    75         mGetCodePointsOption = true;
    76         mParsedCodePointSet = re::makeCC();
    77     }
    78     void setShowFileNameOption(bool showF = true) {mShowFileNameOption = showF;}
    79     void setShowLineNumberOption(bool showN = true) {mShowLineNumberingOption = showN;}
    80     void setNormalizeLineBreaksOption(bool normLB = true) {mNormalizeLineBreaksOption = normLB;}
    81    
     25 
    8226    void doGrep(const std::string & fileName);
    83     re::CC * getParsedCodepoints() { return mParsedCodePointSet;}
    8427private:
    85     void write_matched_line(llvm::raw_ostream & out, const char * buffer, ssize_t line_start, ssize_t line_end);
     28   
     29    bool finalLineIsUnterminated() const;
    8630
    87     ssize_t write_matches(llvm::raw_ostream & out, const char *buffer, ssize_t first_line_start);
    88    
    89     bool finalLineIsUnterminated() const;
    90     ssize_t extract_codepoints(char * buffer, ssize_t first_line_start);
    91 
    92     bool mCountOnlyOption;
    93     bool mGetCodePointsOption;
    94     bool mShowFileNameOption;
    95     bool mShowLineNumberingOption;
    96     bool mNormalizeLineBreaksOption;
    97    
    98     re::CC * mParsedCodePointSet;
    99 
    100     transpose_fcn_T mTransposeFcn;
    101     process_block_initialize_carries_fcn mInitializeCarriesFcn;
    102     process_block_fcn mProcessBlockFcn;
     31    main_fcn_T mMainFcn;
    10332   
    10433    std::string mFileName;
    10534    size_t mFileSize;
    10635    char * mFileBuffer;
    107     ScannerT mLineBreak_scanner;
    108     ScannerT mMatch_scanner;
    109     size_t mLineNum;
    11036};
    11137
Note: See TracChangeset for help on using the changeset viewer.