Ignore:
Timestamp:
Jan 14, 2017, 3:49:56 PM (2 years ago)
Author:
nmedfort
Message:

Changes working towards simplifying accessing stream elements + some modifications to simplify include / forward declarations within the CodeGen? library.

File:
1 edited

Legend:

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

    r5257 r5260  
    77#define KERNEL_BUILDER_H
    88
    9 #include "streamset.h"
    10 #include "interface.h"
    11 #include <vector>
    12 #include <llvm/IR/Type.h>
     9#include <string>           // for string
     10#include <memory>           // for unique_ptr
     11#include "interface.h"      // for KernelInterface
     12#include <boost/container/flat_map.hpp>
    1313#include <IR_Gen/idisa_builder.h>
    14 #include <boost/container/flat_map.hpp>
     14namespace llvm { class ConstantInt; }
     15namespace llvm { class Function; }
     16namespace llvm { class IntegerType; }
     17namespace llvm { class LoadInst; }
     18namespace llvm { class Type; }
     19namespace llvm { class Value; }
     20namespace parabix { class StreamSetBuffer; }
    1521
    1622const std::string blockNoScalar = "blockNo";
     
    2228const std::string blkMaskSuffix = "_blkMask";
    2329
    24 using namespace parabix;
    2530namespace kernel {
    2631   
     
    3237    // the full implementation of all required methods.     
    3338    //
    34     std::unique_ptr<Module> createKernelModule(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs);
     39    std::unique_ptr<llvm::Module> createKernelModule(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
    3540   
    3641    // Generate the Kernel to the current module (iBuilder->getModule()).
    37     void generateKernel(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs);
     42    void generateKernel(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
    3843   
    3944    void createInstance() override;
    4045
    41     Function * generateThreadFunction(const std::string & name) const;
     46    llvm::Function * generateThreadFunction(const std::string & name) const;
    4247
    43     Value * getBlockNo(Value * self) const;
    44     virtual Value * getProcessedItemCount(Value * self, const std::string & ssName) const override;
    45     virtual Value * getProducedItemCount(Value * self, const std::string & ssName) const override;
     48    llvm::Value * getBlockNo(llvm::Value * self) const;
     49    virtual llvm::Value * getProcessedItemCount(llvm::Value * self, const std::string & ssName) const override;
     50    virtual llvm::Value * getProducedItemCount(llvm::Value * self, const std::string & ssName) const override;
    4651   
    4752    bool hasNoTerminateAttribute() { return mNoTerminateAttribute;}
    4853   
    49     Value * getTerminationSignal(Value * self) const override;
     54    llvm::Value * getTerminationSignal(llvm::Value * self) const override;
    5055   
    51     inline IntegerType * getSizeTy() const {
     56    inline llvm::IntegerType * getSizeTy() const {
    5257        return getBuilder()->getSizeTy();
    5358    }
    5459
    55     inline Type * getStreamTy(const unsigned FieldWidth = 1) {
     60    inline llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
    5661        return getBuilder()->getStreamTy(FieldWidth);
    5762    }
    5863   
    59     inline Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
     64    inline llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
    6065        return getBuilder()->getStreamSetTy(NumElements, FieldWidth);
    6166    }
     
    7075    // data has been extracted from the kernel for further pipeline processing, the
    7176    // segment number must be incremented and stored using releaseLogicalSegmentNo.
    72     LoadInst * acquireLogicalSegmentNo(Value * self) const;
     77    llvm::LoadInst * acquireLogicalSegmentNo(llvm::Value * self) const;
    7378
    74     void releaseLogicalSegmentNo(Value * self, Value * newFieldVal) const;
     79    void releaseLogicalSegmentNo(llvm::Value * self, llvm::Value * newFieldVal) const;
    7580
    7681    virtual ~KernelBuilder() = 0;
    7782   
    78     std::vector<StreamSetBuffer *> getStreamSetInputBuffers() {return mStreamSetInputBuffers;}
    79     std::vector<StreamSetBuffer *> getStreamSetOutputBuffers() {return mStreamSetOutputBuffers;}
     83    const std::vector<const parabix::StreamSetBuffer *> & getStreamSetInputBuffers() const { return mStreamSetInputBuffers; }
     84
     85    const std::vector<const parabix::StreamSetBuffer *> & getStreamSetOutputBuffers() const { return mStreamSetOutputBuffers; }
    8086
    8187
     
    110116    virtual void generateDoBlockMethod() const = 0;
    111117
    112     virtual void generateDoBlockLogic(Value * self, Value * blockNo) const;
     118    virtual void generateDoBlockLogic(llvm::Value * self, llvm::Value * blockNo) const;
    113119
    114120    // Each kernel builder subtypre must also specify the logic for processing the
     
    129135    // Add an additional scalar field to the KernelState struct.
    130136    // Must occur before any call to addKernelDeclarations or createKernelModule.
    131     unsigned addScalar(Type * type, const std::string & name);
     137    unsigned addScalar(llvm::Type * type, const std::string & name);
    132138
    133139    unsigned getScalarCount() const;
     
    137143   
    138144    // Get the index of a named scalar field within the kernel state struct.
    139     ConstantInt * getScalarIndex(const std::string & name) const;
     145    llvm::ConstantInt * getScalarIndex(const std::string & name) const;
    140146   
    141147    // Get the value of a scalar field for a given instance.
    142     Value * getScalarField(Value * self, const std::string & fieldName) const;
     148    llvm::Value * getScalarField(llvm::Value * self, const std::string & fieldName) const;
    143149
    144150    // Set the value of a scalar field for a given instance.
    145     void setScalarField(Value * self, const std::string & fieldName, Value * newFieldVal) const;
     151    void setScalarField(llvm::Value * self, const std::string & fieldName, llvm::Value * newFieldVal) const;
    146152   
    147153    // Get a parameter by name.
    148     Value * getParameter(Function * f, const std::string & paramName) const;
     154    llvm::Value * getParameter(llvm::Function * f, const std::string & paramName) const;
    149155
    150     Value * getStream(Value * self, const std::string & name, Value * blockNo, const unsigned index) {
    151         return getStream(self, name, blockNo, iBuilder->getInt32(index));
    152     }
     156    llvm::Value * getStream(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
    153157
    154     Value * getStream(Value * self, const std::string & name, Value * blockNo, Value * index);
    155    
     158    llvm::Value * getStream(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index1, llvm::Value * index2) const;
     159
     160    llvm::Value * getStreamView(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
     161
     162    llvm::Value * getStreamView(llvm::Type * type, llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
     163
    156164    // Stream set helpers.
    157165    unsigned getStreamSetIndex(const std::string & name) const;
    158166   
    159     Value * getScalarFieldPtr(Value * self, const std::string & name) const;
     167    llvm::Value * getScalarFieldPtr(llvm::Value * self, const std::string & name) const;
    160168
    161     Value * getStreamSetStructPtr(Value * self, const std::string & name) const;
     169    llvm::Value * getStreamSetStructPtr(llvm::Value * self, const std::string & name) const;
    162170
    163     size_t getStreamSetBufferSize(Value * self, const std::string & name) const;
     171    llvm::Value * getStreamSetPtr(llvm::Value * self, const std::string & name, llvm::Value * blockNo) const;
     172   
     173    void setBlockNo(llvm::Value * self, llvm::Value * value) const;
    164174
    165     Value * getStreamSetBlockPtr(Value * self, const std::string & name, Value * blockNo) const;
    166    
    167     void setBlockNo(Value * self, Value * newFieldVal) const;
     175    virtual void setProcessedItemCount(llvm::Value * self, const std::string & ssName, llvm::Value * newFieldVal) const;
    168176
    169     virtual void setProcessedItemCount(Value * self, const std::string & ssName, Value * newFieldVal) const;
     177    virtual void setProducedItemCount(llvm::Value * self, const std::string & ssName, llvm::Value * newFieldVal) const;
    170178
    171     virtual void setProducedItemCount(Value * self, const std::string & ssName, Value * newFieldVal) const;
     179    void setTerminationSignal(llvm::Value * self) const;
    172180
    173     void setTerminationSignal(Value * self) const;
     181private:
     182
     183    const parabix::StreamSetBuffer * getStreamSetBuffer(const std::string & name) const;
    174184
    175185protected:
    176186
    177     std::vector<Type *>             mKernelFields;
    178     NameMap                         mKernelMap;
    179     NameMap                         mStreamSetNameMap;
    180     std::vector<StreamSetBuffer *>  mStreamSetInputBuffers;
    181     std::vector<StreamSetBuffer *>  mStreamSetOutputBuffers;
    182     bool                            mNoTerminateAttribute;
     187    std::vector<llvm::Type *>                       mKernelFields;
     188    NameMap                                         mKernelMap;
     189    NameMap                                         mStreamSetNameMap;
     190    std::vector<const parabix::StreamSetBuffer *>   mStreamSetInputBuffers;
     191    std::vector<const parabix::StreamSetBuffer *>   mStreamSetOutputBuffers;
     192    bool                                            mNoTerminateAttribute;
    183193
    184194};
Note: See TracChangeset for help on using the changeset viewer.