Changeset 5261


Ignore:
Timestamp:
Jan 16, 2017, 9:55:26 AM (8 months ago)
Author:
cameron
Message:

Move responsibility for ProducedItemCount? into doSegment unless overridden

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.cpp

    r5260 r5261  
    4141    setScalarField(self, "EOFmask", iBuilder->bitblock_mask_from(remaining));
    4242    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    43     /* Adjust the produced item count */
    44     Value * produced = getProducedItemCount(self, "ResultStream");
    45     produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    46     setProducedItemCount(self, "ResultStream", iBuilder->CreateAdd(produced, remaining));
    4743    iBuilder->CreateRetVoid();
    4844    iBuilder->restoreIP(savePoint);
     
    113109        iBuilder->CreateStore(iBuilder->CreateAnd(e[mPatternLen-1][j], iBuilder->CreateNot(e[mPatternLen-1][j-1])), ptr);
    114110    }
    115 
    116     Value * produced = getProducedItemCount(kernelStuctParam, "ResultStream");
    117     produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    118     setProducedItemCount(kernelStuctParam, "ResultStream", produced);
    119111       
    120112    iBuilder->CreateRetVoid();
     
    132124mEditDistance(dist),
    133125mPatternLen(pattLen){
    134 
     126setDoBlockUpdatesProducedItemCountsAttribute(false);
    135127}
    136128
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.cpp

    r5260 r5261  
    4242    setScalarField(self, "EOFmask", iBuilder->bitblock_mask_from(remaining));
    4343    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    44     /* Adjust the produced item count */
    45     Value * produced = getProducedItemCount(self, "ResultStream");
    46     produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    47     setProducedItemCount(self, "ResultStream", iBuilder->CreateAdd(produced, remaining));
    4844    iBuilder->CreateRetVoid();
    4945    iBuilder->restoreIP(savePoint);
     
    119115        iBuilder->CreateStore(iBuilder->CreateAnd(e[mPatternLen - 1][j], iBuilder->CreateNot(e[mPatternLen - 1][j - 1])), ptr);
    120116    }
    121 
    122     Value * produced = getProducedItemCount(kernelStuctParam, "ResultStream");
    123     produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    124     setProducedItemCount(kernelStuctParam, "ResultStream", produced);
    125        
    126117    iBuilder->CreateRetVoid();
    127118    iBuilder->restoreIP(savePoint);
     
    138129mEditDistance(dist),
    139130mPatternLen(pattLen) {
    140 
     131setDoBlockUpdatesProducedItemCountsAttribute(false);
    141132}
    142133
  • icGREP/icgrep-devel/icgrep/kernels/deletion.cpp

    r5260 r5261  
    131131mDeletionFieldWidth(fw),
    132132mStreamCount(streamCount) {
    133 
     133    mDoBlockUpdatesProducedItemCountsAttribute = true;
    134134}
    135135
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5260 r5261  
    3333                             std::vector<Binding> internal_scalars)
    3434: KernelInterface(builder, kernelName, stream_inputs, stream_outputs, scalar_parameters, scalar_outputs, internal_scalars),
    35 mNoTerminateAttribute(false) {
     35mNoTerminateAttribute(false),
     36mDoBlockUpdatesProducedItemCountsAttribute(false) {
    3637
    3738}
     
    249250   
    250251    iBuilder->SetInsertPoint(stridesDone);
    251     processed = iBuilder->CreateAdd(processed, iBuilder->CreateMul(stridesToDo, stride));
    252     setProcessedItemCount(self, mStreamSetInputs[0].name, processed);
     252   
     253    Value * segmentItemsProcessed = iBuilder->CreateMul(stridesToDo, stride);
     254    for (unsigned i = 0; i < mStreamSetInputs.size(); i++) {
     255        Value * preProcessed = getProcessedItemCount(self, mStreamSetInputs[i].name);
     256        setProcessedItemCount(self, mStreamSetInputs[i].name, iBuilder->CreateAdd(preProcessed, segmentItemsProcessed));
     257    }
     258    if (!mDoBlockUpdatesProducedItemCountsAttribute) {
     259        for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
     260            Value * preProduced = getProducedItemCount(self, mStreamSetOutputs[i].name);
     261            setProducedItemCount(self, mStreamSetOutputs[i].name, iBuilder->CreateAdd(preProduced, segmentItemsProcessed));
     262        }
     263    }
    253264    iBuilder->CreateBr(segmentDone);
    254265    iBuilder->SetInsertPoint(segmentDone);
     
    326337       
    327338    createFinalBlockCall(self, remainingItems);
    328     processed = iBuilder->CreateAdd(processed, remainingItems);
    329     setProcessedItemCount(self, mStreamSetInputs[0].name, processed);       
     339   
     340    for (unsigned i = 0; i < mStreamSetInputs.size(); i++) {
     341        Value * preProcessed = getProcessedItemCount(self, mStreamSetInputs[i].name);
     342        setProcessedItemCount(self, mStreamSetInputs[i].name, iBuilder->CreateAdd(preProcessed, remainingItems));
     343    }
     344    if (!mDoBlockUpdatesProducedItemCountsAttribute) {
     345        for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
     346            Value * preProduced = getProducedItemCount(self, mStreamSetOutputs[i].name);
     347            setProducedItemCount(self, mStreamSetOutputs[i].name, iBuilder->CreateAdd(preProduced, remainingItems));
     348        }
     349    }
    330350//#ifndef NDEBUG
    331351//    iBuilder->CallPrintInt(mKernelName + "_processed final", processed);
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5260 r5261  
    109109   
    110110    void setNoTerminateAttribute(bool noTerminate = true) {mNoTerminateAttribute = noTerminate;}
     111    void setDoBlockUpdatesProducedItemCountsAttribute(bool doesUpdate = true) {mDoBlockUpdatesProducedItemCountsAttribute = doesUpdate;}
    111112   
    112113    virtual void prepareKernel();
     
    191192    std::vector<const parabix::StreamSetBuffer *>   mStreamSetOutputBuffers;
    192193    bool                                            mNoTerminateAttribute;
     194    bool                                            mDoBlockUpdatesProducedItemCountsAttribute;
    193195
    194196};
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5260 r5261  
    6666}
    6767
     68P2SKernel::P2SKernel(IDISA::IDISA_Builder * iBuilder) :
     69    KernelBuilder(iBuilder, "p2s",
     70                  {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}},
     71                  {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream"}},
     72                  {}, {}, {}) {
     73
     74    }
     75   
     76
    6877void P2SKernelWithCompressedOutput::generateDoBlockMethod() const {
    6978    auto savePoint = iBuilder->saveIP();
     
    93102    Value * unit_counts = iBuilder->fwCast(units_per_register, iBuilder->CreateBlockAlignedLoad(delCountBlock_ptr));
    94103
     104    Value * unitsGenerated = getProducedItemCount(self, "byteStream"); // units generated to buffer
    95105    Value * output_ptr = getStreamView(i8PtrTy, self, "byteStream", blockNo, iBuilder->getInt32(0));
    96106    Value * offset = iBuilder->getInt32(0);
     
    99109        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(j)), i32);
    100110    }
    101     iBuilder->CreateRetVoid();
    102     iBuilder->restoreIP(savePoint);
    103 }
     111    unitsGenerated = iBuilder->CreateAdd(unitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
     112    setProducedItemCount(self, "byteStream", unitsGenerated);
     113
     114    iBuilder->CreateRetVoid();
     115    iBuilder->restoreIP(savePoint);
     116}
     117   
     118P2SKernelWithCompressedOutput::P2SKernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
     119    KernelBuilder(iBuilder, "p2s_compress",
     120                  {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
     121                  {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream"}},
     122                  {}, {}, {}) {
     123        setDoBlockUpdatesProducedItemCountsAttribute(true);
     124
     125    }
     126   
     127   
    104128
    105129void P2S16Kernel::generateDoBlockMethod() const {
     
    140164    iBuilder->restoreIP(savePoint);
    141165}
    142 
     166   
     167
     168P2S16Kernel::P2S16Kernel(IDISA::IDISA_Builder * iBuilder) :
     169    KernelBuilder(iBuilder, "p2s_16",
     170                  {Binding{iBuilder->getStreamSetTy(16, 1), "basisBits"}},
     171                  {Binding{iBuilder->getStreamSetTy(1, 16), "i16Stream"}},
     172                  {}, {}, {}) {
     173       
     174    }
     175
     176   
    143177void P2S16KernelWithCompressedOutput::generateDoBlockMethod() const {
    144178    auto savePoint = iBuilder->saveIP();
     
    219253}
    220254   
    221 }
     255P2S16KernelWithCompressedOutput::P2S16KernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
     256    KernelBuilder(iBuilder, "p2s_16_compress",
     257                  {Binding{iBuilder->getStreamSetTy(16, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
     258                  {Binding{iBuilder->getStreamSetTy(1, 16), "i16Stream"}},
     259                  {},
     260                  {},
     261                  {Binding{iBuilder->getSizeTy(), "unitsGenerated"}, Binding{iBuilder->getSizeTy(), "unitsWritten"}}) {
     262        setDoBlockUpdatesProducedItemCountsAttribute(true);
     263}
     264   
     265   
     266}
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.h

    r5260 r5261  
    1919class P2SKernel : public KernelBuilder {
    2020public:
    21     P2SKernel(IDISA::IDISA_Builder * iBuilder) :
    22     KernelBuilder(iBuilder, "p2s",
    23                   {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}},
    24                   {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream"}},
    25                   {}, {}, {}) {}
     21    P2SKernel(IDISA::IDISA_Builder * iBuilder);
    2622   
    2723private:
     
    3228class P2SKernelWithCompressedOutput : public KernelBuilder {
    3329public:
    34     P2SKernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
    35     KernelBuilder(iBuilder, "p2s_compress",
    36                   {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
    37                   {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream"}},
    38                   {}, {}, {}) {}
    39    
     30    P2SKernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder);   
    4031private:
    4132    void generateDoBlockMethod() const override;
     
    4536class P2S16Kernel : public KernelBuilder {
    4637public:
    47     P2S16Kernel(IDISA::IDISA_Builder * iBuilder) :
    48     KernelBuilder(iBuilder, "p2s_16",
    49                   {Binding{iBuilder->getStreamSetTy(16, 1), "basisBits"}},
    50                   {Binding{iBuilder->getStreamSetTy(1, 16), "i16Stream"}},
    51                   {}, {}, {}) {}
    52    
     38    P2S16Kernel(IDISA::IDISA_Builder * iBuilder);   
    5339private:
    5440    void generateDoBlockMethod() const override;
     
    5945class P2S16KernelWithCompressedOutput : public KernelBuilder {
    6046public:
    61     P2S16KernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
    62     KernelBuilder(iBuilder, "p2s_16_compress",
    63                   {Binding{iBuilder->getStreamSetTy(16, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
    64                   {Binding{iBuilder->getStreamSetTy(1, 16), "i16Stream"}},
    65                   {},
    66                   {},
    67                   {Binding{iBuilder->getSizeTy(), "unitsGenerated"}, Binding{iBuilder->getSizeTy(), "unitsWritten"}}) {}
     47    P2S16KernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder);
    6848       
    6949private:
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5260 r5261  
    4242// a continous buffer for the full segment (number of blocks).
    4343
     44   
     45expand3_4Kernel::expand3_4Kernel(IDISA::IDISA_Builder * iBuilder) :
     46    KernelBuilder(iBuilder, "expand3_4",
     47                  {Binding{iBuilder->getStreamSetTy(1, 8), "sourceStream"}},
     48                  {Binding{iBuilder->getStreamSetTy(1, 8), "expandedStream"}},
     49                  {}, {}, {}) {
     50        setDoBlockUpdatesProducedItemCountsAttribute(true);
     51    }
     52   
     53   
    4454void expand3_4Kernel::generateDoSegmentMethod() const {
    4555    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
     
    465475}
    466476
     477   
     478radix64Kernel::radix64Kernel(IDISA::IDISA_Builder * iBuilder) :
     479    KernelBuilder(iBuilder, "radix64",
     480                  {Binding{iBuilder->getStreamSetTy(1, 8), "expandedStream"}},
     481                  {Binding{iBuilder->getStreamSetTy(1, 8), "radix64stream"}},
     482                  {}, {}, {}) {
     483        setDoBlockUpdatesProducedItemCountsAttribute(true);
     484}
     485   
    467486void radix64Kernel::generateDoBlockMethod() const {
    468487    auto savePoint = iBuilder->saveIP();
     
    481500}
    482501
     502base64Kernel::base64Kernel(IDISA::IDISA_Builder * iBuilder) :
     503    KernelBuilder(iBuilder, "base64",
     504                  {Binding{iBuilder->getStreamSetTy(1, 8), "radix64stream"}},
     505                  {Binding{iBuilder->getStreamSetTy(1, 8), "base64stream"}},
     506                  {}, {}, {}) {
     507        setDoBlockUpdatesProducedItemCountsAttribute(true);
     508    }
     509   
    483510
    484511void base64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) const {       
  • icGREP/icgrep-devel/icgrep/kernels/radix64.h

    r5260 r5261  
    2424public:
    2525   
    26     expand3_4Kernel(IDISA::IDISA_Builder * iBuilder) :
    27     KernelBuilder(iBuilder, "expand3_4",
    28                   {Binding{iBuilder->getStreamSetTy(1, 8), "sourceStream"}},
    29                   {Binding{iBuilder->getStreamSetTy(1, 8), "expandedStream"}},
    30                   {}, {}, {}) {}
     26    expand3_4Kernel(IDISA::IDISA_Builder * iBuilder);
    3127   
    3228private:
     
    3935public:
    4036   
    41     radix64Kernel(IDISA::IDISA_Builder * iBuilder) :
    42     KernelBuilder(iBuilder, "radix64",
    43                   {Binding{iBuilder->getStreamSetTy(1, 8), "expandedStream"}},
    44                   {Binding{iBuilder->getStreamSetTy(1, 8), "radix64stream"}},
    45                   {}, {}, {}) {}
    46 
     37    radix64Kernel(IDISA::IDISA_Builder * iBuilder);
    4738private:
    4839    virtual void generateDoBlockLogic(llvm::Value * self, llvm::Value * blockNo) const override;
     
    5445public:
    5546   
    56     base64Kernel(IDISA::IDISA_Builder * iBuilder) :
    57     KernelBuilder(iBuilder, "base64",
    58                   {Binding{iBuilder->getStreamSetTy(1, 8), "radix64stream"}},
    59                   {Binding{iBuilder->getStreamSetTy(1, 8), "base64stream"}},
    60                   {}, {}, {}) {}
    61    
     47    base64Kernel(IDISA::IDISA_Builder * iBuilder);   
    6248private:
    6349    virtual void generateDoBlockLogic(llvm::Value * self, llvm::Value * blockNo) const override;
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5260 r5261  
    147147    iBuilder->SetInsertPoint(finalPartialBlock);
    148148    iBuilder->CreateCall(doBlockFunction, {self});
    149     /* Adjust the produced item count */
    150     Value * produced = getProducedItemCount(self, "basisBits");
    151     produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    152     setProducedItemCount(self, "basisBits", iBuilder->CreateAdd(produced, remainingBytes));
    153149   
    154150    iBuilder->CreateBr(exitBlock);
     
    177173        iBuilder->CreateBlockAlignedStore(basisbits[i], basisBits);
    178174    }
    179     Value * produced = getProducedItemCount(self, "basisBits");
    180     produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    181     setProducedItemCount(self, "basisBits", produced);   
    182175}
    183176   
     
    201194: KernelBuilder(builder, "s2p", {Binding{builder->getStreamSetTy(1, 8), "byteStream"}}, {Binding{builder->getStreamSetTy(8, 1), "basisBits"}}, {}, {}, {}) {
    202195    setNoTerminateAttribute(true);
    203 
    204 }
    205 
    206 }
     196    setDoBlockUpdatesProducedItemCountsAttribute(false);
     197
     198}
     199
     200}
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5260 r5261  
    8686    Value * const self = &*(f->arg_begin());
    8787    mPabloCompiler->compile(self, f);
    88     for (auto ss : mStreamSetOutputs) {
    89         Value * produced = getProducedItemCount(self, ss.name);
    90         produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    91         setProducedItemCount(self, ss.name, produced);
    92     }
    9388    iBuilder->CreateRetVoid();
    9489    #ifndef NDEBUG
     
    117112    setScalarField(self, "EOFmask", iBuilder->bitblock_mask_from(remaining));
    118113    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    119     /* Adjust the produced item count */
    120     for (auto ss : mStreamSetOutputs) {
    121         Value * produced = getProducedItemCount(self, ss.name);
    122         produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    123         produced = iBuilder->CreateAdd(produced, remaining);
    124         setProducedItemCount(self, ss.name, produced);
    125     }
    126114    iBuilder->CreateRetVoid();
    127115    #ifndef NDEBUG
     
    136124, mSymbolTable(new SymbolGenerator(mAllocator))
    137125, mEntryBlock(PabloBlock::Create(this)) {
    138 
     126setDoBlockUpdatesProducedItemCountsAttribute(false);
    139127}
    140128
Note: See TracChangeset for help on using the changeset viewer.