|
AI Engine API User Guide (AIE-API) 2025.2
|
Loading...
Searching...
No Matches
Loop pipelining
Overview
These functions provide the ability to finely control the pipelining of a loop.
Classes | |
| struct | aie::loop_options |
| A structure containing options related to loop iteration peeling. More... | |
Functions | |
| template<unsigned MinIters, loop_options Opts = loop_options{}, typename Fn> | |
| void | aie::peeled_loop (unsigned count, Fn &&fn) |
| Invokes a function object a given number of times, applying peeling at the front and back of the loop. | |
| template<unsigned MinIters, loop_options Opts = loop_options{}, typename Fn> | |
| void | aie::pipelined_loop (unsigned count, Fn &&fn) |
| Invokes a function object a given number of times. | |
| template<unsigned MinIters, loop_options OptsFn1 = loop_options{}, loop_options OptsFn2 = loop_options{}, typename Fn1, typename Fn2> | |
| void | aie::pipelined_loops (unsigned count, Fn1 &&fn1, Fn2 &&fn2) |
| Invokes two function objects a given number of times. | |
Class Documentation
◆ aie::loop_options
| struct aie::loop_options |
A structure containing options related to loop iteration peeling.
To be used with aie::pipelined_loop
Function Documentation
◆ peeled_loop()
template<unsigned MinIters, loop_options Opts = loop_options{}, typename Fn>
| void aie::peeled_loop | ( | unsigned | count, |
| Fn && | fn ) |
Invokes a function object a given number of times, applying peeling at the front and back of the loop.
constexpr unsigned MinIters = 8;
auto loop_body = [&](unsigned idx){ ... };
aie::peeled_loop<MinIters, aie::loop_options{.peel_front = 2, .peel_back = 1}>(n, loop_body);
void peeled_loop(unsigned count, Fn &&fn)
Invokes a function object a given number of times, applying peeling at the front and back of the loop...
Definition utils.hpp:762
A structure containing options related to loop iteration peeling.
Definition utils.hpp:572
- Template Parameters
-
MinIters Lower bound on the number of iterations of the loop body Opts Options related to peeling loop iterations
- Parameters
-
count Number of iterations fn The callable to the function
◆ pipelined_loop()
template<unsigned MinIters, loop_options Opts = loop_options{}, typename Fn>
| void aie::pipelined_loop | ( | unsigned | count, |
| Fn && | fn ) |
Invokes a function object a given number of times.
The pipelining can be controlled by optionally peeling iterations.
constexpr unsigned MinIters = 8;
auto loop_body = [&](unsigned idx){ ... };
aie::pipelined_loop<MinIters, aie::loop_options{.peel_front = 2, .peel_back = 1}>(n, loop_body);
void pipelined_loop(unsigned count, Fn &&fn)
Invokes a function object a given number of times.
Definition utils.hpp:736
- Template Parameters
-
MinIters Lower bound on the number of iterations of the loop body Opts Options related to peeling loop iterations
- Parameters
-
count Number of iterations fn The callable to pipeline
◆ pipelined_loops()
template<unsigned MinIters, loop_options OptsFn1 = loop_options{}, loop_options OptsFn2 = loop_options{}, typename Fn1, typename Fn2>
| void aie::pipelined_loops | ( | unsigned | count, |
| Fn1 && | fn1, | ||
| Fn2 && | fn2 ) |
Invokes two function objects a given number of times.
The pipelining of each can be controlled by optionally peeling iterations.
- Template Parameters
-
MinIters Lower bound on the number of iterations of the loop body OptsFn1 Options related to peeling loop iterations of the first function OptsFn2 Options related to peeling loop iterations of the second function
- Parameters
-
count Number of iterations fn1 The first callable to pipeline fn2 The second callable to pipeline
For example, take the following
constexpr unsigned MinIters = 4;
auto loop_body1 = [&](unsigned idx){ ... };
auto loop_body2 = [&](unsigned idx){ ... };
unsigned n = 16;
aie::pipelined_loops<MinIters, aie::loop_options{.peel_front = 5, .peel_back = 2},
aie::loop_options{.peel_front = 3, .peel_back = 4}>(n, loop_body1, loop_body2);
void pipelined_loops(unsigned count, Fn1 &&fn1, Fn2 &&fn2)
Invokes two function objects a given number of times.
Definition utils.hpp:803
This will result in the following execution:
|stage0 |stage1 |stage2 (main loop) |stage3 |stage4 |
----|-------|-----------|-----------------------------------|-------|-------|
fn1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14| 15| - | - |
fn2 | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14| 15|