MimIR
0.4-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
split_apply.cpp
Go to the documentation of this file.
1
#include "
mim/plug/gpu/phase/split_apply.h
"
2
3
#include <
mim/driver.h
>
4
5
namespace
mim::plug::gpu::phase
{
6
7
// run extendable pipelines as a phase inspired by optimize.cpp
8
static
void
run_stage
(
World
& world,
flags_t
annex) {
9
const
Def
* stages = world.
annex
(annex);
10
auto
body = stages->as<
Lam
>()->body();
11
auto
callee =
App::uncurry_callee
(body);
12
13
auto
create_phase = world.
driver
().
phase
(callee->flags());
14
if
(!create_phase) fe::throwf(
"no phase registered for stage `{}`; is its plugin loaded?"
, callee);
15
16
auto
stage = (*create_phase)(world);
17
auto
phase
= stage.get()->as<
Phase
>();
18
if
(
auto
app = body->isa<
App
>())
phase
->apply(app);
19
phase
->run();
20
}
21
22
void
SplitApply::start
() {
23
split_phase.run();
24
swap
(
old_world
(), split_phase.old_world());
25
swap
(
new_world
(), split_phase.new_world());
26
27
run_stage
(
old_world
(),
Annex::base<gpu::host_specific_phases>
());
28
run_stage
(
new_world
(),
Annex::base<gpu::device_specific_phases>
());
29
}
30
31
}
// namespace mim::plug::gpu::phase
mim::App
Definition
lam.h:224
mim::App::uncurry_callee
const Def * uncurry_callee() const
Definition
lam.h:326
mim::Def
Base class for all Defs.
Definition
def.h:273
mim::Driver::phase
auto phase(flags_t flags)
Definition
driver.h:191
mim::Lam
A function.
Definition
lam.h:113
mim::Phase
A Phase performs one self-contained task over the whole World.
Definition
phase.h:25
mim::RWPhase::new_world
World & new_world()
Create new Defs into this.
Definition
phase.h:452
mim::RWPhase::old_world
World & old_world()
Get old Defs from here.
Definition
phase.h:451
mim::Rewriter::swap
friend void swap(Rewriter &rw1, Rewriter &rw2) noexcept
Definition
rewrite.h:89
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:40
mim::World::driver
Driver & driver()
Definition
world.h:103
mim::World::annex
const Def * annex(Sym sym)
Lookup annex by Sym.
Definition
world.h:294
mim::plug::gpu::phase::SplitApply::start
void start() final
RWBase::start() and then swaps the two worlds.
Definition
split_apply.cpp:22
driver.h
mim::plug::gpu::phase
Definition
lower_map_reduce.h:7
mim::plug::gpu::phase::run_stage
static void run_stage(World &world, flags_t annex)
Definition
split_apply.cpp:8
mim::flags_t
u64 flags_t
Definition
types.h:39
split_apply.h
mim::Annex::base
static consteval flags_t base()
Definition
plugin.h:250
src
mim
plug
gpu
phase
split_apply.cpp
Generated by
1.18.0