Changeset 6143


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

lz4_grep: some bug fixing and refactor

Location:
icGREP/icgrep-devel/icgrep
Files:
9 added
4 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r6137 r6143  
    103103add_library(UCDlib UCD/CaseFolding.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp)
    104104add_library(GrepEngine  ${GREP_CORE_SRC} grep/grep_engine.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/charclasses.cpp kernels/streams_merge.cpp kernels/until_n.cpp kernels/UCD_property_kernel.cpp kernels/grapheme_kernel.cpp)
    105 add_library(LZ4_Lib lz4/lz4_frame_decoder.cpp kernels/cc_kernel.cpp kernels/pdep_kernel.cpp lz4/lz4_decompression_generator.cpp kernels/lz4/lz4_block_decoder.cpp kernels/bitstream_pdep_kernel.cpp kernels/bitstream_gather_pdep_kernel.cpp kernels/swizzled_multiple_pdep_kernel.cpp kernels/fake_stream_generating_kernel.cpp kernels/lz4/decompression/lz4_bytestream_decompression.cpp kernels/lz4/decompression/lz4_swizzled_decompression.cpp kernels/lz4/decompression/lz4_parallel_bytestream_decompression.cpp kernels/lz4/decompression/lz4_sequential_decompression_base.cpp kernels/lz4/decompression/lz4_bitstream_decompression.cpp kernels/lz4/decompression/lz4_twist_decompression.cpp kernels/lz4/twist_kernel.cpp kernels/lz4/untwist_kernel.cpp lz4/lz4_base_generator.cpp)
     105add_library(LZ4_Lib lz4/lz4_frame_decoder.cpp kernels/cc_kernel.cpp kernels/pdep_kernel.cpp lz4/lz4_decompression_generator.cpp kernels/lz4/lz4_block_decoder.cpp kernels/bitstream_pdep_kernel.cpp kernels/bitstream_gather_pdep_kernel.cpp kernels/swizzled_multiple_pdep_kernel.cpp kernels/fake_stream_generating_kernel.cpp kernels/lz4/decompression/lz4_bytestream_decompression.cpp kernels/lz4/decompression/lz4_swizzled_decompression.cpp kernels/lz4/decompression/lz4_sequential_decompression_base.cpp kernels/lz4/decompression/lz4_bitstream_decompression.cpp kernels/lz4/decompression/lz4_twist_decompression.cpp kernels/lz4/twist_kernel.cpp kernels/lz4/untwist_kernel.cpp lz4/lz4_base_generator.cpp)
    106106add_library(LZParabix_Lib lzparabix/LZParabixGenerator.cpp kernels/lzparabix/decoder/LZParabixBlockDecoder.cpp kernels/lzparabix/decoder/LZParabixAioBaseKernel.cpp lzparabix/LZParabixGrepGenerator.cpp kernels/fake_stream_generating_kernel.cpp kernels/lzparabix/encoder/LZParabixCompressionKernel.cpp kernels/lzparabix/decoder/LZParabixLiteralDecoderKernel.cpp kernels/lzparabix/decoder/LZParabixBitStreamAioKernel.cpp kernels/lzparabix/decoder/LZParabixSwizzledAioKernel.cpp)
    107107
     
    130130add_executable(character_deposit character_deposit.cpp kernels/cc_kernel.cpp kernels/pdep_kernel.cpp kernels/bitstream_pdep_kernel.cpp)
    131131add_executable(lz4_decoder lz4_decoder.cpp)
    132 add_executable(lz4_grep grep_interface.cpp util/file_select.cpp lz4_grep.cpp lz4/lz4_grep_generator.cpp)
     132add_executable(lz4_grep grep_interface.cpp util/file_select.cpp lz4_grep.cpp lz4/grep/lz4_grep_base_generator.cpp lz4/grep/lz4_grep_bytestream_generator.cpp lz4/grep/lz4_grep_bytestream_generator.h lz4/grep/lz4_grep_bitstream_generator.cpp lz4/grep/lz4_grep_bitstream_generator.h lz4/grep/lz4_grep_swizzle_generator.cpp lz4/grep/lz4_grep_swizzle_generator.h)
    133133add_executable(lzparabix_decoder lzparabix_decoder.cpp)
    134134add_executable(lzparabix_grep lzparabix_grep.cpp grep_interface.cpp util/file_select.cpp)
  • icGREP/icgrep-devel/icgrep/kernels/lz4/decompression/lz4_twist_decompression.cpp

    r6136 r6143  
    2828    {
    2929        mStreamSetInputs.push_back(Binding{b->getStreamSetTy(1, twistWidth), "inputTwistStream", RateEqualTo("byteStream")});
     30//        mStreamSetInputs.push_back(Binding{b->getStreamSetTy(1, twistWidth), "refTwistStream"});
    3031        mStreamSetOutputs.push_back(Binding{b->getStreamSetTy(1, twistWidth), "outputTwistStream", BoundedRate(0, 1)});
    3132
    3233        this->addScalar(b->getInt8PtrTy(), "temporaryInputPtr");
     34        this->addScalar(b->getInt8PtrTy(), "temporaryOutputPtr");
    3335    }
    3436
     
    4143        Constant* SIZE_ITEMS_PER_BYTE = b->getSize(mItemsPerByte);
    4244        Constant* INT_FW_TWIST_WIDTH = b->getIntN(COPY_FW, mTwistWidth);
    43         Type* INT8_PTR_TY = b->getInt8PtrTy();
    4445        Type* INT_FW_TY = b->getIntNTy(COPY_FW);
    4546        Type* INT_FW_PTR_TY = INT_FW_TY->getPointerTo();
     
    5556        Value* initInputPtr = b->CreateGEP(temporayInputPtr, initInputOffset);
    5657
    57         Value* outputByteBasePtr = b->CreatePointerCast(b->getRawOutputPointer("outputTwistStream", SIZE_0), INT8_PTR_TY);
     58
     59        Value* outputByteBasePtr = b->getScalarField("temporaryOutputPtr");
    5860        Value* outputPos = b->getScalarField("outputPos");
    59         Value* outputCapacity = b->getCapacity("outputTwistStream");
    60 
    61         Value* outputPosRem = b->CreateURem(outputPos, outputCapacity);
     61
     62        Value* outputPosRem = b->CreateSub(outputPos, b->getProducedItemCount("outputTwistStream"));
    6263        Value* outputPosByteRem = b->CreateUDiv(outputPosRem, SIZE_ITEMS_PER_BYTE);
    6364
     
    6970        Value* outputPosRemByteItem = b->CreateURem(outputPos, SIZE_ITEMS_PER_BYTE);
    7071        Value* outputMask = this->getOutputMask(b, outputPos);
    71 
    7272
    7373        // ---- EntryBlock
     
    9595        BasicBlock* literalCopyExit = b->CreateBasicBlock("literalCopyExit");
    9696
     97
    9798        b->CreateCondBr(b->CreateICmpULT(phiCopiedLength, literalLength), literalCopyBody, literalCopyExit);
    9899
     
    103104        Value* outputFwPtr = b->CreatePointerCast(phiOutputPtr, INT_FW_PTR_TY);
    104105
     106
    105107        Value* inputTargetValue = b->CreateLoad(inputFwPtr);
     108
     109
    106110        inputTargetValue = b->CreateLShr(inputTargetValue, b->CreateMul(literalStartRemByteItem, INT_FW_TWIST_WIDTH));
    107111        inputTargetValue = b->CreateShl(inputTargetValue, b->CreateMul(outputPosRemByteItem, INT_FW_TWIST_WIDTH));
     
    111115
    112116        Value* outputValue = b->CreateAnd(phiOutputLastByte, outputMask);
     117
    113118        outputValue = b->CreateOr(outputValue, inputTargetValue);
     119
    114120        b->CreateStore(outputValue, outputFwPtr);
    115 
    116121
    117122        phiOutputLastByte->addIncoming(b->CreateLShr(outputValue, b->getSize(this->getNormalCopyLength() * mTwistWidth)), b->GetInsertBlock());
     
    124129        // ---- literalCopyExit
    125130        b->SetInsertPoint(literalCopyExit);
     131
     132
    126133        b->setScalarField("outputPos", b->CreateAdd(outputPos, literalLength));
    127134    }
     
    141148
    142149
    143         Value* outputCapacity = b->getCapacity("outputTwistStream");
    144 
    145         Value* outputByteBasePtr = b->CreatePointerCast(b->getRawOutputPointer("outputTwistStream", SIZE_0), INT8_PTR_TY);
     150//        Value* outputCapacity = b->getCapacity("outputTwistStream");
     151
     152//        Value* outputByteBasePtr = b->CreatePointerCast(b->getRawOutputPointer("outputTwistStream", SIZE_0), INT8_PTR_TY);
     153        Value* outputByteBasePtr = b->getScalarField("temporaryOutputPtr");
    146154
    147155        Value* outputPos = b->getScalarField("outputPos");
    148         Value* outputPosRem = b->CreateURem(outputPos, outputCapacity);
     156//        Value* outputPosRem = b->CreateURem(outputPos, outputCapacity);
     157        Value* outputPosRem = b->CreateSub(outputPos, b->getProducedItemCount("outputTwistStream"));
    149158
    150159        // ---- EntryBlock
     
    214223
    215224
    216 
    217         Value* outputByteBasePtr = b->CreatePointerCast(b->getRawOutputPointer("outputTwistStream", b->getSize(0)), INT8_PTR_TY);
    218         Value* outputCapacity = b->getCapacity("outputTwistStream");
     225//        Value* outputByteBasePtr = b->CreatePointerCast(b->getRawOutputPointer("outputTwistStream", b->getSize(0)), INT8_PTR_TY);
     226//        Value* outputCapacity = b->getCapacity("outputTwistStream");
     227        Value* outputByteBasePtr = b->getScalarField("temporaryOutputPtr");
    219228        Value* outputPos = b->getScalarField("outputPos");
    220         Value* outputPosRem = b->CreateURem(outputPos, outputCapacity);
     229
     230
     231//        Value* outputPosRem = b->CreateURem(outputPos, outputCapacity);
     232        Value* outputPosRem = b->CreateSub(outputPos, b->getProducedItemCount("outputTwistStream"));
    221233
    222234        Value* outputPosRemByteItem = b->CreateURem(outputPosRem, SIZE_ITEMS_PER_BYTE);
     
    225237
    226238        Value* outputBytePos = b->CreateUDiv(outputPosRem, SIZE_ITEMS_PER_BYTE);
     239
     240
    227241        Value* initCopyToPtr = b->CreateGEP(outputByteBasePtr, outputBytePos);
    228 
    229242        Value* initOutputLastByte = b->CreateZExt(b->CreateLoad(initCopyToPtr), INT_FW_TY);
    230243
     
    319332
    320333    void LZ4TwistDecompressionKernel::setProducedOutputItemCount(const std::unique_ptr<KernelBuilder> &b, llvm::Value* produced) {
     334        Constant* SIZE_ITEMS_PER_BYTE = b->getSize(mItemsPerByte);
     335        Constant* SIZE_0 = b->getSize(0);
     336        Type* INT8_PTR_TY = b->getInt8PtrTy();
     337
     338        Value* oldProduced = b->getProducedItemCount("outputTwistStream");
     339
     340        Value* outputByteBasePtr = b->CreatePointerCast(b->getRawOutputPointer("outputTwistStream", SIZE_0), INT8_PTR_TY);
     341        Value* outputCapacity = b->getCapacity("outputTwistStream");
     342        Value* outputPosRem = b->CreateURem(oldProduced, outputCapacity);
     343
     344        Value* outputPosByteRem = b->CreateUDiv(outputPosRem, SIZE_ITEMS_PER_BYTE);
     345        Value* actualOutputPtr = b->CreateGEP(outputByteBasePtr, outputPosByteRem);
     346        b->CreateMemCpy(actualOutputPtr, b->getScalarField("temporaryOutputPtr"), b->getSize(mBlockSize / mItemsPerByte), 1);
     347
     348        Value* ptr = b->CreateGEP(b->CreatePointerCast(b->getScalarField("temporaryOutputPtr"), b->getBitBlockType()->getPointerTo()), b->getSize(0x16f));
     349
    321350        b->setProducedItemCount("outputTwistStream", produced);
    322351    }
     
    325354    void LZ4TwistDecompressionKernel::initializationMethod(const std::unique_ptr<KernelBuilder> &b) {
    326355        b->setScalarField("temporaryInputPtr", b->CreateMalloc(b->getSize(mBlockSize / mItemsPerByte)));
     356        b->setScalarField("temporaryOutputPtr", b->CreateMalloc(b->getSize(mBlockSize / mItemsPerByte + COPY_FW / BYTE_WIDTH)));
     357
    327358    }
    328359
     
    356387    void LZ4TwistDecompressionKernel::beforeTermination(const std::unique_ptr<KernelBuilder> &b) {
    357388        b->CreateFree(b->getScalarField("temporaryInputPtr"));
     389        b->CreateFree(b->getScalarField("temporaryOutputPtr"));
    358390    }
    359391
  • icGREP/icgrep-devel/icgrep/kernels/lz4/untwist_kernel.cpp

    r6136 r6143  
    6767        }
    6868    }
     69
     70    StreamCompareKernel::StreamCompareKernel(const std::unique_ptr<kernel::KernelBuilder> &b,
     71                                             unsigned int numberOfStream):
     72            BlockOrientedKernel("UntwistByPEXTKernel",
     73                                {
     74                                        Binding{b->getStreamSetTy(numberOfStream, 1), "stream1", FixedRate(), Principal()},
     75                                        Binding{b->getStreamSetTy(numberOfStream, 1), "stream2", FixedRate()}
     76                                },
     77                                {
     78//                                        Binding{b->getStreamSetTy(numberOfOutputStream, 1), "basisBits"}
     79                                }, {}, {}, {}),mNumberOfStream(numberOfStream)
     80    {
     81//        this->setStride(4 * 1024 * 1024);
     82        this->addScalar(b->getSizeTy(), "pos");
     83    }
     84
     85    void StreamCompareKernel::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> &b) {
     86        Value* s1 = b->loadInputStreamBlock("stream1", b->getSize(0));
     87        Value* s2 = b->loadInputStreamBlock("stream2", b->getSize(0));
     88
     89        for (unsigned i = 0 ; i < 4; i++) {
     90            Value* v1 = b->CreateExtractElement(s1, i);
     91            Value* v2 = b->CreateExtractElement(s2, i);
     92            Value* shouldPrint = b->CreateICmpNE(v1, v2);
     93            b->CallPrintIntCond("---pos", b->getScalarField("pos"), shouldPrint);
     94
     95//            b->CallPrintIntCond("s1_available", b->getAvailableItemCount("stream1"), shouldPrint);
     96            b->CallPrintRegisterCond("s1", s1, shouldPrint);
     97            b->CallPrintRegisterCond("s2", s2, shouldPrint);
     98        }
     99        b->setScalarField("pos", b->CreateAdd(b->getScalarField("pos"), b->getSize(b->getBitBlockWidth())));
     100    };
    69101}
  • icGREP/icgrep-devel/icgrep/kernels/lz4/untwist_kernel.h

    r6136 r6143  
    1919        void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & b) override;
    2020    };
     21
     22    class StreamCompareKernel final : public BlockOrientedKernel{
     23    public:
     24        StreamCompareKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned numberOfStream = 1);
     25    protected:
     26        const unsigned mNumberOfStream;
     27        void generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & b) override;
     28    };
    2129}
    2230
  • icGREP/icgrep-devel/icgrep/lz4/lz4_base_generator.cpp

    r6137 r6143  
    1313#include <kernels/lz4/decompression/lz4_twist_decompression.h>
    1414#include <kernels/lz4/decompression/lz4_bitstream_decompression.h>
    15 #include <kernels/lz4/decompression/lz4_parallel_bytestream_decompression.h>
    1615
    1716
     
    132131
    133132    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(8, 1),
    134                                                                                        this->getDefaultBufferBlocks());
     133                                                                                       this->getDefaultBufferBlocks(), 1);
    135134
    136135    Kernel * unSwizzleK2 = mPxDriver.addKernelInstance<SwizzleGenerator>(b, 8, 1, 2);
     
    147146}
    148147
    149 parabix::StreamSetBuffer *LZ4BaseGenerator::parallelByteStreamDecompression(
    150         parabix::StreamSetBuffer *compressedByteStream,
    151         bool enableGather, bool enableScatter,
    152         int minParallelLevel) {
    153     auto & iBuilder = mPxDriver.getBuilder();
    154     LZ4BlockInfo blockInfo = this->getBlockInfo(compressedByteStream);
    155     StreamSetBuffer *const decompressionByteStream
    156             = mPxDriver.addBuffer<StaticBuffer>(iBuilder,
    157                                                 iBuilder->getStreamSetTy(1, 8),
    158                                                 this->getDefaultBufferBlocks(), 1);
    159 
    160     Kernel *lz4AioK
    161             = mPxDriver.addKernelInstance<LZ4ParallelByteStreamDecompressionKernel>(iBuilder, mLz4BlockSize,
    162                                                                                     enableGather, enableScatter,
    163                                                                                     minParallelLevel);
    164     lz4AioK->setInitialArguments({mFileSize});
    165     mPxDriver.makeKernelCall(
    166             lz4AioK,
    167             {
    168                     compressedByteStream,
    169 
    170                     blockInfo.isCompress,
    171                     blockInfo.blockStart,
    172                     blockInfo.blockEnd
    173             }, {
    174                     decompressionByteStream
    175             });
    176 
    177     return decompressionByteStream;
    178 }
    179 
    180148std::vector<StreamSetBuffer*> LZ4BaseGenerator::convertCompressedBitsStreamWithBitStreamAioApproach(
    181149        parabix::StreamSetBuffer* compressedByteStream,
     
    185153
    186154    LZ4BlockInfo blockInfo = this->getBlockInfo(compressedByteStream);
    187 
    188     unsigned numOfStreams = compressedBitStreams[0]->getNumOfStreams();
    189 
    190     // 1, 2, 4, 8
    191 
    192     if (numOfStreams <= 2) {
    193         StreamSetBuffer* twistedCharClasses = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(1, 2),
    194                                                                                    this->getDefaultBufferBlocks());
    195         kernel::Kernel* twistK = mPxDriver.addKernelInstance<kernel::TwistByPDEPKernel>(b, numOfStreams, 2);
    196         mPxDriver.makeKernelCall(twistK, {compressedBitStreams[0]}, {twistedCharClasses});
    197 
    198         StreamSetBuffer* uncompressedTwistedCharClasses = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(1, 2),
    199                                                                                                this->getDefaultBufferBlocks());
    200         Kernel* lz4I4AioK = mPxDriver.addKernelInstance<LZ4TwistDecompressionKernel>(b, 2);
    201         lz4I4AioK->setInitialArguments({mFileSize});
    202         mPxDriver.makeKernelCall(lz4I4AioK, {
    203                 compressedByteStream,
    204 
    205                 blockInfo.isCompress,
    206                 blockInfo.blockStart,
    207                 blockInfo.blockEnd,
    208 
    209                 twistedCharClasses
    210         }, {
    211                                             uncompressedTwistedCharClasses
    212                                     });
    213 
    214         StreamSetBuffer* untwistedCharClasses = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(numOfStreams),
    215                                                                                      this->getDefaultBufferBlocks());
    216         kernel::Kernel* untwistK = mPxDriver.addKernelInstance<kernel::UntwistByPEXTKernel>(b, numOfStreams, 2);
    217         mPxDriver.makeKernelCall(untwistK, {uncompressedTwistedCharClasses}, {untwistedCharClasses});
    218         return {untwistedCharClasses};
    219     }
    220 
    221     if (numOfStreams <= 4) {
    222         StreamSetBuffer* twistedCharClasses = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(1, 4),
    223                                                                                    this->getDefaultBufferBlocks());
    224         kernel::Kernel* twistK = mPxDriver.addKernelInstance<kernel::TwistByPDEPKernel>(b, numOfStreams, 4);
    225         mPxDriver.makeKernelCall(twistK, {compressedBitStreams[0]}, {twistedCharClasses});
    226 
    227 
    228         StreamSetBuffer* uncompressedTwistedCharClasses = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(1, 4),
    229                                                                                                this->getDefaultBufferBlocks());
    230 
    231         Kernel* lz4I4AioK = mPxDriver.addKernelInstance<LZ4TwistDecompressionKernel>(b, 4);
    232         lz4I4AioK->setInitialArguments({mFileSize});
    233         mPxDriver.makeKernelCall(lz4I4AioK, {
    234                 compressedByteStream,
    235 
    236                 blockInfo.isCompress,
    237                 blockInfo.blockStart,
    238                 blockInfo.blockEnd,
    239 
    240                 twistedCharClasses
    241         }, {
    242                                             uncompressedTwistedCharClasses
    243                                     });
    244 
    245         StreamSetBuffer* untwistedCharClasses = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(numOfStreams),
    246                                                                                      this->getDefaultBufferBlocks());
    247         kernel::Kernel* untwistK = mPxDriver.addKernelInstance<kernel::UntwistByPEXTKernel>(b, numOfStreams, 4);
    248         mPxDriver.makeKernelCall(untwistK, {uncompressedTwistedCharClasses}, {untwistedCharClasses});
    249         return {untwistedCharClasses};
    250     }
    251155
    252156    std::vector<StreamSetBuffer *> inputStreams = {
     
    266170        inputStreams.push_back(compressedBitStreams[i]);
    267171        outputStream.push_back(mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(numOfStreams, 1),
    268                                                                  this->getDefaultBufferBlocks()));
     172                                                                 this->getDefaultBufferBlocks(), 1));
    269173    }
    270174
  • icGREP/icgrep-devel/icgrep/lz4/lz4_base_generator.h

    r6137 r6143  
    2525public:
    2626    LZ4BaseGenerator();
    27 
     27    virtual ~LZ4BaseGenerator(){};
    2828protected:
    2929    //// Member Function
     
    4848            parabix::StreamSetBuffer* compressedByteStream,
    4949            parabix::StreamSetBuffer* compressedBasisBits
    50     );
    51 
    52     parabix::StreamSetBuffer *parallelByteStreamDecompression(
    53             parabix::StreamSetBuffer *compressedByteStream,
    54             bool enableGather, bool enableScatter, int minParallelLevel
    5550    );
    5651
  • 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.