Ignore:
Timestamp:
Apr 4, 2017, 12:09:16 PM (3 years ago)
Author:
cameron
Message:

ParabixDriver/ObjectCache? separate compilation and linking: initial check-in with wc

File:
1 edited

Legend:

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

    r5390 r5391  
    120120}
    121121
     122std::unique_ptr<Module> KernelBuilder::createKernelStub() {
     123    return make_unique<Module>(getName() + "_" + iBuilder->getBuilderUniqueName(), iBuilder->getContext());
     124}
     125
     126void KernelBuilder::setCallParameters(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
     127    mStreamSetInputBuffers.assign(inputs.begin(), inputs.end());
     128    for (unsigned i = 0; i < mStreamSetInputBuffers.size(); ++i) {
     129        if (LLVM_UNLIKELY(mStreamSetInputBuffers[i] == nullptr)) {
     130            report_fatal_error(getName() + ": input stream set " + std::to_string(i)
     131                               + " cannot be null when calling generateKernel()");
     132        }
     133    }
     134    if (LLVM_UNLIKELY(mStreamSetInputs.size() != mStreamSetInputBuffers.size())) {
     135        report_fatal_error(getName() + ": expected " + std::to_string(mStreamSetInputs.size()) +
     136                           " input stream sets but generateKernel() was given "
     137                           + std::to_string(mStreamSetInputBuffers.size()));
     138    }
     139   
     140    mStreamSetOutputBuffers.assign(outputs.begin(), outputs.end());
     141    for (unsigned i = 0; i < mStreamSetOutputBuffers.size(); ++i) {
     142        if (LLVM_UNLIKELY(mStreamSetOutputBuffers[i] == nullptr)) {
     143            report_fatal_error(getName() + ": output stream set " + std::to_string(i)
     144                               + " cannot be null when calling generateKernel()");
     145        }
     146    }
     147    if (LLVM_UNLIKELY(mStreamSetOutputs.size() != mStreamSetOutputBuffers.size())) {
     148        report_fatal_error(getName() + ": expected " + std::to_string(mStreamSetOutputs.size())
     149                           + " output stream sets but generateKernel() was given "
     150                           + std::to_string(mStreamSetOutputBuffers.size()));
     151    }
     152    prepareKernel(); // possibly overridden by the KernelBuilder subtype
     153   
     154}   
     155
    122156std::unique_ptr<Module> KernelBuilder::createKernelModule(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
    123157    auto saveModule = iBuilder->getModule();
    124158    auto savePoint = iBuilder->saveIP();
    125     auto module = make_unique<Module>(getName() + "_" + iBuilder->getBitBlockTypeName(), iBuilder->getContext());
     159    auto module = createKernelStub();
    126160    iBuilder->setModule(module.get());
    127161    generateKernel(inputs, outputs);
     
    132166
    133167void KernelBuilder::generateKernel(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
    134 
    135     mStreamSetInputBuffers.assign(inputs.begin(), inputs.end());
    136     for (unsigned i = 0; i < mStreamSetInputBuffers.size(); ++i) {
    137         if (LLVM_UNLIKELY(mStreamSetInputBuffers[i] == nullptr)) {
    138             report_fatal_error(getName() + ": input stream set " + std::to_string(i)
    139                                + " cannot be null when calling generateKernel()");
    140         }
    141     }
    142     if (LLVM_UNLIKELY(mStreamSetInputs.size() != mStreamSetInputBuffers.size())) {
    143         report_fatal_error(getName() + ": expected " + std::to_string(mStreamSetInputs.size()) +
    144                            " input stream sets but generateKernel() was given "
    145                            + std::to_string(mStreamSetInputBuffers.size()));
    146     }
    147 
    148     mStreamSetOutputBuffers.assign(outputs.begin(), outputs.end());
    149     for (unsigned i = 0; i < mStreamSetOutputBuffers.size(); ++i) {
    150         if (LLVM_UNLIKELY(mStreamSetOutputBuffers[i] == nullptr)) {
    151             report_fatal_error(getName() + ": output stream set " + std::to_string(i)
    152                                + " cannot be null when calling generateKernel()");
    153         }
    154     }
    155     if (LLVM_UNLIKELY(mStreamSetOutputs.size() != mStreamSetOutputBuffers.size())) {
    156         report_fatal_error(getName() + ": expected " + std::to_string(mStreamSetOutputs.size())
    157                            + " output stream sets but generateKernel() was given "
    158                            + std::to_string(mStreamSetOutputBuffers.size()));
    159     }
    160 
    161 
     168    setCallParameters(inputs, outputs);
     169    generateKernel();
     170}
     171
     172void KernelBuilder::generateKernel() {
    162173    auto savePoint = iBuilder->saveIP();
    163     prepareKernel(); // possibly overridden by the KernelBuilder subtype
    164174    addKernelDeclarations(iBuilder->getModule());
    165175    callGenerateInitMethod();
Note: See TracChangeset for help on using the changeset viewer.