Changeset 5258


Ignore:
Timestamp:
Jan 12, 2017, 9:19:15 PM (10 months ago)
Author:
cameron
Message:

Fix for segment-pipeline-parallel

File:
1 edited

Legend:

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

    r5257 r5258  
    102102    }
    103103    segmentWait.push_back(segmentLoop); // If the last kernel does not terminate, loop back.
    104     partialSegmentWait.push_back(exitThreadBlock); // If the last kernel does terminate, we're done.
     104    partialSegmentWait.push_back(exitThreadBlock); // After the last kernel terminates, we're done.
    105105
    106106    iBuilder->SetInsertPoint(entryBlock);
     
    121121    PHINode * segNo = iBuilder->CreatePHI(size_ty, 2, "segNo");
    122122    segNo->addIncoming(myThreadId, entryBlock);
     123    Value * nextSegNo = iBuilder->CreateAdd(segNo, iBuilder->getSize(1));
    123124    unsigned last_kernel = kernels.size() - 1;
    124125    Value * alreadyDone = kernels[last_kernel]->getTerminationSignal(instancePtrs[last_kernel]);
    125126    iBuilder->CreateCondBr(alreadyDone, exitThreadBlock, segmentWait[0]);
    126127
     128   
     129   
    127130    for (unsigned i = 0; i < kernels.size(); i++) {
    128131        iBuilder->SetInsertPoint(segmentWait[i]);
     
    137140        kernels[i]->createDoSegmentCall(instancePtrs[i], segmentBlocks);
    138141        if (kernels[i]->hasNoTerminateAttribute()) {
    139             kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, iBuilder->getSize(1)));
     142            kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], nextSegNo);
    140143            iBuilder->CreateBr(segmentWait[i+1]);
    141144        }
    142145        else {
    143146            Value * terminated = kernels[i]->getTerminationSignal(instancePtrs[i]);
    144             kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, iBuilder->getSize(1)));
     147            kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], nextSegNo);
    145148            iBuilder->CreateCondBr(terminated, partialSegmentWait[i+1], segmentWait[i+1]);
    146149        }
     
    153156            iBuilder->SetInsertPoint(partialSegmentLoopBody[i]);
    154157            kernels[i]->createFinalSegmentCall(instancePtrs[i], segmentBlocks);
    155             kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, iBuilder->getSize(1)));
     158            kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], nextSegNo);
    156159            iBuilder->CreateBr(partialSegmentWait[i+1]);
    157160        }
Note: See TracChangeset for help on using the changeset viewer.