Ignore:
Timestamp:
Apr 8, 2017, 12:56:07 PM (2 years ago)
Author:
nmedfort
Message:

Bug fixes for object cache. Minor optimization of FunctionTypeBuilder?.

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

Legend:

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

    r5398 r5399  
    120120}
    121121
    122 std::unique_ptr<Module> KernelBuilder::createKernelStub() {
     122std::unique_ptr<Module> KernelBuilder::createKernelStub(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs) {
     123    setCallParameters(inputs, outputs);
    123124    std::string cacheName = getName() + "_" + iBuilder->getBuilderUniqueName();
    124125    for (auto & b: mStreamSetInputBuffers) {
     
    128129        cacheName += ":" + b->getUniqueID();
    129130    }
     131    prepareKernel();
    130132    return make_unique<Module>(cacheName, iBuilder->getContext());
    131133}
    132134
    133 void KernelBuilder::setCallParameters(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
     135void KernelBuilder::setCallParameters(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs) {
     136    assert (mStreamSetInputBuffers.empty());
    134137    mStreamSetInputBuffers.assign(inputs.begin(), inputs.end());
    135138    for (unsigned i = 0; i < mStreamSetInputBuffers.size(); ++i) {
     
    144147                           + std::to_string(mStreamSetInputBuffers.size()));
    145148    }
    146    
     149    assert (mStreamSetOutputBuffers.empty());
    147150    mStreamSetOutputBuffers.assign(outputs.begin(), outputs.end());
    148151    for (unsigned i = 0; i < mStreamSetOutputBuffers.size(); ++i) {
     
    156159                           + " output stream sets but generateKernel() was given "
    157160                           + std::to_string(mStreamSetOutputBuffers.size()));
    158     }
    159     prepareKernel(); // possibly overridden by the KernelBuilder subtype
    160    
     161    }       
    161162}   
    162163
     
    170171
    171172
    172 std::unique_ptr<Module> KernelBuilder::createKernelModule(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
     173std::unique_ptr<Module> KernelBuilder::createKernelModule(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs) {
    173174    auto saveModule = iBuilder->getModule();
    174175    auto savePoint = iBuilder->saveIP();
    175     auto module = createKernelStub();
     176    auto module = createKernelStub(inputs, outputs);
    176177    iBuilder->setModule(module.get());
    177178    generateKernel(inputs, outputs);
     
    181182}
    182183
    183 void KernelBuilder::generateKernel(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
     184void KernelBuilder::generateKernel(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs) {
    184185    setCallParameters(inputs, outputs);
     186    prepareKernel(); // possibly overridden by the KernelBuilder subtype
    185187    generateKernel();
    186188}
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5398 r5399  
    3030    using StreamPort = std::pair<Port, unsigned>;
    3131    using StreamMap = boost::container::flat_map<std::string, StreamPort>;
     32    using StreamSetBuffers = std::vector<parabix::StreamSetBuffer *>;
    3233public:
    3334   
     
    6566    // Create a module stub for the kernel, populated only with its Module ID.     
    6667    //
    67     std::unique_ptr<llvm::Module> createKernelStub();
     68    std::unique_ptr<llvm::Module> createKernelStub(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs);
    6869   
    6970    // Create a module for the kernel, including the kernel state type declaration and
    7071    // the full implementation of all required methods.     
    7172    //
    72     std::unique_ptr<llvm::Module> createKernelModule(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
    73    
    74     void setCallParameters(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
     73    std::unique_ptr<llvm::Module> createKernelModule(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs);
     74   
     75    void setCallParameters(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs);
    7576
    7677    // Generate the Kernel to the current module (iBuilder->getModule()).
    7778    void generateKernel();
    78     void generateKernel(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
     79    void generateKernel(const StreamSetBuffers & inputs, const StreamSetBuffers & outputs);
    7980   
    8081    void createInstance() override;
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.cpp

    r5385 r5399  
    2828, std::string linebreak
    2929, unsigned basisBitsCount)
    30 : PabloKernel(iBuilder, linebreak +"_kernel", {Binding{iBuilder->getStreamSetTy(basisBitsCount), "basis"}}, {Binding{iBuilder->getStreamSetTy(1), "linebreak", Add1()}}) {
     30: PabloKernel(iBuilder, "Parabix:" + linebreak + "_kernel", {Binding{iBuilder->getStreamSetTy(basisBitsCount), "basis"}}, {Binding{iBuilder->getStreamSetTy(1), "linebreak", Add1()}}) {
    3131
    3232    CC_Compiler ccc(this, getInput(0));
  • icGREP/icgrep-devel/icgrep/kernels/stdin_kernel.cpp

    r5398 r5399  
    6868
    6969StdInKernel::StdInKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
    70 : SegmentOrientedKernel(iBuilder, "stdin_source", {}, {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "InputStream"}}, {}, {}, {})
     70: SegmentOrientedKernel(iBuilder, "Parabix:stdin_source", {}, {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "InputStream"}}, {}, {}, {})
    7171, mSegmentBlocks(blocksPerSegment)
    7272, mCodeUnitWidth(codeUnitWidth) {
Note: See TracChangeset for help on using the changeset viewer.