Ignore:
Timestamp:
Oct 25, 2017, 4:57:58 PM (20 months ago)
Author:
nmedfort
Message:

First stage of MultiBlockKernel? and pipeline restructuring

File:
1 edited

Legend:

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

    r5695 r5706  
    2121namespace kernel {
    2222
    23 void ScanMatchKernel::generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> &iBuilder) {
     23void ScanMatchKernel::generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> &iBuilder, Value * const numOfStrides) {
    2424
    2525    Module * const m = iBuilder->getModule();
     
    4242    const unsigned fieldCount = iBuilder->getBitBlockWidth() / sizeTy->getBitWidth();
    4343    VectorType * const scanwordVectorType =  VectorType::get(sizeTy, fieldCount);
    44     Constant * blockSize = iBuilder->getSize(iBuilder->getBitBlockWidth());
    45 
    46     Function::arg_iterator args = mCurrentMethod->arg_begin();
    47     /* self = */ args++;
    48     Value * itemsToDo = &*(args++);
    49     /* inputStreamAvail = */ args++;
    50     Value * match_result = &*(args++);
    51     Value * line_break = &*(args++);
    52     /* input_stream = */ args++;
    53 
    54     Value * blocksToDo = iBuilder->CreateUDivCeil(itemsToDo, blockSize);
     44
     45    Value * match_result = iBuilder->getInputStreamBlockPtr("matchResult", iBuilder->getInt32(0));
     46    Value * line_break = iBuilder->getInputStreamBlockPtr("lineBreak", iBuilder->getInt32(0));
     47
     48    Value * blocksToDo = iBuilder->CreateAdd(numOfStrides, iBuilder->CreateZExt(mIsFinal, numOfStrides->getType()));
     49    blocksToDo = iBuilder->CreateMul(blocksToDo, iBuilder->getSize(mStride / iBuilder->getBitBlockWidth()));
    5550   
    5651    Value * match_result_ptr = iBuilder->CreateBitCast(match_result, scanwordVectorType->getPointerTo());
     
    140135            phiRecordStart->addIncoming(matchRecordStart, loop_final_block);
    141136            Value * matchRecordEnd = iBuilder->CreateAdd(phiScanwordPos, iBuilder->CreateCountForwardZeroes(phiMatchWord));
    142             Value * const inputStream = iBuilder->getRawInputPointer("InputStream", iBuilder->getInt32(0), iBuilder->getInt32(0));
     137            Value * const inputStream = iBuilder->getRawInputPointer("InputStream", iBuilder->getInt32(0));
    143138            Function * dispatcher = m->getFunction("accumulate_match_wrapper"); assert (dispatcher);
    144139            Value * start_ptr = iBuilder->CreateGEP(inputStream, matchRecordStart);
     
    195190
    196191    iBuilder->SetInsertPoint(blocksExit);
    197     iBuilder->CreateCondBr(iBuilder->CreateICmpULT(itemsToDo, blockSize), callFinalizeScan, scanReturn);
     192    iBuilder->CreateCondBr(mIsFinal, callFinalizeScan, scanReturn);
     193
    198194    iBuilder->SetInsertPoint(callFinalizeScan);
    199195    Value * bufSize = iBuilder->getBufferedSize("InputStream");
    200196    Function * finalizer = m->getFunction("finalize_match_wrapper"); assert (finalizer);
    201     Value * const buffer_base = iBuilder->getRawInputPointer("InputStream", iBuilder->getInt32(0), iBuilder->getInt32(0));
     197    Value * const buffer_base = iBuilder->getRawInputPointer("InputStream", iBuilder->getInt32(0));
    202198    Value * buffer_end_address = iBuilder->CreateGEP(buffer_base, bufSize);
    203199    iBuilder->CreateCall(finalizer, {accumulator, buffer_end_address});
    204200    iBuilder->CreateBr(scanReturn);
     201
    205202    iBuilder->SetInsertPoint(scanReturn);
    206203   
     
    209206ScanMatchKernel::ScanMatchKernel(const std::unique_ptr<kernel::KernelBuilder> & b)
    210207: MultiBlockKernel("scanMatch",
    211     {Binding{b->getStreamSetTy(1, 1), "matchResult"}, Binding{b->getStreamSetTy(1, 1), "lineBreak"}, Binding{b->getStreamSetTy(1, 8), "InputStream", UnknownRate()}},
     208    {Binding{b->getStreamSetTy(1, 1), "matchResult", FixedRate(), Principle()}, Binding{b->getStreamSetTy(1, 1), "lineBreak"}, Binding{b->getStreamSetTy(1, 8), "InputStream", UnknownRate()}},
    212209    {},
    213210    {Binding{b->getIntAddrTy(), "accumulator_address"}},
Note: See TracChangeset for help on using the changeset viewer.