Changeset 6119


Ignore:
Timestamp:
Jun 28, 2018, 1:54:52 AM (3 weeks ago)
Author:
xwa163
Message:
  1. Add some BasisSetNumbering? option to fix bug of multiplexing
  2. Use BiigEndian? BitNumbering? for lz4 and lzparabix related pipeline
  3. Support multiplexing in LZ4BitStreamAio pipeline
Location:
icGREP/icgrep-devel/icgrep
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.cpp

    r5872 r6119  
    5757
    5858
    59 CharClassesKernel::CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<CC *> && ccs, bool useDirectCC)
     59CharClassesKernel::CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<CC *> && ccs, bool useDirectCC, cc::BitNumbering basisNumbering)
    6060: CharClassesSignature(ccs, useDirectCC)
    6161, PabloKernel(iBuilder,
     
    6363              {},
    6464              {Binding{iBuilder->getStreamSetTy(ccs.size(), 1), "charclasses"}})
    65 , mCCs(std::move(ccs)) {
     65, mCCs(std::move(ccs)), mBasisSetNumbering(basisNumbering) {
    6666    if (useDirectCC) {
    6767        mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(1, 8), "byteData"}});
     
    8282        ccc = make_unique<cc::Direct_CC_Compiler>(getEntryScope(), pb.createExtract(getInput(0), pb.getInteger(0)));
    8383    } else {
    84         ccc = make_unique<cc::Parabix_CC_Compiler>(getEntryScope(), getInputStreamSet("basis"));
     84        ccc = make_unique<cc::Parabix_CC_Compiler>(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering);
    8585    }
    8686    unsigned n = mCCs.size();
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.h

    r5854 r6119  
    77
    88#include <pablo/pablo_kernel.h>  // for PabloKernel
     9#include <cc/alphabet.h>
    910
    1011namespace kernel { class KernelBuilder; }
     
    2223class CharClassesKernel : public CharClassesSignature, public pablo::PabloKernel {
    2324public:
    24     CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<re::CC *> && ccs, bool useDirectCC = false);
     25    CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<re::CC *> && ccs, bool useDirectCC = false, cc::BitNumbering basisNumbering = cc::BitNumbering::LittleEndian);
    2526    bool hasSignature() const override { return true; }
    2627    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
     
    2930    void generatePabloMethod() override;
    3031protected:
     32    cc::BitNumbering mBasisSetNumbering;
    3133    std::vector<re::CC *> mCCs;
    3234   
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5989 r6119  
    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)
     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),
     
    258258{Binding{b->getStreamSetTy(1, 1), "matches", FixedRate(), Add1()}})
    259259, mExternals(externals)
    260 , mAlphabets(alphabets) {
     260, mAlphabets(alphabets)
     261, mBasisSetNumbering(basisSetNumbering){
    261262}
    262263
     
    267268void ICGrepKernel::generatePabloMethod() {
    268269    PabloBuilder pb(getEntryScope());
    269     cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
    270     RE_Compiler re_compiler(getEntryScope(), ccc);
     270    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering);
     271    RE_Compiler re_compiler(getEntryScope(), ccc, mBasisSetNumbering);
    271272    for (auto & e : mExternals) {
    272273        re_compiler.addPrecompiled(e, pb.createExtract(getInputStreamVar(e), pb.getInteger(0)));
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.h

    r5989 r6119  
    77
    88#include <pablo/pablo_kernel.h>  // for PabloKernel
     9#include <cc/alphabet.h>
    910
    1011namespace IDISA { class IDISA_Builder; }
     
    6162class ICGrepKernel : public ICGrepSignature, public pablo::PabloKernel {
    6263public:
    63     ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {});
     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);
    6465    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    6566    bool isCachable() const override { return true; }
     
    6869    std::vector<std::string> mExternals;
    6970    std::vector<cc::Alphabet *> mAlphabets;
     71    cc::BitNumbering mBasisSetNumbering;
    7072};
    7173
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.cpp

    r5915 r6119  
    2424using namespace IDISA;
    2525
    26 LineFeedKernelBuilder::LineFeedKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & b, Binding && inputStreamSet)
     26LineFeedKernelBuilder::LineFeedKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & b, Binding && inputStreamSet, cc::BitNumbering basisNumbering)
    2727: PabloKernel(b, "lf" + std::to_string(getNumOfStreams(inputStreamSet.getType())) + "x" + std::to_string(getStreamFieldWidth(inputStreamSet.getType())),
    2828// input
     
    3030{Binding{b->getStreamSetTy(1), "lf"}}),
    3131    mNumOfStreams(getNumOfStreams(inputStreamSet.getType())),
    32     mStreamFieldWidth(getStreamFieldWidth(inputStreamSet.getType()))
     32    mStreamFieldWidth(getStreamFieldWidth(inputStreamSet.getType())),
     33    mBasisSetNumbering(basisNumbering)
    3334{
    3435}
     
    4041        ccc = make_unique<cc::Direct_CC_Compiler>(getEntryScope(), pb.createExtract(getInput(0), pb.getInteger(0)));
    4142    } else {
    42         ccc = make_unique<cc::Parabix_CC_Compiler>(getEntryScope(), getInputStreamSet("basis"));
     43        ccc = make_unique<cc::Parabix_CC_Compiler>(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering);
    4344    }
    4445    PabloAST * LF = ccc->compileCC("LF", makeByte(0x0A), pb);
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.h

    r5861 r6119  
    77
    88#include <pablo/pablo_kernel.h>  // for PabloKernel
     9#include <cc/alphabet.h>
    910
    1011namespace kernel { class KernelBuilder; }
     
    1516class LineFeedKernelBuilder final : public pablo::PabloKernel {
    1617public:
    17     LineFeedKernelBuilder(const std::unique_ptr<KernelBuilder> & b, kernel::Binding && inputStreamSet);
     18    LineFeedKernelBuilder(const std::unique_ptr<KernelBuilder> & b, kernel::Binding && inputStreamSet, cc::BitNumbering basisNumbering = cc::BitNumbering::LittleEndian);
    1819    bool isCachable() const override { return true; }
    1920    bool hasSignature() const override { return false; }
     
    2223    unsigned mNumOfStreams;
    2324    unsigned mStreamFieldWidth;
     25    cc::BitNumbering mBasisSetNumbering;
    2426};
    2527
  • icGREP/icgrep-devel/icgrep/lz4/LZ4Generator.cpp

    r6118 r6119  
    402402    sourceK->setInitialArguments({mInputStream, mFileSize});
    403403    mPxDriver.makeKernelCall(sourceK, {}, {mCompressedByteStream});
    404     Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::LittleEndian);
     404    Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::BigEndian);
    405405    mPxDriver.makeKernelCall(s2pk, {mCompressedByteStream}, {mCompressedBasisBits});
    406406}
    407407
    408408StreamSetBuffer * LZ4Generator::generateBitStreamAIODecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    409 //// Decode Block Information
     409    return this->convertCompressedBitsStreamWithBitStreamAioApproach({mCompressedBasisBits}, "combined")[0];
     410}
     411
     412std::vector<StreamSetBuffer*> LZ4Generator::convertCompressedBitsStreamWithBitStreamAioApproach(
     413        std::vector<StreamSetBuffer*> compressedBitStreams, std::string prefix) {
     414    auto mGrepDriver = &mPxDriver;
     415    auto & iBuilder = mGrepDriver->getBuilder();
     416
     417    //// Decode Block Information
    410418    StreamSetBuffer * const BlockData_IsCompressed = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), this->getInputBufferBlocks(iBuilder), 1);
    411419    StreamSetBuffer * const BlockData_BlockStart = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 64), this->getInputBufferBlocks(iBuilder), 1);
    412420    StreamSetBuffer * const BlockData_BlockEnd = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 64), this->getInputBufferBlocks(iBuilder), 1);
    413421
    414     //// Generate Helper Markers Extenders, FX, XF
    415 //    StreamSetBuffer * const Extenders = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), this->getInputBufferBlocks(iBuilder), 1);
    416 //    mMatchOffsetMarker = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), this->getInputBufferBlocks(iBuilder));
    417 //    Kernel * extenderK = mPxDriver.addKernelInstance<ParabixCharacterClassKernelBuilder>(iBuilder, "extenders", std::vector<re::CC *>{re::makeCC(0xFF)}, 8);
    418 //    mPxDriver.makeKernelCall(extenderK, {mCompressedBasisBits}, {Extenders});
    419 
    420422
    421423    Kernel * blockDecoderK = mPxDriver.addKernelInstance<LZ4BlockDecoderKernel>(iBuilder);
     
    423425    mPxDriver.makeKernelCall(blockDecoderK, {mCompressedByteStream}, {BlockData_IsCompressed, BlockData_BlockStart, BlockData_BlockEnd});
    424426
    425     StreamSetBuffer* decompressedBitStream = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), this->getDecompressedBufferBlocks(iBuilder));
    426 
    427     Kernel* lz4BitStreamAioK = mPxDriver.addKernelInstance<LZ4BitStreamAioKernel>(iBuilder);
    428     lz4BitStreamAioK->setInitialArguments({mFileSize});
    429     mPxDriver.makeKernelCall(
    430             lz4BitStreamAioK,
    431             {
    432                     mCompressedByteStream,
    433 
    434 //                    Extenders,
    435 
    436                     // Block Data
    437                     BlockData_IsCompressed,
    438                     BlockData_BlockStart,
    439                     BlockData_BlockEnd,
    440 
    441                     mCompressedBasisBits
    442             }, {
    443                     decompressedBitStream
    444             });
    445     return decompressedBitStream;
    446 
    447 }
     427
     428    std::vector<StreamSetBuffer *> inputStreams = {
     429            mCompressedByteStream,
     430
     431            // Block Data
     432            BlockData_IsCompressed,
     433            BlockData_BlockStart,
     434            BlockData_BlockEnd
     435    };
     436
     437    std::vector<StreamSetBuffer *> outputStream;
     438    std::vector<unsigned> numbersOfStreams;
     439
     440    for (unsigned i = 0; i < compressedBitStreams.size(); i++) {
     441        unsigned numOfStreams = compressedBitStreams[i]->getNumOfStreams();
     442        numbersOfStreams.push_back(numOfStreams);
     443        inputStreams.push_back(compressedBitStreams[i]);
     444        outputStream.push_back(mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(numOfStreams, 1), this->getInputBufferBlocks(iBuilder)));
     445    }
     446
     447    Kernel* lz4AioK = mPxDriver.addKernelInstance<LZ4BitStreamAioKernel>(iBuilder, numbersOfStreams);
     448    lz4AioK->setInitialArguments({mFileSize});
     449    mPxDriver.makeKernelCall(lz4AioK, inputStreams, outputStream);
     450
     451    return outputStream;
     452}
     453
    448454
    449455StreamSetBuffer * LZ4Generator::generateSwizzledAIODecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
  • icGREP/icgrep-devel/icgrep/lz4/LZ4Generator.h

    r6118 r6119  
    3636protected:
    3737    //// Protected Method
     38    std::vector<parabix::StreamSetBuffer*> convertCompressedBitsStreamWithBitStreamAioApproach(
     39            std::vector<parabix::StreamSetBuffer*> compressedBitStreams, std::string prefix);
     40
    3841    void generateMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    3942    // Pipeline
  • icGREP/icgrep-devel/icgrep/lz4/LZ4GrepGenerator.cpp

    r6118 r6119  
    5353#include <kernels/lz4/lz4_block_decoder.h>
    5454#include <kernels/lz4/aio/lz4_swizzled_aio.h>
     55#include <kernels/lz4/aio/lz4_bitstream_aio.h>
    5556
    5657
     
    102103    const unsigned baseBufferSize = this->getInputBufferBlocks(idb);
    103104    StreamSetBuffer * LineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    104     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()});
     105    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    105106    mPxDriver.makeKernelCall(linefeedK, {decompressedBasisBits}, {LineFeedStream});
    106107    return LineFeedStream;
    107108}
    108109
    109 StreamSetBuffer * LZ4GrepGenerator::convertCompressedBitsStreamWithAioApproach(parabix::StreamSetBuffer* compressedBitStream, int numberOfStream, std::string prefix) {
     110
     111
     112StreamSetBuffer * LZ4GrepGenerator::convertCompressedBitsStreamWithSwizzledAioApproach(
     113        parabix::StreamSetBuffer *compressedBitStream, int numberOfStream, std::string prefix) {
    110114    auto mGrepDriver = &mPxDriver;
    111115    auto & iBuilder = mGrepDriver->getBuilder();
     
    117121
    118122    //// Generate Helper Markers Extenders, FX, XF
    119     StreamSetBuffer * const Extenders = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), this->getInputBufferBlocks(iBuilder), 1);
    120     mMatchOffsetMarker = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), this->getInputBufferBlocks(iBuilder));
    121     Kernel * extenderK = mPxDriver.addKernelInstance<ParabixCharacterClassKernelBuilder>(iBuilder, "extenders", std::vector<re::CC *>{re::makeCC(0xFF)}, 8);
    122     mPxDriver.makeKernelCall(extenderK, {mCompressedBasisBits}, {Extenders});
     123//    StreamSetBuffer * const Extenders = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), this->getInputBufferBlocks(iBuilder), 1);
     124//    mMatchOffsetMarker = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), this->getInputBufferBlocks(iBuilder));
     125//    Kernel * extenderK = mPxDriver.addKernelInstance<ParabixCharacterClassKernelBuilder>(iBuilder, "extenders", std::vector<re::CC *>{re::makeCC(0xFF)}, 8);
     126//    mPxDriver.makeKernelCall(extenderK, {mCompressedBasisBits}, {Extenders});
    123127
    124128
     
    142146            {
    143147                    mCompressedByteStream,
    144                     Extenders,
     148//                    Extenders,
    145149
    146150                    // Block Data
     
    227231
    228232    StreamSetBuffer * CompressedLineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    229     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()});
     233    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    230234    mPxDriver.makeKernelCall(linefeedK, {mCompressedBasisBits}, {CompressedLineFeedStream});
    231235    return this->convertCompressedBitsStream(CompressedLineFeedStream, 1, "LineFeed");
     
    260264    StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
    261265
    262     kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
     266    kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis), false, cc::BitNumbering::BigEndian);
    263267    mGrepDriver->makeKernelCall(ccK, {mCompressedBasisBits}, {CharClasses});
    264268
    265269    StreamSetBuffer * CompressedLineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    266     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()});
     270    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    267271    mPxDriver.makeKernelCall(linefeedK, {mCompressedBasisBits}, {CompressedLineFeedStream});
    268272
     
    270274    kernel::Kernel* streamCombineKernel = mPxDriver.addKernelInstance<StreamsCombineKernel>(idb, std::vector<unsigned>({1, (unsigned)numOfCharacterClasses}));
    271275    mPxDriver.makeKernelCall(streamCombineKernel, {CompressedLineFeedStream, CharClasses}, {combinedStream});
    272     StreamSetBuffer * decompressedCombinedStream = this->convertCompressedBitsStreamWithAioApproach(combinedStream, 1 + numOfCharacterClasses, "combined");
     276    StreamSetBuffer * decompressedCombinedStream = this->convertCompressedBitsStreamWithSwizzledAioApproach(
     277            combinedStream, 1 + numOfCharacterClasses, "combined");
    273278
    274279    StreamSetBuffer * LineBreakStream = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1), baseBufferSize);
     
    283288    mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits});
    284289
    285     kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()});
     290    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    286291    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    287292    MatchResultsBufs[0] = MatchResults;
     
    312317
    313318};
    314 std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> LZ4GrepGenerator::multiplexingGrepPipeline(std::vector<re::RE *> &REs, bool useAio) {
     319std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> LZ4GrepGenerator::multiplexingGrepPipeline(std::vector<re::RE *> &REs, bool useAio, bool useSwizzled) {
    315320
    316321    this->initREs(REs);
     
    342347    StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
    343348
    344     kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
     349    kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis), false, cc::BitNumbering::BigEndian);
    345350    mGrepDriver->makeKernelCall(ccK, {mCompressedBasisBits}, {CharClasses});
    346351
    347352    StreamSetBuffer * CompressedLineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    348     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()});
     353    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    349354    mPxDriver.makeKernelCall(linefeedK, {mCompressedBasisBits}, {CompressedLineFeedStream});
    350355
    351     StreamSetBuffer * combinedStream = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses + 1), baseBufferSize);
    352     kernel::Kernel* streamCombineKernel = mPxDriver.addKernelInstance<StreamsCombineKernel>(idb, std::vector<unsigned>({1, (unsigned)numOfCharacterClasses}));
    353     mPxDriver.makeKernelCall(streamCombineKernel, {CompressedLineFeedStream, CharClasses}, {combinedStream});
    354     StreamSetBuffer * decompressedCombinedStream = nullptr;
    355 
    356     if (useAio) {
    357         decompressedCombinedStream = this->convertCompressedBitsStreamWithAioApproach(combinedStream, 1 + numOfCharacterClasses, "combined");
     356
     357    StreamSetBuffer * LineBreakStream = nullptr;
     358    StreamSetBuffer * decompressedCharClasses = nullptr;
     359    if (useSwizzled) {
     360        StreamSetBuffer * combinedStream = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses + 1), baseBufferSize);
     361        kernel::Kernel* streamCombineKernel = mPxDriver.addKernelInstance<StreamsCombineKernel>(idb, std::vector<unsigned>({1, (unsigned)numOfCharacterClasses}));
     362        mPxDriver.makeKernelCall(streamCombineKernel, {CompressedLineFeedStream, CharClasses}, {combinedStream});
     363        StreamSetBuffer * decompressedCombinedStream = nullptr;
     364
     365        if (useAio) {
     366            decompressedCombinedStream = this->convertCompressedBitsStreamWithSwizzledAioApproach(combinedStream, 1 + numOfCharacterClasses, "combined");
     367        } else {
     368            decompressedCombinedStream = this->convertCompressedBitsStream(combinedStream, 1 + numOfCharacterClasses, "combined");
     369        }
     370
     371        LineBreakStream = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1), baseBufferSize);
     372        decompressedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
     373        kernel::Kernel* streamSplitKernel = mPxDriver.addKernelInstance<StreamsSplitKernel>(idb, std::vector<unsigned>({1, (unsigned)numOfCharacterClasses}));
     374        mPxDriver.makeKernelCall(streamSplitKernel, {decompressedCombinedStream}, {LineBreakStream, decompressedCharClasses});
    358375    } else {
    359         decompressedCombinedStream = this->convertCompressedBitsStream(combinedStream, 1 + numOfCharacterClasses, "combined");
    360     }
    361 
    362     StreamSetBuffer * LineBreakStream = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1), baseBufferSize);
    363     StreamSetBuffer * decompressedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
    364     kernel::Kernel* streamSplitKernel = mPxDriver.addKernelInstance<StreamsSplitKernel>(idb, std::vector<unsigned>({1, (unsigned)numOfCharacterClasses}));
    365     mPxDriver.makeKernelCall(streamSplitKernel, {decompressedCombinedStream}, {LineBreakStream, decompressedCharClasses});
    366 
    367     /*
    368     StreamSetBuffer * LineBreakStream = this->convertCompressedBitsStream(CompressedLineFeedStream, 1, "LineFeed");
    369     StreamSetBuffer * decompressedCharClasses = this->convertCompressedBitsStream(CharClasses, numOfCharacterClasses, "mpx");
    370      */
     376        auto ret = this->convertCompressedBitsStreamWithBitStreamAioApproach({CompressedLineFeedStream, CharClasses}, "combined");
     377        LineBreakStream = ret[0];
     378        decompressedCharClasses = ret[1];
     379    }
    371380
    372381    StreamSetBuffer * fakeMatchCopiedBits = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(8), this->getInputBufferBlocks(idb));
     
    374383    mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits});
    375384
    376     kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()});
     385    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    377386    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    378387    MatchResultsBufs[0] = MatchResults;
     
    431440
    432441        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    433         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames);
     442        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames, std::vector<cc::Alphabet *>(), cc::BitNumbering::BigEndian);
    434443        mGrepDriver->makeKernelCall(icgrepK, icgrepInputSets, {MatchResults});
    435444        MatchResultsBufs[i] = MatchResults;
     
    547556    iBuilder->CreateRet(matchedLineCount);
    548557
     558
     559    mPxDriver.finalizeObject();
     560}
     561
     562void LZ4GrepGenerator::generateMultiplexingBitStreamAioPipeline(re::RE* regex) {
     563    auto & iBuilder = mPxDriver.getBuilder();
     564    this->generateCountOnlyMainFunc(iBuilder);
     565
     566    this->generateLoadByteStreamAndBitStream(iBuilder);
     567    StreamSetBuffer * LineBreakStream;
     568    StreamSetBuffer * Matches;
     569    std::vector<re::RE*> res = {regex};
     570    std::tie(LineBreakStream, Matches) = multiplexingGrepPipeline(res, true, false);
     571
     572    kernel::Kernel * matchCountK = mPxDriver.addKernelInstance<kernel::PopcountKernel>(iBuilder);
     573    mPxDriver.makeKernelCall(matchCountK, {Matches}, {});
     574    mPxDriver.generatePipelineIR();
     575
     576    iBuilder->setKernel(matchCountK);
     577    Value * matchedLineCount = iBuilder->getAccumulator("countResult");
     578    matchedLineCount = iBuilder->CreateZExt(matchedLineCount, iBuilder->getInt64Ty());
     579
     580    mPxDriver.deallocateBuffers();
     581
     582    iBuilder->CreateRet(matchedLineCount);
    549583
    550584    mPxDriver.finalizeObject();
     
    634668
    635669    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), this->getDecompressedBufferBlocks(iBuilder));
    636     Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::LittleEndian, /*aligned = */ true, "a");
     670    Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::BigEndian, /*aligned = */ true, "a");
    637671    mPxDriver.makeKernelCall(s2pk, {decompressedByteStream}, {decompressionBitStream});
    638672
     
    675709
    676710    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), this->getDecompressedBufferBlocks(iBuilder));
    677     Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::LittleEndian, /*aligned = */ true, "a");
     711    Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::BigEndian, /*aligned = */ true, "a");
    678712    mPxDriver.makeKernelCall(s2pk, {decompressedByteStream}, {decompressionBitStream});
    679713
  • icGREP/icgrep-devel/icgrep/lz4/LZ4GrepGenerator.h

    r6118 r6119  
    2828
    2929    void generateMultiplexingCompressedBitStream(std::vector<re::RE *> &REs);
    30     std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> multiplexingGrepPipeline(std::vector<re::RE *> &REs, bool useAio = false);
     30    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> multiplexingGrepPipeline(std::vector<re::RE *> &REs, bool useAio = false, bool useSwizzled = true);
    3131
    3232
     
    3434
    3535    void generateMultiplexingSwizzledAioPipeline(re::RE *regex);
    36 
    3736    void generateSwizzledAioPipeline(re::RE* regex);
     37    void generateMultiplexingBitStreamAioPipeline(re::RE* regex);
    3838    void generateBitStreamAioPipeline(re::RE* regex);
    3939
     
    7474
    7575    parabix::StreamSetBuffer * convertCompressedBitsStreamWithSwizzledApproach(parabix::StreamSetBuffer* compressedBitStream, int numberOfStream, std::string prefix);
    76     parabix::StreamSetBuffer * convertCompressedBitsStreamWithAioApproach(parabix::StreamSetBuffer* compressedBitStream, int numberOfStream, std::string prefix);
     76    parabix::StreamSetBuffer * convertCompressedBitsStreamWithSwizzledAioApproach(
     77            parabix::StreamSetBuffer *compressedBitStream, int numberOfStream, std::string prefix);
     78
     79
    7780    parabix::StreamSetBuffer * convertCompressedBitsStream(parabix::StreamSetBuffer* compressedBitStream, int numberOfStream, std::string prefix);
    7881};
  • icGREP/icgrep-devel/icgrep/lz4_grep.cpp

    r6118 r6119  
    5858
    5959
    60 
    6160int main(int argc, char *argv[]) {
    6261    // This boilerplate provides convenient stack traces and clean LLVM exit
     
    9190            }
    9291        } else if (bitStreamDecompression) {
    93             g.generateBitStreamAioPipeline(re_ast);
     92            if (enableMultiplexing) {
     93                g.generateMultiplexingBitStreamAioPipeline(re_ast);
     94            } else {
     95                g.generateBitStreamAioPipeline(re_ast);
     96            }
     97
    9498        } else {
    9599            g.generateAioPipeline(re_ast);
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGenerator.cpp

    r6114 r6119  
    102102    sourceK->setInitialArguments({mInputStream, mFileSize});
    103103    mPxDriver.makeKernelCall(sourceK, {}, {mCompressedByteStream});
    104     Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::LittleEndian);
     104    Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, cc::BitNumbering::BigEndian);
    105105    mPxDriver.makeKernelCall(s2pk, {mCompressedByteStream}, {mCompressedBasisBits});
    106106}
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGrepGenerator.cpp

    r6114 r6119  
    126126    StreamSetBuffer * Matches;
    127127    std::vector<re::RE*> res = {regex};
    128 //    std::tie(LineBreakStream, Matches) = grepPipeline(res);
    129     std::tie(LineBreakStream, Matches) = multiplexingGrepPipeline(res);
    130 
     128    if (mEnableMultiplexing) {
     129        std::tie(LineBreakStream, Matches) = multiplexingGrepPipeline(res);
     130    } else {
     131        std::tie(LineBreakStream, Matches) = grepPipeline(res);
     132    }
    131133
    132134//    Kernel * outK = mPxDriver.addKernelInstance<FileSink>(iBuilder, 8);
     
    180182    StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), baseBufferSize);
    181183
    182     kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
     184    kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis), false, cc::BitNumbering::BigEndian);
    183185    mGrepDriver->makeKernelCall(ccK, {mCompressedBasisBits}, {CharClasses});
    184186
    185187    StreamSetBuffer * CompressedLineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    186     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()});
     188    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    187189    mPxDriver.makeKernelCall(linefeedK, {mCompressedBasisBits}, {CompressedLineFeedStream});
    188190
     
    197199    mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits});
    198200
    199     kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()});
     201    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
    200202    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    201203    MatchResultsBufs[0] = MatchResults;
     
    260262
    261263        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    262         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames);
     264        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames, std::vector<cc::Alphabet *>(), cc::BitNumbering::BigEndian);
    263265        mGrepDriver->makeKernelCall(icgrepK, icgrepInputSets, {MatchResults});
    264266        MatchResultsBufs[i] = MatchResults;
     
    295297    const unsigned baseBufferSize = this->getInputBufferBlocks(idb);
    296298    StreamSetBuffer * LineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    297     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()});
     299    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    298300    mPxDriver.makeKernelCall(linefeedK, {decompressedBasisBits}, {LineFeedStream});
    299301    return LineFeedStream;
  • icGREP/icgrep-devel/icgrep/lzparabix_grep.cpp

    r6114 r6119  
    7777    re::RE * re_ast = re::RE_Parser::parse(regexString, re::MULTILINE_MODE_FLAG);
    7878
    79     LZParabixGrepGenerator g;
     79    LZParabixGrepGenerator g(enableMultiplexing);
    8080
    8181    g.generateCountOnlyAioPipeline(re_ast);
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5936 r6119  
    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));
     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)
     630RE_Compiler::RE_Compiler(PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering)
    631631: mEntryScope(scope)
    632632, mCCCompiler(ccCompiler)
     
    634634, mWhileTest(nullptr)
    635635, mStarDepth(0)
    636 , mCompiledName(&mBaseMap) {
     636, mCompiledName(&mBaseMap)
     637, mBasisSetNumbering(basisSetNumbering){
    637638    PabloBuilder pb(mEntryScope);
    638639    mLineBreak = pb.createZeroes();  // default so "^/$" matches start/end of text only
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5901 r6119  
    1212#include <pablo/builder.hpp>
    1313#include <vector>       // for vector<>::iterator
     14#include <cc/alphabet.h>
     15
    1416namespace cc { class CC_Compiler; class Alphabet;}
    1517namespace pablo { class PabloAST; }
     
    5052    };
    5153
    52     RE_Compiler(pablo::PabloBlock * scope, cc::CC_Compiler & ccCompiler);
     54    RE_Compiler(pablo::PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian);
    5355   
    5456    //
     
    146148    NameMap                                         mBaseMap;
    147149    std::map<std::string, pablo::PabloAST *>        mExternalNameMap;
    148 
     150    cc::BitNumbering mBasisSetNumbering;
    149151};
    150152
Note: See TracChangeset for help on using the changeset viewer.