Ignore:
Timestamp:
Apr 19, 2017, 10:57:56 AM (2 years ago)
Author:
cameron
Message:

Parabix driver can take ownership of kernelbuilder instances; uniquify mmap kernel name

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

Legend:

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

    r5398 r5414  
    4444
    4545MMapSourceKernel::MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
    46 : SegmentOrientedKernel(iBuilder, "Parabix:mmap_source",
     46    : SegmentOrientedKernel(iBuilder, "Parabix:mmap_source" + std::to_string(blocksPerSegment) + "@" + std::to_string(codeUnitWidth),
    4747    {},
    4848    {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}},
  • icGREP/icgrep-devel/icgrep/kernels/toolchain.cpp

    r5411 r5414  
    224224}
    225225
     226kernel::KernelBuilder * ParabixDriver::addKernelInstance(std::unique_ptr<kernel::KernelBuilder> kb) {
     227    mOwnedKernels.push_back(std::move(kb));
     228    return mOwnedKernels.back().get();
     229}
     230
    226231
    227232void ParabixDriver::addKernelCall(kernel::KernelBuilder & kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) {
    228233    assert (mModuleMap.count(&kb) == 0);
    229     mKernelList.push_back(&kb);
     234    mPipeline.push_back(&kb);
    230235    mModuleMap.emplace(&kb, kb.createKernelStub(inputs, outputs));
     236}
     237
     238void ParabixDriver::makeKernelCall(kernel::KernelBuilder * kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) {
     239    assert (mModuleMap.count(kb) == 0);
     240    mPipeline.push_back(kb);
     241    mModuleMap.emplace(kb, kb->createKernelStub(inputs, outputs));
    231242}
    232243
    233244void ParabixDriver::generatePipelineIR() {
    234245    #ifndef NDEBUG
    235     if (LLVM_UNLIKELY(mKernelList.empty())) {
     246    if (LLVM_UNLIKELY(mPipeline.empty())) {
    236247        report_fatal_error("Pipeline must contain at least one kernel");
    237248    } else {
    238         boost::container::flat_set<kernel::KernelBuilder *> K(mKernelList.begin(), mKernelList.end());
    239         if (LLVM_UNLIKELY(K.size() != mKernelList.size())) {
     249        boost::container::flat_set<kernel::KernelBuilder *> K(mPipeline.begin(), mPipeline.end());
     250        if (LLVM_UNLIKELY(K.size() != mPipeline.size())) {
    240251            report_fatal_error("Kernel definitions can only occur once in the pipeline");
    241252        }
     
    243254    #endif
    244255    // note: instantiation of all kernels must occur prior to initialization
    245     for (const auto & k : mKernelList) {
     256    for (const auto & k : mPipeline) {
    246257        k->addKernelDeclarations(mMainModule);
    247258    }
    248     for (const auto & k : mKernelList) {
     259    for (const auto & k : mPipeline) {
    249260        k->createInstance();
    250261    }
    251     for (const auto & k : mKernelList) {
     262    for (const auto & k : mPipeline) {
    252263        k->initializeInstance();
    253264    }
    254265    if (codegen::pipelineParallel) {
    255         generateParallelPipeline(iBuilder, mKernelList);
     266        generateParallelPipeline(iBuilder, mPipeline);
    256267    } else if (codegen::segmentPipelineParallel) {
    257         generateSegmentParallelPipeline(iBuilder, mKernelList);
     268        generateSegmentParallelPipeline(iBuilder, mPipeline);
    258269    } else {
    259270        codegen::ThreadNum = 1;
    260         generatePipelineLoop(iBuilder, mKernelList);
    261     }
    262     for (const auto & k : mKernelList) {
     271        generatePipelineLoop(iBuilder, mPipeline);
     272    }
     273    for (const auto & k : mPipeline) {
    263274        k->terminateInstance();
    264275    }
  • icGREP/icgrep-devel/icgrep/kernels/toolchain.h

    r5409 r5414  
    7272    parabix::StreamSetBuffer * addBuffer(std::unique_ptr<parabix::StreamSetBuffer> b);
    7373   
     74    kernel::KernelBuilder * addKernelInstance(std::unique_ptr<kernel::KernelBuilder> kb);
     75   
    7476    void addKernelCall(kernel::KernelBuilder & kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
     77    void makeKernelCall(kernel::KernelBuilder * kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
    7578   
    7679    void generatePipelineIR();
     
    9194    llvm::ExecutionEngine *                 mEngine;
    9295    ParabixObjectCache *                    mCache;
    93     std::vector<kernel::KernelBuilder *>    mKernelList;
     96    std::vector<kernel::KernelBuilder *>    mPipeline;
    9497    // Owned kernels and buffers that will persist with this ParabixDriver instance.
    9598    std::vector<std::unique_ptr<kernel::KernelBuilder>> mOwnedKernels;
Note: See TracChangeset for help on using the changeset viewer.