Ignore:
Timestamp:
Jan 27, 2017, 2:22:06 PM (2 years ago)
Author:
nmedfort
Message:

Optimized Symbol Generation (and fixed potential bug that could allow duplicate names being constructed); made PabloKernel? extend PabloAST (temporarily removed PabloAST::getName() to avoid diamond problem); added an internal scalar to PabloKernel? struct for each Count to avoid InOut? output scalar variable problem; allowed CodeMotionPass? to move code within the same scope but across a branch statement. Began work on separating Kernels into either Block-Oriented or Segment-Oriented kernels.

File:
1 edited

Legend:

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

    r5276 r5283  
    4545
    4646    llvm::Value * getBlockNo(llvm::Value * self) const;
     47
    4748    virtual llvm::Value * getProcessedItemCount(llvm::Value * self, const std::string & ssName) const override;
     49
    4850    virtual llvm::Value * getProducedItemCount(llvm::Value * self, const std::string & ssName) const override;
    4951   
     
    9092    KernelBuilder(IDISA::IDISA_Builder * builder,
    9193                    std::string && kernelName,
    92                     std::vector<Binding> stream_inputs,
    93                     std::vector<Binding> stream_outputs,
    94                     std::vector<Binding> scalar_parameters,
    95                     std::vector<Binding> scalar_outputs,
    96                     std::vector<Binding> internal_scalars);
     94                    std::vector<Binding> && stream_inputs,
     95                    std::vector<Binding> && stream_outputs,
     96                    std::vector<Binding> && scalar_parameters,
     97                    std::vector<Binding> && scalar_outputs,
     98                    std::vector<Binding> && internal_scalars);
    9799
    98100    //
     
    107109    // be added, the default method for preparing kernel state may be used.
    108110   
    109     void setNoTerminateAttribute(bool noTerminate = true) {mNoTerminateAttribute = noTerminate;}
    110     void setDoBlockUpdatesProducedItemCountsAttribute(bool doesUpdate = true) {mDoBlockUpdatesProducedItemCountsAttribute = doesUpdate;}
     111    void setNoTerminateAttribute(const bool noTerminate = true) {
     112        mNoTerminateAttribute = noTerminate;
     113    }
     114
     115    void setDoBlockUpdatesProducedItemCountsAttribute(const bool doesUpdate = true) {
     116        mDoBlockUpdatesProducedItemCountsAttribute = doesUpdate;
     117    }
    111118   
    112119    virtual void prepareKernel();
    113    
    114     // Each kernel builder subtype must provide its own logic for generating
    115     // doBlock calls.
    116     virtual void generateDoBlockMethod() const;
    117 
    118     virtual void generateDoBlockLogic(llvm::Value * self, llvm::Value * blockNo) const;
    119 
    120     // Each kernel builder subtypre must also specify the logic for processing the
    121     // final block of stream data, if there is any special processing required
    122     // beyond simply calling the doBlock function.   In the case that the final block
    123     // processing may be trivially implemented by dispatching to the doBlock method
    124     // without additional preparation, the default generateFinalBlockMethod need
    125     // not be overridden.
    126    
    127     virtual void generateFinalBlockMethod() const;
    128    
     120       
    129121    virtual void generateInitMethod() const;
    130122   
    131     virtual void generateDoSegmentMethod() const;
     123    virtual void generateDoSegmentMethod() const = 0;
    132124   
    133125    // Add an additional scalar field to the KernelState struct.
     
    135127    unsigned addScalar(llvm::Type * type, const std::string & name);
    136128
     129    unsigned addUnnamedScalar(llvm::Type * type);
     130
    137131    unsigned getScalarCount() const;
    138132
     
    146140    llvm::Value * getScalarField(llvm::Value * self, const std::string & fieldName) const;
    147141
     142    llvm::Value * getScalarField(llvm::Value * self, llvm::Value * index) const;
     143
    148144    // Set the value of a scalar field for a given instance.
    149     void setScalarField(llvm::Value * self, const std::string & fieldName, llvm::Value * newFieldVal) const;
    150    
     145    void setScalarField(llvm::Value * self, const std::string & fieldName, llvm::Value * value) const;
     146
     147    void setScalarField(llvm::Value * self, llvm::Value * index, llvm::Value * value) const;
     148
    151149    // Get a parameter by name.
    152     llvm::Value * getParameter(llvm::Function * f, const std::string & paramName) const;
     150    llvm::Argument * getParameter(llvm::Function * f, const std::string & name) const;
    153151
    154152    llvm::Value * getStream(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
     
    165163    llvm::Value * getScalarFieldPtr(llvm::Value * self, const std::string & name) const;
    166164
     165    llvm::Value * getScalarFieldPtr(llvm::Value * self, llvm::Value * index) const;
     166
    167167    llvm::Value * getStreamSetBufferPtr(llvm::Value * self, const std::string & name) const;
    168168
     169    llvm::Value * getStreamSetBufferPtr(llvm::Value * self, llvm::Value * index) const;
     170
    169171    llvm::Value * getStreamSetPtr(llvm::Value * self, const std::string & name, llvm::Value * blockNo) const;
    170172   
    171173    void setBlockNo(llvm::Value * self, llvm::Value * value) const;
    172174
    173     virtual void setProcessedItemCount(llvm::Value * self, const std::string & ssName, llvm::Value * newFieldVal) const;
    174 
    175     virtual void setProducedItemCount(llvm::Value * self, const std::string & ssName, llvm::Value * newFieldVal) const;
    176 
    177 
    178 private:
     175    virtual void setProcessedItemCount(llvm::Value * self, const std::string & name, llvm::Value * value) const;
     176
     177    virtual void setProducedItemCount(llvm::Value * self, const std::string & name, llvm::Value * value) const;
     178
     179protected:
    179180
    180181    const parabix::StreamSetBuffer * getStreamSetBuffer(const std::string & name) const;
     
    191192
    192193};
     194
     195class BlockOrientedKernel : public KernelBuilder {
     196protected:
     197
     198    // Each kernel builder subtype must provide its own logic for generating
     199    // doBlock calls.
     200    virtual void generateDoBlockMethod() const = 0;
     201
     202    virtual void generateDoBlockLogic(llvm::Value * self, llvm::Value * blockNo) const;
     203
     204    // Each kernel builder subtypre must also specify the logic for processing the
     205    // final block of stream data, if there is any special processing required
     206    // beyond simply calling the doBlock function.   In the case that the final block
     207    // processing may be trivially implemented by dispatching to the doBlock method
     208    // without additional preparation, the default generateFinalBlockMethod need
     209    // not be overridden.
     210
     211    virtual void generateFinalBlockMethod() const;
     212
     213    virtual void generateDoSegmentMethod() const final;
     214
     215    BlockOrientedKernel(IDISA::IDISA_Builder * builder,
     216                        std::string && kernelName,
     217                        std::vector<Binding> && stream_inputs,
     218                        std::vector<Binding> && stream_outputs,
     219                        std::vector<Binding> && scalar_parameters,
     220                        std::vector<Binding> && scalar_outputs,
     221                        std::vector<Binding> && internal_scalars);
     222
     223    virtual ~BlockOrientedKernel() { }
     224};
     225
     226class SegmentOrientedKernel : public KernelBuilder {
     227protected:
     228    SegmentOrientedKernel(IDISA::IDISA_Builder * builder,
     229                          std::string && kernelName,
     230                          std::vector<Binding> && stream_inputs,
     231                          std::vector<Binding> && stream_outputs,
     232                          std::vector<Binding> && scalar_parameters,
     233                          std::vector<Binding> && scalar_outputs,
     234                          std::vector<Binding> && internal_scalars);
     235
     236    virtual ~SegmentOrientedKernel() { }
     237};
     238
     239
     240
    193241}
    194242#endif
Note: See TracChangeset for help on using the changeset viewer.