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

Separate processedItemCounts and producedItemCounts for each stream set

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.