Changeset 5300


Ignore:
Timestamp:
Feb 4, 2017, 9:28:54 AM (8 months ago)
Author:
cameron
Message:

getScalarOutput for Pablo kernels; use in wc

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5299 r5300  
    4242
    4343
     44Var * PabloKernel::getScalarOutput(std::string outputName) {
     45    const auto f = mScalarOutputNameMap.find(outputName);
     46    if (LLVM_UNLIKELY(f == mScalarOutputNameMap.end())) {
     47        llvm::report_fatal_error("Kernel does not contain scalar: " + outputName);
     48    }
     49    return f->second;
     50}
     51
     52
     53
    4454Var * PabloKernel::addInput(const std::string & name, Type * const type) {
    4555    Var * param = new (mAllocator) Var(mSymbolTable->makeString(name, iBuilder), type, mAllocator, Var::ReadOnly);
     
    6575    } else {
    6676        mScalarOutputs.emplace_back(type, name);
     77        mScalarOutputNameMap.emplace(name, result);
    6778    }
    6879    assert (mStreamSetOutputs.size() + mScalarOutputs.size() == mOutputs.size());
     
    161172        mOutputs.push_back(result);
    162173        mVariables.push_back(result);
     174        mScalarOutputNameMap.emplace(ss.name, result);
    163175    }
    164176}
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5299 r5300  
    1212#include <util/slab_allocator.h>
    1313#include <llvm/ADT/StringRef.h>
     14#include <boost/container/flat_map.hpp>      // for mScalarOutputNameMap
    1415
    1516namespace IDISA { class IDISA_Builder; }
     
    8586   
    8687    Var * getOutputSet(std::string inputSetName);
     88   
     89    Var * getScalarOutput(std::string outputName);
    8790
    8891    Var * getOutput(const unsigned index) {
     
    151154    std::vector<PabloAST *>         mConstants;
    152155    std::vector<Var *>              mVariables;
    153 
     156    boost::container::flat_map<std::string, Var *> mScalarOutputNameMap;
    154157};
    155158
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5292 r5300  
    9090void wc_gen(PabloKernel * kernel) {
    9191    //  input: 8 basis bit streams
     92    const auto u8bitSet = kernel->getInputSet("u8bit");
    9293    //  output: 3 counters
    9394   
    94     cc::CC_Compiler ccc(kernel);
     95    cc::CC_Compiler ccc(kernel, u8bitSet);
    9596   
    9697    PabloBuilder & pb = ccc.getBuilder();
    9798
    98     Var * lc = kernel->addOutput("lineCount", kernel->getSizeTy());
    99     Var * wc = kernel->addOutput("wordCount", kernel->getSizeTy());
    100     Var * cc = kernel->addOutput("charCount", kernel->getSizeTy());
     99    Var * lc = kernel->getScalarOutput("lineCount");
     100    Var * wc = kernel->getScalarOutput("wordCount");
     101    Var * cc = kernel->getScalarOutput("charCount");
    101102
    102103    if (CountLines) {
     
    151152    S2PKernel  s2pk(iBuilder);
    152153    std::unique_ptr<Module> s2pM = s2pk.createKernelModule({&ByteStream}, {&BasisBits});
    153 
    154     PabloKernel wck(iBuilder, "wc");
     154   
     155    PabloKernel wck(iBuilder, "wc", {Binding{iBuilder->getStreamSetTy(8, 1), "u8bit"}}, {},
     156                      {Binding{iBuilder->getSizeTy(), "lineCount"}, Binding{iBuilder->getSizeTy(), "wordCount"}, Binding{iBuilder->getSizeTy(), "charCount"}});
     157
    155158    wc_gen(&wck);
    156159    pablo_function_passes(&wck);
Note: See TracChangeset for help on using the changeset viewer.