Changeset 5136


Ignore:
Timestamp:
Aug 29, 2016, 2:04:44 PM (3 years ago)
Author:
lindanl
Message:

Remove unused code.

File:
1 edited

Legend:

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

    r5135 r5136  
    120120
    121121using namespace parabix;
    122 /*
    123 void GrepEngine::grepCodeGen(std::string moduleName, re::RE * re_ast, bool CountOnly, bool UTF_16, bool isNameExpression) {
    124     isUTF_16 = UTF_16;
    125     Module * M = new Module(moduleName, getGlobalContext());
    126    
    127     IDISA::IDISA_Builder * iBuilder = IDISA::GetIDISA_Builder(M);
    128 
    129     const unsigned segmentSize = codegen::SegmentSize;
    130 
    131     Encoding::Type type;
    132     type = UTF_16 ? Encoding::Type::UTF_16 : Encoding::Type::UTF_8;
    133     unsigned bits;
    134     bits = UTF_16 ? 16 : 8;
    135 
    136     Encoding encoding(type, bits);
    137     mIsNameExpression = isNameExpression;
    138 
    139     Type * const size_ty = iBuilder->getSizeTy();
    140     Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    141     Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(iBuilder->getBitBlockType(), (UTF_16 ? 16 : 8)), 1), 0);
    142     Type * const resultTy = CountOnly ? size_ty : iBuilder->getVoidTy();
    143     Function * const mainFn = cast<Function>(M->getOrInsertFunction("Main", resultTy, inputType, size_ty, size_ty, nullptr));
    144     mainFn->setCallingConv(CallingConv::C);
    145     iBuilder->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFn, 0));
    146     Function::arg_iterator args = mainFn->arg_begin();
    147    
    148     Value * const inputStream = &*(args++);
    149     inputStream->setName("input");
    150     Value * const fileSize = &*(args++);
    151     fileSize->setName("fileSize");
    152     Value * const fileIdx = &*(args++);
    153     fileIdx->setName("fileIdx");
    154 
    155        
    156     ExternalUnboundedBuffer ByteStream(iBuilder, StreamSetType(1, i8));
    157     CircularBuffer BasisBits(iBuilder, StreamSetType(8, i1), segmentSize);
    158 
    159     kernel::s2pKernel  s2pk(iBuilder);
    160     s2pk.generateKernel({&ByteStream}, {&BasisBits});
    161 
    162     re_ast = re::regular_expression_passes(encoding, re_ast);   
    163     pablo::PabloFunction * function = re::re2pablo_compiler(encoding, re_ast, CountOnly);
    164     pablo_function_passes(function);
    165    
    166     if (CountOnly) {
    167         pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, {"matchedLineCount"});
    168         icgrepK.generateKernel({&BasisBits}, {});
    169 
    170         ByteStream.setStreamSetBuffer(inputStream);
    171         BasisBits.allocateBuffer();
    172        
    173         Value * s2pInstance = s2pk.createInstance({});
    174         Value * icgrepInstance = icgrepK.createInstance({});
    175        
    176         generatePipelineLoop(iBuilder, {&s2pk, &icgrepK}, {s2pInstance, icgrepInstance}, fileSize);
    177         Value * matchCount = icgrepK.createGetAccumulatorCall(icgrepInstance, "matchedLineCount");
    178         iBuilder->CreateRet(matchCount);
    179     }
    180     else {
    181         CircularBuffer MatchResults(iBuilder, StreamSetType(2, i1), segmentSize);
    182         pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, {});
    183         icgrepK.generateKernel({&BasisBits},  {&MatchResults});
    184 
    185         ByteStream.setStreamSetBuffer(inputStream);
    186         BasisBits.allocateBuffer();
    187         MatchResults.allocateBuffer();
    188        
    189         Value * s2pInstance = s2pk.createInstance({});
    190         Value * icgrepInstance = icgrepK.createInstance({});
    191         kernel::scanMatchKernel scanMatchK(iBuilder, mIsNameExpression);
    192         scanMatchK.generateKernel({&MatchResults}, {});
    193                
    194         Value * scanMatchInstance = scanMatchK.createInstance({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx});
    195        
    196         generatePipelineLoop(iBuilder, {&s2pk, &icgrepK, &scanMatchK}, {s2pInstance, icgrepInstance, scanMatchInstance}, fileSize);
    197         iBuilder->CreateRetVoid();
    198     }
    199    
    200     mEngine = JIT_to_ExecutionEngine(M);
    201     ApplyObjectCache(mEngine);
    202     icgrep_Linking(M, mEngine);
    203 
    204 #ifndef NDEBUG
    205     verifyModule(*M, &dbgs());
    206 #endif
    207 
    208     mEngine->finalizeObject();
    209     delete iBuilder;
    210    
    211     if (CountOnly) {
    212         mGrepFunction_CountOnly = reinterpret_cast<GrepFunctionType_CountOnly>(mEngine->getPointerToFunction(mainFn));
    213     } else {
    214         mGrepFunction = reinterpret_cast<GrepFunctionType>(mEngine->getPointerToFunction(mainFn));
    215     }
    216 
    217 }
    218 */
     122
    219123void GrepEngine::grepCodeGen(std::string moduleName, re::RE * re_ast, bool CountOnly, bool UTF_16, bool isNameExpression) {
    220124    isUTF_16 = UTF_16;
     
    293197    pthreadExitFunc->addFnAttr(llvm::Attribute::NoReturn);
    294198    pthreadExitFunc->setCallingConv(llvm::CallingConv::C);
    295    
    296     // Type * const pthreadsTy = ArrayType::get(pthreadTy, 3);
    297     // AllocaInst * const pthreads = iBuilder->CreateAlloca(pthreadsTy);
    298     // Value * pthreadsPtr1 = iBuilder->CreateGEP(pthreads, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    299     // Value * pthreadsPtr2 = iBuilder->CreateGEP(pthreads, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    300     // Value * pthreadsPtr3 = iBuilder->CreateGEP(pthreads, {iBuilder->getInt32(0), iBuilder->getInt32(2)});
    301     // Value * nullVal = Constant::getNullValue(voidPtrTy);
    302     // AllocaInst * const status = iBuilder->CreateAlloca(int8PtrTy);
    303199
    304200    if (CountOnly) {
     
    308204
    309205        if (pipelineParallel){
    310             // const auto ip = iBuilder->saveIP();
    311             // Function * s2p_func = s2pk.generateThreadFunction("s2p");
    312             // Function * icgrep_func = icgrepK.generateThreadFunction("icgrep");
    313             // iBuilder->restoreIP(ip);
    314 
    315             // iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtr1, nullVal, s2p_func, iBuilder->CreateBitCast(s2pInstance, int8PtrTy)}));
    316             // iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtr2, nullVal, icgrep_func, iBuilder->CreateBitCast(icgrepInstance, int8PtrTy)}));
    317          
    318             // Value * threadID1 = iBuilder->CreateLoad(pthreadsPtr1);
    319             // Value * threadID2 = iBuilder->CreateLoad(pthreadsPtr2);
    320 
    321             // iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadID1, status}));
    322             // iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadID2, status}));
    323206            generatePipelineParallel(iBuilder, {&s2pk, &icgrepK}, {s2pInstance, icgrepInstance});
    324 
    325207        }
    326208        else{
    327209            generatePipelineLoop(iBuilder, {&s2pk, &icgrepK}, {s2pInstance, icgrepInstance}, fileSize);
    328 
    329210        }
    330211       
     
    347228        if (pipelineParallel){
    348229            generatePipelineParallel(iBuilder, {&s2pk, &icgrepK, &scanMatchK}, {s2pInstance, icgrepInstance, scanMatchInstance});
    349 
    350230        }
    351231        else{
    352232            generatePipelineLoop(iBuilder, {&s2pk, &icgrepK, &scanMatchK}, {s2pInstance, icgrepInstance, scanMatchInstance}, fileSize);
    353233        }
    354         // const auto ip = iBuilder->saveIP();
    355         // Function * s2p_func = s2pk.generateThreadFunction("s2p");
    356         // Function * icgrep_func = icgrepK.generateThreadFunction("icgrep");   
    357         // Function * scan_func = scanMatchK.generateThreadFunction("scanMatch");
    358         // iBuilder->restoreIP(ip);
    359        
    360         // iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtr1, nullVal, s2p_func, iBuilder->CreateBitCast(s2pInstance, int8PtrTy)}));
    361         // iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtr2, nullVal, icgrep_func, iBuilder->CreateBitCast(icgrepInstance, int8PtrTy)}));
    362         // iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtr3, nullVal, scan_func, iBuilder->CreateBitCast(scanMatchInstance, int8PtrTy)}));
    363 
    364         // Value * threadID1 = iBuilder->CreateLoad(pthreadsPtr1);
    365         // Value * threadID2 = iBuilder->CreateLoad(pthreadsPtr2);
    366         // Value * threadID3 = iBuilder->CreateLoad(pthreadsPtr3);
    367      
    368         // iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadID1, status}));
    369         // iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadID2, status}));
    370         // iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadID3, status}));
     234
    371235        iBuilder->CreateRetVoid();
    372236
     
    536400
    537401
    538 
    539 
    540402void icgrep_Linking(Module * m, ExecutionEngine * e) {
    541403    Module::FunctionListType & fns = m->getFunctionList();
Note: See TracChangeset for help on using the changeset viewer.