Ignore:
Timestamp:
Feb 5, 2017, 3:25:17 PM (2 years ago)
Author:
cameron
Message:

Refined copy-back buffers, use copyback in p2s_compressed; stdout/filesink mods for circular buffers

File:
1 edited

Legend:

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

    r5297 r5303  
    1010
    1111using namespace llvm;
     12using namespace parabix;
    1213
    1314namespace kernel{
     
    176177        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j + 1)), i32Ty);
    177178    }
    178     i16UnitsGenerated = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
    179     setProducedItemCount("i16Stream", i16UnitsGenerated);
     179    Value * i16UnitsFinal = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
     180    setProducedItemCount("i16Stream", i16UnitsFinal);
     181    auto const &b  = getStreamSetBuffer("i16Stream");
     182
     183    if (auto cb = dyn_cast<CircularCopybackBuffer>(b)) {
     184        BasicBlock * copyBack = CreateBasicBlock("copyBack");
     185        BasicBlock * p2sCompressDone = CreateBasicBlock("p2sCompressDone");
     186       
     187        // Check for overflow into the buffer overflow area and copy data back if so.
     188        Value * accessible = cb->getLinearlyAccessibleItems(i16UnitsGenerated);
     189        offset = iBuilder->CreateZExt(offset, iBuilder->getSizeTy());
     190        Value * wraparound = iBuilder->CreateICmpULT(accessible, offset);
     191        iBuilder->CreateCondBr(wraparound, copyBack, p2sCompressDone);
     192       
     193        iBuilder->SetInsertPoint(copyBack);
     194        Value * copyItems = iBuilder->CreateSub(offset, accessible);
     195        cb->createCopyBack(getStreamSetBufferPtr("i16Stream"), copyItems);
     196        iBuilder->CreateBr(p2sCompressDone);
     197        iBuilder->SetInsertPoint(p2sCompressDone);
     198    }
    180199}
    181200   
Note: See TracChangeset for help on using the changeset viewer.