Ignore:
Timestamp:
Jul 23, 2018, 4:56:33 AM (12 months ago)
Author:
xwa163
Message:
  1. More experiment on lz4 grep
  2. Improve performance of lzparabix grep
File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/lz4/aio/lz4_sequential_aio_base.cpp

    r6118 r6132  
    2727                    Binding{b->getStreamSetTy(1, 64), "blockStart", RateEqualTo("isCompressed"), AlwaysConsume()},
    2828                    Binding{b->getStreamSetTy(1, 64), "blockEnd", RateEqualTo("isCompressed"), AlwaysConsume()}
    29 
    3029            },
    3130            //Outputs
     
    4342                                           Binding{b->getInt64Ty(), "outputPos"},
    4443
    45 
    46                                    }){
     44                                           Binding{b->getInt1Ty(), "hasCallInitialization"}
     45
     46
     47                                   }),
     48             mBlockSize(blockSize) {
    4749        this->setStride(blockSize);
    4850        addAttribute(MustExplicitlyTerminate());
     
    5153    // ---- Kernel Methods
    5254    void LZ4SequentialAioBaseKernel::generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> &b) {
     55        Value* hasCallInitialization = b->getScalarField("hasCallInitialization");
     56
     57        BasicBlock* initializationBlock = b->CreateBasicBlock("initializationBlock");
     58        BasicBlock* entryBlock = b->CreateBasicBlock("entryBlock");
    5359        BasicBlock* exitBlock = b->CreateBasicBlock("exitBlock");
     60
     61        b->CreateLikelyCondBr(hasCallInitialization, entryBlock, initializationBlock);
     62
     63        // ---- initializationBlock
     64        b->SetInsertPoint(initializationBlock);
     65        b->setScalarField("hasCallInitialization", b->getInt1(true));
     66        this->initializationMethod(b);
     67        b->CreateBr(entryBlock);
     68
     69        // ---- entryBlock
     70        b->SetInsertPoint(entryBlock);
    5471        BasicBlock* blockEndConBlock = b->CreateBasicBlock("blockEndConBlock");
    5572
     
    7289
    7390        b->SetInsertPoint(processBlock);
    74 
    7591        //TODO handle uncompressed block
     92        this->prepareProcessBlock(b, blockStart, blockEnd);
     93
    7694        this->processCompressedLz4Block(b, blockStart, blockEnd);
     95
    7796        this->storePendingOutput(b);
    7897
     
    87106        b->CreateBr(exitBlock);
    88107
     108        // ---- exitBlock
    89109        b->SetInsertPoint(exitBlock);
     110
     111        BasicBlock* beforeTerminationBlock = b->CreateBasicBlock("beforeTerminationBlock");
     112        BasicBlock* terminationBlock = b->CreateBasicBlock("terminationBlock");
     113
     114        b->CreateUnlikelyCondBr(b->getTerminationSignal(), beforeTerminationBlock, terminationBlock);
     115
     116        // ---- beforeTerminationBlock
     117        b->SetInsertPoint(beforeTerminationBlock);
     118        this->beforeTermination(b);
     119        b->CreateBr(terminationBlock);
     120
     121        // ---- terminationBlock
     122        b->SetInsertPoint(terminationBlock);
    90123    }
    91124
     
    116149        b->SetInsertPoint(processBody);
    117150        /*
    118         auto accelerationRet = this->doAcceleration(b, phiCursorValue, lz4BlockEnd);
     151        auto accelerationRet = this->doAcceleration(b, phiCursorValue, lz4BlockStart, lz4BlockEnd);
    119152        Value* tokenMarkers = accelerationRet.first.first;
    120153
     
    125158        nextTokenGlobalPos = this->processLz4Sequence(b, nextTokenGlobalPos, lz4BlockEnd);
    126159        */
    127         Value* nextTokenGlobalPos = this->processLz4Sequence(b, phiCursorValue, lz4BlockEnd);
     160        Value* nextTokenGlobalPos = this->processLz4Sequence(b, phiCursorValue, lz4BlockStart, lz4BlockEnd);
    128161        phiCursorValue->addIncoming(nextTokenGlobalPos, b->GetInsertBlock());
    129162        b->CreateBr(processCon);
     
    133166
    134167    std::pair<std::pair<llvm::Value *, llvm::Value *>, llvm::Value *>
    135     LZ4SequentialAioBaseKernel::doAcceleration(const std::unique_ptr<KernelBuilder> &b, llvm::Value *beginTokenPos,
    136                                      llvm::Value *blockEnd) {
     168    LZ4SequentialAioBaseKernel::doAcceleration(
     169            const std::unique_ptr<KernelBuilder> &b,
     170            llvm::Value *beginTokenPos,
     171            llvm::Value *blockStart,
     172            llvm::Value *blockEnd) {
    137173        BasicBlock* entryBlock = b->GetInsertBlock();
    138174
     
    229265        // TODO all of the literal data here will always be in the same 64-bit literal block, it may be better if we provide
    230266        //      this information to the literal copy method, especially when we are working with swizzled form
    231         this->doAccelerationLiteralCopy(b, literalStartGlobalPos, literalLength);
     267        this->doAccelerationLiteralCopy(b, literalStartGlobalPos, literalLength, blockStart);
    232268        this->doAccelerationMatchCopy(b, matchOffset, matchLength);
    233269
     
    246282    }
    247283
    248     llvm::Value *LZ4SequentialAioBaseKernel::processLz4Sequence(const std::unique_ptr<KernelBuilder> &b,
    249                                                       llvm::Value *beginTokenPos,
    250                                                       llvm::Value *lz4BlockEnd) {
     284    llvm::Value *LZ4SequentialAioBaseKernel::processLz4Sequence(
     285            const std::unique_ptr<KernelBuilder> &b,
     286            llvm::Value *beginTokenPos,
     287            llvm::Value *lz4BlockStart,
     288            llvm::Value *lz4BlockEnd) {
    251289        // Constant
    252290        ConstantInt* SIZE_0 = b->getSize(0);
     
    307345
    308346        // This literal copy will always cross 64 bits literal boundary
    309         this->doLiteralCopy(b, literalStartPos, literalLength);
     347        this->doLiteralCopy(b, literalStartPos, literalLength, lz4BlockStart);
    310348        BasicBlock* extendLiteralEndFinal = b->GetInsertBlock();
    311349
Note: See TracChangeset for help on using the changeset viewer.