Ignore:
Timestamp:
Feb 2, 2018, 2:49:08 PM (15 months ago)
Author:
nmedfort
Message:

Revised pipeline structure to better control I/O rates

File:
1 edited

Legend:

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

    r5852 r5856  
    9898    const ProcessingRate & rate = mKernel->getBinding(name).getRate();
    9999    if (LLVM_UNLIKELY(rate.isDerived())) {
     100        assert (false);
    100101        report_fatal_error("Cannot set item count: " + name + " is a Derived rate");
    101102    }
     
    237238    Type * const fieldWidthTy = getIntNTy(fieldWidth);
    238239
    239     Value * const n = buf->getStreamSetCount(this, getStreamHandle(name));
     240    Value * n = buf->getStreamSetCount(this, getStreamHandle(name));
    240241
    241242    if (isConstantOne(n) || fieldWidth == blockWidth || (isConstantZero(targetOffset) && isConstantZero(sourceOffset))) {
    242         if (isConstantOne(n)) {
    243             if (LLVM_LIKELY(itemWidth < 8)) {
    244                 itemsToCopy = CreateUDivCeil(itemsToCopy, getSize(8 / itemWidth));
    245             } else if (LLVM_UNLIKELY(itemWidth > 8)) {
    246                 itemsToCopy = CreateMul(itemsToCopy, getSize(itemWidth / 8));
    247             }
    248         } else {
    249             if (LLVM_LIKELY(blockWidth > (itemWidth * 8))) {
    250                 itemsToCopy = CreateUDivCeil(itemsToCopy, getSize(blockWidth / (8 * itemWidth)));
    251             } else if (LLVM_LIKELY(blockWidth < (itemWidth * 8))) {
    252                 itemsToCopy = CreateUDivCeil(CreateMul(itemsToCopy, getSize(8)), getSize(blockWidth / itemWidth));
    253             }
     243        if (LLVM_LIKELY(itemWidth < 8)) {
     244            itemsToCopy = CreateUDivCeil(itemsToCopy, getSize(8 / itemWidth));
     245        } else if (LLVM_UNLIKELY(itemWidth > 8)) {
     246            itemsToCopy = CreateMul(itemsToCopy, getSize(itemWidth / 8));
     247        }
     248        if (!isConstantOne(n)) {
    254249            itemsToCopy = CreateMul(itemsToCopy, n);
    255250        }
     
    260255
    261256    } else { // either the target offset or source offset is non-zero but not both
     257
    262258        VectorType * const blockTy = getBitBlockType();
    263259        PointerType * const blockPtrTy = blockTy->getPointerTo();
     
    448444
    449445StoreInst * KernelBuilder::storeOutputStreamBlock(const std::string & name, Value * streamIndex, Value * toStore) {
    450     return CreateBlockAlignedStore(toStore, getOutputStreamBlockPtr(name, streamIndex));
     446    Value * const ptr = getOutputStreamBlockPtr(name, streamIndex);
     447    Type * const storeTy = toStore->getType();
     448    Type * const ptrElemTy = ptr->getType()->getPointerElementType();
     449    if (LLVM_UNLIKELY(storeTy != ptrElemTy)) {
     450        if (LLVM_LIKELY(storeTy->canLosslesslyBitCastTo(ptrElemTy))) {
     451            toStore = CreateBitCast(toStore, ptrElemTy);
     452        } else {
     453            std::string tmp;
     454            raw_string_ostream out(tmp);
     455            out << "invalid type conversion when calling storeOutputStreamBlock on " <<  name << ": ";
     456            ptrElemTy->print(out);
     457            out << " vs. ";
     458            storeTy->print(out);
     459        }
     460    }
     461    return CreateBlockAlignedStore(toStore, ptr);
    451462}
    452463
     
    463474
    464475StoreInst * KernelBuilder::storeOutputStreamPack(const std::string & name, Value * streamIndex, Value * packIndex, Value * toStore) {
    465     return CreateBlockAlignedStore(toStore, getOutputStreamPackPtr(name, streamIndex, packIndex));
     476    Value * const ptr = getOutputStreamPackPtr(name, streamIndex, packIndex);
     477    Type * const storeTy = toStore->getType();
     478    Type * const ptrElemTy = ptr->getType()->getPointerElementType();
     479    if (LLVM_UNLIKELY(storeTy != ptrElemTy)) {
     480        if (LLVM_LIKELY(storeTy->canLosslesslyBitCastTo(ptrElemTy))) {
     481            toStore = CreateBitCast(toStore, ptrElemTy);
     482        } else {
     483            std::string tmp;
     484            raw_string_ostream out(tmp);
     485            out << "invalid type conversion when calling storeOutputStreamPack on " <<  name << ": ";
     486            ptrElemTy->print(out);
     487            out << " vs. ";
     488            storeTy->print(out);
     489        }
     490    }
     491    return CreateBlockAlignedStore(toStore, ptr);
    466492}
    467493
     
    548574}
    549575
     576void KernelBuilder::doubleCapacity(const std::string & name) {
     577    const StreamSetBuffer * const buf = mKernel->getAnyStreamSetBuffer(name);
     578    return buf->doubleCapacity(this, getStreamHandle(name));
     579}
     580
    550581BasicBlock * KernelBuilder::CreateConsumerWait() {
    551582    const auto consumers = mKernel->getStreamOutputs();
Note: See TracChangeset for help on using the changeset viewer.