Ignore:
Timestamp:
Jan 5, 2017, 3:54:40 PM (3 years ago)
Author:
nmedfort
Message:

Code clean up to enforce proper calling order of KernelBuilder? methods

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r5245 r5246  
    292292    // We always use the 0-th slot for the summary value, even when it's implicit
    293293    mCurrentFrameIndex = mCarryInfo->hasExplicitSummary() ? 1 : 0;
    294 
    295294}
    296295
     
    390389
    391390    // Create a mask to implement circular buffer indexing
    392     Value * indexMask = ConstantInt::get(iBuilder->getSizeTy(), nearest_pow2(entries) - 1);
     391    Value * indexMask = iBuilder->getSize(nearest_pow2(entries) - 1);
    393392    Value * blockIndex = mKernel->getScalarField(mSelf, blockNoScalar);
    394393    Value * carryIndex0 = iBuilder->CreateSub(blockIndex, iBuilder->getSize(entries));
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5245 r5246  
    261261    if (whileStatement->getBound()) {
    262262        bound_phi = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2, "while_bound");
    263         bound_phi->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), whileStatement->getBound()), whileEntryBlock);
     263        bound_phi->addIncoming(iBuilder->getSize(whileStatement->getBound()), whileEntryBlock);
    264264    }
    265265#endif
     
    452452            std::string inputName = var->getName()->to_string();;
    453453            Value * blockNo = mKernel->getScalarField(mSelf, blockNoScalar);
    454             Value * lookAhead_blockPtr  = mKernel->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, ConstantInt::get(iBuilder->getSizeTy(), block_shift)));
     454            Value * lookAhead_blockPtr  = mKernel->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, iBuilder->getSize(block_shift)));
    455455            Value * lookAhead_inputPtr = iBuilder->CreateGEP(lookAhead_blockPtr, {iBuilder->getInt32(0), iBuilder->getInt32(index)});
    456456            Value * lookAhead = iBuilder->CreateBlockAlignedLoad(lookAhead_inputPtr);
     
    458458                value = lookAhead;
    459459            } else { // Need to form shift result from two adjacent blocks.
    460                 Value * lookAhead_blockPtr1  = mKernel->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, ConstantInt::get(iBuilder->getSizeTy(), block_shift + 1)));
     460                Value * lookAhead_blockPtr1  = mKernel->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, iBuilder->getSize(block_shift + 1)));
    461461                Value * lookAhead_inputPtr1 = iBuilder->CreateGEP(lookAhead_blockPtr1, {iBuilder->getInt32(0), iBuilder->getInt32(index)});
    462462                Value * lookAhead1 = iBuilder->CreateBlockAlignedLoad(lookAhead_inputPtr1);
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5245 r5246  
    1717using namespace IDISA;
    1818
    19 Var * PabloKernel::addInput(const std::string name, Type * const type) {
     19Var * PabloKernel::addInput(const std::string & name, Type * const type) {
    2020    Var * param = new (mAllocator) Var(mSymbolTable->make(name, iBuilder), type, mAllocator, true);
    2121    mInputs.push_back(param);
     
    8080}
    8181
    82 void PabloKernel::generateDoBlockMethod() {
     82void PabloKernel::generateDoBlockMethod() const {
    8383    auto savePoint = iBuilder->saveIP();
    8484    Module * const m = iBuilder->getModule();
     
    8787    mPabloCompiler->compile(self, f);
    8888    Value * produced = getProducedItemCount(self);
    89     produced = iBuilder->CreateAdd(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     89    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    9090    setProducedItemCount(self, produced);
    9191    iBuilder->CreateRetVoid();
     
    9696}
    9797
    98 void PabloKernel::generateFinalBlockMethod() {
     98void PabloKernel::generateFinalBlockMethod() const {
    9999    auto savePoint = iBuilder->saveIP();
    100100    Module * m = iBuilder->getModule();
     
    117117    /* Adjust the produced item count */
    118118    Value * produced = getProducedItemCount(self);
    119     produced = iBuilder->CreateSub(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     119    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    120120    setProducedItemCount(self, iBuilder->CreateAdd(produced, remaining));
    121121    iBuilder->CreateRetVoid();
     
    126126}
    127127
    128 void PabloKernel::initializeKernelState(Value * self) {   
    129     iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), self);
     128void PabloKernel::initializeKernelState(Value * self) const {
     129    iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), self);   
    130130}
    131131
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5240 r5246  
    4141    // using the pablo.Count operation.
    4242   
    43     ~PabloKernel();
     43    virtual ~PabloKernel();
    4444
    4545    PabloBlock * getEntryBlock() {
     
    6565    }
    6666
    67     Var * addInput(const std::string name, Type * const type);
     67    Var * addInput(const std::string & name, Type * const type);
    6868
    6969    unsigned getNumOfInputs() const {
     
    110110    void prepareKernel() override;
    111111
    112     void generateDoBlockMethod() override;
     112    void generateDoBlockMethod() const override;
    113113   
    114     void initializeKernelState(Value * self) override;
     114    void initializeKernelState(Value * self) const override;
    115115
    116116    // The default method for Pablo final block processing sets the
    117117    // EOFmark bit and then calls the standard DoBlock function.
    118118    // This may be overridden for specialized processing.
    119     virtual void generateFinalBlockMethod() override;
     119    virtual void generateFinalBlockMethod() const override;
    120120
    121121    inline String * getName(const std::string & name) const {
Note: See TracChangeset for help on using the changeset viewer.