Changeset 5843


Ignore:
Timestamp:
Jan 25, 2018, 2:03:09 PM (10 months ago)
Author:
cameron
Message:

CC Compiler refactoring step

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.cpp

    r5837 r5843  
    371371Value * IDISA_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
    372372    if (fw <= 8) {
    373         const unsigned fw_wkg = 64;
     373        const unsigned fw_wkg = 32;
    374374        Value * aLo = simd_srli(fw_wkg, a, fw/2);
    375375        Value * bLo = simd_srli(fw_wkg, b, fw/2);
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r5836 r5843  
    2222namespace cc {
    2323
    24 CC_Compiler::CC_Compiler(pablo::PabloKernel * kernel, pablo::Var * basisBits)
     24CC_Compiler::CC_Compiler(pablo::PabloKernel * kernel, std::vector<pablo::PabloAST *> basisBitSet)
    2525: mBuilder(kernel->getEntryScope())
    26 , mEncodingBits(basisBits->getType()->getArrayNumElements())
    27 , mBasisBit(mEncodingBits) {
    28     for (unsigned i = 0; i != mEncodingBits; i++) {
    29         mBasisBit[i] = mBuilder.createExtract(basisBits, mBuilder.getInteger(i)); assert (mBasisBit[i]);
    30     }
     26, mEncodingBits(basisBitSet.size())
     27, mBasisBit(basisBitSet) {
    3128    mEncodingMask = (static_cast<unsigned>(1) << mEncodingBits) - static_cast<unsigned>(1);
    3229}
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r5842 r5843  
    1616namespace cc {
    1717
    18 class CC_NameMap;
    19 
    2018class CC_Compiler{
    2119    friend class ParabixCharacterClassKernelBuilder;
    2220public:
    23 
    24     using Vars = std::vector<pablo::Var *>;
    25 
    26     CC_Compiler(pablo::PabloKernel * kernel, pablo::Var * basisBitSet);
     21   
     22    CC_Compiler(pablo::PabloKernel * kernel, std::vector<pablo::PabloAST *> basisBitSet);
    2723   
    2824    pablo::PabloAST * compileCC(const re::CC *cc);
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5842 r5843  
    292292void PreprocessKernel::generatePabloMethod() {
    293293    PabloBuilder pb(getEntryScope());
    294     cc::CC_Compiler ccc(this, getInputStreamVar("basis"));
     294    cc::CC_Compiler ccc(this, getInputStreamSet("basis"));
    295295    PabloAST * A = ccc.compileCC(re::makeCC(re::makeCC(0x41), re::makeCC(0x61)), pb);
    296296    PabloAST * C = ccc.compileCC(re::makeCC(re::makeCC(0x43), re::makeCC(0x63)), pb);
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp

    r5842 r5843  
    111111void ParabixCharacterClassKernelBuilder::generatePabloMethod() {
    112112    PabloBuilder pb(getEntryScope());
    113     CC_Compiler ccc(this, getInput(0));
     113    cc::CC_Compiler ccc(this, getInputStreamSet("basis"));
    114114    for (unsigned i = 0; i < mCharClasses.size(); ++i) {
    115115        pb.createAssign(getOutput(i), ccc.compileCC("cc", mCharClasses[i], pb));
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.cpp

    r5842 r5843  
    7575    PabloBuilder pb(getEntryScope());
    7676
    77     CC_Compiler ccc(this, getInput(0));
     77    CC_Compiler ccc(this, getInputStreamSet("basis"));
    7878    unsigned n = mCCs.size();
    7979
  • icGREP/icgrep-devel/icgrep/kernels/delmask_kernel.cpp

    r5842 r5843  
    2222    //  input: 8 basis bit streams
    2323   
    24     const auto u8bitSet = this->getInputStreamVar("u8bit");
    25     PabloAST * u8_bits[8];
    26     for (int i = 0; i < 8; ++i) {
    27         u8_bits[i] = main.createExtract(u8bitSet, main.getInteger(i));
    28     }
     24    std::vector<PabloAST *> u8_bits = getInputStreamSet("u8bit");
    2925    //  output: delmask stream + error stream
    3026   
    31     cc::CC_Compiler ccc(this, u8bitSet);
     27    cc::CC_Compiler ccc(this, u8_bits);
    3228   
    3329    Zeroes * zeroes = main.createZeroes();
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5842 r5843  
    4242void RequiredStreams_UTF8::generatePabloMethod() {
    4343    PabloBuilder pb(getEntryScope());
    44     cc::CC_Compiler ccc(this, getInput(0));
     44    cc::CC_Compiler ccc(this, getInputStreamSet("basis"));
    4545    Zeroes * const ZEROES = pb.createZeroes();
    4646    PabloAST * const u8pfx = ccc.compileCC(makeByte(0xC0, 0xFF));
     
    135135void RequiredStreams_UTF16::generatePabloMethod() {
    136136    PabloBuilder pb(getEntryScope());
    137     cc::CC_Compiler ccc(this, getInput(0));
     137    cc::CC_Compiler ccc(this, getInputStreamSet("basis"));
    138138   
    139139    PabloAST * u16hi_hi_surrogate = ccc.compileCC(makeCC(0xD800, 0xDBFF, &cc::UTF16));    //u16hi_hi_surrogate = [\xD8-\xDB]
     
    208208void ICGrepKernel::generatePabloMethod() {
    209209    PabloBuilder pb(getEntryScope());
    210     Var * const basis = getInputStreamVar("basis");
    211     cc::CC_Compiler cc_compiler(this, basis);
     210    cc::CC_Compiler cc_compiler(this, getInputStreamSet("basis"));
    212211    RE_Compiler re_compiler(this, cc_compiler);
    213212    for (auto a : mAlphabets) {
    214         auto basis = getInputStreamVar(a->getName() + "_basis");
    215         re_compiler.addAlphabet(a, basis);
     213        auto mpx_basis = getInputStreamSet(a->getName() + "_basis");
     214        re_compiler.addAlphabet(a, mpx_basis);
    216215    }
    217216    PabloAST * const matches = re_compiler.compile(mRE);
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.cpp

    r5842 r5843  
    4040    PabloAST * LF = compileCCfromCodeUnitStream(makeByte(0x0A), getInput(0), pb);
    4141    #else
    42     CC_Compiler ccc(this, getInput(0));
     42    cc::CC_Compiler ccc(this, getInputStreamSet("basis"));
    4343    PabloAST * LF = ccc.compileCC("LF", makeByte(0x0A), pb);
    4444    #endif
     
    5959void LineBreakKernelBuilder::generatePabloMethod() {
    6060    PabloBuilder pb(getEntryScope());
    61     CC_Compiler ccc(this, getInput(0));
     61    cc::CC_Compiler ccc(this, getInputStreamSet("basis"));
    6262
    6363    Integer * const ZERO = pb.getInteger(0);
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5793 r5843  
    4646    }
    4747
     48    // Return the number of streams for a static stream set or 0 for an expandable stream set.
     49    unsigned getNumOfStreams () const {
     50        if (mBufferKind == BufferKind::ExpandableBuffer) return 0;
     51        size_t numStreams = 1;
     52        if (mBaseType->isArrayTy()) {
     53            numStreams = mBaseType->getArrayNumElements();
     54        }
     55        return numStreams;
     56    }
     57   
     58    unsigned getStreamFieldWidth () const {
     59        if (mBaseType->isArrayTy()) {
     60            return mBaseType->getArrayElementType()->getScalarSizeInBits();
     61        }
     62        return mBaseType->getScalarSizeInBits();
     63    }
     64   
    4865    unsigned getAddressSpace() const {
    4966        return mAddressSpace;
  • icGREP/icgrep-devel/icgrep/kernels/u8u32_kernel.cpp

    r5842 r5843  
    2222   
    2323    //  input: 8 basis bit streams
    24     const auto u8bitSet = this->getInputStreamVar("u8bit");
    25     PabloAST * u8_bits[8];
    26     for (int i = 0; i < 8; ++i) {
    27         u8_bits[i] = main.createExtract(u8bitSet, main.getInteger(i));
    28     }
     24    std::vector<PabloAST *> u8_bits = getInputStreamSet("u8bit");
    2925    //  output: 32 u8-indexed streams, + delmask stream + error stream
    3026   
    31     cc::CC_Compiler ccc(this, u8bitSet);
     27    cc::CC_Compiler ccc(this, u8_bits);
    3228   
    3329    Zeroes * zeroes = main.createZeroes();
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5836 r5843  
    1212#include <pablo/pablo_toolchain.h>
    1313#include <kernels/kernel_builder.h>
     14#include <kernels/streamset.h>
    1415#include <llvm/IR/Module.h>
    1516
     
    3233    return mInputs[index];
    3334}
     35
     36std::vector<PabloAST *> PabloKernel::getInputStreamSet(const std::string & name) {
     37    Port port; unsigned index;
     38    std::tie(port, index) = getStreamPort(name);
     39    assert (port == Port::Input);
     40    auto numStreams = mStreamSetInputBuffers[index]->getNumOfStreams();
     41    std::vector<PabloAST *> inputSet(numStreams);
     42    for (unsigned i = 0; i < numStreams; i++) {
     43        inputSet[i] = mEntryScope->createExtract(mInputs[index], mEntryScope->getInteger(i));
     44    }
     45    return inputSet;
     46}
     47
    3448
    3549Var * PabloKernel::getOutputStreamVar(const std::string & name) {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5836 r5843  
    6363   
    6464    Var * getInputStreamVar(const std::string & name);
     65   
     66    std::vector<PabloAST *> getInputStreamSet(const std::string & name);
    6567
    6668    Var * getInput(const unsigned index) {
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5842 r5843  
    5151
    5252   
    53 void RE_Compiler::addAlphabet(cc::Alphabet * a, pablo::Var * basis_set) {
     53void RE_Compiler::addAlphabet(cc::Alphabet * a, std::vector<pablo::PabloAST *> basis_set) {
    5454    mAlphabets.push_back(a);
    5555    mAlphabetCompilers.push_back(make_unique<cc::CC_Compiler>(mKernel, basis_set));
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5842 r5843  
    6666    // the alphabet value and the set of parallel bit streams that comprise
    6767    // a basis for the coded alphabet values.
    68    
    69     void addAlphabet(cc::Alphabet * a, pablo::Var * basis_set);
     68
     69    void addAlphabet(cc::Alphabet * a, std::vector<pablo::PabloAST* > basis_set);
    7070
    7171    pablo::PabloAST * compile(RE * re, pablo::PabloAST * const initialCursors = nullptr);
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5842 r5843  
    6969   
    7070    //  input: 8 basis bit streams
    71     const auto u8bitSet = getInputStreamVar("u8bit");
    72     PabloAST * u8_bits[8];
    73     for (int i = 0; i < 8; ++i) {
    74         u8_bits[i] = main.createExtract(u8bitSet, main.getInteger(i));
    75     }
     71    std::vector<PabloAST *> u8_bits = getInputStreamSet("u8bit");
    7672
    7773    //  output: 16 u8-indexed streams, + delmask stream + error stream
     
    8884    Var * error_mask = main.createVar("error_mask", zeroes);
    8985
    90     cc::CC_Compiler ccc(this, u8bitSet);
     86    cc::CC_Compiler ccc(this, u8_bits);
    9187
    9288    // The logic for processing non-ASCII bytes will be embedded within an if-hierarchy.
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5842 r5843  
    102102    PabloBuilder pb(getEntryScope());
    103103    //  input: 8 basis bit streams
    104     const auto u8bitSet = getInputStreamVar("u8bit");
     104    std::vector<PabloAST *> u8_bits = getInputStreamSet("u8bit");
    105105    //  output: 3 counters
    106106
    107     cc::CC_Compiler ccc(this, u8bitSet);
     107    cc::CC_Compiler ccc(this, u8_bits);
    108108
    109109    Var * lc = getOutputScalarVar("lineCount");
Note: See TracChangeset for help on using the changeset viewer.