Changeset 5995


Ignore:
Timestamp:
Apr 28, 2018, 11:55:19 AM (12 months ago)
Author:
cameron
Message:

Fix a pipeline bug when two kernel inputs have the same buffer!

Location:
icGREP/icgrep-devel/icgrep/toolchain
Files:
2 edited

Legend:

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

    r5985 r5995  
    302302        module = mMainModule;
    303303        iBuilder->setKernel(nullptr);
    304         //mPassManager.run(*mMainModule);
     304        mPassManager.run(*mMainModule);
    305305        for (Kernel * const kernel : mPipeline) {
    306306            if (LLVM_UNLIKELY(kernel->getModule() == nullptr)) {
  • icGREP/icgrep-devel/icgrep/toolchain/pipeline.cpp

    r5985 r5995  
    675675    // Since it is possible that a sole consumer of some stream could terminate early, set the
    676676    // initial consumed amount to the amount produced in this iteration.
    677     std::vector<PHINode *> consumedItemCountPhi(inputs.size());
     677
     678    // First determine the priorConsumedItemCounts, making sure
     679    // that none of them are previous input buffers of this kernel!
    678680    std::vector<Value *> priorConsumedItemCount(inputs.size());
    679681
     
    681683        const StreamSetBuffer * const buffer = kernel->getStreamSetInputBuffer(i);
    682684        auto c = consumedItemCount.find(buffer);
    683         PHINode * const consumedPhi = b->CreatePHI(b->getSizeTy(), 2);
    684         Value * consumed = nullptr;
    685685        if (c == consumedItemCount.end()) {
    686686            const auto p = producedItemCount.find(buffer);
    687687            assert (p != producedItemCount.end());
    688             consumed = p->second;
     688            priorConsumedItemCount[i] = p->second;
     689        } else {
     690            priorConsumedItemCount[i] = c->second;
     691        }
     692    }
     693
     694    std::vector<PHINode *> consumedItemCountPhi(inputs.size());
     695
     696    for (unsigned i = 0; i < inputs.size(); ++i) {
     697        const StreamSetBuffer * const buffer = kernel->getStreamSetInputBuffer(i);
     698        PHINode * const consumedPhi = b->CreatePHI(b->getSizeTy(), 2);
     699        auto c = consumedItemCount.find(buffer);
     700        if (c == consumedItemCount.end()) {
     701            const auto p = producedItemCount.find(buffer);
     702            assert (p != producedItemCount.end());
    689703            consumedItemCount.emplace(buffer, consumedPhi);
    690704        } else {
    691             consumed = c->second;
    692705            c->second = consumedPhi;
    693706        }
    694         consumedPhi->addIncoming(consumed, kernelEntry);
     707        consumedPhi->addIncoming(priorConsumedItemCount[i], kernelEntry);
    695708        consumedItemCountPhi[i] = consumedPhi;
    696         priorConsumedItemCount[i] = consumed;
    697709    }
    698710
Note: See TracChangeset for help on using the changeset viewer.