Changeset 5265


Ignore:
Timestamp:
Jan 17, 2017, 1:29:52 PM (10 months ago)
Author:
cameron
Message:

Eliminate unneeded doBlock functions

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
6 edited

Legend:

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

    r5263 r5265  
    117117    addKernelDeclarations(m);
    118118    generateInitMethod();       // possibly overridden by the KernelBuilder subtype
    119     generateDoBlockMethod();    // must be implemented by the KernelBuilder subtype
    120     generateFinalBlockMethod(); // possibly overridden by the KernelBuilder subtype
    121119    generateDoSegmentMethod();
    122120
     
    176174}
    177175
     176// Note: this may be overridden to incorporate doBlock logic directly into
     177// the doSegment function.
     178void KernelBuilder::generateDoBlockMethod() const {
     179    llvm::report_fatal_error(mKernelName + " DoBlock method called but not implemented");
     180}
     181
    178182
    179183//  The default doSegment method dispatches to the doBlock routine for
    180184//  each block of the given number of blocksToDo, and then updates counts.
    181185void KernelBuilder::generateDoSegmentMethod() const {
     186    generateDoBlockMethod();    // must be implemented by the KernelBuilder subtype
     187    generateFinalBlockMethod(); // possibly overridden by the KernelBuilder subtype
     188
     189 
    182190    auto savePoint = iBuilder->saveIP();
    183191    Module * m = iBuilder->getModule();
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5263 r5265  
    115115    // Each kernel builder subtype must provide its own logic for generating
    116116    // doBlock calls.
    117     virtual void generateDoBlockMethod() const = 0;
     117    virtual void generateDoBlockMethod() const;
    118118
    119119    virtual void generateDoBlockLogic(llvm::Value * self, llvm::Value * blockNo) const;
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.cpp

    r5263 r5265  
    5555}
    5656
    57 // The doBlock method is deprecated.   But in case it is used, just call doSegment with
    58 // 1 as the number of blocks to do.
    59 void MMapSourceKernel::generateDoBlockMethod() const {
    60     auto savePoint = iBuilder->saveIP();
    61     Module * m = iBuilder->getModule();
    62     Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
    63     Function * doSegmentFunction = m->getFunction(mKernelName + doSegment_suffix);
    64     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    65     Value * self = getParameter(doBlockFunction, "self");
    66     iBuilder->CreateCall(doSegmentFunction, {self, ConstantInt::getNullValue(iBuilder->getInt1Ty())});
    67     iBuilder->CreateRetVoid();
    68     iBuilder->restoreIP(savePoint);
    69 }
    7057
    7158MMapSourceKernel::MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth) :
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.h

    r5263 r5265  
    2323    unsigned mCodeUnitWidth;
    2424 
    25     void generateDoBlockMethod() const override;
    2625    void generateDoSegmentMethod() const override;
    2726   
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5264 r5265  
    1010
    1111namespace kernel {
    12 
    13 // The doBlock method is deprecated.   But in case it is used, just call doSegment with
    14 // 1 as the number of blocks to do.
    15 void StdOutKernel::generateDoBlockMethod() const {
    16     auto savePoint = iBuilder->saveIP();
    17     Module * m = iBuilder->getModule();
    18     Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
    19     Function * doSegmentFunction = m->getFunction(mKernelName + doSegment_suffix);
    20     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    21     Value * self = getParameter(doBlockFunction, "self");
    22     iBuilder->CreateCall(doSegmentFunction, {self, iBuilder->getSize(1)});
    23     iBuilder->CreateRetVoid();
    24     iBuilder->restoreIP(savePoint);
    25 }
    2612           
    2713// Rather than using doBlock logic to write one block at a time, this custom
     
    3925    Function::arg_iterator args = doSegmentFunction->arg_begin();
    4026    Value * self = &*(args++);
    41     Value * doFinal = &*(args++);
     27    /* unused Value * doFinal = &*(args++);*/ args++;
    4228    Value * producerPos = &*(args++);
    4329    ////iBuilder->CallPrintInt("blocksToDo", blocksToDo);
     
    6349}
    6450
    65 void StdOutKernel::generateFinalBlockMethod() const {
    66     auto savePoint = iBuilder->saveIP();
    67     Module * m = iBuilder->getModule();
    68     Function * finalBlockFunction = m->getFunction(mKernelName + finalBlock_suffix);
    69     Type * i8PtrTy = iBuilder->getInt8PtrTy();   
    70     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "fb_flush", finalBlockFunction, 0));
    71     Constant * blockItems = iBuilder->getSize(iBuilder->getBitBlockWidth());
    72     Constant * itemBytes = iBuilder->getSize(mCodeUnitWidth/8);
    73     Value * self = getParameter(finalBlockFunction, "self");
    74     Value * streamStructPtr = getStreamSetStructPtr(self, "codeUnitBuffer");
    75     LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr));
    76     Value * processed = getProcessedItemCount(self, "codeUnitBuffer");
    77     Value * itemsAvail = iBuilder->CreateSub(producerPos, processed);
    78     Value * blockNo = getScalarField(self, blockNoScalar);
    79     Value * byteOffset = iBuilder->CreateMul(iBuilder->CreateURem(processed, blockItems), itemBytes);
    80     Value * bytePtr = getStreamView(i8PtrTy, self, "codeUnitBuffer", blockNo, byteOffset);
    81     iBuilder->CreateWriteCall(iBuilder->getInt32(1), bytePtr, iBuilder->CreateMul(itemsAvail, itemBytes));
    82     setProcessedItemCount(self, "codeUnitBuffer", producerPos);
    83     mStreamSetInputBuffers[0]->setConsumerPos(streamStructPtr, producerPos);
    84     setTerminationSignal(self);
    85     iBuilder->CreateRetVoid();
    86     iBuilder->restoreIP(savePoint);
    8751}
    88 }
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.h

    r5256 r5265  
    2626    unsigned mCodeUnitWidth;
    2727 
    28     void generateDoBlockMethod() const override;
    29     void generateFinalBlockMethod() const override;
    3028    void generateDoSegmentMethod() const override;
    3129   
Note: See TracChangeset for help on using the changeset viewer.