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

Pablo Kernel progress

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.