Ignore:
Timestamp:
May 7, 2018, 1:15:37 PM (12 months ago)
Author:
xwa163
Message:
  1. New version of lz4_swizzled_match_copy kernel with higher performance
  2. Adjust related pipeline code
  3. Remove legacy comments
File:
1 edited

Legend:

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

    r5985 r6020  
    1 //
    2 // Created by wxy325 on 2018/3/16.
    3 //
    41
    52#include "lz4_index_builder.h"
     
    4340           Binding{iBuilder->getStreamSetTy(1, 1), "deletionMarker", BoundedRate(0, 1)},
    4441           Binding{iBuilder->getStreamSetTy(1, 1), "M0Marker", BoundedRate(0, 1)},
    45            Binding{iBuilder->getStreamSetTy(1, 1), "M0CountMarker", BoundedRate(0, 1)},
    4642           Binding{iBuilder->getStreamSetTy(1, 1), "MatchOffsetMarker", RateEqualTo("byteStream")}
    4743    },
     
    6258
    6359    void LZ4IndexBuilderKernel::generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> &iBuilder) {
    64 //        iBuilder->CallPrintInt("IndexBuilder:entry", iBuilder->getSize(0));
    65 
    6660        BasicBlock* exitBlock = iBuilder->CreateBasicBlock("exitBlock");
    6761        BasicBlock* blockEndConBlock = iBuilder->CreateBasicBlock("blockEndConBlock");
     
    170164        BasicBlock* entryBlock = iBuilder->GetInsertBlock();
    171165
    172         Value* matchLengthStartPos = iBuilder->CreateAdd(offsetPos, INT64_ONE);
     166        Value* extendMatchStartPos = iBuilder->CreateAdd(offsetPos, INT64_ONE);
    173167        Value* extendedMatchValue = iBuilder->CreateICmpEQ(iBuilder->CreateAnd(token, iBuilder->getInt8(0xf)), iBuilder->getInt8(0xf));
    174168
     
    181175
    182176        //ExtendMatchBodyBlock
    183         Value* newCursorPos = this->advanceUntilNextZero(iBuilder, "extender", iBuilder->CreateAdd(matchLengthStartPos, INT64_ONE), blockEnd);
     177        Value* newCursorPos = this->advanceUntilNextZero(iBuilder, "extender", iBuilder->CreateAdd(extendMatchStartPos, INT64_ONE), blockEnd);
    184178        BasicBlock* advanceFinishBlock = iBuilder->GetInsertBlock();
    185179
    186         // ----May be in a different segment now
    187180        iBuilder->CreateBr(extendMatchExitBlock);
    188181
     
    191184        PHINode* phiCursorPosAfterMatch = iBuilder->CreatePHI(iBuilder->getInt64Ty(), 2);
    192185        phiCursorPosAfterMatch->addIncoming(newCursorPos, advanceFinishBlock);
    193         phiCursorPosAfterMatch->addIncoming(matchLengthStartPos, entryBlock);
    194 
    195         Value* oldMatchExtensionSize = iBuilder->CreateSub(phiCursorPosAfterMatch, matchLengthStartPos);
    196         extendedMatchValue = iBuilder->CreateICmpEQ(iBuilder->CreateAnd(token, iBuilder->getInt8(0xf)), iBuilder->getInt8(0xf));
    197         Value* matchExtensionSize = iBuilder->CreateSelect(
    198                 iBuilder->CreateICmpEQ(extendedMatchValue, iBuilder->getInt1(true)),
    199                 oldMatchExtensionSize,
    200                 iBuilder->getSize(0)
    201         );
     186        phiCursorPosAfterMatch->addIncoming(extendMatchStartPos, entryBlock);
     187
     188        Value* oldMatchExtensionSize = iBuilder->CreateSub(phiCursorPosAfterMatch, extendMatchStartPos);
     189//        extendedMatchValue = iBuilder->CreateICmpEQ(iBuilder->CreateAnd(token, iBuilder->getInt8(0xf)), iBuilder->getInt8(0xf));
     190        Value* matchExtensionSize = iBuilder->CreateSelect(extendedMatchValue, oldMatchExtensionSize, iBuilder->getSize(0));
    202191        Value* matchLengthBase = iBuilder->CreateZExt(iBuilder->CreateAnd(token, iBuilder->getInt8(0x0f)), iBuilder->getInt64Ty());
    203192        Value* matchLength = iBuilder->CreateAdd(matchLengthBase, iBuilder->getInt64(4));
     
    235224
    236225
    237         iBuilder->setProducedItemCount("M0CountMarker", iBuilder->CreateAdd(iBuilder->getProducedItemCount("M0CountMarker"), iBuilder->getSize(1)));
     226
    238227        this->markCircularOutputBitstream(iBuilder, "MatchOffsetMarker", offsetPos);
    239228        this->increaseScalarField(iBuilder, "m0OutputPos", matchLength);
     
    244233
    245234    void LZ4IndexBuilderKernel::generateProcessCompressedBlock(const std::unique_ptr<KernelBuilder> &iBuilder, Value* blockStart, Value* blockEnd) {
    246         // Constant
    247235        Value* clearPos = iBuilder->getScalarField("compressedSpaceClearPos");
    248236        // We can not only clear [blockStart, blockEnd), since there are 4 bytes between blockEnd and nextBlockStart
     
    372360
    373361    Value * LZ4IndexBuilderKernel::generateLoadInt64NumberInput(const unique_ptr<KernelBuilder> &iBuilder, string inputBufferName, Value * globalOffset) {
    374         Constant* SIZE_STRIDE_SIZE = iBuilder->getSize(getStride());
     362//        Constant* SIZE_STRIDE_SIZE = iBuilder->getSize(getStride());
     363        Constant* SIZE_STRIDE_SIZE = iBuilder->getSize(this->getInputStreamSetBuffer(inputBufferName)->getBufferBlocks() * iBuilder->getBitBlockWidth());
    375364        Value * processed = iBuilder->getProcessedItemCount(inputBufferName);
    376365        processed = iBuilder->CreateAnd(processed, ConstantExpr::getNeg(SIZE_STRIDE_SIZE));
     
    389378        fieldValue = iBuilder->CreateAdd(fieldValue, value);
    390379        iBuilder->setScalarField(fieldName, fieldValue);
    391     }
    392 
    393     void LZ4IndexBuilderKernel::generateStoreNumberOutput(const unique_ptr<KernelBuilder> &iBuilder,
    394                                                           const string & outputBufferName,
    395                                                           Value * value) {
    396 
    397         Value * outputOffset = iBuilder->getProducedItemCount(outputBufferName);
    398         Value * outputRawPtr = iBuilder->getRawOutputPointer(outputBufferName, outputOffset);
    399         iBuilder->CreateStore(value, outputRawPtr);
    400         iBuilder->setProducedItemCount(outputBufferName, iBuilder->CreateAdd(outputOffset, iBuilder->getSize(1)));
    401380    }
    402381
Note: See TracChangeset for help on using the changeset viewer.