Ignore:
Timestamp:
Apr 19, 2017, 10:57:56 AM (2 years ago)
Author:
cameron
Message:

Parabix driver can take ownership of kernelbuilder instances; uniquify mmap kernel name

File:
1 edited

Legend:

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

    r5411 r5414  
    8888//
    8989
    90 void wc_gen(PabloKernel * kernel) {
     90std::unique_ptr<PabloKernel> wc_gen(IDISA::IDISA_Builder * iBuilder) {
     91   
     92    auto kernel = std::unique_ptr<PabloKernel>(new PabloKernel(iBuilder, "Parabix:wc",
     93                    {Binding{iBuilder->getStreamSetTy(8, 1), "u8bit"}},
     94                    {},
     95                    {},
     96                    {Binding{iBuilder->getSizeTy(), "lineCount"}, Binding{iBuilder->getSizeTy(), "wordCount"}, Binding{iBuilder->getSizeTy(), "charCount"}}));
     97   
    9198    //  input: 8 basis bit streams
    9299    const auto u8bitSet = kernel->getInputStreamVar("u8bit");
    93100    //  output: 3 counters
    94101   
    95     cc::CC_Compiler ccc(kernel, u8bitSet);
     102    cc::CC_Compiler ccc(kernel.get(), u8bitSet);
    96103   
    97104    PabloBuilder & pb = ccc.getBuilder();
     
    121128        pb.createAssign(cc, pb.createCount(u8Begin));
    122129    }
     130    pablo_function_passes(kernel.get());
     131    return kernel;
    123132}
    124133
     
    156165    StreamSetBuffer * BasisBits = pxDriver.addBuffer(make_unique<SingleBlockBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1)));
    157166
    158     MMapSourceKernel mmapK(iBuilder);
    159     mmapK.setInitialArguments({fileSize});
    160     pxDriver.addKernelCall(mmapK, {}, {ByteStream});
    161 
    162     S2PKernel  s2pk(iBuilder);
    163     pxDriver.addKernelCall(s2pk, {ByteStream}, {BasisBits});
    164    
    165     PabloKernel wck(iBuilder, "Parabix:wc",
    166         {Binding{iBuilder->getStreamSetTy(8, 1), "u8bit"}},
    167         {},
    168         {},
    169         {Binding{iBuilder->getSizeTy(), "lineCount"}, Binding{iBuilder->getSizeTy(), "wordCount"}, Binding{iBuilder->getSizeTy(), "charCount"}});
    170 
    171     wc_gen(&wck);
    172     pablo_function_passes(&wck);
    173     pxDriver.addKernelCall(wck, {BasisBits}, {});
     167    KernelBuilder * mmapK = pxDriver.addKernelInstance(make_unique<MMapSourceKernel>(iBuilder));
     168    mmapK->setInitialArguments({fileSize});
     169    pxDriver.makeKernelCall(mmapK, {}, {ByteStream});
     170
     171    KernelBuilder * s2pk = pxDriver.addKernelInstance(make_unique<S2PKernel>(iBuilder));
     172    pxDriver.makeKernelCall(s2pk, {ByteStream}, {BasisBits});
     173   
     174    KernelBuilder * wck = pxDriver.addKernelInstance(wc_gen(iBuilder));
     175    pxDriver.makeKernelCall(wck, {BasisBits}, {});
    174176
    175177
    176178    pxDriver.generatePipelineIR();
    177179   
    178     Value * lineCount = wck.createGetAccumulatorCall("lineCount");
    179     Value * wordCount = wck.createGetAccumulatorCall("wordCount");
    180     Value * charCount = wck.createGetAccumulatorCall("charCount");
     180    Value * lineCount = wck->createGetAccumulatorCall("lineCount");
     181    Value * wordCount = wck->createGetAccumulatorCall("wordCount");
     182    Value * charCount = wck->createGetAccumulatorCall("charCount");
    181183
    182184    iBuilder->CreateCall(record_counts_routine, std::vector<Value *>({lineCount, wordCount, charCount, fileSize, fileIdx}));
Note: See TracChangeset for help on using the changeset viewer.