AI Engine API User Guide (AIE-API) 2025.1
Loading...
Searching...
No Matches

Overview

These functions provide the ability to finely control the pipelining of a loop.

Classes

struct  aie::LoopOptions
 A structure containing options related to loop iteration peeling. More...
 

Functions

template<unsigned MinIters, LoopOptions Opts = LoopOptions{}, typename Fn>
void aie::pipelined_loop (unsigned count, Fn &&fn)
 Invokes a function object a given number of times.
 
template<unsigned MinIters, LoopOptions OptsFn1 = LoopOptions{}, LoopOptions OptsFn2 = LoopOptions{}, 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::LoopOptions

struct aie::LoopOptions

A structure containing options related to loop iteration peeling.

To be used with aie::pipelined_loop

Class Members
unsigned peel_back = 0 The number of iterations to peel at the back of the loop.
unsigned peel_front = 0 The number of iterations to peel at the front of the loop.
int preamble_offset = 0 Adjust the preamble.

Function Documentation

◆ pipelined_loop()

template<unsigned MinIters, LoopOptions Opts = LoopOptions{}, 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::LoopOptions{.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:602
A structure containing options related to loop iteration peeling.
Definition utils.hpp:571
Template Parameters
MinItersLower bound on the number of iterations of the loop body
OptsOptions related to peeling loop iterations
Parameters
countNumber of iterations
fnThe callable to pipeline

◆ pipelined_loops()

template<unsigned MinIters, LoopOptions OptsFn1 = LoopOptions{}, LoopOptions OptsFn2 = LoopOptions{}, 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
MinItersLower bound on the number of iterations of the loop body
OptsFn1Options related to peeling loop iterations of the first function
OptsFn2Options related to peeling loop iterations of the second function
Parameters
countNumber of iterations
fn1The first callable to pipeline
fn2The 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::LoopOptions{.peel_front = 5, .peel_back = 2},
aie::LoopOptions{.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:685

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|