Ignore:
Timestamp:
May 7, 2017, 4:34:48 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work. PabloKernel? now abstract base type with a 'generatePabloMethod' hook to generate Pablo code.

File:
1 edited

Legend:

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

    r5435 r5436  
    2929#include <toolchain/object_cache.h>
    3030#include <toolchain/pipeline.h>
     31#include <kernels/kernel_builder.h>
    3132#include <kernels/kernel.h>
    3233#include <sys/stat.h>
     
    181182    iBuilder.reset(IDISA::GetIDISA_Builder(mMainModule));
    182183    iBuilder->setDriver(this);
     184    iBuilder->setModule(mMainModule);
    183185}
    184186
     
    199201}
    200202
    201 void ParabixDriver::addKernelCall(kernel::Kernel & kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) {
     203void ParabixDriver::addKernelCall(kernel::Kernel & kb, const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
    202204    assert ("addKernelCall or makeKernelCall was already run on this kernel." && (kb.getModule() == nullptr));
    203205    mPipeline.emplace_back(&kb);
    204     kb.setBuilder(iBuilder.get());
     206    assert (mMainModule);
     207    kb.setBuilder(iBuilder);
    205208    kb.createKernelStub(inputs, outputs);
    206209}
    207210
    208 void ParabixDriver::makeKernelCall(kernel::Kernel * kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) {
     211void ParabixDriver::makeKernelCall(kernel::Kernel * kb, const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
    209212    assert ("addKernelCall or makeKernelCall was already run on this kernel." && (kb->getModule() == nullptr));
    210     mPipeline.emplace_back(kb);
    211     kb->setBuilder(iBuilder.get());
     213    mPipeline.emplace_back(kb);   
     214    kb->setBuilder(iBuilder);
    212215    kb->createKernelStub(inputs, outputs);
    213216}
     
    227230    // note: instantiation of all kernels must occur prior to initialization
    228231    for (const auto & k : mPipeline) {
    229         k->setBuilder(iBuilder.get());
    230232        k->addKernelDeclarations();
    231233    }
    232234    for (const auto & k : mPipeline) {
    233         k->setBuilder(iBuilder.get());
    234235        k->createInstance();
    235236    }
    236237    for (const auto & k : mPipeline) {
    237         k->setBuilder(iBuilder.get());
    238238        k->initializeInstance();
    239239    }
    240240    if (codegen::pipelineParallel) {
    241         generateParallelPipeline(iBuilder.get(), mPipeline);
     241        generateParallelPipeline(iBuilder, mPipeline);
    242242    } else if (codegen::segmentPipelineParallel) {
    243         generateSegmentParallelPipeline(iBuilder.get(), mPipeline);
     243        generateSegmentParallelPipeline(iBuilder, mPipeline);
    244244    } else {
    245245        codegen::ThreadNum = 1;
    246         generatePipelineLoop(iBuilder.get(), mPipeline);
     246        generatePipelineLoop(iBuilder, mPipeline);
    247247    }
    248248    for (const auto & k : mPipeline) {
    249         k->setBuilder(iBuilder.get());
     249        k->setBuilder(iBuilder);
    250250        k->finalizeInstance();
    251251    }
     
    310310        if (uncachedObject) {
    311311            iBuilder->setModule(m);
    312             k->setBuilder(iBuilder.get());
     312            k->setBuilder(iBuilder);
    313313            k->generateKernel();
    314314            PM.run(*m);
     
    327327    } catch (...) { m->dump(); throw; }
    328328    #endif
     329}
     330
     331const std::unique_ptr<kernel::KernelBuilder> & ParabixDriver::getBuilder() {
     332    return iBuilder;
    329333}
    330334
Note: See TracChangeset for help on using the changeset viewer.