Ignore:
Timestamp:
Feb 22, 2017, 4:51:39 PM (2 years ago)
Author:
xuedongx
Message:

LineBreak? Kernel for GPU.

File:
1 edited

Legend:

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

    r5339 r5341  
    9696            if(codegen::NVPTX){
    9797                codegen::BlockSize = 128;
    98                 std::vector<size_t> LFPositions = preprocess(fileBuffer, fileSize);
     98                char * LineBreak;
     99                if (posix_memalign((void**)&LineBreak, 32, fileSize)) {
     100                    std::cerr << "Cannot allocate memory for linebreak.\n";
     101                    exit(-1);
     102                }
     103                std::vector<size_t> LFPositions = preprocess(fileBuffer, fileSize, LineBreak);
    99104
    100105                const unsigned numOfGroups = codegen::GroupNum;
     
    111116                else{
    112117                    size_t intputSize = startPoints[numOfGroups]-accumBytes[numOfGroups]+accumBytes[numOfGroups-1];
    113                     mGrepFunction_CPU((char *)rslt, fileBuffer, intputSize, fileIdx);
     118                    mGrepFunction_CPU((char *)rslt, LineBreak, fileBuffer, intputSize, fileIdx);
    114119                    return;
    115120                }
     
    203208    Type * const size_ty = iBuilder->getSizeTy();
    204209    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    205     Type * const rsltType = PointerType::get(ArrayType::get(iBuilder->getBitBlockType(), 2), 0);
    206     Function * const mainCPUFn = cast<Function>(m->getOrInsertFunction("CPU_Main", iBuilder->getVoidTy(), rsltType, int8PtrTy, size_ty, size_ty, nullptr));
     210    Type * const rsltType = PointerType::get(ArrayType::get(iBuilder->getBitBlockType(), 1), 0);
     211    Function * const mainCPUFn = cast<Function>(m->getOrInsertFunction("CPU_Main", iBuilder->getVoidTy(), rsltType, rsltType, int8PtrTy, size_ty, size_ty, nullptr));
    207212    mainCPUFn->setCallingConv(CallingConv::C);
    208213    iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", mainCPUFn, 0));
     
    211216    Value * const rsltStream = &*(args++);
    212217    rsltStream->setName("rslt");
     218    Value * const lbStream = &*(args++);
     219    lbStream->setName("lb");
    213220    Value * const inputStream = &*(args++);
    214221    inputStream->setName("input");
     
    220227    const unsigned segmentSize = codegen::SegmentSize;
    221228
    222     ExternalFileBuffer MatchResults(iBuilder, iBuilder->getStreamSetTy(2, 1));
     229    ExternalFileBuffer MatchResults(iBuilder, iBuilder->getStreamSetTy(1, 1));
    223230    MatchResults.setStreamSetBuffer(rsltStream, fileSize);
    224231
    225     kernel::MMapSourceKernel mmapK(iBuilder, segmentSize);
    226     mmapK.generateKernel({}, {&MatchResults});
    227     mmapK.setInitialArguments({fileSize});
    228 
    229 
     232    kernel::MMapSourceKernel mmapK1(iBuilder, segmentSize);
     233    mmapK1.generateKernel({}, {&MatchResults});
     234    mmapK1.setInitialArguments({fileSize});
     235
     236
     237    ExternalFileBuffer LineBreak(iBuilder, iBuilder->getStreamSetTy(1, 1));
     238    LineBreak.setStreamSetBuffer(lbStream, fileSize);
     239   
     240    kernel::MMapSourceKernel mmapK2(iBuilder, segmentSize);
     241    mmapK2.generateKernel({}, {&LineBreak});
     242    mmapK2.setInitialArguments({fileSize});
    230243
    231244    kernel::ScanMatchKernel scanMatchK(iBuilder, grepType);
    232     scanMatchK.generateKernel({&MatchResults}, {});
     245    scanMatchK.generateKernel({&MatchResults, &LineBreak}, {});
    233246           
    234247    scanMatchK.setInitialArguments({inputStream, fileSize, fileIdx});
    235248   
    236     generatePipelineLoop(iBuilder, {&mmapK, &scanMatchK});
     249    generatePipelineLoop(iBuilder, {&mmapK1, &mmapK2, &scanMatchK});
    237250    iBuilder->CreateRetVoid();
    238251
Note: See TracChangeset for help on using the changeset viewer.