Changeset 6216 for icGREP


Ignore:
Timestamp:
Dec 4, 2018, 1:48:37 PM (3 months ago)
Author:
cameron
Message:

Abort on null: DirectCharacterClassKernel?, on by default

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.cpp

    r6213 r6216  
    317317                P->CreateKernelCall<ByteBitGrepKernel>(prefixRE, suffixRE, ByteStream, MatchResults, externals);
    318318            }
     319            Kernel * LB_nullK = P->CreateKernelCall<DirectCharacterClassKernelBuilder>( "breakCC", std::vector<re::CC *>{mBreakCC}, ByteStream, LineBreakStream, callbackObject);
     320            mGrepDriver.LinkFunction(LB_nullK, "signal_dispatcher", kernel::signal_dispatcher);
    319321            P->CreateKernelCall<DirectCharacterClassKernelBuilder>( "breakCC", std::vector<re::CC *>{mBreakCC}, ByteStream, LineBreakStream);
    320322            requiresComplexTest = false;
     
    328330            P->CreateKernelCall<S2P_PabloKernel>(ByteStream, BasisBits);
    329331        } else {
    330             P->CreateKernelCall<S2PKernel>(ByteStream, BasisBits);
     332            Kernel * s2pK = P->CreateKernelCall<S2PKernel>(ByteStream, BasisBits, cc::BitNumbering::LittleEndian, callbackObject);
     333            mGrepDriver.LinkFunction(s2pK, "signal_dispatcher", kernel::signal_dispatcher);
    331334        }
    332335
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp

    r6184 r6216  
    1919
    2020DirectCharacterClassKernelBuilder::DirectCharacterClassKernelBuilder(
    21         const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * byteStream, StreamSet * ccStream)
    22 : PabloKernel(b, ccSetName +"_direct",
     21        const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * byteStream, StreamSet * ccStream, Scalar * signalNullObject)
     22: PabloKernel(b, ccSetName + (signalNullObject ? "_direct_abort_on_null" : "_direct"),
    2323// input
    2424{Binding{"byteStream", byteStream}},
    2525// output
    26 {Binding{"ccStream", ccStream}})
    27 , mCharClasses(std::move(charClasses)) {
     26{Binding{"ccStream", ccStream}},
     27makeInputScalarBindings(signalNullObject),
     28{}), mCharClasses(std::move(charClasses)), mAbortOnNull(signalNullObject != nullptr) {
    2829    if (LLVM_UNLIKELY(ccStream->getNumElements() != mCharClasses.size())) {
    2930        report_fatal_error("cc streamset must have " + std::to_string(mCharClasses.size()) + " streams");
     31    }
     32    if (mAbortOnNull) {
     33        addAttribute(CanTerminateEarly());
     34    }
     35}
     36
     37Bindings DirectCharacterClassKernelBuilder::makeInputScalarBindings(Scalar * signalNullObject) {
     38    if (signalNullObject) {
     39        return {Binding{"handler_address", signalNullObject}};
     40    } else {
     41        return {};
    3042    }
    3143}
     
    3547    cc::Direct_CC_Compiler ccc(getEntryScope(), getInputStreamSet("byteStream")[0]);
    3648    Var * outputVar = getOutputStreamVar("ccStream");
     49    PabloAST * nonNull = nullptr;
     50    if (mAbortOnNull) {
     51        PabloAST * nullCC = pb.createTerminateAt(ccc.compileCC(makeCC(0, &cc::Byte)), pb.getInteger(0));
     52        nonNull = pb.createNot(nullCC);
     53    }
    3754    for (unsigned i = 0; i < mCharClasses.size(); ++i) {
    38         pb.createAssign(pb.createExtract(outputVar, i), ccc.compileCC(mCharClasses[i]));
     55        PabloAST * cc = ccc.compileCC(mCharClasses[i]);
     56        if (mAbortOnNull) {
     57            cc = pb.createAnd(nonNull, cc);
     58        }
     59        pb.createAssign(pb.createExtract(outputVar, i), cc);
    3960    }
    4061}
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.h

    r6184 r6216  
    77
    88#include <pablo/pablo_kernel.h>
     9#include <kernels/callback.h>
    910
    1011namespace IDISA { class IDISA_Builder; }
     
    1516class DirectCharacterClassKernelBuilder final : public pablo::PabloKernel {
    1617public:   
    17     DirectCharacterClassKernelBuilder(const std::unique_ptr<KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * byteStream, StreamSet * ccStream);
     18    DirectCharacterClassKernelBuilder(const std::unique_ptr<KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * byteStream, StreamSet * ccStream, Scalar * signalNullObject = nullptr);
    1819protected:
    1920    void generatePabloMethod() override;
     21    Bindings makeInputScalarBindings(Scalar * signalNullObject);
    2022private:
    2123    const std::vector<re::CC *> mCharClasses;
     24    bool mAbortOnNull;
    2225};
    2326
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r6214 r6216  
    196196Bindings S2PKernel::makeOutputBindings(StreamSet * const BasisBits, bool abortOnNull) {
    197197    if (abortOnNull) {
    198         return {Binding("basisBits", BasisBits, FixedRate(), Deferred())};
     198        return {Binding("basisBits", BasisBits)};
    199199    } else {
    200200        return {Binding("basisBits", BasisBits)};
     
    202202}
    203203
    204 Bindings S2PKernel::makeInputScalarBindings(bool abortOnNull, Scalar * signalNullObject) {
    205     if (abortOnNull) {
     204Bindings S2PKernel::makeInputScalarBindings(Scalar * signalNullObject) {
     205    if (signalNullObject) {
    206206        return {Binding{"handler_address", signalNullObject}};
    207207    } else {
     
    211211
    212212S2PKernel::S2PKernel(const std::unique_ptr<KernelBuilder> &, StreamSet * const codeUnitStream, StreamSet * const BasisBits, const cc::BitNumbering numbering,
    213                      bool abortOnNull, Scalar * signalNullObject)
    214     : MultiBlockKernel((abortOnNull ? "s2pa" : "s2p") + std::to_string(BasisBits->getNumElements()) + cc::numberingSuffix(numbering),
     213                     Scalar * signalNullObject)
     214    : MultiBlockKernel((signalNullObject ? "s2pa" : "s2p") + std::to_string(BasisBits->getNumElements()) + cc::numberingSuffix(numbering),
    215215{Binding{"byteStream", codeUnitStream, FixedRate(), Principal()}},
    216 makeOutputBindings(BasisBits, abortOnNull), makeInputScalarBindings(abortOnNull, signalNullObject), {}, {}),
     216makeOutputBindings(BasisBits, signalNullObject), makeInputScalarBindings(signalNullObject), {}, {}),
    217217mBasisSetNumbering(numbering),
    218 mAbortOnNull(abortOnNull),
     218mAbortOnNull(signalNullObject != nullptr),
    219219mNumOfStreams(BasisBits->getNumElements()) {
    220220    assert (codeUnitStream->getFieldWidth() == BasisBits->getNumElements());
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.h

    r6214 r6216  
    2323              StreamSet * const BasisBits,
    2424              const cc::BitNumbering basisNumbering = cc::BitNumbering::LittleEndian,
    25               bool abortOnNull = false, Scalar * signalNullObject = nullptr);
     25              Scalar * signalNullObject = nullptr);
    2626
    2727
     
    3030protected:
    3131    Bindings makeOutputBindings(StreamSet * const BasisBits, bool abortOnNull);
    32     Bindings makeInputScalarBindings(bool abortOnNull, Scalar * signalNullObject);
     32    Bindings makeInputScalarBindings(Scalar * signalNullObject);
    3333    void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> & kb, llvm::Value * const numOfStrides) override;
    3434private:
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r6215 r6216  
    484484        } else if (const TerminateAt * s = dyn_cast<TerminateAt>(stmt)) {
    485485            Value * signal_strm = compileExpression(b, s->getExpr());
    486             llvm::errs() << "Here\n";
    487             b->CallPrintRegister("signal_strm", signal_strm);
    488486            BasicBlock * signalCallBack = b->CreateBasicBlock("signalCallBack");
    489487            BasicBlock * postSignal = b->CreateBasicBlock("postSignal");
Note: See TracChangeset for help on using the changeset viewer.