Ignore:
Timestamp:
Jun 18, 2016, 9:52:23 PM (3 years ago)
Author:
cameron
Message:

Pablo Kernels subclass KernelBuilder?, provide generateKernel overrride

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
2 edited

Legend:

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

    r5059 r5062  
    44 */
    55
    6 #include <kernels/streamset.h>
    76#include <pablo/pablo_kernel.h>
    87#include <pablo/pablo_compiler.h>
     
    1514PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder,
    1615                         std::string kernelName,
    17                          PabloFunction * pf,
     16                         PabloFunction * function,
    1817                         std::vector<std::string> accumulators) :
    19     KernelInterface(builder, kernelName,
    20                     {StreamSetBinding{StreamSetType(pf->getNumOfParameters(), 1), "inputs"}},
    21                     {StreamSetBinding{StreamSetType(pf->getNumOfResults(), 1), "outputs"}},
     18    KernelBuilder(builder, kernelName,
     19                    {StreamSetBinding{StreamSetType(function->getNumOfParameters(), 1), "inputs"}},
     20                    {StreamSetBinding{StreamSetType(function->getNumOfResults(), 1), "outputs"}},
    2221                    {},
    2322                    {},
    2423                    {ScalarBinding{builder->getBitBlockType(), "EOFmark"}}),
    25     mPabloFunction(pf) {
     24    mPabloFunction(function) {
    2625    mScalarOutputs = accumBindings(accumulators);
     26    pablo_compiler = new PabloCompiler(builder, this, function);
    2727}
    28 
    2928
    3029std::vector<ScalarBinding> PabloKernel::accumBindings(std::vector<std::string> accum_names) {
     
    3736}
    3837
    39 std::unique_ptr<llvm::Module> PabloKernel::createKernelModule() {
    40     std::unique_ptr<llvm::Module> theModule = KernelInterface::createKernelModule();
     38void PabloKernel::prepareKernel() {
     39    errs() << "PabloKernel::prepareKernel\n";
     40    Type * carryDataType = pablo_compiler->initializeCarryData();
     41    addScalar(carryDataType, "carries");
     42    finalizeKernelStateType();
     43}
    4144
    42     Module * m = theModule.get();
     45void PabloKernel::generateKernel() {
     46    KernelBuilder::generateKernel();
     47    Module * m = iBuilder->getModule();
    4348    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;
     49    pablo_compiler->compile(m->getFunction(mKernelName + doBlock_suffix));
    4950}
    5051
    5152void PabloKernel::addFinalBlockMethod(Module * m) {
    52     Function * doBlockFunction = m->getFunction(mKernelName + "_DoBlock");
    53     Function * finalBlockFunction = m->getFunction(mKernelName + "_FinalBlock");
     53    Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
     54    Function * finalBlockFunction = m->getFunction(mKernelName + finalBlock_suffix);
    5455    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "fb_entry", finalBlockFunction, 0));
    5556    // Final Block arguments: self, remaining, then the standard DoBlock args.
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5059 r5062  
    77#define PABLO_KERNEL_H
    88
    9 #include <kernels/interface.h>
    10 #include <kernels/streamset.h>
     9#include <kernels/kernel.h>
    1110#include <IDISA/idisa_builder.h>
    1211#include <pablo/function.h>
    1312
    14 class PabloCompiler;
     13namespace pablo {
     14   
     15class PabloCompiler; class CarryManager;
    1516
    16 namespace pablo {
    1717
    18 class PabloKernel : public KernelInterface {
     18class PabloKernel : public kernel::KernelBuilder {
    1919public:
    2020    PabloKernel(IDISA::IDISA_Builder * builder,
     
    2222                    PabloFunction * function,
    2323                    std::vector<std::string> accumulators);
    24 // At present only population count accumulator are supported,
    25 // using the pablo.Count operation.
     24    // At present only population count accumulator are supported,
     25    // using the pablo.Count operation.
     26   
     27    // A custom method for preparing kernel declarations is needed,
     28    // so that the carry data requirements may be accommodated before
     29    // finalizing the KernelStateType.
     30    void prepareKernel();
    2631
    27     std::unique_ptr<llvm::Module> createKernelModule() override;
     32    void generateKernel() override;
    2833   
    2934protected:
     
    3641
    3742    std::vector<ScalarBinding> accumBindings(std::vector<std::string> accum_names);
     43   
     44    //std::unique_ptr<pablo::PabloCompiler> pablo_compiler;
     45    PabloCompiler * pablo_compiler;
    3846
    3947    friend class PabloCompiler;
     48    friend class CarryManager;
    4049};
    4150}
Note: See TracChangeset for help on using the changeset viewer.