Ignore:
Timestamp:
Oct 1, 2016, 12:03:14 PM (3 years ago)
Author:
cameron
Message:

Kernel/pipeline progress: sychronize with logicalSegmentNo

File:
1 edited

Legend:

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

    r5165 r5174  
    5353
    5454    iBuilder->SetInsertPoint(entryBlock);
    55 
    5655    Value * sharedStruct = iBuilder->CreateBitCast(input, PointerType::get(sharedStructType, 0));
    5756    Value * myThreadId = ConstantInt::get(size_ty, id);
     
    6665    int segmentSize = codegen::SegmentSize;
    6766    Constant * segmentBlocks = ConstantInt::get(size_ty, segmentSize);
    68     Constant * hypersegmentBlocks = ConstantInt::get(size_ty, segmentSize * threadNum);
    6967    Constant * segmentBytes = ConstantInt::get(size_ty, iBuilder->getStride() * segmentSize);
    7068    Constant * hypersegmentBytes = ConstantInt::get(size_ty, iBuilder->getStride() * segmentSize * threadNum);
    7169    Constant * const blockSize = ConstantInt::get(size_ty, iBuilder->getStride());
    7270
     71    Value * myFirstSegNo = myThreadId;  //
    7372    // The offset of my starting segment within the thread group hypersegment.
    74     Value * myBlockNo = iBuilder->CreateMul(segmentBlocks, myThreadId);
    7573    Value * myOffset = iBuilder->CreateMul(segmentBytes, myThreadId);
    7674    Value * fullSegLimit = iBuilder->CreateAdd(myOffset, segmentBytes);
     
    8179    PHINode * remainingBytes = iBuilder->CreatePHI(size_ty, 2, "remainingBytes");
    8280    remainingBytes->addIncoming(fileSize, entryBlock);
    83     PHINode * blockNo = iBuilder->CreatePHI(size_ty, 2, "blockNo");
    84     blockNo->addIncoming(myBlockNo, entryBlock);
     81    PHINode * segNo = iBuilder->CreatePHI(size_ty, 2, "segNo");
     82    segNo->addIncoming(myFirstSegNo, entryBlock);
    8583
    8684    Value * LT_fullSegment = iBuilder->CreateICmpSLT(remainingBytes, fullSegLimit);
     
    8987    for (unsigned i = 0; i < kernels.size(); i++) {
    9088        iBuilder->SetInsertPoint(segmentWait[i]);
    91         Value * curBlockNo = kernels[i]->getBlockNo(instancePtrs[i]);
    92         Value * cond = iBuilder->CreateICmpEQ(curBlockNo, blockNo);
     89        Value * processedSegmentCount = kernels[i]->getLogicalSegmentNo(instancePtrs[i]);
     90        Value * cond = iBuilder->CreateICmpEQ(segNo, processedSegmentCount);
    9391        iBuilder->CreateCondBr(cond, segmentLoopBody[i], segmentWait[i]);
    9492
     
    10098   
    10199    remainingBytes->addIncoming(iBuilder->CreateSub(remainingBytes, hypersegmentBytes), segmentLoopBody[kernels.size()-1]);
    102     blockNo->addIncoming(iBuilder->CreateAdd(blockNo, hypersegmentBlocks), segmentLoopBody[kernels.size()-1]);
     100    segNo->addIncoming(iBuilder->CreateAdd(segNo, ConstantInt::get(size_ty, threadNum)), segmentLoopBody[kernels.size()-1]);
    103101    iBuilder->CreateBr(segmentLoop);
    104102
     
    114112    for (unsigned i = 0; i < kernels.size(); i++) {
    115113        iBuilder->SetInsertPoint(partialSegmentWait[i]);
    116         Value * curBlockNo = kernels[i]->getBlockNo(instancePtrs[i]);
    117         Value * cond = iBuilder->CreateICmpEQ(curBlockNo, blockNo);
     114        Value * processedSegmentCount = kernels[i]->getLogicalSegmentNo(instancePtrs[i]);
     115        Value * cond = iBuilder->CreateICmpEQ(segNo, processedSegmentCount);
    118116        iBuilder->CreateCondBr(cond, partialSegmentLoopBody[i], partialSegmentWait[i]);
    119117
     
    255253    BasicBlock * fullBodyBlock = BasicBlock::Create(iBuilder->getContext(), "fullBody", main, 0);
    256254    BasicBlock * finalBlock = BasicBlock::Create(iBuilder->getContext(), "final", main, 0);
     255    BasicBlock * exitBlock = BasicBlock::Create(iBuilder->getContext(), "exit", main, 0);
    257256   
    258257   
     
    316315        kernels[i]->createFinalBlockCall(instances[i], remainingBytes);
    317316    }
     317    iBuilder->CreateBr(exitBlock);
     318    iBuilder->SetInsertPoint(exitBlock);
     319
    318320}
Note: See TracChangeset for help on using the changeset viewer.