Ignore:
Timestamp:
Jun 2, 2017, 7:14:05 AM (2 years ago)
Author:
cameron
Message:

Update popcount kernel to new Pablo interface

Location:
icGREP/icgrep-devel/icgrep
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5489 r5491  
    1515#include <kernels/linebreak_kernel.h>
    1616#include <kernels/streams_merge.h>
    17 #include <kernels/match_count.h>
    1817#include <kernels/source_kernel.h>
    1918#include <kernels/s2p_kernel.h>
     
    367366    }
    368367
    369     kernel::MatchCount matchCountK(idb);
    370     mGrepDriver->addKernelCall(matchCountK, {MergedResults}, {});
     368    kernel::Kernel * matchCountK = mGrepDriver->addKernelInstance(make_unique<kernel::PopcountKernel>(idb));
     369    mGrepDriver->makeKernelCall(matchCountK, {MergedResults}, {});
    371370    mGrepDriver->generatePipelineIR();
    372 
    373     idb->setKernel(&matchCountK);
    374     Value * matchedLineCount = idb->getScalarField("matchedLineCount");
     371    idb->setKernel(matchCountK);
     372    Value * matchedLineCount = idb->getAccumulator("countResult");
    375373    matchedLineCount = idb->CreateZExt(matchedLineCount, int64Ty);
    376374   
     
    472470        idb->CreateRet(idb->getInt64(0));
    473471    } else {
    474         kernel::Kernel * matchCountK = mGrepDriver->addKernelInstance(make_unique<kernel::MatchCount>(idb));
     472        kernel::Kernel * matchCountK = mGrepDriver->addKernelInstance(make_unique<kernel::PopcountKernel>(idb));
    475473        mGrepDriver->makeKernelCall(matchCountK, {MergedResults}, {});
    476474        mGrepDriver->generatePipelineIR();
    477475        idb->setKernel(matchCountK);
    478         Value * matchedLineCount = idb->getScalarField("matchedLineCount");
     476        Value * matchedLineCount = idb->getAccumulator("countResult");
    479477        matchedLineCount = idb->CreateZExt(matchedLineCount, int64Ty);
    480478        idb->CreateRet(matchedLineCount);
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5464 r5491  
    6767
    6868
     69void PopcountKernel::generatePabloMethod() {
     70    auto pb = this->getEntryBlock();
     71    const auto toCount = pb->createExtract(getInputStreamVar("toCount"), pb->getInteger(0));
     72    pablo::Var * countResult = getOutputScalarVar("countResult");
     73    pb->createAssign(countResult, pb->createCount(toCount));
     74}
     75
     76
    6977PopcountKernel::PopcountKernel (const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    7078: PabloKernel(iBuilder, "Popcount",
     
    7482              {Binding{iBuilder->getSizeTy(), "countResult"}}) {
    7583   
    76     auto pb = this->getEntryBlock();
    77     const auto toCount = pb->createExtract(getInputStreamVar("toCount"), pb->getInteger(0));
    78     pablo::Var * countResult = getOutputScalarVar("countResult");
    79     pb->createAssign(countResult, pb->createCount(toCount));
    8084}
     85
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.h

    r5454 r5491  
    3939public:
    4040    PopcountKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
     41    bool isCachable() const override { return true; }
     42    bool hasSignature() const override { return false; }
     43protected:
     44    void generatePabloMethod() override;   
    4145};
    4246
Note: See TracChangeset for help on using the changeset viewer.