Ignore:
Timestamp:
Aug 10, 2018, 3:07:59 AM (11 months ago)
Author:
xwa163
Message:

lz4_grep: some bug fixing and refactor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/lz4_grep.cpp

    r6137 r6143  
    2525
    2626#include <iostream>
    27 #include <lz4/lz4_grep_generator.h>
     27#include <lz4/grep/lz4_grep_base_generator.h>
     28#include <lz4/grep/lz4_grep_bitstream_generator.h>
     29#include <lz4/grep/lz4_grep_bytestream_generator.h>
     30#include <lz4/grep/lz4_grep_swizzle_generator.h>
     31
    2832
    2933
     
    4751static cl::opt<bool> countOnly("count-only", cl::desc("Only count the match result"), cl::init(false), cl::cat(lz4GrepFlags));
    4852static cl::opt<bool> enableMultiplexing("enable-multiplexing", cl::desc("Enable CC multiplexing."), cl::init(false), cl::cat(lz4GrepFlags));
     53static cl::opt<bool> utf8CC("utf8-CC", cl::desc("Use UTF-8 Character Class."), cl::init(false), cl::cat(lz4GrepFlags));
    4954
    5055static cl::OptionCategory lz4GrepDebugFlags("LZ4 Grep Debug Flags", "lz4d debug options");
    51 static cl::opt<bool> parallelDecompression("parallel-decompression", cl::desc("Use parallel Approach for LZ4 Decompression"), cl::init(false), cl::cat(lz4GrepDebugFlags));
    5256static cl::opt<bool> swizzledDecompression("swizzled-decompression", cl::desc("Use swizzle approach for decompression"), cl::init(false), cl::cat(lz4GrepDebugFlags));
    5357static cl::opt<bool> bitStreamDecompression("bitstream-decompression", cl::desc("Use bit stream approach for decompression"), cl::init(false), cl::cat(lz4GrepDebugFlags));
    54 static cl::opt<bool> enableGather("enable-gather", cl::desc("Enable gather intrinsics"), cl::init(false), cl::cat(lz4GrepDebugFlags));
    55 static cl::opt<bool> enableScatter("enable-scatter", cl::desc("Enable scatter intrinsics"), cl::init(false), cl::cat(lz4GrepDebugFlags));
    56 static cl::opt<int> minParallelLevel("min-parallel-level", cl::desc("Mininum parallel level"), cl::init(1), cl::cat(lz4GrepDebugFlags));
    5758
    5859
     
    7879    char *fileBuffer = const_cast<char *>(mappedFile.data());
    7980    re::RE * re_ast = re::RE_Parser::parse(regexString, re::MULTILINE_MODE_FLAG);
    80     LZ4GrepGenerator g(enableMultiplexing);
     81
     82    LZ4GrepBaseGenerator* g = nullptr;
     83    if (swizzledDecompression) {
     84        g = new LZ4GrepSwizzleGenerator();
     85    } else if (bitStreamDecompression) {
     86        g = new LZ4GrepBitStreamGenerator();
     87    } else {
     88        g = new LZ4GrepByteStreamGenerator();
     89    }
     90
    8191    if (countOnly) {
    82         if (parallelDecompression) {
    83             g.generateParallelAioPipeline(re_ast, enableGather, enableScatter, minParallelLevel);
    84         } else if (swizzledDecompression) {
    85             if (enableMultiplexing) {
    86                 g.generateMultiplexingSwizzledAioPipeline(re_ast);
    87             } else {
    88                 g.generateSwizzledAioPipeline(re_ast);
    89             }
    90         } else if (bitStreamDecompression) {
    91             if (enableMultiplexing) {
    92                 g.generateMultiplexingBitStreamAioPipeline(re_ast);
    93             } else {
    94                 g.generateBitStreamAioPipeline(re_ast);
    95             }
    96         } else {
    97             if (enableMultiplexing) {
    98                 g.generateByteStreamMultiplexingAioPipeline(re_ast);
    99             } else {
    100                 g.generateAioPipeline(re_ast);
    101             }
    102         }
    103 
    104         auto main = g.getCountOnlyGrepMainFunction();
     92        g->generateCountOnlyGrepPipeline(re_ast, enableMultiplexing, utf8CC);
     93        auto main = g->getCountOnlyGrepMainFunction();
    10594        uint64_t countResult = main(fileBuffer, lz4Frame.getBlocksStart(), lz4Frame.getBlocksStart() + lz4Frame.getBlocksLength(), lz4Frame.hasBlockChecksum());
    10695        llvm::outs() << countResult << "\n";
    10796    } else {
    108         g.generateScanMatchGrepPipeline(re_ast);
    109         g.invokeScanMatchGrep(fileBuffer, lz4Frame.getBlocksStart(), lz4Frame.getBlocksStart() + lz4Frame.getBlocksLength(), lz4Frame.hasBlockChecksum());
    110 
     97        g->generateScanMatchGrepPipeline(re_ast);
     98        g->invokeScanMatchGrep(fileBuffer, lz4Frame.getBlocksStart(), lz4Frame.getBlocksStart() + lz4Frame.getBlocksLength(), lz4Frame.hasBlockChecksum());
    11199    }
    112100
     101    mappedFile.close();
     102    delete g;
    113103
    114     mappedFile.close();
    115104    return 0;
    116105}
Note: See TracChangeset for help on using the changeset viewer.