aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Pass/PassTiming.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-15[mlir] Remove unused includes (NFC) (#148872)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2024-09-20[MLIR] Fix crash when using --mlir-timing (#109463)Ian Wood1-3/+3
2023-01-14[mlir] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-2/+2
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-13[mlir] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-09-07[mlir:PassTiming] Always use parentInfo for determining pipeline parent scopeRiver Riddle1-10/+7
This fixes a bug where, depending on thread usage, a pipeline may be misattributed to a timer that wasn't it's parent. Differential Revision: https://reviews.llvm.org/D132979
2022-05-12[mlir:Pass] Add support for op-agnostic pass managersRiver Riddle1-4/+9
This commit refactors the current pass manager support to allow for operation agnostic pass managers. This allows for a series of passes to be executed on any viable pass manager root operation, instead of one specific operation type. Op-agnostic/generic pass managers only allow for adding op-agnostic passes. These types of pass managers are extremely useful when constructing pass pipelines that can apply to many different types of operations, e.g., the default inliner simplification pipeline. With the advent of interface/trait passes, this support can be used to define FunctionOpInterface pass managers, or other pass managers that effectively operate on specific interfaces/traits/etc (see #52916 for an example). Differential Revision: https://reviews.llvm.org/D123536
2021-11-16[mlir][NFC] Replace references to Identifier with StringAttrRiver Riddle1-2/+2
This is part of the replacement of Identifier with StringAttr. Differential Revision: https://reviews.llvm.org/D113953
2021-05-12[MLIR] Factor pass timing out into a dedicated timing managerFabian Schuiki1-420/+112
This factors out the pass timing code into a separate `TimingManager` that can be plugged into the `PassManager` from the outside. Users are able to provide their own implementation of this manager, and use it to time additional code paths outside of the pass manager. Also allows for multiple `PassManager`s to run and contribute to a single timing report. More specifically, moves most of the existing infrastructure in `Pass/PassTiming.cpp` into a new `Support/Timing.cpp` file and adds a public interface in `Support/Timing.h`. The `PassTiming` instrumentation becomes a wrapper around the new timing infrastructure which adapts the instrumentation callbacks to the new timers. Reviewed By: rriddle, lattner Differential Revision: https://reviews.llvm.org/D100647
2020-12-14[mlir][Inliner] Refactor the inliner to use nested pass pipelines instead of ↵River Riddle1-10/+7
just canonicalization Now that passes have support for running nested pipelines, the inliner can now allow for users to provide proper nested pipelines to use for optimization during inlining. This revision also changes the behavior of optimization during inlining to optimize before attempting to inline, which should lead to a more accurate cost model and prevents the need for users to schedule additional duplicate cleanup passes before/after the inliner that would already be run during inlining. Differential Revision: https://reviews.llvm.org/D91211
2020-09-02Use an Identifier instead of an OperationName internally for OpPassManager ↵Mehdi Amini1-5/+5
identification (NFC) This allows to defers the check for traits to the execution instead of forcing it on the pipeline creation. In particular, this is making our pipeline creation tolerant to dialects not being loaded in the context yet. Reviewed By: rriddle, GMNGeoffrey Differential Revision: https://reviews.llvm.org/D86915
2020-04-29[mlir][Pass][NFC] Merge OpToOpPassAdaptor and OpToOpPassAdaptorParallelRiver Riddle1-12/+9
This moves the threading check to runOnOperation. This produces a much cleaner interface for the adaptor pass, and will allow for the ability to enable/disable threading in a much cleaner way in the future. Differential Revision: https://reviews.llvm.org/D78313
2020-04-28Make MLIR Pass Timing output configurable through injectionMehdi Amini1-26/+41
This makes it possible for the client to control where the pass timings will be printed. Differential Revision: https://reviews.llvm.org/D78891
2020-04-10[mlir][NFC] Refactor ClassID into a TypeID class.River Riddle1-6/+6
Summary: ClassID is a bit janky right now as it involves passing a magic pointer around. This revision hides the internal implementation mechanism within a new class TypeID. This class is a value-typed wrapper around the original ClassID implementation. Differential Revision: https://reviews.llvm.org/D77768
2020-04-05[mlir] NFC: Fix trivial typoKazuaki Ishizaki1-1/+1
Differential Revision: https://reviews.llvm.org/D77473
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-1/+1
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-26Mass update the MLIR license header to mention "Part of the LLVM project"Mehdi Amini1-1/+1
This is an artifact from merging MLIR into LLVM, the file headers are now aligned with the rest of the project.
2019-12-23Adjust License.txt file to use the LLVM licenseMehdi Amini1-13/+4
PiperOrigin-RevId: 286906740
2019-12-18NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle1-8/+7
in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
2019-12-06minor spelling tweaksKazuaki Ishizaki1-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
2019-12-05Add support for instance specific pass statistics.River Riddle1-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
2019-10-20Fix minor spelling tweaks (NFC)Kazuaki Ishizaki1-3/+3
Closes tensorflow/mlir#177 PiperOrigin-RevId: 275692653
2019-09-30Pass the pointer of the parent pipeline collection pass to ↵River Riddle1-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
2019-09-23Fix a number of Clang-Tidy warnings.Christian Sigg1-3/+4
PiperOrigin-RevId: 270632324
2019-09-14NFC: Pass PassInstrumentations by unique_ptr instead of raw pointer.River Riddle1-1/+1
This makes the ownership model explicit, and removes potential user errors. PiperOrigin-RevId: 269122834
2019-09-09Add support for coalescing adjacent nested pass pipelines.River Riddle1-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
2019-09-08Refactor PassTiming to support nested pipelines.River Riddle1-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
2019-09-02Refactor the pass manager to support operations other than FuncOp/ModuleOp.River Riddle1-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
2019-08-16NFC: Refactor the PassInstrumentation framework to operate on Operation ↵River Riddle1-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
2019-05-10 Replace dyn_cast<> with isa<> when the returned value is unused (NFC)Mehdi Amini1-2/+1
Fix a gcc warning. -- PiperOrigin-RevId: 247669360
2019-04-01 Update variable in PassTiming to refer to system_clock instead of ↵River Riddle1-1/+1
high_resolution_clock. -- PiperOrigin-RevId: 241260071
2019-03-29Add support for multi-threaded pass timing.River Riddle1-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
2019-03-29Add experimental support for multi-threading the pass manager. This adds ↵River Riddle1-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
2019-03-29Replace the usages of llvm::Timer in PassTiming in favor of a simple nested ↵River Riddle1-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
2019-03-29Add an instrumentation for conditionally printing the IR before and after ↵River Riddle1-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
2019-03-29Refactor pass timing so that it is toggled on the passmanager via ↵River Riddle1-5/+76
'enableTiming'. This also makes the pipeline view the default display mode. PiperOrigin-RevId: 238079916
2019-03-29Add a new instrumentation for timing pass and analysis execution. This is ↵River Riddle1-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