Ignore:
Timestamp:
Dec 20, 2017, 11:42:53 AM (14 months ago)
Author:
nmedfort
Message:

Bug fix for pipeline: it was terminating too early when there was insufficient output space to process all of the input for a kernel.

File:
1 edited

Legend:

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

    r5782 r5793  
    118118
    119119Value * KernelBuilder::getTerminationSignal() {
    120     if (mKernel->hasNoTerminateAttribute()) {
    121         return getFalse();
    122     }
    123     return getScalarField(Kernel::TERMINATION_SIGNAL);
     120    return CreateICmpNE(getScalarField(Kernel::TERMINATION_SIGNAL), getSize(0));
    124121}
    125122
    126123void KernelBuilder::setTerminationSignal(llvm::Value * const value) {
    127     assert (!mKernel->hasNoTerminateAttribute());
    128124    assert (value->getType() == getInt1Ty());
    129125    if (codegen::DebugOptionIsSet(codegen::TraceCounts)) {
    130126        CallPrintIntToStderr(mKernel->getName() + ": setTerminationSignal", value);
    131127    }
    132     setScalarField(Kernel::TERMINATION_SIGNAL, value);
     128    setScalarField(Kernel::TERMINATION_SIGNAL, CreateZExt(value, getSizeTy()));
    133129}
    134130
     
    142138    return buf->getLinearlyWritableItems(this, getStreamHandle(name), fromPosition, getConsumedItemCount(name), reverse);
    143139}
    144 
    145 //Value * KernelBuilder::getLinearlyCopyableItems(const std::string & name, Value * fromPosition, bool reverse) {
    146 //    const StreamSetBuffer * const buf = mKernel->getOutputStreamSetBuffer(name);
    147 //    return buf->getLinearlyCopyableItems(this, getStreamHandle(name), fromPosition, reverse);
    148 //}
    149140
    150141/** ------------------------------------------------------------------------------------------------------------- *
     
    196187
    197188    const StreamSetBuffer * const buf = mKernel->getAnyStreamSetBuffer(name);
     189
    198190    const auto itemWidth = getItemWidth(buf->getBaseType());
    199191    assert ("invalid item width" && is_power_2(itemWidth));
     
    202194    // (w.r.t the stream copy) would be n*m. By taking this into account we can optimize and simplify the copy code.
    203195    const auto fieldWidth = getFieldWidth(itemWidth * itemAlignment, blockWidth);
    204 
    205 //    CallPrintInt(mKernel->getName() + "_" + name + "_target", target);
    206 //    CallPrintInt(mKernel->getName() + "_" + name + "_targetOffset", targetOffset);
    207 //    CallPrintInt(mKernel->getName() + "_" + name + "_source", source);
    208 //    CallPrintInt(mKernel->getName() + "_" + name + "_sourceOffset", sourceOffset);
    209 //    CallPrintInt(mKernel->getName() + "_" + name + "_itemsToCopy", itemsToCopy);
    210 
     196    const auto alignment = (fieldWidth + 7) / 8;
    211197    if (LLVM_LIKELY(itemWidth < fieldWidth)) {
    212         Constant * const factor = getSize(fieldWidth / itemWidth);
    213         CreateAssertZero(CreateURem(targetOffset, factor), "target offset is not a multiple of its field width");
    214         targetOffset = CreateUDiv(targetOffset, factor);
    215         CreateAssertZero(CreateURem(sourceOffset, factor), "source offset is not a multiple of its field width");
    216         sourceOffset = CreateUDiv(sourceOffset, factor);
     198        const auto factor = fieldWidth / itemWidth;
     199        Constant * const FACTOR = getSize(factor);
     200        if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
     201            ConstantInt * const ALIGNMENT = getSize(alignment);
     202            const auto kernelName = mKernel->getName()+ ": " + name;
     203            CreateAssertZero(CreateURem(CreatePtrToInt(target, getSizeTy()), ALIGNMENT), kernelName + " target is misaligned (" + std::to_string(alignment) + ")");
     204            CreateAssertZero(CreateURem(targetOffset, FACTOR), kernelName + " target offset is misaligned (" + std::to_string(factor) + ")");
     205            CreateAssertZero(CreateURem(CreatePtrToInt(source, getSizeTy()), ALIGNMENT), kernelName + " source is misaligned (" + std::to_string(alignment) + ")");
     206            CreateAssertZero(CreateURem(sourceOffset, FACTOR), kernelName + " source offset is misaligned (" + std::to_string(factor) + ")");
     207        }
     208        targetOffset = CreateUDiv(targetOffset, FACTOR);
     209        sourceOffset = CreateUDiv(sourceOffset, FACTOR);
    217210    }
    218211
     
    240233
    241234    */
    242 
    243     const auto alignment = (fieldWidth + 7) / 8;
    244235
    245236    Type * const fieldWidthTy = getIntNTy(fieldWidth);
     
    396387}
    397388
    398 void KernelBuilder::CreateCopyBack(const std::string & name, llvm::Value * from, llvm::Value * to) {
    399     const StreamSetBuffer * const buf = mKernel->getAnyStreamSetBuffer(name);
    400     buf->genCopyBackLogic(this, getStreamHandle(name), from, to, name);
    401 }
    402 
    403389Value * KernelBuilder::getConsumerLock(const std::string & name) {
    404390    return getScalarField(name + Kernel::CONSUMER_SUFFIX);
Note: See TracChangeset for help on using the changeset viewer.