Ignore:
Timestamp:
Apr 15, 2017, 4:42:33 PM (2 years ago)
Author:
nmedfort
Message:

First attempt to allow Kernels to wait for consumers to finish processing before performing a realloc.

File:
1 edited

Legend:

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

    r5402 r5408  
    7575
    7676class KernelInterface {
    77 
    7877public:
    7978    /*
     
    101100    void addKernelDeclarations(llvm::Module * client);
    102101
    103     virtual void createInstance() = 0;
     102    virtual llvm::Value * createInstance() = 0;
     103
     104    virtual void initializeInstance() = 0;
    104105
    105106    void setInitialArguments(std::vector<llvm::Value *> args);
    106107
    107     llvm::Value * getInstance() const { return mKernelInstance; }
     108    llvm::Value * getInstance() const {
     109        return mKernelInstance;
     110    }
    108111
    109112    unsigned getLookAhead() const {
     
    115118    }
    116119
    117     virtual llvm::Value * getProducedItemCount(llvm::Value * instance, const std::string & name, llvm::Value * doFinal = nullptr) const = 0;
     120    virtual llvm::Value * getProducedItemCount(const std::string & name, llvm::Value * doFinal = nullptr) const = 0;
    118121
    119     virtual void setProducedItemCount(llvm::Value * instance, const std::string & name, llvm::Value * value) const = 0;
     122    virtual void setProducedItemCount(const std::string & name, llvm::Value * value) const = 0;
    120123
    121     virtual llvm::Value * getProcessedItemCount(llvm::Value * instance, const std::string & name) const = 0;
     124    virtual llvm::Value * getProcessedItemCount(const std::string & name) const = 0;
    122125
    123     virtual void setProcessedItemCount(llvm::Value * instance, const std::string & name, llvm::Value * value) const = 0;
     126    virtual void setProcessedItemCount(const std::string & name, llvm::Value * value) const = 0;
    124127
    125     virtual llvm::Value * getTerminationSignal(llvm::Value * instance) const = 0;
     128    virtual llvm::Value * getTerminationSignal() const = 0;
    126129
    127     virtual void setTerminationSignal(llvm::Value * instance) const = 0;
     130    virtual void setTerminationSignal() const = 0;
    128131   
    129132    void setLookAhead(unsigned lookAheadPositions) {
     
    147150                    std::vector<Binding> && internal_scalars)
    148151    : iBuilder(builder)
     152    , mKernelInstance(nullptr)
     153    , mKernelStateType(nullptr)
     154    , mLookAheadPositions(0)
    149155    , mKernelName(kernelName)
    150156    , mStreamSetInputs(stream_inputs)
     
    153159    , mScalarOutputs(scalar_outputs)
    154160    , mInternalScalars(internal_scalars)
    155     , mKernelStateType(nullptr)
    156     , mKernelInstance(nullptr)
    157     , mLookAheadPositions(0) {
     161    {
    158162
    159163    }
    160164   
     165    void setInstance(llvm::Value * const instance) {
     166        assert ("kernel instance cannot be null!" && instance);
     167        assert ("kernel instance must point to a valid kernel state type!" && (instance->getType()->getPointerElementType() == mKernelStateType));
     168        mKernelInstance = instance;
     169    }
     170
    161171protected:
    162172   
    163     IDISA::IDISA_Builder * const iBuilder;
    164     std::string mKernelName;
    165     std::vector<llvm::Value *> mInitialArguments;
    166     std::vector<Binding> mStreamSetInputs;
    167     std::vector<Binding> mStreamSetOutputs;
    168     std::vector<Binding> mScalarInputs;
    169     std::vector<Binding> mScalarOutputs;
    170     std::vector<Binding> mInternalScalars;
    171     llvm::StructType * mKernelStateType;
    172     llvm::Value * mKernelInstance;
    173     unsigned mLookAheadPositions;
    174    
     173    IDISA::IDISA_Builder * const    iBuilder;
     174    llvm::Value *                   mKernelInstance;
     175    llvm::StructType *              mKernelStateType;
     176    unsigned                        mLookAheadPositions;
     177    std::string                     mKernelName;
     178    std::vector<llvm::Value *>      mInitialArguments;
     179    std::vector<Binding>            mStreamSetInputs;
     180    std::vector<Binding>            mStreamSetOutputs;
     181    std::vector<Binding>            mScalarInputs;
     182    std::vector<Binding>            mScalarOutputs;
     183    std::vector<Binding>            mInternalScalars;
    175184};
    176185
Note: See TracChangeset for help on using the changeset viewer.