| AI Engine API User Guide (AIE-API) 2025.2

Loading...
Searching...
No Matches
Functions
Register pinning
Uility functions and classes » Non-portable optimizations

## Overview

These functions provide a semi-portable interface to pin variables, such as vectors, accumulators, masks, and pointers, to a given register/set of registers.

## Functions
template<unsigned Reg = (unsigned)-1, AIE_RegFile RegFile = AIE_RegFile::Default, typename T>
auto | aie::utils::locate_in_register (T &&val)
| Binds a value 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.

## 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 value to a specified register.

The type and size of the value determines the type of register and the template parameter `Reg` selects which specific register to bind it to.

Template Parameters

  Reg | Numeric identifier of the register the value will be bound to.
  RegFile | Register file to locate the value.

Parameters

  val | The value to be pinned. This may be an aie::vector, aie::accum, or scalar value.

Example:

aie::vector<int32, 16> v;
aie::utils::locate_in_register<4>(v)
aie::vector
Type for vector registers.
Definition vector.hpp:79
aie::utils::locate_in_register
auto locate_in_register(T &&val)
Binds a value to a specified register.
Definition utils.hpp:956

This will bind `v` to register `x4` on AIE-ML:

- `Reg` template parameter is set to `4`.
- `v` is a vector of 512bit, so it will bind to a `x` 512bit vector register.

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

  Reg | Numeric identifier of register to bind the first variable to.
  RegFile | Which register file to locate the variable in.

Parameters

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

Example:

aie::vector<int32, 16> vs[3];
aie::utils::locate_in_register<4>(vs)

This will bind `vs[0]` to `x4`, `vs[1]` to `x5` and `vs[2]` to `x6` on AIE-ML.

See also
  locate_in_register(T&&)