Ignore:
Timestamp:
May 6, 2017, 4:05:05 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5429 r5435  
    8282}
    8383
    84 //
    85 //
    86 
    87 std::unique_ptr<PabloKernel> wc_gen(IDISA::IDISA_Builder * iBuilder) {
    88    
    89     auto kernel = std::unique_ptr<PabloKernel>(new PabloKernel(iBuilder, "Parabix:wc",
    90                     {Binding{iBuilder->getStreamSetTy(8, 1), "u8bit"}},
    91                     {},
    92                     {},
    93                     {Binding{iBuilder->getSizeTy(), "lineCount"}, Binding{iBuilder->getSizeTy(), "wordCount"}, Binding{iBuilder->getSizeTy(), "charCount"}}));
    94    
     84class WordCountKernel final: public pablo::PabloKernel {
     85public:
     86    WordCountKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b);
     87    bool isCachable() const override { return true; }
     88    bool moduleIDisSignature() const override { return true; }
     89    void prepareKernel() override;
     90};
     91
     92WordCountKernel::WordCountKernel (const std::unique_ptr<IDISA::IDISA_Builder> & b)
     93: PabloKernel(b, "wc",
     94    {Binding{b->getStreamSetTy(8, 1), "u8bit"}},
     95    {},
     96    {},
     97    {Binding{b->getSizeTy(), "lineCount"}, Binding{b->getSizeTy(), "wordCount"}, Binding{b->getSizeTy(), "charCount"}}) {
     98
     99}
     100
     101void WordCountKernel::prepareKernel() {
     102
    95103    //  input: 8 basis bit streams
    96     const auto u8bitSet = kernel->getInputStreamVar("u8bit");
     104    const auto u8bitSet = getInputStreamVar("u8bit");
    97105    //  output: 3 counters
    98    
    99     cc::CC_Compiler ccc(kernel.get(), u8bitSet);
    100    
     106
     107    cc::CC_Compiler ccc(this, u8bitSet);
     108
    101109    PabloBuilder & pb = ccc.getBuilder();
    102110
    103     Var * lc = kernel->getOutputScalarVar("lineCount");
    104     Var * wc = kernel->getOutputScalarVar("wordCount");
    105     Var * cc = kernel->getOutputScalarVar("charCount");
     111    Var * lc = getOutputScalarVar("lineCount");
     112    Var * wc = getOutputScalarVar("wordCount");
     113    Var * cc = getOutputScalarVar("charCount");
    106114
    107115    if (CountLines) {
     
    122130        // not UTF-8, or is not valid?
    123131        //
    124         PabloAST * u8Begin = ccc.compileCC(re::makeCC(re::makeCC(0, 0x7F), re::makeCC(0xC2, 0xF4)));       
     132        PabloAST * u8Begin = ccc.compileCC(re::makeCC(re::makeCC(0, 0x7F), re::makeCC(0xC2, 0xF4)));
    125133        pb.createAssign(cc, pb.createCount(u8Begin));
    126134    }
    127     pablo_function_passes(kernel.get());
    128     return kernel;
    129 }
    130 
    131 
    132 
     135    pablo_function_passes(this);
     136    PabloKernel::prepareKernel();
     137}
    133138
    134139typedef void (*WordCountFunctionType)(uint32_t fd, size_t fileIdx);
     
    136141void wcPipelineGen(ParabixDriver & pxDriver) {
    137142
    138     auto iBuilder = pxDriver.getIDISA_Builder();
     143    auto & iBuilder = pxDriver.getBuilder();
    139144    Module * m = iBuilder->getModule();
    140145   
     
    161166    StreamSetBuffer * const BasisBits = pxDriver.addBuffer(make_unique<SingleBlockBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1)));
    162167
    163     KernelBuilder * mmapK = pxDriver.addKernelInstance(make_unique<MMapSourceKernel>(iBuilder));
     168    Kernel * mmapK = pxDriver.addKernelInstance(make_unique<MMapSourceKernel>(iBuilder));
    164169    mmapK->setInitialArguments({fileDecriptor});
    165170    pxDriver.makeKernelCall(mmapK, {}, {ByteStream});
    166171
    167     KernelBuilder * s2pk = pxDriver.addKernelInstance(make_unique<S2PKernel>(iBuilder));
     172    Kernel * s2pk = pxDriver.addKernelInstance(make_unique<S2PKernel>(iBuilder));
    168173    pxDriver.makeKernelCall(s2pk, {ByteStream}, {BasisBits});
    169174   
    170     KernelBuilder * wck = pxDriver.addKernelInstance(wc_gen(iBuilder));
     175    Kernel * wck = pxDriver.addKernelInstance(make_unique<WordCountKernel>(iBuilder));
    171176    pxDriver.makeKernelCall(wck, {BasisBits}, {});
    172 
    173177
    174178    pxDriver.generatePipelineIR();
Note: See TracChangeset for help on using the changeset viewer.