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

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

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5390 r5391  
    145145
    146146    KernelInterface(IDISA::IDISA_Builder * builder,
    147                     std::string && kernelName,
     147                    std::string kernelName,
    148148                    std::vector<Binding> && stream_inputs,
    149149                    std::vector<Binding> && stream_outputs,
  • 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();
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5390 r5391  
    2828public:
    2929   
     30    // Create a module stub for the kernel, populated only with its Module ID.     
     31    //
     32    std::unique_ptr<llvm::Module> createKernelStub();
     33   
    3034    // Create a module for the kernel, including the kernel state type declaration and
    3135    // the full implementation of all required methods.     
     
    3337    std::unique_ptr<llvm::Module> createKernelModule(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
    3438   
     39    void setCallParameters(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
     40
    3541    // Generate the Kernel to the current module (iBuilder->getModule()).
     42    void generateKernel();
    3643    void generateKernel(const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs);
    3744   
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.cpp

    r5377 r5391  
    5050
    5151MMapSourceKernel::MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
    52 : SegmentOrientedKernel(iBuilder, "mmap_source",
     52: SegmentOrientedKernel(iBuilder, "Parabix:mmap_source",
    5353    {},
    5454    {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}},
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5377 r5391  
    162162
    163163S2PKernel::S2PKernel(IDISA::IDISA_Builder * builder)
    164 : BlockOrientedKernel(builder, "s2p", {Binding{builder->getStreamSetTy(1, 8), "byteStream"}}, {Binding{builder->getStreamSetTy(8, 1), "basisBits"}}, {}, {}, {}) {
     164: BlockOrientedKernel(builder, "Parabix:s2p",
     165    {Binding{builder->getStreamSetTy(1, 8), "byteStream"}}, {Binding{builder->getStreamSetTy(8, 1), "basisBits"}}, {}, {}, {}) {
    165166    setNoTerminateAttribute(true);
    166167}
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5389 r5391  
    222222
    223223ScanMatchKernel::ScanMatchKernel(IDISA::IDISA_Builder * iBuilder, GrepType grepType, const unsigned codeUnitWidth)
    224 : BlockOrientedKernel(iBuilder, "scanMatch" + std::to_string(codeUnitWidth),
     224: BlockOrientedKernel(iBuilder, "Parabix:scanMatch" + std::to_string(codeUnitWidth),
    225225    {Binding{iBuilder->getStreamSetTy(1, 8), "InputStream"}, Binding{iBuilder->getStreamSetTy(1, 1), "matchResult"}, Binding{iBuilder->getStreamSetTy(1, 1), "lineBreak"}},
    226226    {},
Note: See TracChangeset for help on using the changeset viewer.