source: icGREP/icgrep-devel/icgrep/do_grep.h @ 4726

Last change on this file since 4726 was 4726, checked in by cameron, 4 years ago

Embed carry data in compiled LLVM module; eliminate passing of carry data pointers/size

File size: 2.0 KB
Line 
1#ifndef DO_GREP_H
2#define DO_GREP_H
3/*
4 *  Copyright (c) 2015 International Characters.
5 *  This software is licensed to the public under the Open Software License 3.0.
6 *  icgrep is a trademark of International Characters.
7 */
8
9#include <string>
10#include <stdint.h>
11
12#include "include/simd-lib/bitblock.hpp"
13#include "include/simd-lib/transpose.hpp"
14#include "include/simd-lib/bitblock_iterator.hpp"
15
16struct Output {
17    BitBlock matches;
18    BitBlock LF;
19};
20
21#if (BLOCK_SIZE == 128)
22#define SEGMENT_BLOCKS 7
23#endif
24
25#if (BLOCK_SIZE == 256)
26#define SEGMENT_BLOCKS 15
27#endif
28
29#define SEGMENT_SIZE (BLOCK_SIZE * SEGMENT_BLOCKS)
30
31
32#if (BLOCK_SIZE == 256)
33typedef BitStreamScanner<BitBlock, uint64_t, uint64_t, SEGMENT_BLOCKS> ScannerT;
34#endif
35
36#if (BLOCK_SIZE == 128)
37typedef BitStreamScanner<BitBlock, uint32_t, uint32_t, SEGMENT_BLOCKS> ScannerT;
38#endif
39
40
41typedef void (*process_block_fcn)(const Basis_bits & basis_bits, Output & output);
42
43class GrepExecutor {
44public:
45
46    GrepExecutor(void * process_block)
47    : mCountOnlyOption(false)
48    , mShowFileNameOption(false)
49    , mShowLineNumberingOption(false)
50    , mProcessBlockFcn(reinterpret_cast<process_block_fcn>(process_block)) {
51
52    }
53         
54    void setCountOnlyOption(bool doCount = true) {mCountOnlyOption = doCount;}
55    void setShowFileNameOption(bool showF = true) {mShowFileNameOption = showF;}
56    void setShowLineNumberOption(bool showN = true) {mShowLineNumberingOption = showN;}
57    void setNormalizeLineBreaksOption(bool normLB = true) {mNormalizeLineBreaksOption = normLB;}
58   
59    void doGrep(std::string fileName);
60private:
61    ssize_t write_matches(char * buffer, ssize_t first_line_start);
62    bool finalLineIsUnterminated();
63
64    bool mCountOnlyOption;
65    bool mShowFileNameOption;
66    bool mShowLineNumberingOption;
67    bool mNormalizeLineBreaksOption;
68
69    process_block_fcn mProcessBlockFcn;
70   
71    std::string mFileName;
72    size_t mFileSize;
73    char * mFileBuffer;
74    ScannerT mLineBreak_scanner;
75    ScannerT mMatch_scanner;
76    size_t line_no;
77};
78
79
80#endif
Note: See TracBrowser for help on using the repository browser.