Changeset 5833 for icGREP


Ignore:
Timestamp:
Jan 15, 2018, 3:45:40 PM (15 months ago)
Author:
nmedfort
Message:

Missing change

File:
1 edited

Legend:

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

    r5793 r5833  
    3535
    3636void handleInsufficientData(const std::unique_ptr<KernelBuilder> & b, Value * const produced, Value * const final, BasicBlock * const entry, const Kernel * const consumer,  const Binding & input, const StreamSetBuffer * const buffer);
     37
     38bool requiresCopyBack(const Kernel * k, const ProcessingRate & rate);
    3739
    3840/** ------------------------------------------------------------------------------------------------------------- *
     
    209211
    210212    segNo->addIncoming(b->CreateAdd(segNo, b->getSize(codegen::ThreadNum)), b->GetInsertBlock());
    211     if (LLVM_UNLIKELY(terminated == nullptr)) {
    212         report_fatal_error("error: at least one kernel must have a termination signal");
    213     }
     213
    214214    b->CreateUnlikelyCondBr(terminated, exitThreadBlock, segmentLoop);
    215215
     
    309309
    310310    // Create the basic blocks for the loop.
    311     BasicBlock * pipelineLoop = BasicBlock::Create(b->getContext(), "pipelineLoop", main);
    312     BasicBlock * pipelineExit = BasicBlock::Create(b->getContext(), "pipelineExit", main);
     311    BasicBlock * const pipelineLoop = BasicBlock::Create(b->getContext(), "pipelineLoop", main);
     312    BasicBlock * const pipelineExit = BasicBlock::Create(b->getContext(), "pipelineExit", main);
    313313
    314314    StreamSetBufferMap<Value *> producedItemCount;
     
    328328
    329329        b->setKernel(kernel);
     330
     331        BasicBlock * const entry = b->GetInsertBlock();
     332        BasicBlock * const kernelCode = BasicBlock::Create(b->getContext(), kernel->getName(), main);
     333        BasicBlock * const kernelExit = BasicBlock::Create(b->getContext(), kernel->getName() + "_exit", main);
     334
     335        b->CreateUnlikelyCondBr(b->getTerminationSignal(), kernelExit, kernelCode);
     336
     337        b->SetInsertPoint(kernelCode);
    330338        const auto & inputs = kernel->getStreamInputs();
    331339        const auto & outputs = kernel->getStreamOutputs();
     
    350358        b->createDoSegmentCall(args);
    351359
     360        BasicBlock * const kernelFinished = b->GetInsertBlock();
    352361        Value * const finished = b->getTerminationSignal();
    353         if (terminated) {
    354             // All kernels must agree that we've terminated.
    355             terminated = b->CreateAnd(terminated, finished);
     362        b->CreateBr(kernelExit);
     363
     364        b->SetInsertPoint(kernelExit);
     365        PHINode * const finishedPhi = b->CreatePHI(b->getInt1Ty(), 2);
     366        finishedPhi->addIncoming(b->getTrue(), entry);
     367        finishedPhi->addIncoming(finished, kernelFinished);
     368        if (terminated) { // All kernels must agree that we've terminated.
     369            terminated = b->CreateAnd(terminated, finishedPhi);
    356370        } else {
    357             terminated = finished;
     371            terminated = finishedPhi;
    358372        }
    359373
     
    398412    }
    399413
    400     if (LLVM_UNLIKELY(terminated == nullptr)) {
    401         report_fatal_error("error: at least one kernel must have a termination signal");
    402     }
    403414    b->CreateCondBr(terminated, pipelineExit, pipelineLoop);
    404415
     
    501512}
    502513
     514/** ------------------------------------------------------------------------------------------------------------- *
     515 * @brief requiresCopyBack
     516 ** ------------------------------------------------------------------------------------------------------------- */
     517bool requiresCopyBack(const Kernel * k, const ProcessingRate & rate) {
     518    if (rate.isBounded() || rate.isUnknown()) {
     519        return true;
     520    } else if (rate.isRelative()) {
     521        return requiresCopyBack(k, k->getBinding(rate.getReference()).getRate());
     522    }
     523    return false;
     524}
Note: See TracChangeset for help on using the changeset viewer.