Changeset 6062


Ignore:
Timestamp:
May 31, 2018, 12:10:58 PM (5 months ago)
Author:
xwa163
Message:

fix output for lz4 count-only grep pipeline

Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/lz4/LZ4GrepGenerator.cpp

    r6059 r6062  
    157157
    158158    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), this->getDecompressedBufferBlocks());
    159     // TODO deadloop when add unswizzled kernel
    160159    Kernel * unSwizzleK2 = mPxDriver.addKernelInstance<SwizzleGenerator>(iBuilder, 4, 1, 1, 64, "dst");
    161160    mPxDriver.makeKernelCall(unSwizzleK2, {decompressedSwizzled0}, {decompressionBitStream});
     
    336335
    337336
    338 
    339     if (mGrepRecordBreak == GrepRecordBreakKind::LF) {
    340     } else if (mGrepRecordBreak == GrepRecordBreakKind::Null) {
    341         // TODO fix here
    342 //        kernel::Kernel * breakK = mGrepDriver->addKernelInstance<kernel::ParabixCharacterClassKernelBuilder>(idb, "Null", std::vector<re::CC *>{mBreakCC}, 8);
    343 //        mGrepDriver->makeKernelCall(breakK, {matchCopiedBasisBits}, {LineBreakStream});
    344     }
    345 
    346337    std::map<std::string, StreamSetBuffer *> propertyStream;
    347338
     
    558549void LZ4GrepGenerator::generateMultiplexingSwizzledAioPipeline2(re::RE* regex) {
    559550    auto & iBuilder = mPxDriver.getBuilder();
    560     this->generateMainFunc(iBuilder);
     551    this->generateCountOnlyMainFunc(iBuilder);
    561552
    562553    // GeneratePipeline
     
    576567    Value * matchedLineCount = iBuilder->getAccumulator("countResult");
    577568    matchedLineCount = iBuilder->CreateZExt(matchedLineCount, iBuilder->getInt64Ty());
    578     iBuilder->CallPrintInt("aaa", matchedLineCount);
    579569
    580570    mPxDriver.deallocateBuffers();
    581571
    582     // TODO return matchedLineCount
    583 //        idb->CreateRet(matchedLineCount);
    584 
    585     iBuilder->CreateRetVoid();
     572    iBuilder->CreateRet(matchedLineCount);
     573
    586574
    587575    mPxDriver.finalizeObject();
     
    590578void LZ4GrepGenerator::generateSwizzledAioPipeline(re::RE* regex) {
    591579    auto & iBuilder = mPxDriver.getBuilder();
    592     this->generateMainFunc(iBuilder);
     580    this->generateCountOnlyMainFunc(iBuilder);
    593581
    594582    // GeneratePipeline
     
    618606    Value * matchedLineCount = iBuilder->getAccumulator("countResult");
    619607    matchedLineCount = iBuilder->CreateZExt(matchedLineCount, iBuilder->getInt64Ty());
    620     iBuilder->CallPrintInt("aaa", matchedLineCount);
    621608    mPxDriver.deallocateBuffers();
    622609
    623     // TODO return matchedLineCount
    624 //        idb->CreateRet(matchedLineCount);
    625 
    626     iBuilder->CreateRetVoid();
     610    iBuilder->CreateRet(matchedLineCount);
    627611
    628612    mPxDriver.finalizeObject();
     
    631615void LZ4GrepGenerator::generateAioPipeline(re::RE *regex) {
    632616    auto & iBuilder = mPxDriver.getBuilder();
    633     this->generateMainFunc(iBuilder);
     617    this->generateCountOnlyMainFunc(iBuilder);
    634618
    635619    // GeneratePipeline
     
    640624    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), this->getDecompressedBufferBlocks());
    641625    Kernel * s2pk = mPxDriver.addKernelInstance<S2PKernel>(iBuilder, /*aligned = */ true, "a");
     626//    Kernel * s2pk = mPxDriver.addKernelInstance<S2PByPextKernel>(iBuilder, "a");
    642627    mPxDriver.makeKernelCall(s2pk, {decompressedByteStream}, {decompressionBitStream});
    643628
     
    660645    Value * matchedLineCount = iBuilder->getAccumulator("countResult");
    661646    matchedLineCount = iBuilder->CreateZExt(matchedLineCount, iBuilder->getInt64Ty());
    662     iBuilder->CallPrintInt("aaa", matchedLineCount);
    663647
    664648    mPxDriver.deallocateBuffers();
    665649
    666     // TODO return matchedLineCount
    667 //        idb->CreateRet(matchedLineCount);
    668 
    669     iBuilder->CreateRetVoid();
     650    iBuilder->CreateRet(matchedLineCount);
    670651
    671652    mPxDriver.finalizeObject();
     
    676657void LZ4GrepGenerator::generateCountOnlyGrepPipeline(re::RE *regex, bool enableGather) {
    677658    auto & iBuilder = mPxDriver.getBuilder();
    678     this->generateMainFunc(iBuilder);
     659    this->generateCountOnlyMainFunc(iBuilder);
    679660
    680661    // GeneratePipeline
     
    707688    Value * matchedLineCount = iBuilder->getAccumulator("countResult");
    708689    matchedLineCount = iBuilder->CreateZExt(matchedLineCount, iBuilder->getInt64Ty());
    709     iBuilder->CallPrintInt("aaa", matchedLineCount);
    710690
    711691    mPxDriver.deallocateBuffers();
    712692
    713     // TODO return matchedLineCount
    714 //        idb->CreateRet(matchedLineCount);
    715 
    716     iBuilder->CreateRetVoid();
     693    iBuilder->CreateRet(matchedLineCount);
    717694
    718695    mPxDriver.finalizeObject();
     
    722699void LZ4GrepGenerator::generateSwizzledCountOnlyGrepPipeline(re::RE *regex) {
    723700    auto & iBuilder = mPxDriver.getBuilder();
    724     this->generateMainFunc(iBuilder);
     701    this->generateCountOnlyMainFunc(iBuilder);
    725702
    726703
     
    774751    Value * matchedLineCount = iBuilder->getAccumulator("countResult");
    775752    matchedLineCount = iBuilder->CreateZExt(matchedLineCount, iBuilder->getInt64Ty());
    776     iBuilder->CallPrintInt("aaa", matchedLineCount);
    777753
    778754    mPxDriver.deallocateBuffers();
    779755
    780     // TODO return matchedLineCount
    781 //        idb->CreateRet(matchedLineCount);
    782 
    783     iBuilder->CreateRetVoid();
     756    iBuilder->CreateRet(matchedLineCount);
    784757
    785758    mPxDriver.finalizeObject();
     
    788761ScanMatchGrepMainFunctionType LZ4GrepGenerator::getScanMatchGrepMainFunction() {
    789762    return reinterpret_cast<ScanMatchGrepMainFunctionType>(mPxDriver.getMain());
     763}
     764CountOnlyGrepMainFunctionType LZ4GrepGenerator::getCountOnlyGrepMainFunction() {
     765    return reinterpret_cast<CountOnlyGrepMainFunctionType>(mPxDriver.getMain());
     766}
     767
     768void LZ4GrepGenerator::generateCountOnlyMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
     769    Module * M = iBuilder->getModule();
     770    Type * const int64Ty = iBuilder->getInt64Ty();
     771    Type * const sizeTy = iBuilder->getSizeTy();
     772    Type * const boolTy = iBuilder->getIntNTy(sizeof(bool) * 8);
     773    Type * const voidTy = iBuilder->getVoidTy();
     774    Type * const inputType = iBuilder->getInt8PtrTy();
     775
     776    Function * const main = cast<Function>(M->getOrInsertFunction("Main", int64Ty, inputType, sizeTy, sizeTy, boolTy, nullptr));
     777    main->setCallingConv(CallingConv::C);
     778    Function::arg_iterator args = main->arg_begin();
     779    mInputStream = &*(args++);
     780    mInputStream->setName("input");
     781
     782    mHeaderSize = &*(args++);
     783    mHeaderSize->setName("mHeaderSize");
     784
     785    mFileSize = &*(args++);
     786    mFileSize->setName("mFileSize");
     787
     788    mHasBlockChecksum = &*(args++);
     789    mHasBlockChecksum->setName("mHasBlockChecksum");
     790    // TODO for now, we do not handle blockCheckSum
     791    mHasBlockChecksum = iBuilder->getInt1(false);
     792
     793    iBuilder->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", main, 0));
    790794}
    791795
  • icGREP/icgrep-devel/icgrep/lz4/LZ4GrepGenerator.h

    r6059 r6062  
    1414
    1515typedef void (*ScanMatchGrepMainFunctionType)(char * byte_data, size_t headerSize, size_t filesize, bool hasBlockChecksum, intptr_t match_accumulator);
     16typedef uint64_t (*CountOnlyGrepMainFunctionType)(char * byte_data, size_t headerSize, size_t filesize, bool hasBlockChecksum);
    1617
    1718class LZ4GrepGenerator : public LZ4Generator{
    1819public:
     20
    1921    LZ4GrepGenerator(bool enableMultiplexing = false);
    2022    void generateSwizzledCountOnlyGrepPipeline(re::RE *regex);
     
    3840    void generateAioPipeline(re::RE* regex);
    3941
     42    ScanMatchGrepMainFunctionType getScanMatchGrepMainFunction();
     43    CountOnlyGrepMainFunctionType getCountOnlyGrepMainFunction();
     44
    4045private:
    4146    bool mEnableMultiplexing;
     
    5358    std::vector<std::ostringstream> mResultStrs;
    5459
    55 
     60    void generateCountOnlyMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    5661    void generateScanMatchMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    5762
     
    5964    llvm::Value * match_accumulator;
    6065
    61     ScanMatchGrepMainFunctionType getScanMatchGrepMainFunction();
     66
    6267
    6368    std::unique_ptr<cc::MultiplexedAlphabet> mpx;
  • icGREP/icgrep-devel/icgrep/lz4_grep.cpp

    r6059 r6062  
    8585        }
    8686
    87         auto main = g.getMainFunc();
    88         main(fileBuffer, lz4Frame.getBlocksStart(), lz4Frame.getBlocksStart() + lz4Frame.getBlocksLength(), lz4Frame.hasBlockChecksum());
     87        auto main = g.getCountOnlyGrepMainFunction();
     88        uint64_t countResult = main(fileBuffer, lz4Frame.getBlocksStart(), lz4Frame.getBlocksStart() + lz4Frame.getBlocksLength(), lz4Frame.hasBlockChecksum());
     89        llvm::outs() << countResult << "\n";
    8990    } else if (countOnly) {
    9091        if (swizzledDecompression) {
Note: See TracChangeset for help on using the changeset viewer.