Changeset 5017


Ignore:
Timestamp:
Apr 29, 2016, 4:05:57 PM (19 months ago)
Author:
lindanl
Message:

Passing file index instead of file name as internal state.

Location:
icGREP/icgrep-devel/icgrep
Files:
6 edited

Legend:

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

    r5001 r5017  
    6969}
    7070
    71 void GrepEngine::doGrep(const std::string & fileName) {
     71void GrepEngine::doGrep(const std::string & fileName, const int fileIdx) {
    7272    const path file(fileName);
    7373    if (exists(file)) {
     
    8989        }
    9090        char * const fileBuffer = file.data();
    91         mGrepFunction(fileBuffer, fileSize, fileName.c_str(), finalLineIsUnterminated(fileBuffer, fileSize));
     91        mGrepFunction(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
    9292        file.close();
    9393    }
     
    135135    if(finalLineIsUnterminated(mFileBuffer, mFileSize))
    136136        finalLineUnterminated = 1;   
    137     mGrepFunction(mFileBuffer, mFileSize, mFileName.c_str(), finalLineUnterminated);
     137    mGrepFunction(mFileBuffer, mFileSize, 0, finalLineUnterminated);
    138138
    139139    return getParsedCodePointSet();
  • icGREP/icgrep-devel/icgrep/grep_engine.h

    r5001 r5017  
    1616
    1717class GrepEngine {
    18     typedef void (*GrepFunctionType)(char * byte_data, size_t filesize, const char* filename, uint64_t finalLineUnterminated);
     18    typedef void (*GrepFunctionType)(char * byte_data, size_t filesize, const int fileIdx, uint64_t finalLineUnterminated);
    1919public:
    2020
     
    2525    void grepCodeGen(std::string moduleName, re::RE * re_ast, bool isNameExpression = false);
    2626   
    27     void doGrep(const std::string & fileName);
     27    void doGrep(const std::string & fileName, const int fileIdx);
    2828   
    2929    re::CC *  grepCodepoints();
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r5016 r5017  
    104104
    105105    while (fileIdx < inputFiles.size()){
    106         grepEngine->doGrep(inputFiles[fileIdx]);
     106        grepEngine->doGrep(inputFiles[fileIdx], fileIdx);
    107107       
    108108        count_mutex.lock();
     
    241241    if (Threads <= 1) {
    242242        for (unsigned i = 0; i != inputFiles.size(); ++i) {
    243             grepEngine.doGrep(inputFiles[i]);
     243            grepEngine.doGrep(inputFiles[i], i);
    244244        }       
    245245    } else if (Threads > 1) {
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5014 r5017  
    6262    Type * const inputType = PointerType::get(ArrayType::get(StructType::get(mMod->getContext(), std::vector<Type *>({ArrayType::get(mBitBlockType, 8)})), 1), 0);
    6363
    64     Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", Type::getVoidTy(mMod->getContext()), inputType, int64ty, int8PtrTy, iBuilder->getInt1Ty(), nullptr));
     64    Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", Type::getVoidTy(mMod->getContext()), inputType, int64ty, int64ty, iBuilder->getInt1Ty(), nullptr));
    6565    main->setCallingConv(CallingConv::C);
    6666    Function::arg_iterator args = main->arg_begin();
     
    7070    Value * const bufferSize = &*(args++);
    7171    bufferSize->setName("bufferSize");
    72     Value * const fileName = &*(args++);
    73     fileName->setName("fileName");
     72    Value * const fileIdx = &*(args++);
     73    fileIdx->setName("fileIdx");
    7474    Value * const finalLineUnterminated = &*(args++);
    7575    finalLineUnterminated->setName("finalLineUnterminated");
     
    101101    scanMatchInstance->setInternalState("FileBuf", iBuilder->CreateBitCast(inputStream, int8PtrTy));
    102102    scanMatchInstance->setInternalState("FileSize", bufferSize);
    103     scanMatchInstance->setInternalState("FileName", fileName);
     103    scanMatchInstance->setInternalState("FileIdx", fileIdx);
    104104
    105105    Value * initialBufferSize = nullptr;
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5014 r5017  
    8484        matchProcessor = m->getOrInsertFunction("insert_codepoints", Type::getVoidTy(ctxt), T, T, T, S, nullptr);
    8585    } else {
    86         matchProcessor = m->getOrInsertFunction("wrapped_report_match", Type::getVoidTy(ctxt), T, T, T, S, T, S, nullptr);
     86        matchProcessor = m->getOrInsertFunction("wrapped_report_match", Type::getVoidTy(ctxt), T, T, T, S, T, T, nullptr);
    8787    }
    8888    iBuilder->SetInsertPoint(BasicBlock::Create(ctxt, "entry", function,0));
     
    158158    } else {
    159159        Value * fileSize = iBuilder->CreateLoad(kBuilder->getInternalStateInternal(instance, "FileSize"));
    160         Value * fileName = iBuilder->CreateLoad(kBuilder->getInternalStateInternal(instance, "FileName"));
    161         iBuilder->CreateCall(matchProcessor, std::vector<Value *>({matchRecordNum_phi, matchRecordStart_phi, matchRecordEnd, fileBuf, fileSize, fileName}));
     160        Value * fileIdx = iBuilder->CreateLoad(kBuilder->getInternalStateInternal(instance, "FileIdx"));
     161        iBuilder->CreateCall(matchProcessor, std::vector<Value *>({matchRecordNum_phi, matchRecordStart_phi, matchRecordEnd, fileBuf, fileSize, fileIdx}));
    162162    }
    163163
     
    217217    kBuilder->addInternalState(S, "FileBuf");
    218218    kBuilder->addInternalState(T, "FileSize");
    219     kBuilder->addInternalState(S, "FileName");
     219    kBuilder->addInternalState(T, "FileIdx");
    220220
    221221    Function * function = kBuilder->prepareFunction();
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r5015 r5017  
    146146
    147147extern "C" {
    148     void wrapped_report_match(uint64_t lineNum, uint64_t line_start, uint64_t line_end, const char * buffer, uint64_t filesize, char * filename) {
    149 
    150         int idx = 0;
    151         for (int i=0; i<inputFiles.size(); i++){
    152             if (inputFiles[i] == filename){
    153                 idx = i;
    154                 break;
    155             }
    156         }
     148    void wrapped_report_match(uint64_t lineNum, uint64_t line_start, uint64_t line_end, const char * buffer, uint64_t filesize, int fileIdx) {
     149
     150        int idx = fileIdx;
    157151
    158152        if(CountOnly){
     
    162156
    163157        if (ShowFileNames) {
    164             resultStrs[idx] << filename << ':';
     158            resultStrs[idx] << inputFiles[idx] << ':';
    165159        }
    166160        if (ShowLineNumbers) {
Note: See TracChangeset for help on using the changeset viewer.