Changeset 6133


Ignore:
Timestamp:
Jul 25, 2018, 2:50:09 AM (3 weeks ago)
Author:
xwa163
Message:
  1. Add sourceCC in multiplexed CC
  2. Remove workaround FakeBasisBits? from ICGrep
  3. Implement Swizzled version of LZParabix
  4. Init checkin for SwizzleByGather? Kernel
Location:
icGREP/icgrep-devel/icgrep
Files:
6 added
2 deleted
20 edited

Legend:

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

    r6132 r6133  
    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)
    105105add_library(LZ4_Lib lz4FrameDecoder.cpp kernels/cc_kernel.cpp kernels/lz4/lz4_deposit_uncompressed.cpp kernels/lz4/lz4_generate_deposit_stream.cpp kernels/pdep_kernel.cpp lz4/LZ4Generator.cpp kernels/lz4/lz4_block_decoder.cpp kernels/lz4/lz4_index_builder.cpp kernels/lz4/lz4_swizzled_match_copy_kernel.cpp kernels/bitstream_pdep_kernel.cpp kernels/bitstream_gather_pdep_kernel.cpp kernels/swizzled_multiple_pdep_kernel.cpp kernels/lz4/lz4_bitstream_not_kernel.cpp kernels/lz4/lz4_bitstream_match_copy_kernel.cpp kernels/fake_stream_generating_kernel.cpp kernels/lz4/aio/lz4_bytestream_aio.cpp kernels/lz4/aio/lz4_swizzled_aio.cpp kernels/lz4/aio/lz4_parallel_bytestream_aio.cpp kernels/lz4/aio/lz4_sequential_aio_base.cpp kernels/lz4/aio/lz4_sequential_aio_base.h kernels/lz4/aio/lz4_bitstream_aio.cpp kernels/lz4/aio/lz4_bitstream_aio.h kernels/lz4/aio/lz4_i4_bytestream_aio.cpp kernels/lz4/aio/lz4_i4_bytestream_aio.h)
    106 add_library(LZParabix_Lib lzparabix/LZParabixGenerator.cpp kernels/lzparabix/decoder/LZParabixBlockDecoder.cpp kernels/lzparabix/decoder/LZParabixBlockDecoder.h kernels/lzparabix/decoder/LZParabixAioKernel.cpp kernels/lzparabix/decoder/LZParabixAioKernel.h lzparabix/LZParabixGrepGenerator.cpp lzparabix/LZParabixGrepGenerator.h kernels/fake_stream_generating_kernel.cpp kernels/lzparabix/encoder/LZParabixCompressionKernel.cpp kernels/lzparabix/encoder/LZParabixCompressionKernel.h kernels/lzparabix/decoder/LZParabixLiteralDecoderKernel.cpp kernels/lzparabix/decoder/LZParabixLiteralDecoderKernel.h)
     106add_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
    108108# force the compiler to compile the object cache to ensure that the versioning information is up to date
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r6127 r6133  
    2727    }
    2828
    29 Parabix_CC_Compiler::Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering basisSetNumbering, bool fakeBasisBits)
     29Parabix_CC_Compiler::Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering basisSetNumbering)
    3030: CC_Compiler(scope)
    3131, mEncodingBits(basisBitSet.size())
    3232, mBasisSetNumbering(basisSetNumbering)
    33 , mBasisBit(basisBitSet)
    34 , mFakeBasisBits(fakeBasisBits) {
     33, mBasisBit(basisBitSet) {
    3534    mEncodingMask = (static_cast<unsigned>(1) << mEncodingBits) - static_cast<unsigned>(1);
    3635}
     
    228227template<typename PabloBlockOrBuilder>
    229228inline PabloAST * Parabix_CC_Compiler::getBasisVar(const unsigned i, PabloBlockOrBuilder & pb) const {
    230     if (mFakeBasisBits) {
    231         return pb.createZeroes();
    232     } else {
    233         assert (i < mEncodingBits);
    234         if (mBasisSetNumbering == cc::BitNumbering::BigEndian)
    235             return mBasisBit[mEncodingBits - i - 1];
    236         else return mBasisBit[i];
    237     }
     229    assert (i < mEncodingBits);
     230    if (mBasisSetNumbering == cc::BitNumbering::BigEndian)
     231        return mBasisBit[mEncodingBits - i - 1];
     232    else return mBasisBit[i];
    238233}
    239234
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r6127 r6133  
    4141public:
    4242   
    43     Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering b = BitNumbering::LittleEndian, bool fakeBasisBits = false);
     43    Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering b = BitNumbering::LittleEndian);
    4444   
    4545    pablo::PabloAST * compileCC(const re::CC *cc) override;
     
    7777    std::vector<pablo::PabloAST *>  mBasisBit;
    7878    unsigned                        mEncodingMask;
    79     bool mFakeBasisBits;
    8079};
    8180
  • icGREP/icgrep-devel/icgrep/cc/multiplex_CCs.cpp

    r5934 r6133  
    138138        CC_union = re::makeCC(CC_union, re::makeCC(i, this));
    139139    }
     140    CC_union->sourceCC = sourceCC;
    140141    return CC_union;
    141142}
  • icGREP/icgrep-devel/icgrep/kernels/fake_stream_generating_kernel.cpp

    r6111 r6133  
    99namespace kernel {
    1010
     11    FakeStreamGeneratingKernel::FakeStreamGeneratingKernel(const std::unique_ptr<kernel::KernelBuilder> &b,
     12                                                                 const unsigned numberOfInputStream,
     13                                                                 const unsigned numberOfOutputStream,
     14                                                                 std::string name)
     15            : FakeStreamGeneratingKernel(b, numberOfInputStream, std::vector<unsigned>({numberOfOutputStream}), name) {
     16
     17    }
    1118
    1219    FakeStreamGeneratingKernel::FakeStreamGeneratingKernel(const std::unique_ptr<kernel::KernelBuilder> &b,
    13                                                                  const unsigned int numberOfInputStream,
    14                                                                  const unsigned int numberOfOutputStream,
    15                                                                  std::string name)
     20                                                           const unsigned numberOfInputStream,
     21                                                           std::vector<unsigned> numbersOfOutputStreams,
     22                                                           std::string name)
    1623            : MultiBlockKernel(std::move(name),
    1724// input stream sets
    1825                               {Binding{b->getStreamSetTy(numberOfInputStream), "inputStream", FixedRate(), Principal()}},
    1926// output stream set
    20                                {Binding{b->getStreamSetTy(numberOfOutputStream), "outputStream", RateEqualTo("inputStream")}},
     27                               {},
    2128                               {}, {}, {}) {
    22 
     29        for (unsigned i = 0; i < numbersOfOutputStreams.size(); i++) {
     30            mStreamSetOutputs.push_back(Binding{b->getStreamSetTy(numbersOfOutputStreams[i]), "outputStream" + std::to_string(i), RateEqualTo("inputStream")});
     31        }
    2332    }
    2433
    2534    void FakeStreamGeneratingKernel::generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> &b,
    26                                                                 llvm::Value *const numOfStrides) {
     35                                                             llvm::Value *const numOfStrides) {
    2736    }
     37
    2838}
  • icGREP/icgrep-devel/icgrep/kernels/fake_stream_generating_kernel.h

    r6111 r6133  
    66#include <llvm/IR/Value.h>
    77#include <string>
     8#include <vector>
    89
    910namespace IDISA { class IDISA_Builder; }
     
    1314    class FakeStreamGeneratingKernel final : public MultiBlockKernel {
    1415    public:
    15         FakeStreamGeneratingKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned numberOfInputStream = 1, const unsigned numberOfOutputStream = 1, std::string name = "LZ4FakeStreamGeneratingKernel");
     16        FakeStreamGeneratingKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned numberOfInputStream = 1, const unsigned numberOfOutputStreams = 1, std::string name = "LZ4FakeStreamGeneratingKernel");
     17        FakeStreamGeneratingKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned numberOfInputStream, std::vector<unsigned> numbersOfOutputStreams, std::string name = "LZ4FakeStreamGeneratingKernel");
    1618        bool isCachable() const override { return true; }
    1719        bool hasSignature() const override { return false; }
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r6127 r6133  
    250250}
    251251
    252 ICGrepKernel::ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & b, RE * const re, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets, cc::BitNumbering basisSetNumbering, bool fakeBasisBits)
     252ICGrepKernel::ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & b, RE * const re, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets, cc::BitNumbering basisSetNumbering)
    253253: ICGrepSignature(re)
    254254, PabloKernel(b, "ic" + sha1sum(mSignature),
     
    259259, mExternals(externals)
    260260, mAlphabets(alphabets)
    261 , mBasisSetNumbering(basisSetNumbering)
    262 , mFakeBasisBits(fakeBasisBits){
     261, mBasisSetNumbering(basisSetNumbering) {
    263262}
    264263
     
    269268void ICGrepKernel::generatePabloMethod() {
    270269    PabloBuilder pb(getEntryScope());
    271     cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering, mFakeBasisBits);
    272     RE_Compiler re_compiler(getEntryScope(), ccc, mBasisSetNumbering, mFakeBasisBits);
     270    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering);
     271    RE_Compiler re_compiler(getEntryScope(), ccc, mBasisSetNumbering);
    273272    for (auto & e : mExternals) {
    274273        re_compiler.addPrecompiled(e, pb.createExtract(getInputStreamVar(e), pb.getInteger(0)));
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.h

    r6127 r6133  
    6262class ICGrepKernel : public ICGrepSignature, public pablo::PabloKernel {
    6363public:
    64     ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {}, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian, bool fakeBasisBits = false);
     64    ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {}, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian);
    6565    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    6666    bool isCachable() const override { return true; }
     
    7070    std::vector<cc::Alphabet *> mAlphabets;
    7171    cc::BitNumbering mBasisSetNumbering;
    72     bool mFakeBasisBits;
    7372};
    7473
  • icGREP/icgrep-devel/icgrep/kernels/swizzle.cpp

    r6026 r6133  
    77#include <kernels/kernel_builder.h>
    88#include <string>
     9#include <vector>
    910
    1011using namespace llvm;
     
    7980
    8081
     82    SwizzleByGather::SwizzleByGather(const std::unique_ptr<KernelBuilder> &iBuilder)
     83    : BlockOrientedKernel("swizzleByGather", {}, {}, {}, {}, {}){
     84        for (unsigned i = 0; i < 2; i++) {
     85            mStreamSetInputs.push_back(Binding{iBuilder->getStreamSetTy(4, 1), "inputGroup" + std::to_string(i)});
     86        }
     87        for (unsigned i = 0; i < 1; i++) {
     88            mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(8, 1), "outputGroup" + std::to_string(i), FixedRate(1)});
     89        }
     90    }
     91
     92    void SwizzleByGather::generateDoBlockMethod(const std::unique_ptr<kernel::KernelBuilder> &b) {
     93        Value* outputStreamPtr = b->getOutputStreamBlockPtr("outputGroup0", b->getSize(0));
     94
     95        for (unsigned i = 0; i < 2; i++) {
     96            std::vector<llvm::Value*> inputStream;
     97            Value* inputPtr = b->getInputStreamBlockPtr("inputGroup" + std::to_string(i), b->getSize(0));
     98
     99            Value* inputBytePtr = b->CreatePointerCast(inputPtr, b->getInt8PtrTy());
     100            Function *gatherFunc = Intrinsic::getDeclaration(b->getModule(), Intrinsic::x86_avx2_gather_d_q_256);
     101            Value *addresses = ConstantVector::get(
     102                    {b->getInt32(0), b->getInt32(32), b->getInt32(64), b->getInt32(96)});
     103
     104            for (unsigned j = 0; j < 4; j++) {
     105                Value *gather_result = b->CreateCall(
     106                        gatherFunc,
     107                        {
     108                                UndefValue::get(b->getBitBlockType()),
     109                                inputBytePtr,
     110                                addresses,
     111                                Constant::getAllOnesValue(b->getBitBlockType()),
     112                                b->getInt8(1)
     113                        }
     114                );
     115
     116                inputBytePtr = b->CreateGEP(inputBytePtr, b->getInt32(8));
     117
     118                b->CreateStore(gather_result, outputStreamPtr);
     119                outputStreamPtr = b->CreateGEP(outputStreamPtr, b->getSize(1));
     120            }
     121        }
     122    }
    81123}
  • icGREP/icgrep-devel/icgrep/kernels/swizzle.h

    r6026 r6133  
    6666};
    6767
     68
     69class SwizzleByGather : public BlockOrientedKernel {
     70public:
     71    SwizzleByGather(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
     72
     73protected:
     74    void generateDoBlockMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
     75private:
     76};
     77
    6878}
    6979   
  • icGREP/icgrep-devel/icgrep/lz4/LZ4GrepGenerator.cpp

    r6132 r6133  
    405405
    406406    StreamSetBuffer * LineBreakStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), this->getInputBufferBlocks(idb));
    407     kernel::Kernel * lineFeedGrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, transformCCs(mpx.get(), linefeedCC), externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
     407    kernel::Kernel * lineFeedGrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, transformCCs(mpx.get(), linefeedCC), externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    408408    mGrepDriver->makeKernelCall(lineFeedGrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {LineBreakStream});
    409409
    410410
    411     kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
     411    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    412412    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    413413    MatchResultsBufs[0] = MatchResults;
     
    475475            mGrepDriver->makeKernelCall(ccK, {decompressedBasisBits}, {CharClasses});
    476476
    477             kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
     477            kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    478478            icgrepInputSets.push_back(CharClasses);
    479479            mGrepDriver->makeKernelCall(icgrepK, icgrepInputSets, {MatchResults});
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGenerator.cpp

    r6123 r6133  
    1 //
    2 // Created by wxy325 on 2018/6/18.
    3 //
    41
    52#include "LZParabixGenerator.h"
     
    2219#include <kernels/swizzled_multiple_pdep_kernel.h>
    2320#include <kernels/lzparabix/decoder/LZParabixBlockDecoder.h>
    24 #include <kernels/lzparabix/decoder/LZParabixAioKernel.h>
     21#include <kernels/lzparabix/decoder/LZParabixBitStreamAioKernel.h>
     22#include <kernels/lzparabix/decoder/LZParabixSwizzledAioKernel.h>
    2523#include <kernels/lzparabix/decoder/LZParabixLiteralDecoderKernel.h>
    2624
     
    8381    mPxDriver.makeKernelCall(literalDecoderK, {mCompressedByteStream, BlockData_BlockStart, BlockData_BlockEnd}, {LiteralBitStream});
    8482    return LiteralBitStream;
     83}
     84
     85
     86
     87parabix::StreamSetBuffer* LZParabixGenerator::generateSwizzledBitStreamDecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, parabix::StreamSetBuffer* inputBitStreams) {
     88
     89    Kernel * swizzleK = mPxDriver.addKernelInstance<SwizzleGenerator>(iBuilder, 8, 2, 1);
     90
     91    StreamSetBuffer* inputSwizzled1 = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(4, 1), this->getInputBufferBlocks(iBuilder));
     92    StreamSetBuffer* inputSwizzled2 = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(4, 1), this->getInputBufferBlocks(iBuilder));
     93    mPxDriver.makeKernelCall(swizzleK, {inputBitStreams}, {inputSwizzled1, inputSwizzled2});
     94
     95
     96    StreamSetBuffer* outputSwizzled1 = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(4, 1), this->getInputBufferBlocks(iBuilder));
     97    StreamSetBuffer* outputSwizzled2 = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(4, 1), this->getInputBufferBlocks(iBuilder));
     98    Kernel * aioK = mPxDriver.addKernelInstance<LZParabixSwizzledAioKernel>(iBuilder);
     99    aioK->setInitialArguments({mFileSize});
     100    mPxDriver.makeKernelCall(aioK, {
     101            mCompressedByteStream,
     102            BlockData_BlockStart,
     103            BlockData_BlockEnd,
     104
     105//            inputBitStreams,
     106            inputSwizzled1,
     107            inputSwizzled2
     108    }, {
     109            outputSwizzled1,
     110            outputSwizzled2
     111    });
     112
     113    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), this->getDecompressedBufferBlocks(iBuilder));
     114
     115    Kernel * unSwizzleK2 = mPxDriver.addKernelInstance<SwizzleGenerator>(iBuilder, 8, 1, 2);
     116//    Kernel * unSwizzleK2 = mPxDriver.addKernelInstance<SwizzleByGather>(iBuilder);
     117    mPxDriver.makeKernelCall(unSwizzleK2, {outputSwizzled1, outputSwizzled2}, {decompressionBitStream});
     118    return decompressionBitStream;
    85119}
    86120
     
    101135    }
    102136
    103     Kernel * aioK = mPxDriver.addKernelInstance<LZParabixAioKernel>(iBuilder, numbersOfStreams);
     137    Kernel * aioK = mPxDriver.addKernelInstance<LZParabixBitStreamAioKernel>(iBuilder, numbersOfStreams);
    104138    aioK->setInitialArguments({mFileSize});
    105139    mPxDriver.makeKernelCall(aioK, inputStreams, outputStreams);
     
    133167    }
    134168
    135     Kernel * aioK = mPxDriver.addKernelInstance<LZParabixAioKernel>(iBuilder, numsOfStreams);
     169    Kernel * aioK = mPxDriver.addKernelInstance<LZParabixBitStreamAioKernel>(iBuilder, numsOfStreams);
    136170    aioK->setInitialArguments({mFileSize});
    137171
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGenerator.h

    r6123 r6133  
    6767    parabix::StreamSetBuffer* extractLiteralBitStream(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    6868
     69
     70    parabix::StreamSetBuffer* generateSwizzledBitStreamDecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, parabix::StreamSetBuffer* inputBitStreams);
    6971    std::vector<parabix::StreamSetBuffer*> generateBitStreamDecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<parabix::StreamSetBuffer*> inputBitStreams);
    7072};
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGrepGenerator.cpp

    r6130 r6133  
    119119}
    120120
    121 void LZParabixGrepGenerator::generateCountOnlyAioPipeline(re::RE *regex) {
     121void LZParabixGrepGenerator::generateCountOnlyAioPipeline(re::RE *regex, bool swizzledDecompression ) {
    122122    auto & iBuilder = mPxDriver.getBuilder();
    123123    this->generateCountOnlyMainFunc(iBuilder);
     
    132132        std::tie(LineBreakStream, Matches) = multiplexingGrepPipeline(res);
    133133    } else {
    134         std::tie(LineBreakStream, Matches) = grepPipeline(res);
     134        std::tie(LineBreakStream, Matches) = grepPipeline(res, swizzledDecompression);
    135135    }
    136136
     
    201201    mGrepDriver->makeKernelCall(ccK, {LiteralBitStream}, {CharClasses});
    202202
    203 
    204203    StreamSetBuffer * newLineBreak = nullptr;
     204
     205
     206    StreamSetBuffer * decompressedCharClasses = nullptr;
     207    StreamSetBuffer * u8NoFinalStream = nullptr;
     208    StreamSetBuffer * fakeMatchCopiedBits = nullptr;
     209
    205210    if (allCcByteLength) {
    206211        auto ret = this->generateBitStreamDecompression(idb, {CharClasses});
    207         StreamSetBuffer * decompressedCharClasses = ret[0];
    208         StreamSetBuffer * fakeMatchCopiedBits = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(8), this->getInputBufferBlocks(idb), 1);
    209         Kernel* fakeStreamGeneratorK = mPxDriver.addKernelInstance<FakeStreamGeneratingKernel>(idb, numOfCharacterClasses, 8);
    210         mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits});
    211 
    212         newLineBreak = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), this->getInputBufferBlocks(idb));
    213         kernel::Kernel * lineFeedGrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, transformCCs(mpx.get(), linefeedCC), externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
    214         mGrepDriver->makeKernelCall(lineFeedGrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {newLineBreak});
    215 
    216         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
    217         mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    218         MatchResultsBufs[0] = MatchResults;
     212        decompressedCharClasses = ret[0];
     213        fakeMatchCopiedBits = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(8), this->getInputBufferBlocks(idb), 1);
     214        u8NoFinalStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1), this->getInputBufferBlocks(idb), 1);
     215
     216        Kernel* fakeStreamGeneratorK = mPxDriver.addKernelInstance<FakeStreamGeneratingKernel>(idb, numOfCharacterClasses, std::vector<unsigned>({8, 1}));
     217        mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits, u8NoFinalStream});
    219218    } else {
    220219        re::RE* nonFinalName = re::makeAlt({re::makeByte(0xC2, 0xF4),
     
    227226        auto ret = this->generateBitStreamDecompression(idb, {CharClasses, compressedU8NoFinalStream});
    228227
    229         StreamSetBuffer * decompressedCharClasses = ret[0];
    230         StreamSetBuffer * u8NoFinalStream = ret[1];
    231 
    232         StreamSetBuffer * fakeMatchCopiedBits = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(8), this->getInputBufferBlocks(idb), 1);
     228        decompressedCharClasses = ret[0];
     229        u8NoFinalStream = ret[1];
     230
     231        fakeMatchCopiedBits = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(8), this->getInputBufferBlocks(idb), 1);
    233232        Kernel* fakeStreamGeneratorK = mPxDriver.addKernelInstance<FakeStreamGeneratingKernel>(idb, numOfCharacterClasses, 8);
    234233        mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits});
    235234
    236         newLineBreak = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), this->getInputBufferBlocks(idb));
    237         kernel::Kernel * lineFeedGrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, transformCCs(mpx.get(), linefeedCC), externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
    238         mGrepDriver->makeKernelCall(lineFeedGrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {newLineBreak});
    239 
    240         externalStreamNames.push_back("UTF8_nonfinal");
    241 
    242         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    243         mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, u8NoFinalStream, decompressedCharClasses}, {MatchResults});
    244         MatchResultsBufs[0] = MatchResults;
    245     }
     235    }
     236
     237
     238    newLineBreak = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), this->getInputBufferBlocks(idb));
     239    kernel::Kernel * lineFeedGrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, transformCCs(mpx.get(), linefeedCC), externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
     240    mGrepDriver->makeKernelCall(lineFeedGrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {newLineBreak});
     241
     242    externalStreamNames.push_back("UTF8_nonfinal");
     243
     244    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
     245    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, u8NoFinalStream, decompressedCharClasses}, {MatchResults});
     246    MatchResultsBufs[0] = MatchResults;
     247
    246248
    247249    StreamSetBuffer * MergedResults = MatchResultsBufs[0];
     
    272274
    273275std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *>
    274 LZParabixGrepGenerator::grepPipeline(std::vector<re::RE *> &REs) {
     276LZParabixGrepGenerator::grepPipeline(std::vector<re::RE *> &REs, bool swizzledDecompression) {
    275277
    276278    this->initREs(REs);
     
    293295
    294296
    295     auto ret = this->generateBitStreamDecompression(idb, {LiteralBitStream/*, compressedLineBreakStream*/});
    296     StreamSetBuffer * decompressedBasisBits = ret[0];
    297 //    StreamSetBuffer * LineBreakStream = ret[1];
    298 
    299 //    StreamSetBuffer * decompressedBasisBits = this->generateAioBitStreamDecompressoin(idb, {mCompressedBasisBits})[0];
     297    StreamSetBuffer * decompressedBasisBits = nullptr;
     298    if (swizzledDecompression) {
     299        decompressedBasisBits = this->generateSwizzledBitStreamDecompression(idb, LiteralBitStream);
     300    } else {
     301        auto ret = this->generateBitStreamDecompression(idb, {LiteralBitStream});
     302        decompressedBasisBits = ret[0];
     303    }
     304
    300305    StreamSetBuffer * LineBreakStream = this->linefeedStreamFromDecompressedBits(decompressedBasisBits);
    301306
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGrepGenerator.h

    r6114 r6133  
    2323public:
    2424    LZParabixGrepGenerator(bool enableMultiplexing = false);
    25     void generateCountOnlyAioPipeline(re::RE* regex);
     25    void generateCountOnlyAioPipeline(re::RE* regex, bool swizzledDecompression = false);
    2626    CountOnlyGrepMainFunctionType getCountOnlyGrepMainFunction();
    2727protected:
     
    3636    void initREs(std::vector<re::RE *> & REs);
    3737
    38     std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> grepPipeline(std::vector<re::RE *> &REs);
     38    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> grepPipeline(std::vector<re::RE *> &REs, bool swizzledDecompression);
    3939    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> multiplexingGrepPipeline(std::vector<re::RE *> &REs);
    4040
  • icGREP/icgrep-devel/icgrep/lzparabix_grep.cpp

    r6122 r6133  
    4444static cl::opt<bool> countOnly("count-only", cl::desc("Only count the match result"), cl::init(false), cl::cat(lz4GrepFlags));
    4545static cl::opt<bool> enableMultiplexing("enable-multiplexing", cl::desc("Enable CC multiplexing."), cl::init(false), cl::cat(lz4GrepFlags));
     46static cl::opt<bool> swizzledDecompression("swizzled-decompression", cl::desc("Enable Swizzled Decompression."), cl::init(false), cl::cat(lz4GrepFlags));
    4647
    4748static cl::OptionCategory lz4GrepDebugFlags("LZ4 Grep Debug Flags", "lz4d debug options");
     
    7980    LZParabixGrepGenerator g(enableMultiplexing);
    8081
    81     g.generateCountOnlyAioPipeline(re_ast);
     82    g.generateCountOnlyAioPipeline(re_ast, swizzledDecompression);
    8283    auto main = g.getCountOnlyGrepMainFunction();
    8384    uint64_t countResult = main(fileBuffer, 0, fileSize, false);
  • icGREP/icgrep-devel/icgrep/re/re_analysis.cpp

    r6130 r6133  
    163163            if (srcA == &cc::Byte) {
    164164                return true;
     165            } else if (cc->sourceCC) {
     166                return isByteLength(cc->sourceCC);
    165167//            } else if (srcA == &cc::Unicode) {
    166168//                return cast<cc::MultiplexedAlphabet>(a)->invertCC(cc)->max_codepoint() <= 0x7F;
  • icGREP/icgrep-devel/icgrep/re/re_cc.h

    r5847 r6133  
    4343    virtual ~CC() {}
    4444
     45    const CC* sourceCC;
    4546protected:
    4647    friend CC * makeCC(const cc::Alphabet * alphabet);
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r6127 r6133  
    4949void RE_Compiler::addAlphabet(cc::Alphabet * a, std::vector<pablo::PabloAST *> basis_set) {
    5050    mAlphabets.push_back(a);
    51     mAlphabetCompilers.push_back(make_unique<cc::Parabix_CC_Compiler>(mEntryScope, basis_set, mBasisSetNumbering, false));
     51    mAlphabetCompilers.push_back(make_unique<cc::Parabix_CC_Compiler>(mEntryScope, basis_set, mBasisSetNumbering));
    5252}
    5353
     
    628628}
    629629
    630 RE_Compiler::RE_Compiler(PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering, bool fakeBasisBits)
     630RE_Compiler::RE_Compiler(PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering)
    631631: mEntryScope(scope)
    632632, mCCCompiler(ccCompiler)
     
    635635, mStarDepth(0)
    636636, mCompiledName(&mBaseMap)
    637 , mBasisSetNumbering(basisSetNumbering)
    638 , mFakeBasisBits(fakeBasisBits) {
     637, mBasisSetNumbering(basisSetNumbering) {
    639638    PabloBuilder pb(mEntryScope);
    640639    mLineBreak = pb.createZeroes();  // default so "^/$" matches start/end of text only
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r6127 r6133  
    5252    };
    5353
    54     RE_Compiler(pablo::PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian, bool mFakeBasisBits = false);
     54    RE_Compiler(pablo::PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian);
    5555   
    5656    //
     
    149149    std::map<std::string, pablo::PabloAST *>        mExternalNameMap;
    150150    cc::BitNumbering mBasisSetNumbering;
    151     bool mFakeBasisBits;
    152151};
    153152
Note: See TracChangeset for help on using the changeset viewer.