Ignore:
Timestamp:
Feb 10, 2017, 1:48:34 PM (2 years ago)
Author:
nmedfort
Message:

Adjusted pablo compiler to use getInputStream and getOutputStream when accessing packed stream fields.

File:
1 edited

Legend:

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

    r5307 r5310  
    1010#include <pablo/pe_zeroes.h>
    1111#include <pablo/pe_ones.h>
    12 //#include <llvm/IR/Module.h>
    13 //#include <llvm/IR/Verifier.h>
    14 //#include <IR_Gen/idisa_builder.h>
    1512#include "llvm/Support/Debug.h"
    1613
     
    3128}
    3229
    33 Var * PabloKernel::getInputSet(std::string inputSetName) {
    34     unsigned ssIndex = getStreamSetIndex(inputSetName);
    35     return mInputs[ssIndex];
     30Var * PabloKernel::getInputStreamVar(const std::string & inputSetName) {
     31    return mInputs[getStreamSetIndex(inputSetName)];
    3632}
    3733
    38 Var * PabloKernel::getOutputSet(std::string outputSetName) {
    39     unsigned ssIndex = getStreamSetIndex(outputSetName);
    40     return mOutputs[ssIndex - mInputs.size()];
     34Var * PabloKernel::getOutputStreamVar(const std::string & outputSetName) {
     35    return mOutputs[getStreamSetIndex(outputSetName)];
    4136}
    4237
    43 
    44 Var * PabloKernel::getScalarOutput(std::string outputName) {
     38Var * PabloKernel::getOutputScalarVar(const std::string & outputName) {
    4539    const auto f = mScalarOutputNameMap.find(outputName);
    4640    if (LLVM_UNLIKELY(f == mScalarOutputNameMap.end())) {
    47         llvm::report_fatal_error("Kernel does not contain scalar: " + outputName);
     41        report_fatal_error("Kernel does not contain scalar: " + outputName);
    4842    }
    4943    return f->second;
     
    5145
    5246Var * PabloKernel::addInput(const std::string & name, Type * const type) {
    53     Var * param = new (mAllocator) Var(mSymbolTable->makeString(name, iBuilder), type, mAllocator, Var::ReadOnly);
     47    Var * param = new (mAllocator) Var(mSymbolTable->makeString(name, iBuilder), type, mAllocator, Var::KernelInputParameter);
    5448    param->addUser(this);
    5549    mInputs.push_back(param);
    5650    mVariables.push_back(param);
    5751    if (isStreamType(type)) {
    58         mStreamSetInputs.emplace_back(type, name);
     52        mStreamSetNameMap.emplace(name, mStreamSetInputs.size());
     53        mStreamSetInputs.emplace_back(type, name);       
    5954    } else {
    6055        mScalarInputs.emplace_back(type, name);
     56        param->setScalar();
    6157    }
    6258    assert (mStreamSetInputs.size() + mScalarInputs.size() == mInputs.size());
     
    6561
    6662Var * PabloKernel::addOutput(const std::string & name, Type * const type) {
    67     Var * result = new (mAllocator) Var(mSymbolTable->makeString(name, iBuilder), type, mAllocator, Var::ReadNone);
     63    Var * result = new (mAllocator) Var(mSymbolTable->makeString(name, iBuilder), type, mAllocator, Var::KernelOutputParameter);
    6864    result->addUser(this);
    6965    mOutputs.push_back(result);
    7066    mVariables.push_back(result);
    7167    if (isStreamType(type)) {
     68        mStreamSetNameMap.emplace(name, mStreamSetOutputs.size());
    7269        mStreamSetOutputs.emplace_back(type, name);
    7370    } else {
    7471        mScalarOutputs.emplace_back(type, name);
    7572        mScalarOutputNameMap.emplace(name, result);
     73        result->setScalar();
    7674    }
    7775    assert (mStreamSetOutputs.size() + mScalarOutputs.size() == mOutputs.size());
     
    130128}
    131129
    132 PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder, std::string kernelName)
    133 : BlockOrientedKernel(builder, std::move(kernelName), {}, {}, {}, {}, {Binding{builder->getBitBlockType(), "EOFbit"}, Binding{builder->getBitBlockType(), "EOFmask"}})
    134 , PabloAST(PabloAST::ClassTypeId::Kernel, nullptr, mAllocator)
    135 , mPabloCompiler(new PabloCompiler(this))
    136 , mSymbolTable(new SymbolGenerator(mAllocator))
    137 , mEntryBlock(PabloBlock::Create(this)) {
    138     setDoBlockUpdatesProducedItemCountsAttribute(false);
    139 }
    140 
    141 PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder, std::string kernelName,
    142                          std::vector<Binding> && stream_inputs,
    143                          std::vector<Binding> && stream_outputs,
    144                          std::vector<Binding> && scalar_outputs)
     130PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder, std::string kernelName,
     131                         std::vector<Binding> stream_inputs,
     132                         std::vector<Binding> stream_outputs,
     133                         std::vector<Binding> scalar_parameters,
     134                         std::vector<Binding> scalar_outputs)
    145135: BlockOrientedKernel(builder, std::move(kernelName),
    146136                      std::move(stream_inputs), std::move(stream_outputs),
    147                       {}, std::move(scalar_outputs),
     137                      std::move(scalar_parameters), std::move(scalar_outputs),
    148138                      {Binding{builder->getBitBlockType(), "EOFbit"}, Binding{builder->getBitBlockType(), "EOFmask"}})
    149139, PabloAST(PabloAST::ClassTypeId::Kernel, nullptr, mAllocator)
     
    153143    setDoBlockUpdatesProducedItemCountsAttribute(false);
    154144    prepareKernelSignature();
    155     for (auto ss : mStreamSetInputs) {
    156         Var * param = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::ReadOnly);
     145    for (const Binding & ss : mStreamSetInputs) {
     146        Var * param = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::KernelInputParameter);
    157147        param->addUser(this);
    158148        mInputs.push_back(param);
    159149        mVariables.push_back(param);
    160150    }
    161     for (auto ss : mStreamSetOutputs) {
    162         Var * result = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::ReadNone);
     151    for (const Binding & ss : mStreamSetOutputs) {
     152        Var * result = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::KernelOutputParameter);
    163153        result->addUser(this);
    164154        mOutputs.push_back(result);
    165155        mVariables.push_back(result);
    166156    }
    167     for (auto ss : mScalarOutputs) {
    168         Var * result = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::ReadNone);
     157    for (const Binding & ss : mScalarOutputs) {
     158        Var * result = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::KernelOutputParameter);
    169159        result->addUser(this);
    170160        mOutputs.push_back(result);
Note: See TracChangeset for help on using the changeset viewer.