Ignore:
Timestamp:
Jan 13, 2018, 11:57:43 AM (12 months ago)
Author:
nmedfort
Message:

Pablo support for byte comparisions; LineFeed? kernel processes byte streams directly. Some clean up of PabloBuilder? functionality.

File:
1 edited

Legend:

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

    r5782 r5828  
    2424using namespace llvm;
    2525
    26 inline bool isStreamType(const Type * ty) {
    27     if (ty->isArrayTy()) {
    28         ty = ty->getArrayElementType();
    29     }
    30     if (ty->isVectorTy()) {
    31         return (ty->getVectorNumElements() == 0);
    32     }
    33     return false;
    34 }
    35 
    3626namespace pablo {
    3727
     
    5141
    5242Var * PabloKernel::getOutputScalarVar(const std::string & name) {
    53     const auto f = mScalarOutputNameMap.find(name);
    54     if (LLVM_UNLIKELY(f == mScalarOutputNameMap.end())) {
    55         report_fatal_error("Kernel does not contain scalar: " + name);
    56     }
    57     return f->second;
    58 }
    59 
    60 Var * PabloKernel::addInput(const std::string & name, Type * const type) {
    61     Var * param = new (mAllocator) Var(makeName(name), type, mAllocator, Var::KernelInputParameter);
    62     param->addUser(this);
    63     mInputs.push_back(param);
    64     mVariables.push_back(param);
    65     if (isStreamType(type)) {
    66         mStreamMap.emplace(name, std::make_pair(Port::Input, mStreamSetInputs.size()));
    67         mStreamSetInputs.emplace_back(type, name);       
    68     } else {
    69         mScalarInputs.emplace_back(type, name);
    70         param->setScalar();
    71     }
    72     assert (mStreamSetInputs.size() + mScalarInputs.size() == mInputs.size());
    73     return param;
    74 }
    75 
    76 Var * PabloKernel::addOutput(const std::string & name, Type * const type) {
    77     Var * result = new (mAllocator) Var(makeName(name), type, mAllocator, Var::KernelOutputParameter);
    78     result->addUser(this);
    79     mOutputs.push_back(result);
    80     mVariables.push_back(result);
    81     if (isStreamType(type)) {
    82         mStreamMap.emplace(name, std::make_pair(Port::Output, mStreamSetOutputs.size()));
    83         mStreamSetOutputs.emplace_back(type, name);
    84     } else {
    85         mScalarOutputs.emplace_back(type, name);
    86         mScalarOutputNameMap.emplace(name, result);
    87         result->setScalar();
    88     }
    89     assert (mStreamSetOutputs.size() + mScalarOutputs.size() == mOutputs.size());
    90     return result;
     43    for (Var * out : mScalarOutputVars) {
     44        if (out->getName().equals(name)) {
     45            return out;
     46        }
     47    }
     48    report_fatal_error("Kernel does not contain scalar " + name);
    9149}
    9250
     
    12583}
    12684
    127 void PabloKernel::addInternalKernelProperties(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    128     mSizeTy = iBuilder->getSizeTy();
    129     mStreamTy = iBuilder->getStreamTy();
     85void PabloKernel::addInternalKernelProperties(const std::unique_ptr<kernel::KernelBuilder> & b) {
     86    mSizeTy = b->getSizeTy();
     87    mStreamTy = b->getStreamTy();
     88    mSymbolTable = new SymbolGenerator(b->getContext(), mAllocator);
     89    mEntryBlock = PabloBlock::Create(this);
     90    mContext = &b->getContext();
     91    for (const Binding & ss : mStreamSetInputs) {
     92        Var * param = new (mAllocator) Var(makeName(ss.getName()), ss.getType(), mAllocator, Var::KernelInputParameter);
     93        param->addUser(this);
     94        mInputs.push_back(param);
     95        mVariables.push_back(param);
     96    }
     97    for (const Binding & ss : mStreamSetOutputs) {
     98        Var * result = new (mAllocator) Var(makeName(ss.getName()), ss.getType(), mAllocator, Var::KernelOutputParameter);
     99        result->addUser(this);
     100        mOutputs.push_back(result);
     101        mVariables.push_back(result);
     102    }
     103    for (const Binding & ss : mScalarOutputs) {
     104        Var * result = new (mAllocator) Var(makeName(ss.getName()), ss.getType(), mAllocator, Var::KernelOutputParameter);
     105        result->addUser(this);
     106        mOutputs.push_back(result);
     107        mVariables.push_back(result);
     108        mScalarOutputVars.push_back(result);
     109        result->setScalar();
     110    }
    130111    generatePabloMethod();   
    131112    pablo_function_passes(this);
    132     mPabloCompiler->initializeKernelData(iBuilder);
     113    mPabloCompiler = new PabloCompiler(this);
     114    mPabloCompiler->initializeKernelData(b);
    133115    mSizeTy = nullptr;
    134116    mStreamTy = nullptr;   
     
    142124    mStreamTy = nullptr;
    143125}
     126
     127#if 0
     128void PabloKernel::beginConditionalRegion(const std::unique_ptr<KernelBuilder> & b) {
     129    mPabloCompiler->clearCarryData(b);
     130}
     131#endif
    144132
    145133void PabloKernel::generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, Value * const remainingBytes) {
     
    221209                      {Binding{b->getBitBlockType(), "EOFbit"}, Binding{b->getBitBlockType(), "EOFmask"}})
    222210, PabloAST(PabloAST::ClassTypeId::Kernel, nullptr, mAllocator)
    223 , mPabloCompiler(new PabloCompiler(this))
    224 , mSymbolTable(new SymbolGenerator(b->getContext(), mAllocator))
    225 , mEntryBlock(PabloBlock::Create(this))
     211, mPabloCompiler(nullptr)
     212, mSymbolTable(nullptr)
     213, mEntryBlock(nullptr)
    226214, mSizeTy(nullptr)
    227 , mStreamTy(nullptr) {
    228     prepareStreamSetNameMap();
    229     for (const Binding & ss : mStreamSetInputs) {
    230         Var * param = new (mAllocator) Var(makeName(ss.getName()), ss.getType(), mAllocator, Var::KernelInputParameter);
    231         param->addUser(this);
    232         mInputs.push_back(param);
    233         mVariables.push_back(param);
    234     }
    235     for (const Binding & ss : mStreamSetOutputs) {
    236         Var * result = new (mAllocator) Var(makeName(ss.getName()), ss.getType(), mAllocator, Var::KernelOutputParameter);
    237         result->addUser(this);
    238         mOutputs.push_back(result);
    239         mVariables.push_back(result);
    240     }
    241     for (const Binding & ss : mScalarOutputs) {
    242         Var * result = new (mAllocator) Var(makeName(ss.getName()), ss.getType(), mAllocator, Var::KernelOutputParameter);
    243         result->addUser(this);
    244         mOutputs.push_back(result);
    245         mVariables.push_back(result);
    246         mScalarOutputNameMap.emplace(ss.getName(), result);
    247         result->setScalar();
    248     }
     215, mStreamTy(nullptr)
     216, mContext(nullptr) {
     217
    249218}
    250219
Note: See TracChangeset for help on using the changeset viewer.