1#ifndef PROTEUS_FRONTEND_LOOP_NEST_HPP
2#define PROTEUS_FRONTEND_LOOP_NEST_HPP
50 std::array<std::unique_ptr<LoopBoundInfo<T>>,
51 std::tuple_size_v<
decltype(Loops)>>
55 template <std::size_t...
Is>
56 void setupTiledLoops(std::index_sequence<Is...>) {
61 auto &
Loop = std::get<Is>(Loops);
62 if (
Loop.TileSize.has_value()) {
63 auto &Bounds = std::get<Is>(Loops).Bounds;
65 auto TileIter = Fn.declVar<
T>(
"tile_iter_" + std::to_string(
Is));
66 auto TileStep = Fn.declVar<
T>(
"tile_step_" + std::to_string(
Is));
69 TiledLoopBounds[
Is] = std::make_unique<LoopBoundInfo<T>>(
76 template <std::size_t...
Is>
77 void beginTiledLoops(std::index_sequence<Is...>) {
81 auto &
Loop = std::get<Is>(Loops);
82 if (
Loop.TileSize.has_value()) {
83 auto &Bounds = *TiledLoopBounds[
Is];
84 Fn.beginFor(Bounds.IterVar, Bounds.Init, Bounds.UpperBound,
91 template <std::size_t...
Is>
void emitInnerLoops(std::index_sequence<Is...>) {
95 auto &
Loop = std::get<Is>(Loops);
96 if (
Loop.TileSize.has_value()) {
104 Fn.beginFor(
Loop.Bounds.IterVar,
Loop.Bounds.Init,
105 Loop.Bounds.UpperBound,
Loop.Bounds.Inc);
113 (
void)std::get<Is>(Loops);
119 template <std::size_t...
Is>
void endTiledLoops(std::index_sequence<Is...>) {
123 auto &
Loop = std::get<
sizeof...(Is) - 1U -
Is>(Loops);
124 if (
Loop.TileSize.has_value()) {
131 template <std::size_t...
Is>
132 void tileImpl(
int Tile, std::index_sequence<Is...>) {
133 (std::get<Is>(Loops).tile(
Tile), ...);
138 : Loops(
std::
move(Loops)...), Fn(Fn) {}
Definition LoopNest.hpp:24
ForLoopBuilder(const LoopBoundInfo< T > &Bounds, FuncBase &Fn, BodyLambda &&Body)
Definition LoopNest.hpp:32
FuncBase & Fn
Definition LoopNest.hpp:30
ForLoopBuilder & tile(int Tile)
Definition LoopNest.hpp:35
void emit()
Definition LoopNest.hpp:40
BodyLambda Body
Definition LoopNest.hpp:29
std::optional< int > TileSize
Definition LoopNest.hpp:28
LoopBoundInfo< T > Bounds
Definition LoopNest.hpp:26
T LoopIndexType
Definition LoopNest.hpp:27
void endFor()
Definition Func.cpp:164
void beginFor(Var< T > &IterVar, const Var< T > &InitVar, const Var< T > &UpperBound, const Var< T > &IncVar, const char *File=__builtin_FILE(), int Line=__builtin_LINE())
Definition Func.hpp:309
Definition LoopNest.hpp:12
Var< T > UpperBound
Definition LoopNest.hpp:16
Var< T > Init
Definition LoopNest.hpp:15
Var< T > Inc
Definition LoopNest.hpp:17
Var< T > IterVar
Definition LoopNest.hpp:14
LoopBoundInfo(const Var< T > &IterVar, const Var< T > &Init, const Var< T > &UpperBound, const Var< T > &Inc)
Definition LoopNest.hpp:19
Definition LoopNest.hpp:47
void emit()
Definition LoopNest.hpp:145
LoopNestBuilder(FuncBase &Fn, LoopBuilders... Loops)
Definition LoopNest.hpp:137
LoopNestBuilder & tile(int Tile)
Definition LoopNest.hpp:140
Definition StorageCache.cpp:24
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:114
std::enable_if_t< std::is_arithmetic_v< T >, Var< T > > min(const Var< T > &L, const Var< T > &R)
Definition Func.hpp:1478
Definition Hashing.hpp:147