Changeset 5273


Ignore:
Timestamp:
Jan 23, 2017, 5:20:18 PM (10 months ago)
Author:
cameron
Message:

For segment-pipeline-parallelism, threads must not overwrite buffer segments belonging to other threads

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5267 r5273  
    226226    }
    227227
     228    // segment size made availabe for each call to the mmap source kernel
    228229    const unsigned segmentSize = codegen::SegmentSize;
    229     if (segmentPipelineParallel && codegen::BufferSegments < 2) {
    230         codegen::BufferSegments = 2;
    231     }
    232     const unsigned bufferSegments = codegen::BufferSegments;
     230    unsigned bufferSegments = codegen::BufferSegments;
     231    if (segmentPipelineParallel)
     232        {
     233            bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
     234        }
    233235    const unsigned encodingBits = UTF_16 ? 16 : 8;
    234236
     
    290292    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
    291293   
    292     kernel::MMapSourceKernel mmapK(iBuilder, segmentSize * bufferSegments);
     294    kernel::MMapSourceKernel mmapK(iBuilder, segmentSize);
    293295    mmapK.generateKernel({}, {&ByteStream});
    294296    mmapK.setInitialArguments({fileSize});
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5267 r5273  
    4949        }
    5050    }
    51     /*
     51    /*  TODO:  define sinks for  all outputs so that the following check succeeds on
     52     *  well-structured pipelines.
    5253    for (unsigned k = 0; k < kernels.size(); k++) {
    5354        auto outputSets = kernels[k]->getStreamSetOutputBuffers();
     
    105106
    106107    iBuilder->SetInsertPoint(entryBlock);
     108   
    107109    Value * sharedStruct = iBuilder->CreateBitCast(input, PointerType::get(sharedStructType, 0));
    108110    Constant * myThreadId = ConstantInt::get(size_ty, id);
     
    132134       
    133135        iBuilder->SetInsertPoint(segmentLoopBody[k]);
    134        
    135         //iBuilder->CallPrintInt(kernels[k]->getName() + " segment #", segNo);
    136         if (k == last_kernel) {
    137             segNo->addIncoming(iBuilder->CreateAdd(segNo, ConstantInt::get(size_ty, threadNum)), segmentLoopBody[last_kernel]);
    138         }
    139136        std::vector<Value *> doSegmentArgs = {instancePtrs[k], doFinal};
    140137        for (unsigned j = 0; j < kernels[k]->getStreamInputs().size(); j++) {
     
    142139            std::tie(producerKernel, outputIndex) = producerTable[k][j];
    143140            doSegmentArgs.push_back(ProducerPos[producerKernel][outputIndex]);
    144             //iBuilder->CallPrintInt(kernels[k]->getName() + " producerPos[" + std::to_string(j) + "] ", doSegmentArgs.back());
    145 
    146141        }
    147142        kernels[k]->createDoSegmentCall(doSegmentArgs);
     
    156151        }
    157152        kernels[k]->releaseLogicalSegmentNo(instancePtrs[k], nextSegNo);
    158         if (k == last_kernel) break;
    159         iBuilder->CreateBr(segmentWait[k+1]);
    160     }
    161     iBuilder->CreateCondBr(doFinal, exitThreadBlock, segmentLoop);
     153        if (k == last_kernel) {
     154            segNo->addIncoming(iBuilder->CreateAdd(segNo, ConstantInt::get(size_ty, threadNum)), segmentLoopBody[last_kernel]);
     155            iBuilder->CreateCondBr(doFinal, exitThreadBlock, segmentLoop);
     156        }
     157        else {
     158            iBuilder->CreateBr(segmentWait[k+1]);
     159        }
     160    }
    162161
    163162    iBuilder->SetInsertPoint(exitThreadBlock);
     
    211210        iBuilder->CreateStore(kernels[i]->getInstance(), ptr);
    212211    }
    213    
     212    for (unsigned i = 0; i < kernels.size(); i++) {
     213        kernels[i]->releaseLogicalSegmentNo(kernels[i]->getInstance(), iBuilder->getSize(0));
     214    }
     215
    214216    std::vector<Function *> thread_functions;
    215217    const auto ip = iBuilder->saveIP();
     
    279281    BasicBlock * entryBlock = iBuilder->GetInsertBlock();
    280282    Function * main = entryBlock->getParent();
    281    
     283
    282284    // Create the basic blocks for the loop.
    283285    BasicBlock * segmentLoop = BasicBlock::Create(iBuilder->getContext(), "segmentLoop", main, 0);
Note: See TracChangeset for help on using the changeset viewer.