Ignore:
Timestamp:
Mar 23, 2018, 9:26:50 AM (15 months ago)
Author:
cameron
Message:

Auto RE grouping/threading

File:
1 edited

Legend:

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

    r5913 r5930  
    3939static cl::opt<bool> ByteMode("enable-byte-mode", cl::desc("Process regular expressions in byte mode"));
    4040
    41 static cl::opt<bool> MultiGrepKernels("enable-multigrep-kernels", cl::desc("Construct separated kernels for each regular expression"));
    42 static cl::opt<int> REsPerGroup("re-num", cl::desc("Number of regular expressions processed by each kernel."), cl::init(1));
     41static cl::opt<int> REsPerGroup("re-num", cl::desc("Number of regular expressions processed by each kernel."), cl::init(0));
    4342
    4443static re::ModeFlagSet globalFlags = re::MULTILINE_MODE_FLAG;
     
    7473    }
    7574
    76     if (MultiGrepKernels) {
     75   
     76    // If there are multiple REs, combine them into groups.
     77    // A separate kernel will be created for each group.
     78    if (REs.size() > 1) {
     79        codegen::SegmentPipelineParallel = true;
     80        if (REsPerGroup == 0) {
     81            // If no grouping factor is specified, we use a default formula.
     82            REsPerGroup = (REs.size() + codegen::ThreadNum) / (codegen::ThreadNum + 1);
     83        }
    7784        std::vector<re::RE *> groups;
    7885        auto start = REs.begin();
     
    8895            groups.push_back(*start);
    8996        }
    90         REs.swap(groups);
    91     } else if (REs.size() > 1) {
    92         REs.assign({re::makeAlt(REs.begin(), REs.end())});
    93     }
    94 
     97    REs.swap(groups);
     98    }
    9599    for (re::RE *& re_ast : REs) {
    96100        assert (re_ast);
Note: See TracChangeset for help on using the changeset viewer.