Changeset 6236 for icGREP


Ignore:
Timestamp:
Dec 15, 2018, 1:53:52 PM (4 months ago)
Author:
nmedfort
Message:

Bug fix for S2P on 32-bit machines with 64-bit address space

File:
1 edited

Legend:

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

    r6228 r6236  
    175175        Value * nullInFile = kb->CreateICmpNE(ptrToNull, ConstantPointerNull::get(cast<PointerType>(ptrToNull->getType())));
    176176        kb->CreateCondBr(nullInFile, nullInFileDetected, s2pExit);
     177
    177178        kb->SetInsertPoint(nullInFileDetected);
    178179        // A null byte has been located within the file; set the termination code and call the signal handler.
    179         Value * nullPosn = kb->CreateSub(kb->CreatePtrToInt(ptrToNull, intPtrTy), kb->CreatePtrToInt(byteStreamBasePtr, intPtrTy));
     180        Value * firstNull = kb->CreatePtrToInt(ptrToNull, intPtrTy);
     181        Value * startOfStride = kb->CreatePtrToInt(byteStreamBasePtr, intPtrTy);
     182        Value * itemsBeforeNull = kb->CreateZExtOrTrunc(kb->CreateSub(firstNull, startOfStride), itemsToDo->getType());
     183        Value * producedCount = kb->CreateAdd(kb->getProducedItemCount("basisBits"), itemsBeforeNull);
     184        kb->setProducedItemCount("basisBits", producedCount);
    180185        kb->setTerminationSignal();
    181186        Function * const dispatcher = m->getFunction("signal_dispatcher"); assert (dispatcher);
     
    183188        kb->CreateCall(dispatcher, {handler, ConstantInt::get(kb->getInt32Ty(), NULL_SIGNAL)});
    184189        kb->CreateBr(s2pExit);
     190
    185191        kb->SetInsertPoint(s2pExit);
    186         PHINode * const produced = kb->CreatePHI(kb->getSizeTy(), 3);
    187         produced->addIncoming(itemsToDo, nullByteDetected);
    188         produced->addIncoming(nullPosn, nullInFileDetected);
    189         produced->addIncoming(itemsToDo, s2pFinalize);
    190         Value * producedCount = kb->getProducedItemCount("basisBits");
    191         producedCount = kb->CreateAdd(producedCount, produced);
    192         kb->setProducedItemCount("basisBits", producedCount);
    193192    }
    194193}
     
    210209}
    211210
    212 S2PKernel::S2PKernel(const std::unique_ptr<KernelBuilder> &, StreamSet * const codeUnitStream, StreamSet * const BasisBits, const cc::BitNumbering numbering,
     211S2PKernel::S2PKernel(const std::unique_ptr<KernelBuilder> &,
     212                     StreamSet * const codeUnitStream,
     213                     StreamSet * const BasisBits,
     214                     const cc::BitNumbering numbering,
    213215                     Scalar * signalNullObject)
    214     : MultiBlockKernel((signalNullObject ? "s2pa" : "s2p") + std::to_string(BasisBits->getNumElements()) + cc::numberingSuffix(numbering),
    215 {Binding{"byteStream", codeUnitStream, FixedRate(), Principal()}},
    216 makeOutputBindings(BasisBits, signalNullObject), makeInputScalarBindings(signalNullObject), {}, {}),
    217 mBasisSetNumbering(numbering),
    218 mAbortOnNull(signalNullObject != nullptr),
    219 mNumOfStreams(BasisBits->getNumElements()) {
     216: MultiBlockKernel((signalNullObject ? "s2pa" : "s2p") + std::to_string(BasisBits->getNumElements()) + cc::numberingSuffix(numbering)
     217, {Binding{"byteStream", codeUnitStream, FixedRate(), Principal()}}
     218, makeOutputBindings(BasisBits, signalNullObject)
     219, makeInputScalarBindings(signalNullObject), {}, {})
     220, mBasisSetNumbering(numbering)
     221, mAbortOnNull(signalNullObject != nullptr)
     222, mNumOfStreams(BasisBits->getNumElements()) {
    220223    assert (codeUnitStream->getFieldWidth() == BasisBits->getNumElements());
    221     addAttribute(CanTerminateEarly());
     224    if (mAbortOnNull) addAttribute(CanTerminateEarly());
    222225}
    223226
     
    387390
    388391}
     392
Note: See TracChangeset for help on using the changeset viewer.