Changeset 5059 for icGREP/icgrep-devel


Ignore:
Timestamp:
Jun 17, 2016, 5:47:48 AM (3 years ago)
Author:
cameron
Message:

Pablo Kernel progress

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5047 r5059  
    5858
    5959SET(PABLO_SRC pablo/pabloAST.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/function.cpp pablo/codegenstate.cpp pablo/builder.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_toolchain.cpp pablo/passes/flattenif.cpp)
    60 SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp )
     60SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp pablo/pablo_kernel.cpp)
    6161SET(PABLO_SRC ${PABLO_SRC} kernels/s2p_kernel.cpp kernels/kernel.cpp kernels/instance.cpp kernels/streamset.cpp kernels/interface.cpp)
    6262SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r5007 r5059  
    4747    Module * getModule() const {
    4848        return mMod;
     49    }
     50   
     51    void setModule(Module * m)  {
     52        mMod = m;
    4953    }
    5054   
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5057 r5059  
    44 */
    55
    6 
     6#include <kernels/streamset.h>
    77#include <pablo/pablo_kernel.h>
     8#include <pablo/pablo_compiler.h>
     9#include <llvm/Support/Debug.h>
    810
    911
    1012using namespace pablo;
     13using namespace kernel;
    1114
    1215PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder,
    13                     std::string kernelName,
    14                     PabloFunction * pf,
    15                     std::vector<string> accumulators);
    16     KernelInterface(iBuilder, kernelName,
    17                     {StreamSetBinding{StreamSetType(pf->NumOfParameters(), 1), "inputs"}},
    18                     {StreamSetBinding{StreamSetType(pf->NumOfResults(), 1), "outputs"}},
     16                         std::string kernelName,
     17                         PabloFunction * pf,
     18                         std::vector<std::string> accumulators) :
     19    KernelInterface(builder, kernelName,
     20                    {StreamSetBinding{StreamSetType(pf->getNumOfParameters(), 1), "inputs"}},
     21                    {StreamSetBinding{StreamSetType(pf->getNumOfResults(), 1), "outputs"}},
    1922                    {},
    20                     accumBindings(accumulators),
    21                     {ScalarBinding(iBuilder->getBitBlockType(), "EOFmark"}) {}
     23                    {},
     24                    {ScalarBinding{builder->getBitBlockType(), "EOFmark"}}),
     25    mPabloFunction(pf) {
     26    mScalarOutputs = accumBindings(accumulators);
     27}
    2228
    23 std::vector<ScalarBinding> accumBindings(std::vector<std::string> accum_names) {
     29
     30std::vector<ScalarBinding> PabloKernel::accumBindings(std::vector<std::string> accum_names) {
    2431    std::vector<ScalarBinding> vec;
    25     accum_t = iBuilder->getInt64Ty();
    26     for (a in accum_names) {
     32    Type * accum_t = iBuilder->getInt64Ty();
     33    for (auto a : accum_names) {
    2734        vec.push_back(ScalarBinding{accum_t, a});
    2835    }
     
    3239std::unique_ptr<llvm::Module> PabloKernel::createKernelModule() {
    3340    std::unique_ptr<llvm::Module> theModule = KernelInterface::createKernelModule();
    34     addFinalBlockMethod(theModule);
    35     Function * doBlockFunction = theModule.get()->getFunction(mKernelName + "_DoBlock");
    36     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    37    
    38    
    39    
     41
     42    Module * m = theModule.get();
     43    addFinalBlockMethod(m);
     44    iBuilder->setModule(m);
     45    PabloCompiler pablo_compiler(iBuilder);
     46    pablo_compiler.setKernel(this);
     47    pablo_compiler.compile(mPabloFunction, m->getFunction(mKernelName + "_DoBlock"));
     48    return theModule;
    4049}
    4150
     
    4554    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "fb_entry", finalBlockFunction, 0));
    4655    // Final Block arguments: self, remaining, then the standard DoBlock args.
    47     Function::arg_iterator args = main->arg_begin();
     56    Function::arg_iterator args = finalBlockFunction->arg_begin();
    4857    Value * self = &*(args++);
    4958    Value * remaining = &*(args++);
    5059    std::vector<Value *> doBlockArgs = {self};
    51     while (args != main->arg_end()){
     60    while (args != finalBlockFunction->arg_end()){
    5261        doBlockArgs.push_back(&*args++);
    5362    }
    5463    // Standard Pablo convention for final block processing: set a bit marking
    5564    // the position just past EOF.
    56     Value * EOFmark = iBuilder->CreateShl(ConstantInt::get(iBuilder->getIntNTy(mBlockSize), 1), remaining);
    57     setScalarField(self, "EOFmark", EOFmark);
     65    Type * bitBlockInt = iBuilder->getIntNTy(iBuilder->getBitBlockWidth());
     66    Value * EOFmark = iBuilder->CreateShl(ConstantInt::get(bitBlockInt, 1), iBuilder->CreateZExt(remaining, bitBlockInt));
     67    setScalarField(self, "EOFmark", iBuilder->CreateBitCast(EOFmark, iBuilder->getBitBlockType()));
    5868    iBuilder->CreateCall(doBlockFunction, doBlockArgs);
    5969    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5057 r5059  
    1212#include <pablo/function.h>
    1313
     14class PabloCompiler;
    1415
    1516namespace pablo {
    1617
    17 class PabloKernel : KernelSignature {
     18class PabloKernel : public KernelInterface {
    1819public:
    1920    PabloKernel(IDISA::IDISA_Builder * builder,
    2021                    std::string kernelName,
    2122                    PabloFunction * function,
    22                     std::vector<string> accumulators);
     23                    std::vector<std::string> accumulators);
    2324// At present only population count accumulator are supported,
    2425// using the pablo.Count operation.
     
    3132    // This may be overridden for specialized processing.
    3233    virtual void addFinalBlockMethod(Module * m);
     34   
     35    PabloFunction * mPabloFunction;
    3336
     37    std::vector<ScalarBinding> accumBindings(std::vector<std::string> accum_names);
     38
     39    friend class PabloCompiler;
    3440};
    3541}
Note: See TracChangeset for help on using the changeset viewer.