A Phase performs one self-contained task over the whole World. More...
#include <mim/phase.h>
Public Member Functions | |
Construction & Destruction | |
| Phase (World &world, std::string name) | |
| Phase (World &world, flags_t annex) | |
| virtual | ~Phase ()=default |
| virtual std::unique_ptr< Phase > | recreate () |
| Creates a new instance; needed by a fixed-point PhaseMan. | |
| virtual void | apply (const App *) |
| Invoked if your Phase has additional args. | |
| virtual void | apply (Phase &) |
| Dito, but invoked by Phase::recreate. | |
Redirection | |
A Phase may resolve to a different Phase (or to nothing) after Phase::apply. This is used by the %compile.named stage that resolves a string to another plugin's annex. | |
| virtual bool | redirects () const |
| If true, Phase::create uses take_resolved(). | |
| virtual std::unique_ptr< Phase > | take_resolved () |
| The Phase to use instead; nullptr means elide. | |
Getters | |
| World & | world () |
| Driver & | driver () |
| Log & | log () const |
| std::string_view | name () const |
| flags_t | annex () const |
| const Vector< std::string > & | args () |
| Command-line arguments passed to this Phase's plugin via -X <plugin>:<arg>. | |
Fixed-Point Handling | |
| bool | todo () const |
| void | invalidate (bool todo=true) |
| Signals that another round of fixed-point iteration is required, either as part of. | |
Static Public Member Functions | |
| static std::unique_ptr< Phase > | create (const Flags2Phases &phases, const Def *def) |
| template<class A, class P> | |
| static void | hook (Flags2Phases &phases) |
Protected Attributes | |
| std::string | name_ |
Friends | |
| class | Analysis |
run | |
| virtual void | run () |
| Entry point and generates some debug output; invokes Phase::start. | |
| virtual void | start ()=0 |
| Actual entry. | |
| void | profile_count (std::string_view key, uint64_t n=1) |
Adds n to the custom Profiler counter key of the current run; no-op unless profiling is enabled. | |
| template<class P, class... Args> | |
| static void | run (Args &&... args) |
| Runs a single Phase. | |
A Phase performs one self-contained task over the whole World.
Phases are intended to run in a classical sequence, one after another.
|
inline |
Definition at line 29 of file phase.h.
References name(), name_, and world().
Referenced by mim::Analysis::Analysis(), mim::Analysis::Analysis(), apply(), mim::PhaseMan::apply(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::plug::ll::Emit::Emit(), mim::plug::ll_nvptx::Emit::Emit(), Named::Named(), mim::PhaseMan::PhaseMan(), mim::RWPhase::RWPhase(), mim::RWPhase::RWPhase(), and mim::PhaseMan::start().
|
virtualdefault |
|
inline |
Definition at line 81 of file phase.h.
Referenced by mim::plug::mem::phase::AddMem::AddMem(), mim::Analysis::Analysis(), Named::apply(), mim::plug::autodiff::phase::Eval::augment_pack(), mim::BetaRed::BetaRed(), mim::plug::clos::phase::BranchClosElim::BranchClosElim(), mim::BranchNormalize::BranchNormalize(), mim::Cleanup::Cleanup(), mim::plug::clos::phase::Clos2SJLJ::Clos2SJLJ(), mim::plug::clos::phase::ClosConv::ClosConv(), mim::plug::clos::phase::ClosConvPrep::ClosConvPrep(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::plug::cps::Conv::Conv(), mim::plug::ll::Emit::Emit(), mim::plug::ll_nvptx::Emit::Emit(), mim::EtaConv::EtaConv(), mim::plug::autodiff::phase::Eval::Eval(), mim::plug::tensor::phase::Fuse::Fuse(), mim::LamSpec::LamSpec(), mim::plug::tensor::phase::Lower::Lower(), mim::plug::matrix::phase::LowerAff::LowerAff(), mim::plug::affine::phase::LowerFor::LowerFor(), mim::plug::tensor::phase::LowerGetSet::LowerGetSet(), mim::plug::affine::phase::LowerIndex::LowerIndex(), mim::plug::tensor::phase::LowerMapReduce::LowerMapReduce(), mim::plug::matrix::phase::LowerMatrixHighLevelMapRed::LowerMatrixHighLevelMapRed(), mim::plug::matrix::phase::LowerMatrixMediumLevel::LowerMatrixMediumLevel(), mim::plug::buffer::LowerPtr::LowerPtr(), mim::plug::regex::LowerRegex::LowerRegex(), mim::plug::tensor::phase::LowerToMem::LowerToMem(), mim::plug::clos::phase::LowerTypedClos::LowerTypedClos(), mim::plug::clos::phase::LowerTypedClosPrep::LowerTypedClosPrep(), mim::plug::gpu::phase::MemChecks::MemChecks(), mim::NestPhase< M >::NestPhase(), Phase(), mim::PhaseMan::PhaseMan(), mim::PrefixCleanup::PrefixCleanup(), mim::plug::ll_nvptx::DeviceEmitter::prepare(), recreate(), mim::plug::gpu::phase::RemoveDoubleSyncs::RemoveDoubleSyncs(), mim::Repl::Repl(), mim::RetWrap::RetWrap(), mim::RWPhase::RWPhase(), mim::Scalarize::Scalarize(), mim::plug::mem::phase::SEO::SEO(), mim::plug::gpu::phase::SplitApply::SplitApply(), mim::plug::gpu::phase::SplitOffKernels::SplitOffKernels(), mim::plug::ll_nvptx::Emit::start(), and mim::TailRecElim::TailRecElim().
|
inlinevirtual |
Invoked if your Phase has additional args.
Reimplemented in mim::PhaseMan, mim::PrefixCleanup, and Named.
Definition at line 37 of file phase.h.
Referenced by mim::optimize().
|
inlinevirtual |
Dito, but invoked by Phase::recreate.
Reimplemented in mim::PhaseMan, and mim::PrefixCleanup.
Definition at line 38 of file phase.h.
References Phase().
| const Vector< std::string > & mim::Phase::args | ( | ) |
Command-line arguments passed to this Phase's plugin via -X <plugin>:<arg>.
Derived from Phase::annex; yields an empty Vector for name-constructed Phases.
Definition at line 23 of file phase.cpp.
References mim::Driver::args(), mim::Annex::demangle(), driver(), and mim::Annex::flags2plugin().
Referenced by mim::PhaseMan::apply(), mim::plug::ll::Emitter::declare(), mim::plug::ll::Emitter::declare_rt(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::plug::buffer::LowerPtr::rewrite_imm_App(), mim::plug::matrix::phase::LowerMatrixMediumLevel::rewrite_imm_App(), mim::plug::mem::phase::AddMem::rewrite_imm_App(), run(), mim::plug::ll::Emit::start(), and mim::plug::ll_nvptx::Emit::start().
|
inlinestatic |
Definition at line 50 of file phase.h.
References mim::App::uncurry_callee(), mim::Def::world(), and world().
Referenced by mim::PhaseMan::apply(), Named::apply(), and mim::plug::ll_nvptx::Emit::start().
|
inline |
Definition at line 78 of file phase.h.
References mim::World::driver(), and world().
Referenced by mim::PhaseMan::apply(), Named::apply(), args(), mim::plug::ll::Emitter::Emitter(), mim::plug::ll::Emitter::load_rt_module(), profile_count(), recreate(), run(), mim::PhaseMan::start(), mim::plug::ll_nvptx::Emit::start(), and mim::RWPhase::start().
|
inlinestatic |
Definition at line 70 of file phase.h.
References mim::assert_emplace(), and mim::Annex::base().
Referenced by mim::plug::buffer::reg_phases(), mim::plug::tensor::reg_phases(), reg_phases(), reg_phases(), and reg_phases().
|
inline |
Signals that another round of fixed-point iteration is required, either as part of.
Calling invalidate(todo) bitwise-ORs todo into the internal todo_ flag.
Definition at line 98 of file phase.h.
References todo().
Referenced by mim::EtaConv::rewrite(), mim::BetaRed::rewrite_imm_App(), mim::Scalarize::rewrite_imm_Pi(), mim::Analysis::start(), and mim::PhaseMan::start().
|
inline |
Definition at line 79 of file phase.h.
References mim::Log::log().
|
inline |
Definition at line 80 of file phase.h.
References name_.
Referenced by mim::Analysis::Analysis(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::Emitter< std::string, std::string, BB, Emitter >::Emitter(), mim::plug::ll::Emitter::Emitter(), mim::plug::ll_nvptx::DeviceEmitter::isa_targetspecific_intrinsic(), mim::plug::ll_nvptx::HostEmitter::isa_targetspecific_intrinsic(), mim::NestPhase< M >::NestPhase(), Phase(), mim::plug::ll::Emitter::prepare(), mim::plug::ll_nvptx::DeviceEmitter::prepare(), run(), mim::RWPhase::RWPhase(), mim::plug::gpu::phase::SplitOffKernels::SplitOffKernels(), mim::PhaseMan::start(), mim::plug::ll::Emit::start(), mim::plug::ll_nvptx::Emit::start(), mim::plug::ll_nvptx::HostEmitter::start(), and mim::RWPhase::start().
| void mim::Phase::profile_count | ( | std::string_view | key, |
| uint64_t | n = 1 ) |
Adds n to the custom Profiler counter key of the current run; no-op unless profiling is enabled.
Definition at line 43 of file phase.cpp.
References mim::Profiler::count(), driver(), mim::Flags::None, and mim::Driver::profiler().
Referenced by mim::EtaConv::rewrite(), mim::BetaRed::rewrite_imm_App(), mim::plug::mem::phase::SEO::rewrite_imm_App(), mim::Analysis::start(), and mim::PhaseMan::start().
|
virtual |
|
inlinevirtual |
If true, Phase::create uses take_resolved().
Reimplemented in Named.
|
virtual |
Entry point and generates some debug output; invokes Phase::start.
Definition at line 34 of file phase.cpp.
References driver(), mim::Driver::flags(), name(), mim::Flags::None, mim::Flags::profile, mim::Driver::profiler(), start(), mim::Profiler::start(), mim::Profiler::stop(), mim::World::verify(), and world().
Referenced by mim::sexpr::emit(), mim::plug::ll_nvptx::emit_device(), mim::plug::ll_nvptx::emit_host(), mim::sexpr::emit_slotted(), mim::sexpr::emit_slotted_typed(), mim::sexpr::emit_typed(), and mim::plug::ll_nvptx::Emit::start().
|
inlinestatic |
|
pure virtual |
Actual entry.
Implemented in mim::Analysis, mim::ClosedMutPhase< M >, mim::ClosedMutPhase< Def >, mim::ClosedMutPhase< Lam >, mim::PhaseMan, mim::plug::clos::phase::ClosConv, mim::plug::clos::phase::LowerTypedClos, mim::plug::gpu::phase::SplitApply, mim::plug::gpu::phase::SplitOffKernels, mim::plug::ll::Emit, mim::plug::ll::Emitter, mim::plug::ll_nvptx::DeviceEmitter, mim::plug::ll_nvptx::Emit, mim::plug::ll_nvptx::HostEmitter, mim::plug::mem::phase::AddMem, mim::plug::tensor::phase::LowerToMem, mim::RWPhase, mim::sexpr::Emitter, and Named.
Referenced by run(), mim::plug::ll::Emitter::start(), and mim::sexpr::Emitter::start().
|
inlinevirtual |
|
inline |
Definition at line 90 of file phase.h.
Referenced by invalidate(), mim::Repl::rewrite(), mim::Analysis::start(), mim::PhaseMan::start(), and mim::RWPhase::start().
|
inline |
Definition at line 77 of file phase.h.
Referenced by Named::apply(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::plug::ll::Emitter::convert_ret_pi(), create(), mim::plug::ll_nvptx::DeviceEmitter::DeviceEmitter(), driver(), mim::plug::ll::Emit::Emit(), mim::plug::ll_nvptx::Emit::Emit(), mim::sexpr::Emitter::emit_decl(), mim::plug::ll_nvptx::emit_device(), mim::plug::ll_nvptx::emit_host(), mim::Emitter< std::string, std::string, BB, Emitter >::Emitter(), mim::plug::ll::Emitter::Emitter(), mim::sexpr::Emitter::Emitter(), mim::plug::ll_nvptx::HostEmitter::HostEmitter(), mim::plug::ll_nvptx::HostEmitter::isa_targetspecific_intrinsic(), mim::plug::ll::Emitter::load_rt_module(), mim::NestPhase< M >::NestPhase(), mim::NestPhase< M >::NestPhase(), mim::RWPhase::old_world(), Phase(), Phase(), mim::PhaseMan::PhaseMan(), mim::plug::ll_nvptx::DeviceEmitter::prepare(), recreate(), run(), mim::ClosedMutPhase< M >::start(), mim::plug::ll::Emit::start(), mim::plug::ll_nvptx::DeviceEmitter::start(), mim::plug::ll_nvptx::Emit::start(), and mim::plug::ll_nvptx::HostEmitter::start().
|
friend |
Definition at line 125 of file phase.h.
References Analysis.
Referenced by Analysis, mim::RWPhase::analysis(), mim::RWPhase::analysis(), mim::RWPhase::RWPhase(), and mim::RWPhase::RWPhase().
|
protected |
Definition at line 123 of file phase.h.
Referenced by mim::PhaseMan::apply(), mim::PrefixCleanup::apply(), name(), Phase(), and Phase().