Ignore:
Timestamp:
Feb 15, 2017, 4:08:37 PM (2 years ago)
Author:
nmedfort
Message:

memcpy/memset support for 32-bit systems; more error messages/handling; bug fix for ParabixCharacterClassKernelBuilder?. continued work on parenthesis matching + expandable buffers.

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

Legend:

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

    r5317 r5320  
    6868    auto & builder = ccc.getBuilder();
    6969    for (CC * cc : charClasses) {
    70         Var * const r = addOutput(cc->canonicalName(re::ByteClass), getStreamSetTy());
     70        Var * const r = addOutput(cc->canonicalName(re::ByteClass), getStreamTy());
    7171        builder.createAssign(r, ccc.compileCC("cc", cc, builder));
    7272    }
  • icGREP/icgrep-devel/icgrep/kernels/interface.cpp

    r5297 r5320  
    4545        (++args)->setName(binding.name);
    4646    }
    47     assert ((++args) == init->arg_end());
    4847
    4948    // Create the doSegment function prototype.
     
    6362        (++args)->setName(ss.name + "_availableItems");
    6463    }
    65     assert ((++args) == doSegment->arg_end());
    6664
    6765    // Add any additional kernel declarations
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5317 r5320  
    1212#include <llvm/IR/Module.h>
    1313#include <llvm/Support/raw_ostream.h>
     14#include <llvm/IR/LegacyPassManager.h>
     15#include <llvm/Transforms/Scalar.h>
    1416
    1517static const auto DO_BLOCK_SUFFIX = "_DoBlock";
     
    3234using namespace kernel;
    3335using namespace parabix;
     36using namespace llvm::legacy;
    3437
    3538unsigned KernelBuilder::addScalar(Type * const type, const std::string & name) {
    3639    if (LLVM_UNLIKELY(mKernelStateType != nullptr)) {
    37         report_fatal_error("Cannot add kernel field " + name + " after kernel state finalized");
     40        report_fatal_error("Cannot add field " + name + " to " + getName() + " after kernel state finalized");
    3841    }
    3942    if (LLVM_UNLIKELY(mKernelMap.count(name))) {
    40         report_fatal_error("Kernel already contains field " + name);
     43        report_fatal_error(getName() + " already contains scalar field " + name);
    4144    }
    4245    const auto index = mKernelFields.size();
     
    7275        raw_string_ostream out(tmp);
    7376        out << "kernel contains " << mStreamSetInputBuffers.size() << " input buffers for "
    74         << mStreamSetInputs.size() << " input stream sets.";
     77            << mStreamSetInputs.size() << " input stream sets.";
    7578        report_fatal_error(out.str());
    7679    }
     
    7982        raw_string_ostream out(tmp);
    8083        out << "kernel contains " << mStreamSetOutputBuffers.size() << " output buffers for "
    81         << mStreamSetOutputs.size() << " output stream sets.";
     84            << mStreamSetOutputs.size() << " output stream sets.";
    8285        report_fatal_error(out.str());
    8386    }
     
    123126
    124127void KernelBuilder::generateKernel(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
     128
     129    mStreamSetInputBuffers.assign(inputs.begin(), inputs.end());
     130    for (unsigned i = 0; i < mStreamSetInputBuffers.size(); ++i) {
     131        if (LLVM_UNLIKELY(mStreamSetInputBuffers[i] == nullptr)) {
     132            report_fatal_error(getName() + ": input stream set " + std::to_string(i)
     133                               + " cannot be null when calling generateKernel()");
     134        }
     135    }
     136    if (LLVM_UNLIKELY(mStreamSetInputs.size() != mStreamSetInputBuffers.size())) {
     137        report_fatal_error(getName() + ": expected " + std::to_string(mStreamSetInputs.size()) +
     138                           " input stream sets but generateKernel() was given "
     139                           + std::to_string(mStreamSetInputBuffers.size()));
     140    }
     141
     142    mStreamSetOutputBuffers.assign(outputs.begin(), outputs.end());
     143    for (unsigned i = 0; i < mStreamSetOutputBuffers.size(); ++i) {
     144        if (LLVM_UNLIKELY(mStreamSetOutputBuffers[i] == nullptr)) {
     145            report_fatal_error(getName() + ": output stream set " + std::to_string(i)
     146                               + " cannot be null when calling generateKernel()");
     147        }
     148    }
     149    if (LLVM_UNLIKELY(mStreamSetOutputs.size() != mStreamSetOutputBuffers.size())) {
     150        report_fatal_error(getName() + ": expected " + std::to_string(mStreamSetOutputs.size())
     151                           + " output stream sets but generateKernel() was given "
     152                           + std::to_string(mStreamSetOutputBuffers.size()));
     153    }
     154
     155
    125156    auto savePoint = iBuilder->saveIP();
    126     Module * const m = iBuilder->getModule();
    127     mStreamSetInputBuffers.assign(inputs.begin(), inputs.end());
    128     mStreamSetOutputBuffers.assign(outputs.begin(), outputs.end());
    129157    prepareKernel(); // possibly overridden by the KernelBuilder subtype
    130     addKernelDeclarations(m);
     158    addKernelDeclarations(iBuilder->getModule());
    131159    callGenerateInitMethod();
    132160    generateInternalMethods();
     
    154182        producerPos.push_back(&*(args++));
    155183    }
    156     assert (args == mCurrentFunction->arg_end());
    157184    generateDoSegmentMethod(doFinal, producerPos); // must be overridden by the KernelBuilder subtype
    158185    iBuilder->CreateRetVoid();
     
    177204    const auto f = mKernelMap.find(name);
    178205    if (LLVM_UNLIKELY(f == mKernelMap.end())) {
    179         report_fatal_error("Kernel does not contain scalar: " + name);
     206        report_fatal_error(getName() + " does not contain scalar: " + name);
    180207    }
    181208    return iBuilder->getInt32(f->second);
     
    314341    const auto f = mStreamSetNameMap.find(name);
    315342    if (LLVM_UNLIKELY(f == mStreamSetNameMap.end())) {
    316         throw std::runtime_error("Kernel " + getName() + " does not contain stream set: " + name);
     343        throw std::runtime_error(getName() + " does not contain stream set: " + name);
    317344    }
    318345    return f->second;
     
    329356        }
    330357    }
    331     report_fatal_error(f->getName() + " does not have parameter " + name);
     358    report_fatal_error(getName() + " does not have parameter " + name);
    332359}
    333360
     
    346373void KernelBuilder::createInstance() {
    347374    if (LLVM_UNLIKELY(mKernelStateType == nullptr)) {
    348         report_fatal_error("Cannot create kernel instance before calling prepareKernel()");
     375        report_fatal_error("Cannot instantiate " + getName() + " before calling prepareKernel()");
    349376    }
    350377    mKernelInstance = iBuilder->CreateCacheAlignedAlloca(mKernelStateType);
    351     std::vector<Value *> init_args = {mKernelInstance};
    352     for (auto a : mInitialArguments) {
    353         init_args.push_back(a);
    354     }
    355     for (auto b : mStreamSetInputBuffers) {
    356         init_args.push_back(b->getStreamSetBasePtr());
    357     }
    358     for (auto b : mStreamSetOutputBuffers) {
    359         init_args.push_back(b->getStreamSetBasePtr());
    360     }
    361     Function * initMethod = getInitFunction();
    362     iBuilder->CreateCall(initMethod, init_args);
     378
     379    std::vector<Value *> args;
     380    args.reserve(mInitialArguments.size() + mStreamSetInputBuffers.size() + mStreamSetOutputBuffers.size() + 1);
     381    args.push_back(mKernelInstance);
     382    for (unsigned i = 0; i < mInitialArguments.size(); ++i) {
     383        Value * arg = mInitialArguments[i];
     384        if (LLVM_UNLIKELY(arg == nullptr)) {
     385            report_fatal_error(getName() + ": initial argument " + std::to_string(i)
     386                               + " cannot be null when calling createInstance()");
     387        }
     388        args.push_back(arg);
     389    }
     390    for (unsigned i = 0; i < mStreamSetInputBuffers.size(); ++i) {
     391        assert (mStreamSetInputBuffers[i]);
     392        Value * arg = mStreamSetInputBuffers[i]->getStreamSetBasePtr();
     393        if (LLVM_UNLIKELY(arg == nullptr)) {
     394            report_fatal_error(getName() + ": input stream set " + std::to_string(i)
     395                               + " was not allocated prior to calling createInstance()");
     396        }
     397        args.push_back(arg);
     398    }
     399    assert (mStreamSetInputs.size() == mStreamSetInputBuffers.size());
     400    for (unsigned i = 0; i < mStreamSetOutputBuffers.size(); ++i) {
     401        assert (mStreamSetOutputBuffers[i]);
     402        Value * arg = mStreamSetOutputBuffers[i]->getStreamSetBasePtr();
     403        if (LLVM_UNLIKELY(arg == nullptr)) {
     404            report_fatal_error(getName() + ": output stream set " + std::to_string(i)
     405                               + " was not allocated prior to calling createInstance()");
     406        }
     407        args.push_back(arg);
     408    }
     409    assert (mStreamSetOutputs.size() == mStreamSetOutputBuffers.size());
     410    iBuilder->CreateCall(getInitFunction(), args);
    363411}
    364412
     
    474522    generateDoBlockMethod(); // must be implemented by the KernelBuilder subtype
    475523    iBuilder->CreateRetVoid();
     524
     525    // Use the pass manager to optimize the function.
     526    FunctionPassManager fpm(iBuilder->getModule());
     527    fpm.add(createReassociatePass());             //Reassociate expressions.
     528    fpm.add(createGVNPass());                     //Eliminate common subexpressions.
     529    fpm.add(createInstructionCombiningPass());    //Simple peephole optimizations and bit-twiddling.
     530    fpm.doInitialization();
     531    fpm.run(*mCurrentFunction);
    476532}
    477533
     
    522578    auto args = doBlock->arg_begin();
    523579    args->setName("self");
    524     assert ((++args) == doBlock->arg_end());
    525580
    526581    FunctionType * const finalBlockType = FunctionType::get(iBuilder->getVoidTy(), {selfType, iBuilder->getSizeTy()}, false);
     
    532587    args->setName("self");
    533588    (++args)->setName("remainingBytes");
    534     assert ((++args) == finalBlock->arg_end());
    535589}
    536590
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5305 r5320  
    253253
    254254void generatePipelineLoop(IDISA::IDISA_Builder * iBuilder, const std::vector<KernelBuilder *> & kernels) {
    255     for (auto k : kernels) k->createInstance();
    256    
     255    for (auto k : kernels) {
     256        k->createInstance();
     257    }
    257258    BasicBlock * entryBlock = iBuilder->GetInsertBlock();
    258259    Function * main = entryBlock->getParent();
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5317 r5320  
    2020using namespace llvm;
    2121using namespace IDISA;
     22
     23ArrayType * resolveStreamSetType(IDISA_Builder * const b, Type * type);
     24
     25StructType * resolveExpandableStreamSetType(IDISA_Builder * const b, Type * type);
    2226
    2327void StreamSetBuffer::allocateBuffer() {
     
    173177// Expandable Buffer
    174178
    175 void ExpandableBuffer::ensureStreamCapacity(llvm::Value * self, llvm::Value * streamIndex) const {
    176 
     179// Expandable Buffer
     180
     181void ExpandableBuffer::allocateBuffer() {
     182    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType());
     183    Value * const capacityPtr = iBuilder->CreateGEP(mStreamSetBufferPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
     184    iBuilder->CreateStore(iBuilder->getSize(mInitialCapacity), capacityPtr);
     185    Type * const bufferType = getType()->getStructElementType(1)->getPointerElementType();
     186    ConstantInt * const size = iBuilder->getSize(mBufferBlocks * mInitialCapacity);
     187    Value * const ptr = iBuilder->CreateAlignedMalloc(bufferType, size, iBuilder->getCacheAlignment());
     188    const auto alignment = bufferType->getPrimitiveSizeInBits() / 8;
     189    iBuilder->CreateMemZero(ptr, size, alignment);
     190    Value * const streamSetPtr = iBuilder->CreateGEP(mStreamSetBufferPtr, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
     191    iBuilder->CreateStore(ptr, streamSetPtr);
     192}
     193
     194std::pair<Value *, Value *> ExpandableBuffer::getExpandedStreamOffset(llvm::Value * self, llvm::Value * streamIndex, Value * blockIndex) const {
     195
     196    // MDNode *Weights = MDBuilder(Ctx).createBranchWeights(42, 13);
     197
     198    // ENTRY
     199    Value * const capacityPtr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
     200    Value * const capacity = iBuilder->CreateLoad(capacityPtr);
     201    Value * const streamSetPtr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
     202    Value * const streamSet = iBuilder->CreateLoad(streamSetPtr);
     203
     204    // Are we guaranteed that we can access this stream?
     205    if (LLVM_UNLIKELY(isa<ConstantInt>(streamIndex))) {
     206        if (LLVM_LIKELY(cast<ConstantInt>(streamIndex)->getLimitedValue() < mInitialCapacity)) {
     207            return {streamSet, capacity};
     208        }
     209    }
     210
     211    BasicBlock * const entry = iBuilder->GetInsertBlock();
     212    BasicBlock * const expand = BasicBlock::Create(iBuilder->getContext(), "expand", entry->getParent());
     213    BasicBlock * const resume = BasicBlock::Create(iBuilder->getContext(), "resume", entry->getParent());
     214
     215    assert (streamIndex->getType() == capacity->getType());
     216    Value * cond = iBuilder->CreateICmpULT(streamIndex, capacity);
     217    iBuilder->CreateCondBr(cond, resume, expand);
     218    // EXPAND
     219    iBuilder->SetInsertPoint(expand);
     220    /// TODO: this should call a function rather than be inlined into the block. REVISIT once tested.
     221    Value * newCapacity = iBuilder->CreateMul(streamIndex, iBuilder->getSize(2));
     222    iBuilder->CreateStore(newCapacity, capacityPtr);
     223    Type * bufferType = getType()->getStructElementType(1)->getPointerElementType();
     224    Value * size = iBuilder->CreateMul(newCapacity, iBuilder->getSize(mBufferBlocks));
     225    Value * newStreamSet = iBuilder->CreateAlignedMalloc(bufferType, size, iBuilder->getCacheAlignment());
     226    iBuilder->CreateStore(newStreamSet, streamSetPtr);
     227    Value * const diffCapacity = iBuilder->CreateSub(newCapacity, capacity);
     228    const auto alignment = bufferType->getPrimitiveSizeInBits() / 8;
     229    for (unsigned i = 0; i < mBufferBlocks; ++i) {
     230        ConstantInt * const offset = iBuilder->getSize(i);
     231        Value * srcOffset = iBuilder->CreateMul(capacity, offset);
     232        Value * srcPtr = iBuilder->CreateGEP(streamSet, srcOffset);
     233        Value * destOffset = iBuilder->CreateMul(newCapacity, offset);
     234        Value * destPtr = iBuilder->CreateGEP(newStreamSet, destOffset);
     235        iBuilder->CreateMemCpy(destPtr, srcPtr, capacity, alignment);
     236        Value * destZeroOffset = iBuilder->CreateAdd(destOffset, capacity);
     237        Value * destZeroPtr = iBuilder->CreateGEP(newStreamSet, destZeroOffset);
     238        iBuilder->CreateMemZero(destZeroPtr, diffCapacity, alignment);
     239    }
     240
     241    iBuilder->CreateAlignedFree(streamSet);
     242    iBuilder->CreateBr(resume);
     243    // RESUME
     244    iBuilder->SetInsertPoint(resume);
     245
     246    PHINode * phiStreamSet = iBuilder->CreatePHI(streamSet->getType(), 2);
     247    phiStreamSet->addIncoming(streamSet, entry);
     248    phiStreamSet->addIncoming(newStreamSet, expand);
     249
     250    PHINode * phiCapacity = iBuilder->CreatePHI(capacity->getType(), 2);
     251    phiCapacity->addIncoming(capacity, entry);
     252    phiCapacity->addIncoming(newCapacity, expand);
     253
     254    Value * offset = iBuilder->CreateAdd(iBuilder->CreateMul(blockIndex, phiCapacity), streamIndex);
     255
     256    return {phiStreamSet, offset};
    177257}
    178258
    179259llvm::Value * ExpandableBuffer::getStreamBlockPtr(llvm::Value * self, Value * streamIndex, Value * blockIndex) const {
    180     ensureStreamCapacity(self, streamIndex);
    181 
    182 
    183 
    184     return nullptr;
    185 }
    186 
    187 llvm::Value * ExpandableBuffer::getStreamPackPtr(llvm::Value * self, llvm::Value * streamIndex, Value *blockIndex, Value *packIndex) const {
    188     ensureStreamCapacity(self, streamIndex);
    189 
    190 
    191     return nullptr;
     260    Value * ptr, * offset;
     261    std::tie(ptr, offset) = getExpandedStreamOffset(self, streamIndex, blockIndex);
     262    return iBuilder->CreateGEP(ptr, offset);
     263}
     264
     265llvm::Value * ExpandableBuffer::getStreamPackPtr(llvm::Value * self, llvm::Value * streamIndex, Value * blockIndex, Value * packIndex) const {
     266    Value * ptr, * offset;
     267    std::tie(ptr, offset) = getExpandedStreamOffset(self, streamIndex, blockIndex);
     268    return iBuilder->CreateGEP(ptr, {offset, packIndex});
    192269}
    193270
    194271Value * ExpandableBuffer::getStreamSetBlockPtr(Value *, Value *) const {
    195     report_fatal_error("Expandable buffers: getStreamSetBlockPtr not supported.");
     272    report_fatal_error("Expandable buffers: getStreamSetPtr is not supported.");
    196273}
    197274
    198275Value * ExpandableBuffer::getLinearlyAccessibleItems(llvm::Value *) const {
    199     report_fatal_error("Expandable buffers: getLinearlyAccessibleItems not supported.");
     276    report_fatal_error("Expandable buffers: getLinearlyAccessibleItems is not supported.");
    200277}
    201278
    202279// Constructors
    203 
    204280SingleBlockBuffer::SingleBlockBuffer(IDISA::IDISA_Builder * b, llvm::Type * type)
    205 : StreamSetBuffer(BufferKind::BlockBuffer, b, type, 1, 0) {
     281: StreamSetBuffer(BufferKind::BlockBuffer, b, type, resolveStreamSetType(b, type), 1, 0) {
    206282
    207283}
    208284
    209285ExternalFileBuffer::ExternalFileBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, unsigned AddressSpace)
    210 : StreamSetBuffer(BufferKind::ExternalFileBuffer, b, type, 0, AddressSpace) {
     286: StreamSetBuffer(BufferKind::ExternalFileBuffer, b, type, resolveStreamSetType(b, type), 0, AddressSpace) {
    211287
    212288}
    213289
    214290CircularBuffer::CircularBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace)
    215 : StreamSetBuffer(BufferKind::CircularBuffer, b, type, bufferBlocks, AddressSpace) {
     291: StreamSetBuffer(BufferKind::CircularBuffer, b, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace) {
    216292
    217293}
    218294
    219295CircularCopybackBuffer::CircularCopybackBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace)
    220 : StreamSetBuffer(BufferKind::CircularCopybackBuffer, b, type, bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks) {
     296: StreamSetBuffer(BufferKind::CircularCopybackBuffer, b, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks) {
    221297
    222298}
    223299
    224300ExpandableBuffer::ExpandableBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace)
    225 : StreamSetBuffer(BufferKind::ExpandableBuffer, b, type, bufferBlocks, AddressSpace) {
    226 
    227 }
    228 
    229 inline Type * resolveStreamSetType(IDISA_Builder * const b, Type * const type) {
    230     if (type->isArrayTy()) {
    231         Type * ty = type->getArrayElementType();
    232         if (LLVM_LIKELY(ty->isVectorTy() && ty->getVectorNumElements() == 0)) {
    233             ty = ty->getVectorElementType();
    234             if (LLVM_LIKELY(ty->isIntegerTy())) {
    235                 const auto fieldWidth = cast<IntegerType>(ty)->getBitWidth();
    236                 ty = b->getBitBlockType();
    237                 if (fieldWidth != 1) {
    238                     ty = llvm::ArrayType::get(ty, fieldWidth);
    239                 }
    240                 return ArrayType::get(ty, type->getArrayNumElements());
     301: StreamSetBuffer(BufferKind::ExpandableBuffer, b, type, resolveExpandableStreamSetType(b, type), bufferBlocks, AddressSpace)
     302, mInitialCapacity(type->getArrayNumElements()) {
     303
     304}
     305
     306inline StreamSetBuffer::StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, Type * baseType, Type * resolvedType, unsigned blocks, unsigned AddressSpace)
     307: mBufferKind(k)
     308, iBuilder(b)
     309, mType(resolvedType)
     310, mBufferBlocks(blocks)
     311, mAddressSpace(AddressSpace)
     312, mStreamSetBufferPtr(nullptr)
     313, mBaseType(baseType) {
     314
     315}
     316
     317// Helper routines
     318ArrayType * resolveStreamSetType(IDISA_Builder * const b, Type * type) {
     319    unsigned numElements = 1;
     320    if (LLVM_LIKELY(type->isArrayTy())) {
     321        numElements = type->getArrayNumElements();
     322        type = type->getArrayElementType();
     323    }
     324    if (LLVM_LIKELY(type->isVectorTy() && type->getVectorNumElements() == 0)) {
     325        type = type->getVectorElementType();
     326        if (LLVM_LIKELY(type->isIntegerTy())) {
     327            const auto fieldWidth = cast<IntegerType>(type)->getBitWidth();
     328            type = b->getBitBlockType();
     329            if (fieldWidth != 1) {
     330                type = ArrayType::get(type, fieldWidth);
    241331            }
     332            return ArrayType::get(type, numElements);
    242333        }
    243334    }
     
    249340}
    250341
    251 StreamSetBuffer::StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, Type * type, unsigned blocks, unsigned AddressSpace)
    252 : mBufferKind(k)
    253 , iBuilder(b)
    254 , mType(resolveStreamSetType(b, type))
    255 , mBufferBlocks(blocks)
    256 , mAddressSpace(AddressSpace)
    257 , mStreamSetBufferPtr(nullptr)
    258 , mBaseType(type) {
    259 
    260 }
     342StructType * resolveExpandableStreamSetType(IDISA_Builder * const b, Type * type) {
     343    if (LLVM_LIKELY(type->isArrayTy())) {
     344        type = type->getArrayElementType();
     345    }
     346    if (LLVM_LIKELY(type->isVectorTy() && type->getVectorNumElements() == 0)) {
     347        type = type->getVectorElementType();
     348        if (LLVM_LIKELY(type->isIntegerTy())) {
     349            const auto fieldWidth = cast<IntegerType>(type)->getBitWidth();
     350            type = b->getBitBlockType();
     351            if (fieldWidth != 1) {
     352                type = ArrayType::get(type, fieldWidth);
     353            }
     354            return StructType::get(b->getSizeTy(), type->getPointerTo(), nullptr);
     355        }
     356    }
     357    std::string tmp;
     358    raw_string_ostream out(tmp);
     359    type->print(out);
     360    out << " is an unvalid stream set buffer type.";
     361    report_fatal_error(out.str());
     362}
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5317 r5320  
    5858protected:
    5959
    60     StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * type, unsigned blocks, unsigned AddressSpace);
     60    StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * baseType, llvm::Type * resolvedType, unsigned blocks, unsigned AddressSpace);
    6161
    6262    // Get the buffer pointer for a given block of the stream.
     
    148148// within their set whenever the index exceeds its capacity
    149149//
     150// ExpandableBuffers do not allow access to the base stream set but will automatically increase the number of streams
     151// within their set whenever the index exceeds its capacity
     152//
    150153class ExpandableBuffer : public StreamSetBuffer {
    151154public:
     
    159162
    160163    llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
    161    
     164
     165    void allocateBuffer() override;
     166
    162167protected:
    163168
    164     void ensureStreamCapacity(llvm::Value * self, llvm::Value * streamIndex) const;
     169    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    165170
    166     llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
     171private:
     172
     173    std::pair<llvm::Value *, llvm::Value *> getExpandedStreamOffset(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const;
     174
     175private:
     176
     177    const uint64_t  mInitialCapacity;
     178
    167179};
    168180
Note: See TracChangeset for help on using the changeset viewer.