Changeset 5542 for icGREP


Ignore:
Timestamp:
Jul 2, 2017, 8:06:05 AM (22 months ago)
Author:
cameron
Message:

Buffer handles: bug fix

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

Legend:

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

    r5525 r5542  
    149149            report_fatal_error(getName() + ": " + mStreamSetInputs[i].name + " requires buffer size " + std::to_string(requiredBlocks));
    150150        }
    151         mScalarInputs.emplace_back(mStreamSetInputBuffers[i]->getPointerType(), mStreamSetInputs[i].name + BUFFER_PTR_SUFFIX);
     151        mScalarInputs.emplace_back(mStreamSetInputBuffers[i]->getStreamSetHandle()->getType(), mStreamSetInputs[i].name + BUFFER_PTR_SUFFIX);
    152152        if ((i == 0) || !mStreamSetInputs[i].rate.isExact()) {
    153153            addScalar(idb->getSizeTy(), mStreamSetInputs[i].name + PROCESSED_ITEM_COUNT_SUFFIX);
     
    168168
    169169        }
    170         mScalarInputs.emplace_back(mStreamSetOutputBuffers[i]->getPointerType(), mStreamSetOutputs[i].name + BUFFER_PTR_SUFFIX);
     170        mScalarInputs.emplace_back(mStreamSetOutputBuffers[i]->getStreamSetHandle()->getType(), mStreamSetOutputs[i].name + BUFFER_PTR_SUFFIX);
    171171        if ((mStreamSetInputs.empty() && (i == 0)) || !mStreamSetOutputs[i].rate.isExact()) {
    172172            addScalar(sizeTy, mStreamSetOutputs[i].name + PRODUCED_ITEM_COUNT_SUFFIX);
     
    330330    for (unsigned i = 0; i < mStreamSetInputBuffers.size(); ++i) {
    331331        assert (mStreamSetInputBuffers[i]);
    332         Value * arg = mStreamSetInputBuffers[i]->getStreamSetBasePtr();
     332        Value * arg = mStreamSetInputBuffers[i]->getStreamSetHandle();
    333333        if (LLVM_UNLIKELY(arg == nullptr)) {
    334334            report_fatal_error(getName() + ": input stream set " + std::to_string(i)
     
    340340    for (unsigned i = 0; i < mStreamSetOutputBuffers.size(); ++i) {
    341341        assert (mStreamSetOutputBuffers[i]);
    342         Value * arg = mStreamSetOutputBuffers[i]->getStreamSetBasePtr();
     342        Value * arg = mStreamSetOutputBuffers[i]->getStreamSetHandle();
    343343        if (LLVM_UNLIKELY(arg == nullptr)) {
    344344            report_fatal_error(getName() + ": output stream set " + std::to_string(i)
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5541 r5542  
    1010#include <kernels/kernel_builder.h>
    1111#include <toolchain/toolchain.h>
     12#include <llvm/Support/Debug.h>
     13#include <llvm/Support/Format.h>
    1214
    1315namespace llvm { class Constant; }
     
    577579}
    578580
    579 Type * DynamicBuffer::getStreamSetBlockType() const {
    580     return cast<PointerType>(mType->getStructElementType(int(DynamicBuffer::Field::BaseAddress)))->getElementType();
    581 }
    582 
    583 
    584 
    585 
    586581Value * DynamicBuffer::getBaseAddress(IDISA::IDISA_Builder * const b, Value * const handle) const {
    587582    b->CreateAssert(handle, "DynamicBuffer: instance cannot be null");
     
    629624
    630625void DynamicBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) {
    631     Value * handle = b->CreateCacheAlignedAlloca(getType());
     626    Value * handle = b->CreateCacheAlignedAlloca(mBufferStructType);
    632627    size_t numStreams = 1;
    633628    if (isa<ArrayType>(mBaseType)) {
     
    654649
    655650DynamicBuffer::DynamicBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t initialCapacity, size_t overflow, unsigned swizzle, unsigned addrSpace)
    656 : StreamSetBuffer(BufferKind::DynamicBuffer, type,
    657                   StructType::get(resolveStreamSetType(b, type)->getPointerTo(addrSpace),
    658                                   b->getSizeTy(), b->getSizeTy(), b->getSizeTy(), b->getSizeTy(), b->getSizeTy(), nullptr),
    659                   initialCapacity, addrSpace)
     651: StreamSetBuffer(BufferKind::DynamicBuffer, type, resolveStreamSetType(b, type), initialCapacity, addrSpace)
     652, mBufferStructType(StructType::get(resolveStreamSetType(b, type)->getPointerTo(addrSpace),
     653                                    b->getSizeTy(), b->getSizeTy(), b->getSizeTy(), b->getSizeTy(), b->getSizeTy(), nullptr))
    660654, mSwizzleFactor(swizzle)
    661655, mOverflowBlocks(overflow)
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5541 r5542  
    5454    }
    5555
    56     llvm::Value * getStreamSetBasePtr() const {
     56    llvm::Value * getStreamSetHandle() const {
    5757        return mStreamSetBufferPtr;
    5858    }
     
    315315    llvm::Value * getRawItemPointer(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * streamIndex, llvm::Value * absolutePosition) const override;
    316316
    317     llvm::Type * getStreamSetBlockType() const override;
    318    
    319317protected:
    320318    llvm::Value * getBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
     
    324322private:
    325323    /* Static data */
     324    llvm::Type * mBufferStructType;      /* The type of the buffer struct. */
    326325    unsigned   mSwizzleFactor;     /* Number of streams swizzled together per block.  Must be a small power of 2. Default: 1. */
    327326    size_t     mOverflowBlocks;    /* Number of data blocks of additional space at the end of the buffer for writing only. */
Note: See TracChangeset for help on using the changeset viewer.