Changeset 5250


Ignore:
Timestamp:
Jan 8, 2017, 11:51:40 AM (9 months ago)
Author:
cameron
Message:

Allow for override of kernel init method.

Location:
icGREP/icgrep-devel/icgrep
Files:
4 edited

Legend:

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

    r5247 r5250  
    104104    prepareKernel();            // possibly overridden by the KernelBuilder subtype
    105105    addKernelDeclarations(m);
     106    generateInitMethod();       // possibly overridden by the KernelBuilder subtype
    106107    generateDoBlockMethod();    // must be implemented by the KernelBuilder subtype
    107108    generateFinalBlockMethod(); // possibly overridden by the KernelBuilder subtype
     
    118119        iBuilder->CreateRet(retVal);
    119120    }
    120 
    121     // Implement the initializer function
     121    generateInitMethod();
     122    iBuilder->restoreIP(savePoint);
     123}
     124
     125// Default init method, possibly overridden if special init actions required.
     126void KernelBuilder::generateInitMethod() const {
     127    auto savePoint = iBuilder->saveIP();
     128    Module * const m = iBuilder->getModule();
    122129    Function * initFunction = m->getFunction(mKernelName + init_suffix);
    123130    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "Init_entry", initFunction, 0));   
    124131    Function::arg_iterator args = initFunction->arg_begin();
    125132    Value * self = &*(args++);
    126     initializeKernelState(self);    // possibly overridden by the KernelBuilder subtype
     133    iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), self);
    127134    for (auto binding : mScalarInputs) {
    128135        Value * param = &*(args++);
     
    132139    iBuilder->CreateRetVoid();
    133140    iBuilder->restoreIP(savePoint);
    134 }
    135 
    136 void KernelBuilder::initializeKernelState(Value * self) const {
    137     iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), self);
    138141}
    139142
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5247 r5250  
    4444    virtual Value * getProcessedItemCount(Value * self, const std::string & ssName) const override;
    4545    virtual Value * getProducedItemCount(Value * self, const std::string & ssName) const override;
    46     virtual void initializeKernelState(Value * self) const;
    4746    Value * getTerminationSignal(Value * self) const override;
    4847   
     
    112111   
    113112    virtual void generateFinalBlockMethod() const;
    114 
     113   
     114    virtual void generateInitMethod() const;
     115   
    115116    virtual void generateDoSegmentMethod() const;
    116117   
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5247 r5250  
    131131}
    132132
    133 void PabloKernel::initializeKernelState(Value * self) const {
    134     iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), self);   
    135 }
    136 
    137133PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder, const std::string & kernelName)
    138134: KernelBuilder(builder, kernelName, {}, {}, {}, {}, {Binding{builder->getBitBlockType(), "EOFbit"}, Binding{builder->getBitBlockType(), "EOFmask"}})
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5246 r5250  
    112112    void generateDoBlockMethod() const override;
    113113   
    114     void initializeKernelState(Value * self) const override;
    115 
    116114    // The default method for Pablo final block processing sets the
    117115    // EOFmark bit and then calls the standard DoBlock function.
Note: See TracChangeset for help on using the changeset viewer.