summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Pass/PassTiming.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle2019-12-181-8/+7
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* minor spelling tweaksKazuaki Ishizaki2019-12-061-1/+1
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* Add support for instance specific pass statistics.River Riddle2019-12-051-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Statistics are a way to keep track of what the compiler is doing and how effective various optimizations are. It is useful to see what optimizations are contributing to making a particular program run faster. Pass-instance specific statistics take this even further as you can see the effect of placing a particular pass at specific places within the pass pipeline, e.g. they could help answer questions like "what happens if I run CSE again here". Statistics can be added to a pass by simply adding members of type 'Pass::Statistics'. This class takes as a constructor arguments: the parent pass pointer, a name, and a description. Statistics can be dumped by the pass manager in a similar manner to how pass timing information is dumped, i.e. via PassManager::enableStatistics programmatically; or -pass-statistics and -pass-statistics-display via the command line pass manager options. Below is an example: struct MyPass : public OperationPass<MyPass> { Statistic testStat{this, "testStat", "A test statistic"}; void runOnOperation() { ... ++testStat; ... } }; $ mlir-opt -pass-pipeline='func(my-pass,my-pass)' foo.mlir -pass-statistics Pipeline Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== 'func' Pipeline MyPass (S) 15 testStat - A test statistic MyPass (S) 6 testStat - A test statistic List Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== MyPass (S) 21 testStat - A test statistic PiperOrigin-RevId: 284022014
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-201-3/+3
| | | | | | Closes tensorflow/mlir#177 PiperOrigin-RevId: 275692653
* Pass the pointer of the parent pipeline collection pass to ↵River Riddle2019-09-301-12/+11
| | | | | | | | PassInstrumentation::run*Pipeline. For the cases where there are multiple levels of nested pass managers, the parent thread ID is not enough to distinguish the parent of a given pass pipeline. Passing in the parent pass gives an exact anchor point. PiperOrigin-RevId: 272105461
* Fix a number of Clang-Tidy warnings.Christian Sigg2019-09-231-3/+4
| | | | PiperOrigin-RevId: 270632324
* NFC: Pass PassInstrumentations by unique_ptr instead of raw pointer.River Riddle2019-09-141-1/+1
| | | | | | This makes the ownership model explicit, and removes potential user errors. PiperOrigin-RevId: 269122834
* Add support for coalescing adjacent nested pass pipelines.River Riddle2019-09-091-2/+9
| | | | | | This allows for parallelizing across pipelines of multiple operation types. AdaptorPasses can now hold pass managers for multiple operation types and will dispatch based upon the operation being operated on. PiperOrigin-RevId: 268017344
* Refactor PassTiming to support nested pipelines.River Riddle2019-09-081-65/+142
| | | | | | This is done via a new set of instrumentation hooks runBeforePipeline/runAfterPipeline, that signal the lifetime of a pass pipeline on a specific operation type. These hooks also provide the parent thread of the pipeline, allowing for accurate merging of timers running on different threads. PiperOrigin-RevId: 267909193
* Refactor the pass manager to support operations other than FuncOp/ModuleOp.River Riddle2019-09-021-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change generalizes the structure of the pass manager to allow arbitrary nesting pass managers for other operations, at any level. The only user visible change to existing code is the fact that a PassManager must now provide an MLIRContext on construction. A new class `OpPassManager` has been added that represents a pass manager on a specific operation type. `PassManager` will remain the top-level entry point into the pipeline, with OpPassManagers being nested underneath. OpPassManagers will still be implicitly nested if the operation type on the pass differs from the pass manager. To explicitly build a pipeline, the 'nest' methods on OpPassManager may be used: // Pass manager for the top-level module. PassManager pm(ctx); // Nest a pipeline operating on FuncOp. OpPassManager &fpm = pm.nest<FuncOp>(); fpm.addPass(...); // Nest a pipeline under the FuncOp pipeline that operates on spirv::ModuleOp OpPassManager &spvModulePM = pm.nest<spirv::ModuleOp>(); // Nest a pipeline on FuncOps inside of the spirv::ModuleOp. OpPassManager &spvFuncPM = spvModulePM.nest<FuncOp>(); To help accomplish this a new general OperationPass is added that operates on opaque Operations. This pass can be inserted in a pass manager of any type to operate on any operation opaquely. An example of this opaque OperationPass is a VerifierPass, that simply runs the verifier opaquely on the current operation. /// Pass to verify an operation and signal failure if necessary. class VerifierPass : public OperationPass<VerifierPass> { void runOnOperation() override { Operation *op = getOperation(); if (failed(verify(op))) signalPassFailure(); markAllAnalysesPreserved(); } }; PiperOrigin-RevId: 266840344
* NFC: Refactor the PassInstrumentation framework to operate on Operation ↵River Riddle2019-08-161-12/+8
| | | | | | | | instead of llvm::Any. Now that functions and modules are operations, Operation makes more sense as the opaque object to refer to both. PiperOrigin-RevId: 263883913
* Replace dyn_cast<> with isa<> when the returned value is unused (NFC)Mehdi Amini2019-05-101-2/+1
| | | | | | | | Fix a gcc warning. -- PiperOrigin-RevId: 247669360
* Update variable in PassTiming to refer to system_clock instead of ↵River Riddle2019-04-011-1/+1
| | | | | | | | high_resolution_clock. -- PiperOrigin-RevId: 241260071
* Add support for multi-threaded pass timing.River Riddle2019-03-291-43/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When multi-threading is enabled in the pass manager the meaning of the display slightly changes. First, a new timing column is added, `User Time`, that displays the total time spent across all threads. Secondly, the `Wall Time` column displays the longest individual time spent amongst all of the threads. This means that the `Wall Time` column will continue to give an indicator on the perceived time, or clock time, whereas the `User Time` will display the total cpu time. Example: $ mlir-opt foo.mlir -experimental-mt-pm -cse -canonicalize -convert-to-llvmir -pass-timing ===-------------------------------------------------------------------------=== ... Pass execution timing report ... ===-------------------------------------------------------------------------=== Total Execution Time: 0.0078 seconds ---User Time--- ---Wall Time--- --- Name --- 0.0175 ( 88.3%) 0.0055 ( 70.4%) Function Pipeline 0.0018 ( 9.3%) 0.0006 ( 8.1%) CSE 0.0013 ( 6.3%) 0.0004 ( 5.8%) (A) DominanceInfo 0.0017 ( 8.7%) 0.0006 ( 7.1%) FunctionVerifier 0.0128 ( 64.6%) 0.0039 ( 50.5%) Canonicalizer 0.0011 ( 5.7%) 0.0004 ( 4.7%) FunctionVerifier 0.0004 ( 2.1%) 0.0004 ( 5.2%) ModuleVerifier 0.0010 ( 5.3%) 0.0010 ( 13.4%) LLVMLowering 0.0009 ( 4.3%) 0.0009 ( 11.0%) ModuleVerifier 0.0198 (100.0%) 0.0078 (100.0%) Total PiperOrigin-RevId: 240636269
* Add experimental support for multi-threading the pass manager. This adds ↵River Riddle2019-03-291-1/+1
| | | | | | support for running function pipelines on functions across multiple threads, and is guarded by an off-by-default flag 'experimental-mt-pm'. There are still quite a few things that need to be done before multi-threading is ready for general use(e.g. pass-timing), but this allows for those things to be tested in a multi-threaded environment. PiperOrigin-RevId: 240489002
* Replace the usages of llvm::Timer in PassTiming in favor of a simple nested ↵River Riddle2019-03-291-187/+173
| | | | | | Timer. The output view is simplified to just display the Wall Time. This new infrastructure will greatly simplify the amount of work needed to support multi-threaded execution timing. PiperOrigin-RevId: 238819218
* Add an instrumentation for conditionally printing the IR before and after ↵River Riddle2019-03-291-7/+0
| | | | | | | | | | | | | | | | | pass execution. This instrumentation can be added directly to the PassManager via 'enableIRPrinting'. mlir-opt exposes access to this instrumentation via the following flags: * print-ir-before=(comma-separated-pass-list) - Print the IR before each of the passes provided within the pass list. * print-ir-before-all - Print the IR before every pass in the pipeline. * print-ir-after=(comma-separated-pass-list) - Print the IR after each of the passes provided within the pass list. * print-ir-after-all - Print the IR after every pass in the pipeline. * print-ir-module-scope - Always print the Module IR, even for non module passes. PiperOrigin-RevId: 238523649
* Refactor pass timing so that it is toggled on the passmanager via ↵River Riddle2019-03-291-5/+76
| | | | | | 'enableTiming'. This also makes the pipeline view the default display mode. PiperOrigin-RevId: 238079916
* Add a new instrumentation for timing pass and analysis execution. This is ↵River Riddle2019-03-291-0/+234
made available in mlir-opt via the 'pass-timing' and 'pass-timing-display' flags. The 'pass-timing-display' flag toggles between the different available display modes for the timing results. The current display modes are 'list' and 'pipeline', with 'list' representing the default. Below shows the output for an example mlir-opt command line. mlir-opt foo.mlir -verify-each=false -cse -canonicalize -cse -cse -pass-timing list view (-pass-timing-display=list): * In this mode the results are displayed in a list sorted by total time; with each pass/analysis instance aggregated into one unique result. This mode is similar to the output of 'time-passes' in llvm-opt. ===-------------------------------------------------------------------------=== ... Pass execution timing report ... ===-------------------------------------------------------------------------=== Total Execution Time: 0.0097 seconds (0.0096 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.0051 ( 58.3%) 0.0001 ( 12.2%) 0.0052 ( 53.8%) 0.0052 ( 53.8%) Canonicalizer 0.0025 ( 29.1%) 0.0005 ( 58.2%) 0.0031 ( 31.9%) 0.0031 ( 32.0%) CSE 0.0011 ( 12.6%) 0.0003 ( 29.7%) 0.0014 ( 14.3%) 0.0014 ( 14.2%) DominanceInfo 0.0087 (100.0%) 0.0009 (100.0%) 0.0097 (100.0%) 0.0096 (100.0%) Total pipeline view (-pass-timing-display=pipeline): * In this mode the results are displayed in a nested pipeline view that mirrors the internal pass pipeline that is being executed in the pass manager. This view is useful for understanding specifically which parts of the pipeline are taking the most time, and can also be used to identify when analyses are being invalidated and recomputed. ===-------------------------------------------------------------------------=== ... Pass execution timing report ... ===-------------------------------------------------------------------------=== Total Execution Time: 0.0082 seconds (0.0081 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.0042 (100.0%) 0.0039 (100.0%) 0.0082 (100.0%) 0.0081 (100.0%) Function Pipeline 0.0005 ( 11.6%) 0.0008 ( 21.1%) 0.0013 ( 16.1%) 0.0013 ( 16.2%) CSE 0.0002 ( 5.0%) 0.0004 ( 9.3%) 0.0006 ( 7.0%) 0.0006 ( 7.0%) (A) DominanceInfo 0.0026 ( 61.8%) 0.0018 ( 45.6%) 0.0044 ( 54.0%) 0.0044 ( 54.1%) Canonicalizer 0.0005 ( 11.7%) 0.0005 ( 13.0%) 0.0010 ( 12.3%) 0.0010 ( 12.4%) CSE 0.0003 ( 6.1%) 0.0003 ( 8.3%) 0.0006 ( 7.2%) 0.0006 ( 7.1%) (A) DominanceInfo 0.0002 ( 3.8%) 0.0001 ( 2.8%) 0.0003 ( 3.3%) 0.0003 ( 3.3%) CSE 0.0042 (100.0%) 0.0039 (100.0%) 0.0082 (100.0%) 0.0081 (100.0%) Total PiperOrigin-RevId: 237825367
OpenPOWER on IntegriCloud