AI Engine API User Guide (AIE-API) 2025.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
Uility functions and classes

Overview

Topics

 Print functions
 These functions provide an abstraction on top of printf that allow users to display the contents of AIE types in the standard output.
 
 Loop unrolling functions
 These functions allow users to explicitly unroll the body of a loop.
 

Classes

struct  aie::arch
 Structure used to represent the AIE architecture being compiled against. More...
 

Functions

template<unsigned Reg = (unsigned)-1, AIE_RegFile RegFile = AIE_RegFile::Default, typename T>
auto aie::utils::locate_in_register (T &&val)
 Binds a variable to a specified register.
 
template<unsigned StartIdx = 0, unsigned N, AIE_RegFile RegFile = AIE_RegFile::Default, typename T>
void aie::utils::locate_in_register (T(&arr)[N])
 Binds each variable in an array to sequential registers, starting from the specified register.
 
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::arch

struct aie::arch

Structure used to represent the AIE architecture being compiled against.

Public Types

enum  ArchGeneration : unsigned
 An enum defining available AIE generations, which are defined as: More...
 
enum  ArchVersion : unsigned
 An enum defining available AIE architectures. More...
 

Static Public Member Functions

template<typename... T>
requires (std::is_same_v<T, ArchGeneration> && ...)
static constexpr bool is (T... gens)
 Checks if the current AIE architecture version against the supplied generation pack.
 
template<typename... T>
requires (std::is_same_v<T, ArchVersion> && ...)
static constexpr bool is (T... vs)
 Checks if the current AIE architecture version against the supplied pack.
 

Static Public Attributes

static constexpr ArchGeneration generation = ArchGeneration(__AIE_ARCH__ / 10)
 Represents the current AIE generation.
 
static constexpr ArchVersion version = ArchVersion(__AIE_ARCH__)
 Represents the current AIE architecture version.
 

Member Enumeration Documentation

◆ ArchGeneration

enum aie::arch::ArchGeneration : unsigned

An enum defining available AIE generations, which are defined as:

  • Gen1: AIE
  • Gen2: AIE-ML/XDNA 1, XDNA_2
Enumerator
Gen1 
Gen2 

◆ ArchVersion

enum aie::arch::ArchVersion : unsigned

An enum defining available AIE architectures.

Enumerator
AIE 
AIE_ML 
XDNA_2 

Member Function Documentation

◆ is() [1/2]

template<typename... T>
requires (std::is_same_v<T, ArchGeneration> && ...)
static constexpr bool aie::arch::is ( T... gens)
inlinestaticconstexpr

Checks if the current AIE architecture version against the supplied generation pack.

Parameters
vsA pack of ArchGenerations to test the current version against

◆ is() [2/2]

template<typename... T>
requires (std::is_same_v<T, ArchVersion> && ...)
static constexpr bool aie::arch::is ( T... vs)
inlinestaticconstexpr

Checks if the current AIE architecture version against the supplied pack.

Parameters
vsA pack of ArchVersions to test the current version against

Member Data Documentation

◆ generation

ArchGeneration aie::arch::generation = ArchGeneration(__AIE_ARCH__ / 10)
staticconstexpr

Represents the current AIE generation.

◆ version

ArchVersion aie::arch::version = ArchVersion(__AIE_ARCH__)
staticconstexpr

Represents the current AIE architecture version.

Function Documentation

◆ locate_in_register() [1/2]

template<unsigned Reg = (unsigned)-1, AIE_RegFile RegFile = AIE_RegFile::Default, typename T>
auto aie::utils::locate_in_register ( T && val)

Binds a variable to a specified register.

Template Parameters
RegNumeric identifier of register to bind variable to.
RegFileWhich register file to locate the variable in.
Parameters
val

The value to be placed. This may be an aie::vector, aie::accum, or scalar value.

aie::vector<int32, 16> v; aie::utils::locate_in_register<4>(v) This will place v in x4 on AIE-ML.

◆ locate_in_register() [2/2]

template<unsigned StartIdx = 0, unsigned N, AIE_RegFile RegFile = AIE_RegFile::Default, typename T>
void aie::utils::locate_in_register ( T(&) arr[N])

Binds each variable in an array to sequential registers, starting from the specified register.

Template Parameters
RegNumeric identifier of register to bind the first variable to.
RegFileWhich register file to locate the variable in.
Parameters
val

The value to be placed. This may be an aie::vector, aie::accum, or scalar value.

std::array<aie::vector<int32, 16>, 3> vs; aie::utils::locate_in_register<4>(vs) This will place vs[0] in x4 and vs[1] in x5, and vs[2] in x6 on AIE-ML.

◆ 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.

Template Parameters
MinItersLower bound on the number of iterations of the loop body
OptsOptions related to peeling loop iterations
Parameters
countNumber of iterations
fn

The callable to pipeline

constexpr unsigned MinIters = 8; auto loop_body = [&](unsigned idx){ ... }; aie::pipelined_loop<MinIters, aie::LoopOptions{.peel_front = 2, .peel_back = 1}>(n, loop_body);

◆ 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
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::LoopOptions{.peel_front = 5, .peel_back = 2}, aie::LoopOptions{.peel_front = 3, .peel_back = 4}>(n, loop_body1, loop_body2);

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|

```