Ignore:
Timestamp:
Jun 25, 2016, 9:07:07 AM (3 years ago)
Author:
cameron
Message:

Kernel infrastructure: move common logic into KernelBuilder? base class; demo linking in wc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5063 r5074  
    2929                    std::vector<ScalarBinding> internal_scalars);
    3030   
     31    // Create a module for the kernel, including the kernel state type declaration and
     32    // the full implementation of all required methods.     
     33    //
     34    std::unique_ptr<llvm::Module> createKernelModule();
     35   
     36    // Generate the Kernel to the current module (iBuilder->getModule()).
     37    void generateKernel();
     38   
     39protected:
     40    //
     41    // Kernel builder subtypes define their logic of kernel construction
     42    // in terms of 3 virtual methods for
     43    // (a) preparing the Kernel state data structure
     44    // (b) defining the logic of the doBlock function, and
     45    // (c) defining the logic of the finalBlock function.
     46    //
     47    // Note: the kernel state data structure must only be finalized after
     48    // all scalar fields have been added.   If there are no fields to
     49    // be added, the default method for preparing kernel state may be used.
     50   
     51    virtual void prepareKernelStateType();
     52   
     53    // Each kernel builder subtype must provide its own logic for generating
     54    // doBlock calls.
     55    virtual void generateDoBlockMethod() = 0;
     56   
     57    // Each kernel builder subtypre must also specify the logic for processing the
     58    // final block of stream data, if there is any special processing required
     59    // beyond simply calling the doBlock function.   In the case that the final block
     60    // processing may be trivially implemented by dispatching to the doBlock method
     61    // without additional preparation, the default generateFinalBlockMethod need
     62    // not be overridden.
     63   
     64    virtual void generateFinalBlockMethod();
     65   
    3166    // Add an additional scalar field to the KernelState struct.
    3267    // Must occur before any call to addKernelDeclarations or createKernelModule.
    3368    void addScalar(llvm::Type * t, std::string scalarName);
    34    
    35     void finalizeKernelStateType();
    36    
    37     // Create a module for the kernel, including the kernel state type and
    38     // all required methods.  The init and accumulator output methods will be
    39     // defined, while the doBlock and finalBlock methods will initially be empty.
    40     //
    41     virtual std::unique_ptr<llvm::Module> createKernelModule();
    42    
    43     // Generate Kernel to the current module.
    44     virtual void generateKernel();
    45    
    46     // Add a FinalBlock method that simply calls DoBlock without additional
    47     // preparation.
    48     void addTrivialFinalBlockMethod(Module * m);
    49    
     69       
    5070    // Run-time access of Kernel State and parameters of methods for
    5171    // use in implementing kernels.
Note: See TracChangeset for help on using the changeset viewer.