constraint<T> - 2024.1 English

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
Release Date
2024.1 English

This template class is used to build scalar data constraints on kernels, connections, and ports.


A constraint must appear inside a graph constructor.

Member Functions

constraint<T> operator=(T)

This overloaded equality operator allows you to assign a value to a scalar constraint.


The default constructor is not used. Instead the following special constructors are used with specific meaning.

constraint<std::string>& initialization_function(kernel&)

This constraint allows you to set a specific initialization function for each kernel. The constraint expects a string denoting the name of the initialization function. Where multiple kernels are packed on a core, each initialization function packed on the core is called exactly once. No kernel functions are scheduled until all the initialization functions packed on a core are completed.

An initialization function cannot return a value and cannot have input/output arguments, that is, the function prototype must be as follows.

void init_function_name(void)
Note: The initialization function is called only once when the first graph::run API is called.

This function can be used to initialize global variables and set or clear rounding and saturation modes. It cannot use buffer or stream APIs to access memory or stream interfaces, but stream intrinsics (for example, get_ss()) can be used.

constraint<float>& runtime<ratio>(kernel&)

This constraint allows you to set a specific core usage fraction for a kernel. This is computed as a ratio of the number of cycles taken by one invocation of a kernel (processing one block of data) to the cycle budget. The cycle budget for an application is typically fixed according to the expected data throughput and the block size being processed.

constraint<std::string>& source(kernel&)

This constraint allows you to specify the source file containing the definition of each kernel function. A source constraint must be specified for each kernel.

constraint<int>& fifo_depth(connect&)=[<depth> | (depth)]

This constraint allows you to specify the amount of slack to be inserted on a streaming connection to allow deadlock free execution.

void single_buffer(port<T>&)

This constraint allows you to specify single buffer constraint on a buffer port. By default, a buffer port is double buffered.

 constraint<int> num_buffers(adf::shared_buffer_base& sb)

This constraint allows you to specify the number of buffers that will compose a shared buffer. By default, a shared buffer is single buffered, you can set the number of buffers to two to get a ping-pong buffer implementation. A higher number can be set to absorb a large difference in between write and read rate.

template <typename _XILINX_ADF_T=api_impl::variant>
    constraint<_XILINX_ADF_T> initial_value(adf::port<adf::input>& p);

This constraint allows you to set the initial value for an asynchronous AI Engine-ML input runtime parameter port. It allows the destination kernel to start asynchronously with the specified initial value. You can set both scalar and array runtime parameters using this constraint.

Example scalar: initial_value([1])=6;.

Example array: initial_value([2])={1,2,3};

constraint<int> stack_size(adf::kernel& k);

This constraint allows you to set stack size for individual kernel.

constraint<int> heap_size(adf::kernel& k);

This constraint allows you to set heap size for individual kernel.