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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.