Ignore:
Timestamp:
May 6, 2017, 4:05:05 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work.

File:
1 edited

Legend:

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

    r5434 r5435  
    3838    bool isExact() const {return (mKind == ProcessingRateKind::FixedRatio)||(mKind == ProcessingRateKind::RoundUp)||(mKind == ProcessingRateKind::Add1) ;}
    3939    bool isUnknownRate() const { return mKind == ProcessingRateKind::Unknown; }
    40     llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * b, llvm::Value * principalInputItems, llvm::Value * doFinal = nullptr) const;
    41     llvm::Value * CreateMaxReferenceItemsCalculation(IDISA::IDISA_Builder * b, llvm::Value * outputItems, llvm::Value * doFinal = nullptr) const;
     40    llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * const b, llvm::Value * principalInputItems, llvm::Value * doFinal = nullptr) const;
     41    llvm::Value * CreateMaxReferenceItemsCalculation(IDISA::IDISA_Builder * const b, llvm::Value * outputItems, llvm::Value * doFinal) const;
    4242    friend ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string && referenceStreamSet);
    4343    friend ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string && referenceStreamSet);
     
    4747    uint16_t getRatioNumerator() const { return mRatioNumerator;}
    4848    uint16_t getRatioDenominator() const { return mRatioDenominator;}
    49     std::string referenceStreamSet() const { return mReferenceStreamSet;}
     49    const std::string & referenceStreamSet() const { return mReferenceStreamSet;}
    5050protected:
    5151    ProcessingRate(ProcessingRateKind k, unsigned numerator, unsigned denominator, std::string && referenceStreamSet)
     
    9191    virtual std::string makeSignature() = 0;
    9292
    93     const std::vector<Binding> & getStreamInputs() const { return mStreamSetInputs; }
    94 
    95     const std::vector<Binding> & getStreamOutputs() const { return mStreamSetOutputs; }
    96 
    97     const std::vector<Binding> & getScalarInputs() const { return mScalarInputs; }
    98 
    99     const std::vector<Binding> & getScalarOutputs() const { return mScalarOutputs; }
    100        
     93    const std::vector<Binding> & getStreamInputs() const {
     94        return mStreamSetInputs;
     95    }
     96
     97    const Binding & getStreamInput(const unsigned i) const {
     98        return mStreamSetInputs[i];
     99    }
     100
     101    const std::vector<Binding> & getStreamOutputs() const {
     102        return mStreamSetOutputs;
     103    }
     104
     105    const Binding & getStreamOutput(const unsigned i) const {
     106        return mStreamSetOutputs[i];
     107    }
     108
     109    const std::vector<Binding> & getScalarInputs() const {
     110        return mScalarInputs;
     111    }
     112
     113    const Binding & getScalarInput(const unsigned i) const {
     114        return mScalarInputs[i];
     115    }
     116
     117    const std::vector<Binding> & getScalarOutputs() const {
     118        return mScalarOutputs;
     119    }
     120
     121    const Binding & getScalarOutput(const unsigned i) const {
     122        return mScalarOutputs[i];
     123    }
     124
    101125    // Add ExternalLinkage method declarations for the kernel to a given client module.
    102126    void addKernelDeclarations();
     
    110134    virtual void finalizeInstance() = 0;
    111135
    112     void setInitialArguments(std::vector<llvm::Value *> args);
    113 
     136    void setInitialArguments(std::vector<llvm::Value *> && args) {
     137        mInitialArguments.swap(args);
     138    }
    114139    llvm::Value * getInstance() const {
    115140        return mKernelInstance;
     
    119144        return mLookAheadPositions;
    120145    }
    121    
    122     virtual llvm::Value * getProducedItemCount(const std::string & name, llvm::Value * doFinal = nullptr) const = 0;
    123 
    124     virtual void setProducedItemCount(const std::string & name, llvm::Value * value) const = 0;
    125 
    126     virtual llvm::Value * getProcessedItemCount(const std::string & name) const = 0;
    127 
    128     virtual void setProcessedItemCount(const std::string & name, llvm::Value * value) const = 0;
    129 
    130     virtual llvm::Value * getConsumedItemCount(const std::string & name) const = 0;
    131 
    132     virtual void setConsumedItemCount(const std::string & name, llvm::Value * value) const = 0;
    133 
    134     virtual llvm::Value * getTerminationSignal() const = 0;
    135 
    136     virtual void setTerminationSignal() const = 0;
    137    
    138     void setLookAhead(unsigned lookAheadPositions) {
     146
     147    void setLookAhead(const unsigned lookAheadPositions) {
    139148        mLookAheadPositions = lookAheadPositions;
    140149    }
     
    150159protected:
    151160
     161    virtual llvm::Value * getProducedItemCount(const std::string & name, llvm::Value * doFinal = nullptr) const = 0;
     162
     163    virtual void setProducedItemCount(const std::string & name, llvm::Value * value) const = 0;
     164
     165    virtual llvm::Value * getProcessedItemCount(const std::string & name) const = 0;
     166
     167    virtual void setProcessedItemCount(const std::string & name, llvm::Value * value) const = 0;
     168
     169    virtual llvm::Value * getConsumedItemCount(const std::string & name) const = 0;
     170
     171    virtual void setConsumedItemCount(const std::string & name, llvm::Value * value) const = 0;
     172
     173    virtual llvm::Value * getTerminationSignal() const = 0;
     174
     175    virtual void setTerminationSignal() const = 0;
     176
    152177    llvm::Function * getInitFunction(llvm::Module * const module) const;
    153178
     
    156181    llvm::Function * getTerminateFunction(llvm::Module * const module) const;
    157182
    158     KernelInterface(IDISA::IDISA_Builder * const builder,
    159                     std::string kernelName,
     183    KernelInterface(std::string kernelName,
    160184                    std::vector<Binding> && stream_inputs,
    161185                    std::vector<Binding> && stream_outputs,
     
    163187                    std::vector<Binding> && scalar_outputs,
    164188                    std::vector<Binding> && internal_scalars)
    165     : iBuilder(builder)
     189    : iBuilder(nullptr)
     190    , mModule(nullptr)
    166191    , mKernelInstance(nullptr)
    167192    , mKernelStateType(nullptr)
     
    185210protected:
    186211   
    187     IDISA::IDISA_Builder *          iBuilder;
    188     llvm::Value *                   mKernelInstance;
    189     llvm::StructType *              mKernelStateType;
    190     unsigned                        mLookAheadPositions;
    191     std::string                     mKernelName;
    192     std::vector<llvm::Value *>      mInitialArguments;
    193     std::vector<Binding>            mStreamSetInputs;
    194     std::vector<Binding>            mStreamSetOutputs;
    195     std::vector<Binding>            mScalarInputs;
    196     std::vector<Binding>            mScalarOutputs;
    197     std::vector<Binding>            mInternalScalars;
     212    IDISA::IDISA_Builder *                  iBuilder;
     213    llvm::Module *                          mModule;
     214
     215    llvm::Value *                           mKernelInstance;
     216    llvm::StructType *                      mKernelStateType;
     217    unsigned                                mLookAheadPositions;
     218    std::string                             mKernelName;
     219    std::vector<llvm::Value *>              mInitialArguments;
     220    std::vector<Binding>                    mStreamSetInputs;
     221    std::vector<Binding>                    mStreamSetOutputs;
     222    std::vector<Binding>                    mScalarInputs;
     223    std::vector<Binding>                    mScalarOutputs;
     224    std::vector<Binding>                    mInternalScalars;
    198225};
    199226
Note: See TracChangeset for help on using the changeset viewer.