Ignore:
Timestamp:
Jan 28, 2017, 3:12:03 PM (2 years ago)
Author:
nmedfort
Message:

Start of work to simplify kernel writing. Removed generateDoBlockLogic method.

File:
1 edited

Legend:

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

    r5267 r5285  
    3737    return iBuilder->CreateAnd(bits_minus1, bits);
    3838}
    39 
    4039       
    41 void ScanMatchKernel::generateDoBlockMethod() const {
     40void ScanMatchKernel::generateDoBlockMethod(Function * function, Value * self, Value * blockNo) const {
     41
    4242    auto savePoint = iBuilder->saveIP();
    43     Module * m = iBuilder->getModule();
    44     Function * scanWordFunction = generateScanWordRoutine(m);
     43    Function * scanWordFunction = generateScanWordRoutine(iBuilder->getModule());
     44    iBuilder->restoreIP(savePoint);
     45
    4546    IntegerType * T = iBuilder->getSizeTy();
    4647    const unsigned fieldCount = iBuilder->getBitBlockWidth() / T->getBitWidth();
    47 
    4848    Type * scanwordVectorType =  VectorType::get(T, fieldCount);
    49 
    50     Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
    51 
    52     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    53     Value * kernelStuctParam = getParameter(doBlockFunction, "self");
    54     Value * blockNo = getScalarField(kernelStuctParam, blockNoScalar);
    55     Value * scanwordPos = iBuilder->CreateMul(blockNo, ConstantInt::get(blockNo->getType(), iBuilder->getBitBlockWidth()));
    56    
    57     Value * recordStart = getScalarField(kernelStuctParam, "LineStart");
    58     Value * recordNum = getScalarField(kernelStuctParam, "LineNum");
    59     Value * matches = iBuilder->CreateBlockAlignedLoad(getStream(kernelStuctParam, "matchResults", blockNo, iBuilder->getInt32(0)));
    60     Value * linebreaks = iBuilder->CreateBlockAlignedLoad(getStream(kernelStuctParam, "matchResults", blockNo, iBuilder->getInt32(1)));
     49    Value * scanwordPos = iBuilder->CreateMul(blockNo, ConstantInt::get(blockNo->getType(), iBuilder->getBitBlockWidth()));   
     50    Value * recordStart = getScalarField(self, "LineStart");
     51    Value * recordNum = getScalarField(self, "LineNum");
     52    Value * matches = iBuilder->CreateBlockAlignedLoad(getStream(self, "matchResults", blockNo, iBuilder->getInt32(0)));
     53    Value * linebreaks = iBuilder->CreateBlockAlignedLoad(getStream(self, "matchResults", blockNo, iBuilder->getInt32(1)));
    6154    Value * matchWordVector = iBuilder->CreateBitCast(matches, scanwordVectorType);
    6255    Value * breakWordVector = iBuilder->CreateBitCast(linebreaks, scanwordVectorType);
     
    6457        Value * matchWord = iBuilder->CreateExtractElement(matchWordVector, ConstantInt::get(T, i));
    6558        Value * recordBreaksWord = iBuilder->CreateExtractElement(breakWordVector, ConstantInt::get(T, i));
    66         Value * wordResult = iBuilder->CreateCall(scanWordFunction, {kernelStuctParam, matchWord, recordBreaksWord, scanwordPos, recordStart, recordNum});
     59        Value * wordResult = iBuilder->CreateCall(scanWordFunction, {self, matchWord, recordBreaksWord, scanwordPos, recordStart, recordNum});
    6760        scanwordPos = iBuilder->CreateAdd(scanwordPos, ConstantInt::get(T, T->getBitWidth()));
    6861        recordStart = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({0}));
    6962        recordNum = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({1}));
    7063    }
    71     setScalarField(kernelStuctParam, "LineStart", recordStart);
    72     setScalarField(kernelStuctParam, "LineNum", recordNum);
    73     iBuilder -> CreateRetVoid();
    74     iBuilder->restoreIP(savePoint);
     64    setScalarField(self, "LineStart", recordStart);
     65    setScalarField(self, "LineNum", recordNum);
    7566}
    7667
     
    253244}
    254245
    255 }
     246ScanMatchKernel::ScanMatchKernel(IDISA::IDISA_Builder * iBuilder, GrepType grepType)
     247: BlockOrientedKernel(iBuilder, "scanMatch",
     248    {Binding{iBuilder->getStreamSetTy(2, 1), "matchResults"}},
     249    {},
     250    {Binding{iBuilder->getInt8PtrTy(), "FileBuf"}, Binding{iBuilder->getSizeTy(), "FileSize"}, Binding{iBuilder->getSizeTy(), "FileIdx"}},
     251    {},
     252    {Binding{iBuilder->getSizeTy(), "BlockNo"}, Binding{iBuilder->getSizeTy(), "LineStart"}, Binding{iBuilder->getSizeTy(), "LineNum"}})
     253, mGrepType(grepType) {
     254
     255}
     256
     257}
Note: See TracChangeset for help on using the changeset viewer.