Ignore:
Timestamp:
Feb 18, 2017, 6:19:02 PM (2 years ago)
Author:
cameron
Message:

Make circular copyback testing available for all block-oriented kernels

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
2 edited

Legend:

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

    r5329 r5330  
    533533    mSelf = &(*args);
    534534    iBuilder->SetInsertPoint(CreateBasicBlock("entry"));
     535    std::vector<Value *> priorProduced;
     536    for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
     537        if (isa<CircularCopybackBuffer>(mStreamSetOutputBuffers[i]))  {
     538            priorProduced.push_back(getProducedItemCount(mStreamSetOutputs[i].name));
     539        }
     540    }
    535541    generateDoBlockMethod(); // must be implemented by the KernelBuilder subtype
     542    for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
     543        unsigned priorIdx = 0;
     544        if (auto cb = dyn_cast<CircularCopybackBuffer>(mStreamSetOutputBuffers[i]))  {
     545            BasicBlock * copyBack = CreateBasicBlock(mStreamSetOutputs[i].name + "_copyBack");
     546            BasicBlock * done = CreateBasicBlock(mStreamSetOutputs[i].name + "_copyBackDone");
     547            Value * newlyProduced = iBuilder->CreateSub(getProducedItemCount(mStreamSetOutputs[i].name), priorProduced[priorIdx]);
     548            Value * accessible = cb->getLinearlyAccessibleItems(priorProduced[priorIdx]);
     549            Value * wraparound = iBuilder->CreateICmpULT(accessible, newlyProduced);
     550            iBuilder->CreateCondBr(wraparound, copyBack, done);
     551            iBuilder->SetInsertPoint(copyBack);
     552            Value * copyItems = iBuilder->CreateSub(newlyProduced, accessible);
     553            cb->createCopyBack(getStreamSetBufferPtr(mStreamSetOutputs[i].name), copyItems);
     554            iBuilder->CreateBr(done);
     555            iBuilder->SetInsertPoint(done);
     556            priorIdx++;
     557        }
     558    }   
    536559    iBuilder->CreateRetVoid();
    537560    #ifndef NDEBUG
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5328 r5330  
    173173    Value * i16UnitsFinal = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
    174174    setProducedItemCount("i16Stream", i16UnitsFinal);
    175     const auto b  = getOutputStreamSetBuffer("i16Stream");
    176 
    177     if (auto cb = dyn_cast<CircularCopybackBuffer>(b)) {
    178         BasicBlock * copyBack = CreateBasicBlock("copyBack");
    179         BasicBlock * p2sCompressDone = CreateBasicBlock("p2sCompressDone");
    180        
    181         // Check for overflow into the buffer overflow area and copy data back if so.
    182         Value * accessible = cb->getLinearlyAccessibleItems(i16UnitsGenerated);
    183         offset = iBuilder->CreateZExt(offset, iBuilder->getSizeTy());
    184         Value * wraparound = iBuilder->CreateICmpULT(accessible, offset);
    185         iBuilder->CreateCondBr(wraparound, copyBack, p2sCompressDone);
    186        
    187         iBuilder->SetInsertPoint(copyBack);
    188         Value * copyItems = iBuilder->CreateSub(offset, accessible);
    189         cb->createCopyBack(getStreamSetBufferPtr("i16Stream"), copyItems);
    190         iBuilder->CreateBr(p2sCompressDone);
    191         iBuilder->SetInsertPoint(p2sCompressDone);
    192     }
    193175}
    194176   
Note: See TracChangeset for help on using the changeset viewer.