Changeset 5031


Ignore:
Timestamp:
May 5, 2016, 11:52:53 AM (19 months ago)
Author:
cameron
Message:

Pablo Command Line options restructured

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

Legend:

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

    r5030 r5031  
    1717#include <toolchain.h>
    1818#include <re/re_toolchain.h>
     19#include <pablo/pablo_toolchain.h>
    1920#include <mutex>
    2021
     
    204205
    205206int main(int argc, char *argv[]) {
    206     cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *>{&LegacyGrepOptions, &EnhancedGrepOptions, re::re_toolchain_flags()});
     207    cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *>{&LegacyGrepOptions, &EnhancedGrepOptions, re::re_toolchain_flags(), pablo::pablo_toolchain_flags()});
    207208    cl::ParseCommandLineOptions(argc, argv);
    208209   
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5023 r5031  
    66
    77#include <pablo/pablo_compiler.h>
     8#include <pablo/pablo_toolchain.h>
    89#include <pablo/codegenstate.h>
    910#include <pablo/carry_data.h>
     
    5253#include <hrtime.h>
    5354
    54 static cl::OptionCategory fTracingOptions("Run-time Tracing Options", "These options control execution traces.");
    55 static cl::opt<bool> DumpTrace("dump-trace", cl::init(false), cl::desc("Generate dynamic traces of executed assignments."), cl::cat(fTracingOptions));
    5655
    5756namespace pablo {
     
    121120        Value * inputVal = mKernelBuilder->getInputStream(j);
    122121        const Var * const var = function->getParameter(j);
    123         if (DumpTrace) {
     122        if (DebugOptionIsSet(DumpTrace)) {
    124123            iBuilder->CallPrintRegister(var->getName()->to_string(), iBuilder->CreateBlockAlignedLoad(inputVal));
    125124        }
     
    443442    }
    444443    mMarkerMap[stmt] = expr;
    445     if (DumpTrace) {
     444    if (DebugOptionIsSet(DumpTrace)) {
    446445        iBuilder->CallPrintRegister(stmt->getName()->to_string(), expr);
    447446    }
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.cpp

    r4984 r5031  
    99#include <fstream>
    1010
     11#include <pablo/pablo_toolchain.h>
    1112#include <pablo/pablo_compiler.h>
    1213#include <pablo/optimizers/pablo_simplifier.hpp>
     
    2829
    2930
    30 using namespace pablo;
    31 
    32 
    33 static cl::OptionCategory dPabloDumpOptions("Pablo Dump Options", "These options control printing of intermediate Pablo code.");
    34 
    35 static cl::opt<bool> PrintOptimizedREcode("print-pablo", cl::init(false), cl::desc("print final optimized Pablo code"), cl::cat(dPabloDumpOptions));
    36 static cl::opt<bool> PrintCompiledCCcode("print-CC-pablo", cl::init(false), cl::desc("print Pablo output from character class compiler"), cl::cat(dPabloDumpOptions));
    37 static cl::opt<bool> PrintCompiledREcode("print-RE-pablo", cl::init(false), cl::desc("print Pablo output from the regular expression compiler"), cl::cat(dPabloDumpOptions));
    38 static cl::opt<std::string> PabloOutputFilename("print-pablo-output", cl::init(""), cl::desc("output Pablo filename"), cl::cat(dPabloDumpOptions));
    39 
    40 
    41 static cl::OptionCategory cPabloOptimizationsOptions("Pablo Optimizations", "These options control Pablo optimization passes.");
    42 
    43 static cl::opt<bool> DisableSimplification("disable-simplification", cl::init(false),
    44                                      cl::desc("Disable Pablo Simplification pass (not recommended)"),
    45                                      cl::cat(cPabloOptimizationsOptions));
    46 
    47 static cl::opt<bool> PabloSinkingPass("sinking", cl::init(false),
    48                                       cl::desc("Moves all instructions into the innermost legal If-scope so that they are only executed when needed."),
    49                                       cl::cat(cPabloOptimizationsOptions));
    50 
    51 #ifdef ENABLE_MULTIPLEXING
    52 static cl::opt<bool> PrintUnloweredCode("print-unlowered-pablo", cl::init(false), cl::desc("print Pablo output prior to lowering. "), cl::cat(dPabloDumpOptions));
    53 
    54 static cl::opt<bool> EnableMultiplexing("multiplexing", cl::init(false),
    55                                         cl::desc("combine Advances whose inputs are mutual exclusive into the fewest number of advances possible (expensive)."),
    56                                         cl::cat(cPabloOptimizationsOptions));
    57 
    58 static cl::opt<bool> EnableLowering("lowering", cl::init(false),
    59                                          cl::desc("coalesce associative functions prior to optimization passes."),
    60                                          cl::cat(cPabloOptimizationsOptions));
    61 
    62 static cl::opt<bool> EnablePreDistribution("pre-dist", cl::init(false),
    63                                          cl::desc("apply distribution law optimization prior to multiplexing."),
    64                                          cl::cat(cPabloOptimizationsOptions));
    65 
    66 static cl::opt<bool> EnablePostDistribution("post-dist", cl::init(false),
    67                                          cl::desc("apply distribution law optimization after multiplexing."),
    68                                          cl::cat(cPabloOptimizationsOptions));
    69 
    70 static cl::opt<bool> EnablePrePassScheduling("pre-pass-scheduling", cl::init(false),
    71                                          cl::desc("apply pre-pass scheduling prior to LLVM IR generation."),
    72                                          cl::cat(cPabloOptimizationsOptions));
    73 #endif
    74 
    75 
     31namespace pablo {
     32
     33
     34static cl::OptionCategory PabloOptions("Pablo Options", "These options control printing, generation and instrumentation of Pablo intermediate code.");
     35const cl::OptionCategory * pablo_toolchain_flags() {return &PabloOptions;};
     36   
     37   
     38static cl::bits<PabloDebugFlags>
     39DebugOptions(cl::values(clEnumVal(PrintOptimizedREcode, "print final optimized Pablo code"),
     40                        clEnumVal(PrintCompiledCCcode, "print Pablo output from character class compiler"),
     41                        clEnumVal(PrintCompiledREcode, "print Pablo output from the regular expression compiler"),
     42                        clEnumVal(DumpTrace, "Generate dynamic traces of executed Pablo assignments."),
     43                        clEnumVal(PrintUnloweredCode, "print Pablo output prior to lowering."),
     44                        clEnumValEnd), cl::cat(PabloOptions));
     45   
     46static cl::opt<std::string> PabloOutputFilename("print-pablo-output", cl::init(""), cl::desc("output Pablo filename"), cl::cat(PabloOptions));
     47
     48static cl::bits<PabloCompilationFlags>
     49    PabloOptimizationsOptions(cl::values(clEnumVal(DisableSimplification, "Disable Pablo Simplification pass (not recommended)"),
     50                                         clEnumVal(PabloSinkingPass, "Moves all instructions into the innermost legal If-scope so that they are only executed when needed."),
     51#ifdef ENABLE_MULTIPLEXING
     52                                         clEnumVal(EnableMultiplexing, "combine Advances whose inputs are mutual exclusive into the fewest number of advances possible (expensive)."),
     53                                         clEnumVal(EnableLowering, "coalesce associative functions prior to optimization passes."),
     54                                         clEnumVal(EnablePreDistribution, "apply distribution law optimization prior to multiplexing."),
     55                                         clEnumVal(EnablePostDistribution, "apply distribution law optimization after multiplexing."),
     56                                         clEnumVal(EnablePrePassScheduling, "apply pre-pass scheduling prior to LLVM IR generation."),
     57#endif                                         
     58                            clEnumValEnd), cl::cat(PabloOptions));
     59
     60bool DebugOptionIsSet(PabloDebugFlags flag) {return DebugOptions.isSet(flag);}
     61   
     62   
     63   
    7664#ifdef PRINT_TIMING_INFORMATION
    7765#define READ_CYCLE_COUNTER(name) name = read_cycle_counter();
     
    178166void pablo_function_passes(PabloFunction * function) {
    179167   
    180     if (PrintCompiledREcode) {
     168    if (DebugOptions.isSet(PrintCompiledREcode)) {
    181169        //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    182170        llvm::raw_os_ostream cerr(std::cerr);
     
    203191    const timestamp_t optimization_start = read_cycle_counter();
    204192#endif
    205     if (!DisableSimplification) {
     193    if (!PabloOptimizationsOptions.isSet(DisableSimplification)) {
    206194        READ_CYCLE_COUNTER(simplification_start);
    207195        Simplifier::optimize(*function);
     
    209197    }
    210198#ifdef ENABLE_MULTIPLEXING
    211     if (EnableLowering || EnablePreDistribution || EnablePostDistribution) {
     199    if (PabloOptimizationsOptions.isSet(EnableLowering) || PabloOptimizationsOptions.isSet(EnablePreDistribution) || PabloOptimizationsOptions.isSet(EnablePostDistribution)) {
    212200        READ_CYCLE_COUNTER(coalescing_start);
    213201        CanonicalizeDFG::transform(*function);
    214202        READ_CYCLE_COUNTER(coalescing_end);
    215203    }
    216     if (EnablePreDistribution) {
     204    if (PabloOptimizationsOptions.isSet(EnablePreDistribution)) {
    217205        READ_CYCLE_COUNTER(pre_distribution_start);
    218206        DistributivePass::optimize(*function);
    219207        READ_CYCLE_COUNTER(pre_distribution_end);
    220208    }
    221     if (EnableMultiplexing) {
     209    if (PabloOptimizationsOptions.isSet(EnableMultiplexing)) {
    222210        READ_CYCLE_COUNTER(multiplexing_start);
    223211        MultiplexingPass::optimize(*function);
    224212        READ_CYCLE_COUNTER(multiplexing_end);
    225         if (EnableLowering || EnablePreDistribution || EnablePostDistribution) {
     213        if (PabloOptimizationsOptions.isSet(EnableLowering) || PabloOptimizationsOptions.isSet(EnablePreDistribution) || PabloOptimizationsOptions.isSet(EnablePostDistribution)) {
    226214            CanonicalizeDFG::transform(*function);
    227215        }
    228216    }
    229     if (EnablePostDistribution) {
     217    if (PabloOptimizationsOptions.isSet(EnablePostDistribution)) {
    230218        READ_CYCLE_COUNTER(post_distribution_start);
    231219        DistributivePass::optimize(*function);
     
    233221    }
    234222#endif
    235     if (PabloSinkingPass) {
     223    if (PabloOptimizationsOptions.isSet(PabloSinkingPass)) {
    236224        READ_CYCLE_COUNTER(sinking_start);
    237225        CodeMotionPass::optimize(*function);
     
    239227    }
    240228#ifdef ENABLE_MULTIPLEXING
    241     if (PrintUnloweredCode) {
     229    if (DebugOptions.isSet(PrintUnloweredCode)) {
    242230        //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    243231        llvm::raw_os_ostream cerr(std::cerr);
     
    248236    distribution = SUMMARIZE_VARIADIC_DISTRIBUTION(function);
    249237    #endif
    250     if (EnableLowering || EnablePreDistribution || EnablePostDistribution) {
     238    if (PabloOptimizationsOptions.isSet(EnableLowering) || PabloOptimizationsOptions.isSet(EnablePreDistribution) || PabloOptimizationsOptions.isSet(EnablePostDistribution)) {
    251239        READ_CYCLE_COUNTER(lowering_start);
    252240        FactorizeDFG::transform(*function);
    253241        READ_CYCLE_COUNTER(lowering_end);
    254242    }
    255     if (EnablePrePassScheduling) {
     243    if (PabloOptimizationsOptions.isSet(EnablePrePassScheduling)) {
    256244        READ_CYCLE_COUNTER(scheduling_start);
    257245        SchedulingPrePass::optimize(*function);
     
    262250    const timestamp_t optimization_end = read_cycle_counter();
    263251#endif
    264     if (PrintOptimizedREcode) {
     252    if (DebugOptions.isSet(PrintOptimizedREcode)) {
    265253        if (PabloOutputFilename.empty()) {
    266254            //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
     
    302290}
    303291
     292}
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.h

    r4984 r5031  
    99
    1010#include <pablo/function.h>
     11#include <llvm/Support/CommandLine.h>
    1112
    12 void pablo_function_passes(pablo::PabloFunction * function);
     13namespace pablo {
     14   
     15enum PabloDebugFlags {
     16    PrintOptimizedREcode, PrintCompiledCCcode, PrintCompiledREcode, DumpTrace, PrintUnloweredCode
     17};
    1318
     19enum PabloCompilationFlags {
     20    DisableSimplification, PabloSinkingPass,
     21    EnableMultiplexing, EnableLowering, EnablePreDistribution, EnablePostDistribution, EnablePrePassScheduling
     22};
     23   
     24const cl::OptionCategory * pablo_toolchain_flags();
     25
     26bool DebugOptionIsSet(PabloDebugFlags flag);
     27
     28void pablo_function_passes(PabloFunction * function);
     29
     30}
    1431#endif
Note: See TracChangeset for help on using the changeset viewer.