Ignore:
Timestamp:
Apr 7, 2017, 4:59:04 PM (2 years ago)
Author:
nmedfort
Message:

Continued work on processing stdin input. Partial integration of ParabixDriver? methods into icgrep and editd. Object cache does not currently work for recursive REs.

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

Legend:

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

    r5377 r5398  
    280280}
    281281
    282 Function * preprocessPipeline(Module * m, IDISA::IDISA_Builder * iBuilder) {
     282//
     283// Handler for errors reported through llvm::report_fatal_error.  Report
     284// and signal error code 2 (grep convention).
     285//
     286static void error_handler(void *UserData, const std::string &Message, bool GenCrashDiag) {
     287    throw std::runtime_error(Message);
     288}
     289
     290
     291void preprocessPipeline(ParabixDriver & pxDriver) {
     292
     293    llvm::install_fatal_error_handler(&error_handler);
     294
     295    IDISA::IDISA_Builder * iBuilder = pxDriver.getIDISA_Builder();
     296    Module * m = iBuilder->getModule();
    283297    Type * mBitBlockType = iBuilder->getBitBlockType();
    284298   
     
    298312    Value * const outputStream = &*(args++);
    299313    outputStream->setName("output");
    300    
     314    iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", main));
     315
    301316    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
    302317    SingleBlockBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8));
     
    304319
    305320    MMapSourceKernel mmapK(iBuilder);
    306     std::unique_ptr<Module> mmapM = mmapK.createKernelModule({}, {&ByteStream});
    307321    mmapK.setInitialArguments({fileSize});
    308    
    309     S2PKernel  s2pk(iBuilder);
    310     std::unique_ptr<Module> s2pM = s2pk.createKernelModule({&ByteStream}, {&BasisBits});
     322    pxDriver.addKernelCall(mmapK, {}, {&ByteStream});
     323   
     324    S2PKernel s2pk(iBuilder);
     325    pxDriver.addKernelCall(s2pk, {&ByteStream}, {&BasisBits});
    311326
    312327    PabloKernel ccck(iBuilder, "ccc",
     
    315330
    316331    buildPreprocessKernel(ccck, iBuilder);
    317    
    318     std::unique_ptr<Module> cccM = ccck.createKernelModule({&BasisBits}, {&CCResults});
    319    
    320     mmapK.addKernelDeclarations(m);
    321     s2pk.addKernelDeclarations(m);
    322     ccck.addKernelDeclarations(m);
    323    
    324     iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", main,0));
    325 
     332    pxDriver.addKernelCall(ccck, {&BasisBits}, {&CCResults});
     333         
    326334    ByteStream.setStreamSetBuffer(inputStream);
     335
    327336    BasisBits.allocateBuffer();
     337
    328338    CCResults.setStreamSetBuffer(outputStream);
    329339   
    330     generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &ccck});
    331        
     340    pxDriver.generatePipelineIR();
     341
    332342    iBuilder->CreateRetVoid();
    333    
    334     Linker L(*m);
    335     L.linkInModule(std::move(mmapM));
    336     L.linkInModule(std::move(s2pM));
    337     L.linkInModule(std::move(cccM));
    338    
    339     return main;
     343
     344    errs() << "JitCompileMain()\n";
     345
     346    pxDriver.JITcompileMain();
     347
     348    errs() << "linkAndFinalize()\n";
     349
     350    pxDriver.linkAndFinalize();
     351
     352    errs() << "done\n";
    340353}
    341354
     
    343356typedef void (*preprocessFunctionType)(char * byte_data, size_t filesize, char * output_data);
    344357
    345 preprocessFunctionType preprocessCodeGen() {
    346                            
     358preprocessFunctionType preprocessCodeGen() {                           
    347359    LLVMContext TheContext;
    348360    Module * M = new Module("preprocess", TheContext);
    349361    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    350 
    351     llvm::Function * main_IR = preprocessPipeline(M, idb);
    352 
    353     ExecutionEngine * preprocessEngine = JIT_to_ExecutionEngine(M);
    354    
    355     preprocessEngine->finalizeObject();
    356 
     362    ParabixDriver pxDriver(idb);
     363    preprocessPipeline(pxDriver);
     364    auto f = reinterpret_cast<preprocessFunctionType>(pxDriver.getPointerToMain());
    357365    delete idb;
    358     return reinterpret_cast<preprocessFunctionType>(preprocessEngine->getPointerToFunction(main_IR));
     366    return f;
    359367}
    360368
     
    740748    return 0;
    741749}
    742 
    743 
    744 
    745 
    746 
    747 
    748 
    749 
    750 
    751 
    752 
    753 
    754 
    755 
    756 
  • icGREP/icgrep-devel/icgrep/editd/editdscan_kernel.cpp

    r5317 r5398  
    1212
    1313namespace kernel {
    14 
    15 Value * generateCountForwardZeroes(IDISA::IDISA_Builder * iBuilder, Value * bits) {
    16     Value * cttzFunc = Intrinsic::getDeclaration(iBuilder->getModule(), Intrinsic::cttz, bits->getType());
    17     return iBuilder->CreateCall(cttzFunc, std::vector<Value *>({bits, ConstantInt::get(iBuilder->getInt1Ty(), 0)}));
    18 }
    1914
    2015void editdScanKernel::generateDoBlockMethod() {
     
    7974
    8075    iBuilder->SetInsertPoint(matchesLoopBlock);
    81     Value * match_pos = iBuilder->CreateAdd(generateCountForwardZeroes(iBuilder, matches_phi), basePos);
     76    Value * match_pos = iBuilder->CreateAdd(iBuilder->CreateCountForwardZeroes(matches_phi), basePos);
    8277    Value * matches_new = iBuilder->CreateAnd(matches_phi, iBuilder->CreateSub(matches_phi, ConstantInt::get(T, 1)));
    8378    matches_phi->addIncoming(matches_new, matchesLoopBlock);
Note: See TracChangeset for help on using the changeset viewer.