Changeset 5295


Ignore:
Timestamp:
Feb 2, 2017, 9:17:55 PM (8 months ago)
Author:
cameron
Message:

Debug Options: SerializeThreads?; unify ShowIR, ShowPablo?, ShowREs, ShowASM

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

Legend:

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

    r5292 r5295  
    6565}
    6666
    67 std::vector<Value *> getCopyBackPositions(const KernelBuilder * kernel, Value * instance) {
    68     std::vector<Value *> positions;
    69     auto outputSets = kernel->getStreamSetOutputBuffers();
    70     for (unsigned i = 0; i < outputSets.size(); i++) {
    71         if (isa<LinearCopybackBuffer>(outputSets[i])) {
    72             positions.push_back(kernel->getProducedItemCount(instance, kernel->getStreamOutputs()[i].name));
    73         }
    74     }
    75     return positions;
    76 }
    77 
    78 void createCopyBackCode(const StreamSetBuffer *, Value * startPosition, Value * finalPosition) {
    79     //BasicBlock * doCopyBack = BasicBlock::Create(iBuilder->getContext(), kernels[k]->getName() + "copyBack" +std::to_string(j), threadFunc, 0);
    80    
    81    
    82 }
    83 
    84 
    8567Function * generateSegmentParallelPipelineThreadFunction(std::string name, IDISA::IDISA_Builder * iBuilder, const std::vector<KernelBuilder *> & kernels, Type * sharedStructType, ProducerTable & producerTable, int id) {
    8668   
     
    137119    const unsigned last_kernel = kernels.size() - 1;
    138120    Value * doFinal = ConstantInt::getNullValue(iBuilder->getInt1Ty());
    139    
     121    Value * nextSegNo = iBuilder->CreateAdd(segNo, iBuilder->getSize(1));
    140122    iBuilder->CreateBr(segmentWait[0]);
    141123    for (unsigned k = 0; k < kernels.size(); k++) {
    142124        iBuilder->SetInsertPoint(segmentWait[k]);
    143         Value * processedSegmentCount = kernels[k]->acquireLogicalSegmentNo(instancePtrs[k]);
     125        unsigned waitForKernel = k;
     126        if (codegen::DebugOptionIsSet(codegen::SerializeThreads)) {
     127            waitForKernel = last_kernel;
     128        }
     129        Value * processedSegmentCount = kernels[waitForKernel]->acquireLogicalSegmentNo(instancePtrs[waitForKernel]);
    144130        Value * cond = iBuilder->CreateICmpEQ(segNo, processedSegmentCount);
    145131
     
    160146            doSegmentArgs.push_back(ProducerPos[producerKernel][outputIndex]);
    161147        }
    162         std::vector<Value *> copyBackStartPosition = getCopyBackPositions(kernels[k], instancePtrs[k]);
    163148        kernels[k]->createDoSegmentCall(doSegmentArgs);
    164149        std::vector<Value *> produced;
    165         unsigned copyBackIndex = 0;
    166150        for (unsigned i = 0; i < kernels[k]->getStreamOutputs().size(); i++) {
    167151            produced.push_back(kernels[k]->getProducedItemCount(instancePtrs[k], kernels[k]->getStreamOutputs()[i].name));
    168             if (isa<LinearCopybackBuffer>(kernels[k]->getStreamSetOutputBuffers()[i])) {
    169                 createCopyBackCode(kernels[k]->getStreamSetOutputBuffers()[i], copyBackStartPosition[copyBackIndex], produced[i]);
    170                 copyBackIndex++;
    171             }
    172152        }
    173153        ProducerPos.push_back(produced);
     
    177157        }
    178158
    179         Value * nextSegNo = iBuilder->CreateAdd(segNo, iBuilder->getSize(1));
    180159        kernels[k]->releaseLogicalSegmentNo(instancePtrs[k], nextSegNo);
    181160        if (k == last_kernel) {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.cpp

    r5267 r5295  
    4141   
    4242static cl::bits<PabloDebugFlags>
    43 DebugOptions(cl::values(clEnumVal(PrintOptimizedREcode, "print final optimized Pablo code"),
    44                         clEnumVal(PrintCompiledCCcode, "print Pablo output from character class compiler"),
    45                         clEnumVal(PrintCompiledREcode, "print Pablo output from the regular expression compiler"),
     43DebugOptions(cl::values(clEnumVal(ShowPablo, "Print generated Pablo code"),
     44                        clEnumVal(ShowOptimizedPablo, "Print optimizeed Pablo code"),
     45                        clEnumVal(ShowUnloweredPablo, "Print Pablo code prior to lowering."),
    4646                        clEnumVal(DumpTrace, "Generate dynamic traces of executed Pablo assignments."),
    47                         clEnumVal(PrintUnloweredCode, "print Pablo output prior to lowering."),
    4847                        clEnumValEnd), cl::cat(PabloOptions));
    4948   
     
    171170void pablo_function_passes(PabloKernel * kernel) {
    172171   
    173     if (DebugOptions.isSet(PrintCompiledREcode)) {
     172    if (DebugOptions.isSet(ShowPablo)) {
    174173        //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    175174        errs() << "Initial Pablo AST:\n";
     
    237236    }
    238237#ifdef ENABLE_MULTIPLEXING
    239     if (DebugOptions.isSet(PrintUnloweredCode)) {
     238    if (DebugOptions.isSet(ShowUnloweredPablo)) {
    240239        //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    241240        errs() << "Unlowered Pablo AST:\n";
     
    259258    const timestamp_t optimization_end = read_cycle_counter();
    260259#endif
    261     if (DebugOptions.isSet(PrintOptimizedREcode)) {
     260    if (DebugOptions.isSet(ShowOptimizedPablo)) {
    262261        if (PabloOutputFilename.empty()) {
    263262            //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.h

    r5267 r5295  
    1414
    1515enum PabloDebugFlags {
    16     PrintOptimizedREcode, PrintCompiledCCcode, PrintCompiledREcode, DumpTrace, PrintUnloweredCode
     16    ShowPablo, ShowOptimizedPablo, ShowUnloweredPablo, DumpTrace,
    1717};
    1818
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.cpp

    r5267 r5295  
    2626
    2727static cl::bits<RE_PrintFlags>
    28     PrintOptions(cl::values(clEnumVal(PrintAllREs, "print regular expression passes"),
    29                             clEnumVal(PrintParsedREs, "print out parsed regular expressions"),
    30                             clEnumVal(PrintStrippedREs, "print out REs with nullable prefixes/suffixes removed"),
    31                             clEnumVal(PrintSimplifiedREs, "print out final simplified REs"),
     28    PrintOptions(cl::values(clEnumVal(ShowREs, "Print parsed or generated regular expressions"),
     29                            clEnumVal(ShowAllREs, "Print all regular expression passes"),
     30                            clEnumVal(ShowStrippedREs, "Print REs with nullable prefixes/suffixes removed"),
     31                            clEnumVal(ShowSimplifiedREs, "Print final simplified REs"),
    3232                            clEnumValEnd), cl::cat(RegexOptions));
    3333
     
    5555
    5656RE * regular_expression_passes(RE * re_ast)  {
    57     if (PrintOptions.isSet(PrintAllREs) || PrintOptions.isSet(PrintParsedREs)) {
     57    if (PrintOptions.isSet(ShowAllREs) || PrintOptions.isSet(ShowREs)) {
    5858        std::cerr << "Parser:" << std::endl << Printer_RE::PrintRE(re_ast) << std::endl;
    5959    }
     
    6161    //Optimization passes to simplify the AST.
    6262    re_ast = re::RE_Nullable::removeNullablePrefix(re_ast);
    63     if (PrintOptions.isSet(PrintAllREs) || PrintOptions.isSet(PrintStrippedREs)) {
     63    if (PrintOptions.isSet(ShowAllREs) || PrintOptions.isSet(ShowStrippedREs)) {
    6464        std::cerr << "RemoveNullablePrefix:" << std::endl << Printer_RE::PrintRE(re_ast) << std::endl;
    6565    }
    6666    re_ast = re::RE_Nullable::removeNullableSuffix(re_ast);
    67     if (PrintOptions.isSet(PrintAllREs) || PrintOptions.isSet(PrintStrippedREs)) {
     67    if (PrintOptions.isSet(ShowAllREs) || PrintOptions.isSet(ShowStrippedREs)) {
    6868        std::cerr << "RemoveNullableSuffix:" << std::endl << Printer_RE::PrintRE(re_ast) << std::endl;
    6969    }
    7070    re_ast = re::RE_Nullable::removeNullableAssertion(re_ast);
    71     if (PrintOptions.isSet(PrintAllREs) || PrintOptions.isSet(PrintStrippedREs)) {
     71    if (PrintOptions.isSet(ShowAllREs) || PrintOptions.isSet(ShowStrippedREs)) {
    7272        std::cerr << "RemoveNullableAssertion:" << std::endl << Printer_RE::PrintRE(re_ast) << std::endl;
    7373    }
    7474    re_ast = re::RE_Nullable::removeNullableAfterAssertion(re_ast);
    75     if (PrintOptions.isSet(PrintAllREs) || PrintOptions.isSet(PrintStrippedREs)) {
     75    if (PrintOptions.isSet(ShowAllREs) || PrintOptions.isSet(ShowStrippedREs)) {
    7676        std::cerr << "RemoveNullableAfterAssertion" << std::endl << Printer_RE::PrintRE(re_ast) << std::endl;
    7777    }
    7878   
    7979    re_ast = re::RE_Simplifier::simplify(re_ast);
    80     if (PrintOptions.isSet(PrintAllREs) || PrintOptions.isSet(PrintSimplifiedREs)) {
     80    if (PrintOptions.isSet(ShowAllREs) || PrintOptions.isSet(ShowSimplifiedREs)) {
    8181        //Print to the terminal the AST that was generated by the simplifier.
    8282        std::cerr << "Simplifier:" << std::endl << Printer_RE::PrintRE(re_ast) << std::endl;
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.h

    r5267 r5295  
    1515
    1616enum RE_PrintFlags {
    17     PrintAllREs, PrintParsedREs, PrintStrippedREs, PrintSimplifiedREs
     17    ShowREs, ShowAllREs, ShowStrippedREs, ShowSimplifiedREs
    1818};
    1919   
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r5267 r5295  
    3030
    3131static cl::OptionCategory CodeGenOptions("Code Generation Options", "These options control code generation.");
    32 
    33 
    34 static cl::opt<bool> DumpGeneratedIR("dump-generated-IR", cl::init(false), cl::desc("Print LLVM IR generated by Pablo Compiler."), cl::cat(CodeGenOptions));
     32static cl::bits<DebugFlags>
     33DebugOptions(cl::values(clEnumVal(ShowIR, "Print generated LLVM IR."),
     34#if LLVM_VERSION_MINOR > 6
     35                        clEnumVal(ShowASM, "Print assembly code."),
     36#endif
     37                        clEnumVal(SerializeThreads, "Force segment threads to run sequentially."),
     38                        clEnumValEnd), cl::cat(CodeGenOptions));
     39
    3540static cl::opt<std::string> IROutputFilename("dump-generated-IR-output", cl::init(""), cl::desc("output IR filename"), cl::cat(CodeGenOptions));
    3641#if LLVM_VERSION_MINOR > 6
    37 static cl::opt<bool> DumpASM("DumpASM", cl::init(false), cl::desc("Print Assembly Code."), cl::cat(CodeGenOptions));
    38 #endif
    3942static cl::opt<std::string> ASMOutputFilename("asm-output", cl::init(""), cl::desc("output ASM filename"), cl::cat(CodeGenOptions));
    4043static cl::opt<bool> AsmVerbose("asm-verbose",
    4144                                cl::desc("Add comments to directives."),
    4245                                cl::init(true), cl::cat(CodeGenOptions));
     46#endif
    4347
    4448char OptLevel;
     
    6468const cl::OptionCategory * codegen_flags() {return &CodeGenOptions;}
    6569
     70bool DebugOptionIsSet(DebugFlags flag) {return DebugOptions.isSet(flag);}
     71
     72   
    6673#ifdef CUDA_ENABLED
    6774bool NVPTX;
     
    94101    m->print(out, nullptr);
    95102
    96     if (LLVM_UNLIKELY(codegen::DumpGeneratedIR))
     103    if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::ShowIR)))
    97104            m->dump();
    98105
     
    176183    setAllFeatures(builder);
    177184
    178     if (LLVM_UNLIKELY(codegen::DumpGeneratedIR)) {
     185    if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::ShowIR))) {
    179186        if (codegen::IROutputFilename.empty()) {
    180187            m->dump();
     
    186193    }
    187194#if LLVM_VERSION_MINOR > 6
    188     if (codegen::DumpASM) {
     195    if (codegen::DebugOptionIsSet(codegen::ShowASM)) {
    189196      WriteAssembly(builder.selectTarget(), m);
    190197    }
  • icGREP/icgrep-devel/icgrep/toolchain.h

    r5293 r5295  
    1616
    1717// Command Parameters
     18enum DebugFlags {
     19    ShowIR,
     20#if LLVM_VERSION_MINOR > 6
     21    ShowASM,
     22#endif
     23    SerializeThreads
     24};
     25
     26bool DebugOptionIsSet(DebugFlags flag);
     27
     28
    1829extern char OptLevel;  // set from command line
    1930extern int BlockSize;  // set from command line
Note: See TracChangeset for help on using the changeset viewer.