Ignore:
Timestamp:
Feb 7, 2017, 8:48:33 AM (2 years ago)
Author:
cameron
Message:

When a termination signal is detected for a kernel in one thread, ensure remaining threads exit.

File:
1 edited

Legend:

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

    r5295 r5305  
    128128        }
    129129        Value * processedSegmentCount = kernels[waitForKernel]->acquireLogicalSegmentNo(instancePtrs[waitForKernel]);
    130         Value * cond = iBuilder->CreateICmpEQ(segNo, processedSegmentCount);
     130        Value * ready = iBuilder->CreateICmpEQ(segNo, processedSegmentCount);
    131131
    132132        if (kernels[k]->hasNoTerminateAttribute()) {
    133             iBuilder->CreateCondBr(cond, segmentLoopBody[k], segmentWait[k]);
     133            iBuilder->CreateCondBr(ready, segmentLoopBody[k], segmentWait[k]);
    134134        } else { // If the kernel was terminated in a previous segment then the pipeline is done.
    135135            BasicBlock * completionTest = BasicBlock::Create(iBuilder->getContext(), kernels[k]->getName() + "Completed", threadFunc, 0);
    136             iBuilder->CreateCondBr(cond, completionTest, segmentWait[k]);
     136            BasicBlock * exitBlock = BasicBlock::Create(iBuilder->getContext(), kernels[k]->getName() + "Exit", threadFunc, 0);
     137            iBuilder->CreateCondBr(ready, completionTest, segmentWait[k]);
    137138            iBuilder->SetInsertPoint(completionTest);
    138139            Value * alreadyDone = kernels[k]->getTerminationSignal(instancePtrs[k]);
    139             iBuilder->CreateCondBr(alreadyDone, exitThreadBlock, segmentLoopBody[k]);
     140            iBuilder->CreateCondBr(alreadyDone, exitBlock, segmentLoopBody[k]);
     141            iBuilder->SetInsertPoint(exitBlock);
     142            // Ensure that the next thread will also exit.
     143            kernels[k]->releaseLogicalSegmentNo(instancePtrs[k], nextSegNo);
     144            iBuilder->CreateBr(exitThreadBlock);
    140145        }
    141146        iBuilder->SetInsertPoint(segmentLoopBody[k]);
Note: See TracChangeset for help on using the changeset viewer.