Changeset 5247


Ignore:
Timestamp:
Jan 7, 2017, 12:26:09 PM (10 months ago)
Author:
cameron
Message:

Separate processedItemCounts and producedItemCounts for each stream set

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

Legend:

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

    r5246 r5247  
    4040    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    4141    /* Adjust the produced item count */
    42     Value * produced = getProducedItemCount(self);
     42    Value * produced = getProducedItemCount(self, "ResultStream");
    4343    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    44     setProducedItemCount(self, iBuilder->CreateAdd(produced, remaining));
     44    setProducedItemCount(self, "ResultStream", iBuilder->CreateAdd(produced, remaining));
    4545    iBuilder->CreateRetVoid();
    4646    iBuilder->restoreIP(savePoint);
     
    115115    }
    116116
    117     Value * produced = getProducedItemCount(kernelStuctParam);
     117    Value * produced = getProducedItemCount(kernelStuctParam, "ResultStream");
    118118    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    119     setProducedItemCount(kernelStuctParam, produced);
     119    setProducedItemCount(kernelStuctParam, "ResultStream", produced);
    120120       
    121121    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.cpp

    r5246 r5247  
    4242    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    4343    /* Adjust the produced item count */
    44     Value * produced = getProducedItemCount(self);
     44    Value * produced = getProducedItemCount(self, "ResultStream");
    4545    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    46     setProducedItemCount(self, iBuilder->CreateAdd(produced, remaining));
     46    setProducedItemCount(self, "ResultStream", iBuilder->CreateAdd(produced, remaining));
    4747    iBuilder->CreateRetVoid();
    4848    iBuilder->restoreIP(savePoint);
     
    123123    }
    124124
    125     Value * produced = getProducedItemCount(kernelStuctParam);
     125    Value * produced = getProducedItemCount(kernelStuctParam, "ResultStream");
    126126    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    127     setProducedItemCount(kernelStuctParam, produced);
     127    setProducedItemCount(kernelStuctParam, "ResultStream", produced);
    128128       
    129129    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/kernels/deletion.cpp

    r5246 r5247  
    8383    /* Stream deletion has only been applied within fields; the actual number of data items
    8484     * has not yet changed.   */
    85     Value * produced = getProducedItemCount(self);
     85    Value * produced = getProducedItemCount(self, "outputStreamSet");
    8686    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    87     setProducedItemCount(self, produced);
     87    setProducedItemCount(self, "outputStreamSet", produced);
     88    setProducedItemCount(self, "deletionCounts", produced);
    8889    iBuilder->CreateRetVoid();
    8990    iBuilder->restoreIP(savePoint);
     
    110111    iBuilder->CreateCall(doBlockFunction, {self});
    111112    /* Adjust the produced item count */
    112     Value * produced = getProducedItemCount(self);
     113    Value * produced = getProducedItemCount(self, "outputStreamSet");
    113114    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    114     setProducedItemCount(self, iBuilder->CreateAdd(produced, remainingBytes));
     115    produced =  iBuilder->CreateAdd(produced, remainingBytes);
     116    setProducedItemCount(self, "outputStreamSet", produced);
     117    setProducedItemCount(self, "deletionCounts", produced);
    115118
    116119    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5246 r5247  
    6262    }
    6363
    64     virtual llvm::Value * getProcessedItemCount(llvm::Value * self) const = 0;
    65     virtual llvm::Value * getProducedItemCount(llvm::Value * self) const = 0;
     64    virtual llvm::Value * getProcessedItemCount(llvm::Value * self, const std::string & ssName) const = 0;
     65    virtual llvm::Value * getProducedItemCount(llvm::Value * self, const std::string & ssName) const = 0;
    6666    virtual llvm::Value * getTerminationSignal(llvm::Value * self) const = 0;
    6767   
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5246 r5247  
    6262        mScalarInputs.push_back(Binding{mStreamSetInputBuffers[i]->getStreamSetStructPointerType(), mStreamSetInputs[i].name + structPtrSuffix});
    6363        mStreamSetNameMap.emplace(mStreamSetInputs[i].name, streamSetNo);
     64        addScalar(iBuilder->getSizeTy(), mStreamSetInputs[i].name + processedItemCountSuffix);
    6465        streamSetNo++;
    6566    }
     
    6768        mScalarInputs.push_back(Binding{mStreamSetOutputBuffers[i]->getStreamSetStructPointerType(), mStreamSetOutputs[i].name + structPtrSuffix});
    6869        mStreamSetNameMap.emplace(mStreamSetOutputs[i].name, streamSetNo);
     70        addScalar(iBuilder->getSizeTy(), mStreamSetOutputs[i].name + producedItemCountSuffix);
    6971        streamSetNo++;
    7072    }
     
    8082    addScalar(iBuilder->getSizeTy(), blockNoScalar);
    8183    addScalar(iBuilder->getSizeTy(), logicalSegmentNoScalar);
    82     addScalar(iBuilder->getSizeTy(), processedItemCount);
    83     addScalar(iBuilder->getSizeTy(), producedItemCount);
    8484    addScalar(iBuilder->getInt1Ty(), terminationSignal);
    8585    mKernelStateType = StructType::create(iBuilder->getContext(), mKernelFields, mKernelName);
     
    208208        availablePos = iBuilder->CreateSelect(iBuilder->CreateICmpULT(availablePos, p), availablePos, p);
    209209    }
    210     Value * processed = getProcessedItemCount(self);
     210    Value * processed = getProcessedItemCount(self, mStreamSetInputs[0].name);
    211211    Value * itemsAvail = iBuilder->CreateSub(availablePos, processed);
    212212//#ifndef NDEBUG
     
    237237    iBuilder->SetInsertPoint(stridesDone);
    238238    processed = iBuilder->CreateAdd(processed, iBuilder->CreateMul(stridesToDo, stride));
    239     setProcessedItemCount(self, processed);
     239    setProcessedItemCount(self, mStreamSetInputs[0].name, processed);
    240240    iBuilder->CreateCondBr(lessThanFullSegment, checkFinalStride, segmentDone);
    241241   
     
    265265    Value * remainingItems = iBuilder->CreateSub(availablePos, processed);
    266266    createFinalBlockCall(self, remainingItems);
    267     setProcessedItemCount(self, availablePos);
     267    setProcessedItemCount(self, mStreamSetInputs[0].name, availablePos);
    268268   
    269269    for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
     
    275275   
    276276    iBuilder->SetInsertPoint(segmentDone);
    277     Value * produced = getProducedItemCount(self);
    278277//#ifndef NDEBUG
    279278//    iBuilder->CallPrintInt(mKernelName + "_produced", produced);
    280279//#endif
    281280    for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
     281        Value * produced = getProducedItemCount(self, mStreamSetOutputs[i].name);
    282282        Value * ssStructPtr = getStreamSetStructPtr(self, mStreamSetOutputs[i].name);
    283283        Value * producerPosPtr = mStreamSetOutputBuffers[i]->getProducerPosPtr(ssStructPtr);
     
    320320}
    321321
    322 Value * KernelBuilder::getProcessedItemCount(Value * self) const {
    323     return getScalarField(self, processedItemCount);
    324 }
    325 
    326 Value * KernelBuilder::getProducedItemCount(Value * self) const {
    327     return getScalarField(self, producedItemCount);
     322Value * KernelBuilder::getProcessedItemCount(Value * self, const std::string & ssName) const {
     323    return getScalarField(self, ssName + processedItemCountSuffix);
     324}
     325
     326Value * KernelBuilder::getProducedItemCount(Value * self, const std::string & ssName) const {
     327    return getScalarField(self, ssName + producedItemCountSuffix);
    328328}
    329329
     
    337337}
    338338
    339 void KernelBuilder::setProcessedItemCount(Value * self, Value * newCount) const {
    340     Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(processedItemCount)});
     339void KernelBuilder::setProcessedItemCount(Value * self, const std::string & ssName, Value * newCount) const {
     340    Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(ssName + processedItemCountSuffix)});
    341341    iBuilder->CreateStore(newCount, ptr);
    342342}
    343343
    344 void KernelBuilder::setProducedItemCount(Value * self, Value * newCount) const {
    345     Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(producedItemCount)});
     344void KernelBuilder::setProducedItemCount(Value * self, const std::string & ssName, Value * newCount) const {
     345    Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(ssName + producedItemCountSuffix)});
    346346    iBuilder->CreateStore(newCount, ptr);
    347347}
     
    542542    }
    543543   
    544     Value * produced = getProducedItemCount(self);
    545544    for (unsigned i = 0; i < outbufProducerPtrs.size(); i++) {
     545        Value * produced = getProducedItemCount(self, mStreamSetOutputs[i].name);
    546546        iBuilder->CreateAtomicStoreRelease(produced, outbufProducerPtrs[i]);
    547547    }
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5246 r5247  
    1616const std::string blockNoScalar = "blockNo";
    1717const std::string logicalSegmentNoScalar = "logicalSegNo";
    18 const std::string processedItemCount = "processedItemCount";
    19 const std::string producedItemCount = "producedItemCount";
     18const std::string processedItemCountSuffix = "_processedItemCount";
     19const std::string producedItemCountSuffix = "_producedItemCount";
    2020const std::string terminationSignal = "terminationSignal";
    2121const std::string structPtrSuffix = "_structPtr";
     
    4242
    4343    Value * getBlockNo(Value * self) const;
    44     virtual Value * getProcessedItemCount(Value * self) const override;
    45     virtual Value * getProducedItemCount(Value * self) const override;
     44    virtual Value * getProcessedItemCount(Value * self, const std::string & ssName) const override;
     45    virtual Value * getProducedItemCount(Value * self, const std::string & ssName) const override;
    4646    virtual void initializeKernelState(Value * self) const;
    4747    Value * getTerminationSignal(Value * self) const override;
     
    155155    void setBlockNo(Value * self, Value * newFieldVal) const;
    156156
    157     virtual void setProcessedItemCount(Value * self, Value * newFieldVal) const;
     157    virtual void setProcessedItemCount(Value * self, const std::string & ssName, Value * newFieldVal) const;
    158158
    159     virtual void setProducedItemCount(Value * self, Value * newFieldVal) const;
     159    virtual void setProducedItemCount(Value * self, const std::string & ssName, Value * newFieldVal) const;
    160160
    161161    void setTerminationSignal(Value * self) const;
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5246 r5247  
    156156    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
    157157    Value * delCountBlock_ptr = getStreamSetBlockPtr(self, "deletionCounts", blockNo);
    158     Value * i16UnitsGenerated = getProducedItemCount(self); // units generated to buffer
     158    Value * i16UnitsGenerated = getProducedItemCount(self, "i16Stream"); // units generated to buffer
    159159    Value * i16BlockNo = iBuilder->CreateUDiv(i16UnitsGenerated, stride);
    160160
     
    194194
    195195    i16UnitsGenerated = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
    196     setProducedItemCount(self, i16UnitsGenerated);
     196    setProducedItemCount(self, "i16Stream", i16UnitsGenerated);
    197197    iBuilder->CreateRetVoid();
    198198    iBuilder->restoreIP(savePoint);
     
    213213        doBlockArgs.push_back(&*args++);
    214214    }
    215     Value * i16UnitsGenerated = getProducedItemCount(self); // units generated to buffer
     215    Value * i16UnitsGenerated = getProducedItemCount(self, "i16Stream"); // units generated to buffer
    216216
    217217    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    218     i16UnitsGenerated = getProducedItemCount(self); // units generated to buffer
     218    i16UnitsGenerated = getProducedItemCount(self, "i16Stream"); // units generated to buffer
    219219    for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
    220220        Value * ssStructPtr = getStreamSetStructPtr(self, mStreamSetOutputs[i].name);
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5246 r5247  
    9595
    9696    LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr));
    97     Value * processed = getProcessedItemCount(self);
     97    Value * processed = getProcessedItemCount(self, "sourceStream");
    9898    Value * itemsAvail = iBuilder->CreateSub(producerPos, processed);
    9999   
     
    116116    Value * sourceBlockPtr = getStreamSetBlockPtr(self, "sourceStream", blockNo);
    117117
    118     Value * outputGenerated = getProducedItemCount(self); // bytes previously generated to output
     118    Value * outputGenerated = getProducedItemCount(self, "expandedStream"); // bytes previously generated to output
    119119    Value * outputBlockNo = iBuilder->CreateUDiv(outputGenerated, stride);
    120120
     
    250250
    251251    processed = iBuilder->CreateAdd(processed, itemsToDo);
    252     setProcessedItemCount(self, processed);
     252    setProcessedItemCount(self, "sourceStream", processed);
    253253
    254254    setScalarField(self, blockNoScalar, iBuilder->CreateUDiv(processed, stride));
     
    257257    // input byte.
    258258    Value * totalProduced = iBuilder->CreateAdd(iBuilder->CreateMul(iBuilder->CreateUDiv(processed, Const3), Const4), iBuilder->CreateURem(processed, Const3));
    259     setProducedItemCount(self, totalProduced);
     259    setProducedItemCount(self, "expandedStream", totalProduced);
    260260    Value * ssStructPtr = getStreamSetStructPtr(self, "expandedStream");
    261261
     
    337337        iBuilder->CreateBlockAlignedStore(radix64pack, radix64stream, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    338338    }
    339     Value * produced = getProducedItemCount(self);
     339    Value * produced = getProducedItemCount(self, "radix64stream");
    340340    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    341     setProducedItemCount(self, produced);   
     341    setProducedItemCount(self, "radix64stream", produced);   
    342342}
    343343
     
    450450    iBuilder->SetInsertPoint(fbExit);
    451451    Value * outputNumberAdd = iBuilder->CreateSelect(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(0)), iBuilder->getSize(0), iBuilder->getSize(1));
    452     Value * produced = iBuilder->CreateAdd(getProducedItemCount(self), iBuilder->CreateAdd(remainingBytes, outputNumberAdd));
    453     setProducedItemCount(self, produced);
     452    Value * produced = iBuilder->CreateAdd(getProducedItemCount(self, "radix64stream"), iBuilder->CreateAdd(remainingBytes, outputNumberAdd));
     453    setProducedItemCount(self, "radix64stream", produced);
    454454
    455455    iBuilder->CreateRetVoid();
     
    496496        iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    497497    }
    498     Value * produced = getProducedItemCount(self);
     498    Value * produced = getProducedItemCount(self, "base64stream");
    499499    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    500     setProducedItemCount(self, produced);   
     500    setProducedItemCount(self, "base64stream", produced);
    501501}
    502502
     
    566566    iBuilder->CreateBr(fbExit);
    567567    iBuilder->SetInsertPoint(fbExit);
    568     Value * produced = iBuilder->CreateAdd(getProducedItemCount(self), iBuilder->CreateAdd(remainingBytes, padBytes));
    569     setProducedItemCount(self, produced);
    570 
    571 
     568    Value * produced = iBuilder->CreateAdd(getProducedItemCount(self, "base64stream"), iBuilder->CreateAdd(remainingBytes, padBytes));
     569    setProducedItemCount(self, "base64stream", produced);
    572570    iBuilder->CreateRetVoid();
    573571    iBuilder->restoreIP(savePoint);
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5246 r5247  
    143143    iBuilder->CreateCall(doBlockFunction, {self});
    144144    /* Adjust the produced item count */
    145     Value * produced = getProducedItemCount(self);
     145    Value * produced = getProducedItemCount(self, "basisBits");
    146146    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    147     setProducedItemCount(self, iBuilder->CreateAdd(produced, remainingBytes));
     147    setProducedItemCount(self, "basisBits", iBuilder->CreateAdd(produced, remainingBytes));
    148148   
    149149    iBuilder->CreateBr(exitBlock);
     
    176176        iBuilder->CreateBlockAlignedStore(basisbits[i], basisBits, {iBuilder->getInt32(0), iBuilder->getInt32(i)});
    177177    }
    178     Value * produced = getProducedItemCount(self);
     178    Value * produced = getProducedItemCount(self, "basisBits");
    179179    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    180     setProducedItemCount(self, produced);   
     180    setProducedItemCount(self, "basisBits", produced);   
    181181}
    182182   
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5246 r5247  
    4646    LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr));
    4747    //iBuilder->CallPrintInt("producerPos", producerPos);
    48     Value * processed = getProcessedItemCount(self);
     48    Value * processed = getProcessedItemCount(self, "codeUnitBuffer");
    4949    Value * itemsAvail = iBuilder->CreateSub(producerPos, processed);
    5050    Value * itemsMax = iBuilder->CreateMul(blocksToDo, blockItems);
     
    6262
    6363    processed = iBuilder->CreateAdd(processed, itemsToDo);
    64     setProcessedItemCount(self, processed);
     64    setProcessedItemCount(self, "codeUnitBuffer", processed);
    6565    setScalarField(self, blockNoScalar, iBuilder->CreateUDiv(processed, blockItems));
    6666    mStreamSetInputBuffers[0]->setConsumerPos(streamStructPtr, processed);
     
    9292    Value * streamStructPtr = getStreamSetStructPtr(self, "codeUnitBuffer");
    9393    LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr));
    94     Value * processed = getProcessedItemCount(self);
     94    Value * processed = getProcessedItemCount(self, "codeUnitBuffer");
    9595    Value * itemsAvail = iBuilder->CreateSub(producerPos, processed);
    9696    Value * blockNo = getScalarField(self, blockNoScalar);
     
    9999    Value * bytePtr = iBuilder->CreateGEP(iBuilder->CreateBitCast(basePtr, i8PtrTy), byteOffset);
    100100    iBuilder->CreateWriteCall(iBuilder->getInt32(1), bytePtr, iBuilder->CreateMul(itemsAvail, itemBytes));
    101     setProcessedItemCount(self, producerPos);
     101    setProcessedItemCount(self, "codeUnitBuffer", producerPos);
    102102    mStreamSetInputBuffers[0]->setConsumerPos(streamStructPtr, producerPos);
    103103    setTerminationSignal(self);
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5246 r5247  
    8686    Value * const self = &*(f->arg_begin());
    8787    mPabloCompiler->compile(self, f);
    88     Value * produced = getProducedItemCount(self);
    89     produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    90     setProducedItemCount(self, produced);
     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    }
    9193    iBuilder->CreateRetVoid();
    9294    #ifndef NDEBUG
     
    116118    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    117119    /* Adjust the produced item count */
    118     Value * produced = getProducedItemCount(self);
    119     produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    120     setProducedItemCount(self, iBuilder->CreateAdd(produced, remaining));
     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    }
    121126    iBuilder->CreateRetVoid();
    122127    #ifndef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.