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

Kernel interface provides only those services used for building pipelines

File:
1 edited

Legend:

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

    r5053 r5060  
    1212#include <llvm/IR/Type.h>
    1313#include <IDISA/idisa_builder.h>
    14 #include <boost/container/flat_map.hpp>
    1514#include "streamset.h"
    1615
     
    2524};
    2625   
     26const std::string init_suffix = "_Init";
     27const std::string doBlock_suffix = "_DoBlock";
     28const std::string finalBlock_suffix = "_FinalBlock";
     29const std::string accumulator_infix = "_get_";
     30
    2731class KernelInterface {
    28     using NameMap = boost::container::flat_map<std::string, llvm::ConstantInt *>;
    2932
    3033public:
     
    3538                    std::vector<ScalarBinding> scalar_parameters,
    3639                    std::vector<ScalarBinding> scalar_outputs,
    37                     std::vector<ScalarBinding> internal_scalars);
     40                    std::vector<ScalarBinding> internal_scalars) :
     41    iBuilder(builder),
     42    mKernelName(kernelName),
     43    mStreamSetInputs(stream_inputs),
     44    mStreamSetOutputs(stream_outputs),
     45    mScalarInputs(scalar_parameters),
     46    mScalarOutputs(scalar_outputs),
     47    mInternalScalars(internal_scalars),
     48    mKernelStateType(nullptr) {}
    3849   
    39     void finalizeKernelStateType();
    4050   
    4151    // Add ExternalLinkage method declarations for the kernel to a given client module.
    4252    void addKernelDeclarations(Module * client);
    43    
    44     // Create a module for the kernel, including the kernel state type and
    45     // all required methods.  The init and accumulator output methods will be
    46     // defined, while the doBlock and finalBlock methods will initially be empty.
    47     //
    48     virtual std::unique_ptr<llvm::Module> createKernelModule();
    4953   
    5054    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters);
     
    5357    llvm::Value * createGetAccumulatorCall(llvm::Value * kernelInstance, std::string accumName);
    5458   
     59protected:
    5560   
    56 protected:
    57     // Add an additional scalar field to the KernelState struct.
    58     // Must occur before any call to addKernelDeclarations or createKernelModule.
    59     void addScalar(llvm::Type * t, std::string scalarName);
    60    
    61     // Run-time access of Kernel State and parameters of methods for
    62     // use in implementing kernels.
    63    
    64     // Get the index of a named scalar field within the kernel state struct.
    65     llvm::Value * getScalarIndex(std::string);
    66    
    67     // Get the value of a scalar field for a given instance.
    68     llvm::Value * getScalarField(llvm::Value * self, std::string fieldName);
    69    
    70     // Set the value of a scalar field for a given instance.
    71     void setScalarField(llvm::Value * self, std::string fieldName, llvm::Value * newFieldVal);
    72    
    73     // Get a parameter by name.
    74     llvm::Value * getParameter(llvm::Function * f, std::string paramName);
    75 
    76 
    7761    IDISA::IDISA_Builder * iBuilder;
    7862    std::string mKernelName;
    7963    std::vector<StreamSetBinding> mStreamSetInputs;
    8064    std::vector<StreamSetBinding> mStreamSetOutputs;
    81    
    8265    std::vector<ScalarBinding> mScalarInputs;
    8366    std::vector<ScalarBinding> mScalarOutputs;
    8467    std::vector<ScalarBinding> mInternalScalars;
    85 
    86     std::vector<llvm::Type *>  mKernelFields;
    87     llvm::Type *               mKernelStateType;
    88     NameMap                    mInternalStateNameMap;
     68    llvm::Type * mKernelStateType;
    8969};
    9070
Note: See TracChangeset for help on using the changeset viewer.