Changeset 6221


Ignore:
Timestamp:
Dec 9, 2018, 5:31:37 PM (7 months ago)
Author:
cameron
Message:

Unify Parabix/Direct? CharacterClassKernelBuilders?

Location:
icGREP/icgrep-devel/icgrep
Files:
4 edited
2 moved

Legend:

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

    r6220 r6221  
    1818// ccNameStr, std::vector<re::CC *>{cc}, ByteStream, ccStream
    1919
    20 DirectCharacterClassKernelBuilder::DirectCharacterClassKernelBuilder(
    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"),
     20CharacterClassKernelBuilder::CharacterClassKernelBuilder(
     21        const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * sourceStream, StreamSet * ccStream, Scalar * signalNullObject)
     22: PabloKernel(b, ccSetName + std::to_string(sourceStream->getNumElements()) + "x" + std::to_string(sourceStream->getFieldWidth())
     23                           + (signalNullObject ? "_abort_on_null" : ""),
    2324// input
    24 {Binding{"byteStream", byteStream}},
     25{Binding{"sourceStream", sourceStream}},
    2526// output
    2627{Binding{"ccStream", ccStream}},
     
    3536}
    3637
    37 Bindings DirectCharacterClassKernelBuilder::makeInputScalarBindings(Scalar * signalNullObject) {
     38Bindings CharacterClassKernelBuilder::makeInputScalarBindings(Scalar * signalNullObject) {
    3839    if (signalNullObject) {
    3940        return {Binding{"handler_address", signalNullObject}};
     
    4344}
    4445
    45 void DirectCharacterClassKernelBuilder::generatePabloMethod() {
     46void CharacterClassKernelBuilder::generatePabloMethod() {
    4647    PabloBuilder pb(getEntryScope());
    47     cc::Direct_CC_Compiler ccc(getEntryScope(), getInputStreamSet("byteStream")[0]);
     48    std::unique_ptr<CC_Compiler> ccc;
     49    bool useDirectCC = getInput(0)->getType()->getArrayNumElements() == 1;
     50    if (useDirectCC) {
     51        ccc = make_unique<cc::Direct_CC_Compiler>(getEntryScope(), pb.createExtract(getInput(0), pb.getInteger(0)));
     52    } else {
     53        ccc = make_unique<cc::Parabix_CC_Compiler>(getEntryScope(), getInputStreamSet("sourceStream"));
     54    }
    4855    Var * outputVar = getOutputStreamVar("ccStream");
    4956    PabloAST * nonNull = nullptr;
    5057    if (mAbortOnNull) {
    51         PabloAST * nullCC = pb.createTerminateAt(ccc.compileCC(makeCC(0, &cc::Byte)), pb.getInteger(0));
     58        PabloAST * nullCC = pb.createTerminateAt(ccc->compileCC(makeCC(0, &cc::Byte)), pb.getInteger(0));
    5259        nonNull = pb.createNot(nullCC);
    5360    }
    5461    for (unsigned i = 0; i < mCharClasses.size(); ++i) {
    55         PabloAST * cc = ccc.compileCC(mCharClasses[i]);
     62        PabloAST * cc = ccc->compileCC(mCharClasses[i]);
    5663        if (mAbortOnNull) {
    5764            cc = pb.createAnd(nonNull, cc);
     
    6067    }
    6168}
    62 
    63 
    64 ParabixCharacterClassKernelBuilder::ParabixCharacterClassKernelBuilder (const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, const std::vector<CC *> & charClasses, StreamSet * basisStream, StreamSet * outputStream)
    65 : PabloKernel(b, ccSetName +"_kernel",
    66 // stream inputs
    67 {Binding{"basis", basisStream}}
    68 // stream outputs
    69 , {Binding("outputStream", outputStream)}
    70 )
    71 , mCharClasses(charClasses) {
    72     if (LLVM_UNLIKELY(outputStream->getNumElements() != mCharClasses.size())) {
    73         report_fatal_error("output streamset must have " + std::to_string(mCharClasses.size()) + " streams");
    74     }
    75 }
    76 
    77 void ParabixCharacterClassKernelBuilder::generatePabloMethod() {
    78     PabloBuilder pb(getEntryScope());
    79     cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
    80     Var * outputVar = getOutputStreamVar("outputStream");
    81     for (unsigned i = 0; i < mCharClasses.size(); ++i) {
    82         pb.createAssign(pb.createExtract(outputVar, i), ccc.compileCC(mCharClasses[i]));
    83     }
    84 }
  • icGREP/icgrep-devel/icgrep/cc/cc_kernel.h

    r6220 r6221  
    11/*
    2  *  Copyright (c) 2016 International Characters.
     2 *  Copyright (c) 2018 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 */
     
    1414namespace kernel {
    1515
    16 class DirectCharacterClassKernelBuilder final : public pablo::PabloKernel {
     16class CharacterClassKernelBuilder final : public pablo::PabloKernel {
    1717public:   
    18     DirectCharacterClassKernelBuilder(const std::unique_ptr<KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * byteStream, StreamSet * ccStream, Scalar * signalNullObject = nullptr);
     18    CharacterClassKernelBuilder(const std::unique_ptr<KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, StreamSet * byteStream, StreamSet * ccStream, Scalar * signalNullObject = nullptr);
    1919protected:
    2020    void generatePabloMethod() override;
     
    2525};
    2626
    27 class ParabixCharacterClassKernelBuilder final : public pablo::PabloKernel {
    28 public:
    29     ParabixCharacterClassKernelBuilder(const std::unique_ptr<KernelBuilder> & b, std::string ccSetName, const std::vector<re::CC *> & charClasses, StreamSet * basisStream, StreamSet * outputStream);
    30 protected:
    31     void generatePabloMethod() override;
    32 private:
    33     const std::vector<re::CC *> mCharClasses;
    34 };
    35 
    3627}
    3728#endif
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r6184 r6221  
    2121#include <kernels/source_kernel.h>
    2222#include <kernels/s2p_kernel.h>
    23 #include <kernels/cc_kernel.h>
     23#include <cc/cc_kernel.h>
    2424#include <editd/editdscan_kernel.h>
    2525#include <kernels/streams_merge.h>
     
    351351
    352352    StreamSet * const ChStream = P->CreateStreamSet(4);
    353     P->CreateKernelCall<DirectCharacterClassKernelBuilder>("editd_cc", ccs, ByteStream, ChStream);
     353    P->CreateKernelCall<CharacterClassKernelBuilder>("editd_cc", ccs, ByteStream, ChStream);
    354354
    355355    const auto n = pattGroups.size();
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.cpp

    r6218 r6221  
    1111#include <kernels/callback.h>
    1212#include <kernels/charclasses.h>
    13 #include <kernels/cc_kernel.h>
     13#include <cc/cc_kernel.h>
    1414#include <kernels/grep_kernel.h>
    1515#include <kernels/UCD_property_kernel.h>
     
    305305                    auto ccNameStr = ccName->getFullName();
    306306                    StreamSet * const ccStream = P->CreateStreamSet(1, 1);
    307                     P->CreateKernelCall<DirectCharacterClassKernelBuilder>(ccNameStr, std::vector<re::CC *>{cc}, ByteStream, ccStream);
     307                    P->CreateKernelCall<CharacterClassKernelBuilder>(ccNameStr, std::vector<re::CC *>{cc}, ByteStream, ccStream);
    308308                    options->addExternal(ccNameStr, ccStream);
    309309                }
     
    324324                P->CreateKernelCall<ICGrepKernel>(std::move(options));
    325325            }
    326             Kernel * LB_nullK = P->CreateKernelCall<DirectCharacterClassKernelBuilder>( "breakCC", std::vector<re::CC *>{mBreakCC}, ByteStream, LineBreakStream, callbackObject);
     326            Kernel * LB_nullK = P->CreateKernelCall<CharacterClassKernelBuilder>( "breakCC", std::vector<re::CC *>{mBreakCC}, ByteStream, LineBreakStream, callbackObject);
    327327            mGrepDriver.LinkFunction(LB_nullK, "signal_dispatcher", kernel::signal_dispatcher);
    328328            requiresComplexTest = false;
     
    352352        } else if (mGrepRecordBreak == GrepRecordBreakKind::Null) {
    353353            LineBreakStream = P->CreateStreamSet();
    354             P->CreateKernelCall<DirectCharacterClassKernelBuilder>( "Null", std::vector<re::CC *>{mBreakCC}, BasisBits, LineBreakStream);
     354            P->CreateKernelCall<CharacterClassKernelBuilder>( "Null", std::vector<re::CC *>{mBreakCC}, BasisBits, LineBreakStream);
    355355        } else {
    356356            LineBreakStream = UnicodeLB;
     
    798798
    799799    if (matchAllLines && excludeNothing) {
    800         E->CreateKernelCall<DirectCharacterClassKernelBuilder>(RBname, std::vector<re::CC *>{breakCC}, ByteStream, RecordBreakStream);
     800        E->CreateKernelCall<CharacterClassKernelBuilder>(RBname, std::vector<re::CC *>{breakCC}, ByteStream, RecordBreakStream);
    801801    } else {
    802802        BasisBits = E->CreateStreamSet(8);
    803803        E->CreateKernelCall<S2PKernel>(ByteStream, BasisBits);
    804         E->CreateKernelCall<ParabixCharacterClassKernelBuilder>(RBname, std::vector<re::CC *>{breakCC}, BasisBits, RecordBreakStream);
     804        E->CreateKernelCall<CharacterClassKernelBuilder>(RBname, std::vector<re::CC *>{breakCC}, BasisBits, RecordBreakStream);
    805805    }
    806806
  • icGREP/icgrep-devel/icgrep/lz4/grep/lz4_grep_base_generator.cpp

    r6219 r6221  
    88#include <cc/cc_compiler.h>
    99
    10 #include <kernels/cc_kernel.h>
     10#include <cc/cc_kernel.h>
    1111#include <kernels/s2p_kernel.h>
    1212#include <kernels/p2s_kernel.h>
  • icGREP/icgrep-devel/icgrep/lz4_grep.cpp

    r6184 r6221  
    1818#include <cc/cc_compiler.h>
    1919#include <toolchain/toolchain.h>
    20 #include <kernels/cc_kernel.h>
     20#include <cc/cc_kernel.h>
    2121#include <kernels/streamset.h>
    2222#include <kernels/s2p_kernel.h>
Note: See TracChangeset for help on using the changeset viewer.