set_directive_array_partition - 2021.1 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2021-06-16
Version
2021.1 English

Description

Important: Array_Partition and Array_Reshape pragmas and directives are not supported for M_AXI Interfaces on the top-level function. Instead you can use the hls::vector data types as described in Vector Data Types.

Partitions an array into smaller arrays or individual elements.

This partitioning:
  • Results in RTL with multiple small memories or multiple registers instead of one large memory.
  • Effectively increases the amount of read and write ports for the storage.
  • Potentially improves the throughput of the design.
  • Requires more memory instances or registers.

Syntax

set_directive_array_partition [OPTIONS] <location> <array>
  • <location> is the location (in the format function[/label]) which contains the array variable.
  • <array> is the array variable to be partitioned.

Options

-dim <integer>
Note: Relevant for multi-dimensional arrays only.
Specifies which dimension of the array is to be partitioned.
  • If a value of 0 is used, all dimensions are partitioned with the specified options.
  • Any other value partitions only that dimension. For example, if a value 1 is used, only the first dimension is partitioned.
-factor <integer>
Note: Relevant for type block or cyclic partitioning only.
Specifies the number of smaller arrays that are to be created.
-type (block|cyclic|complete)
  • block partitioning creates smaller arrays from consecutive blocks of the original array. This effectively splits the array into N equal blocks where N is the integer defined by the -factor option.
  • cyclic partitioning creates smaller arrays by interleaving elements from the original array. For example, if -factor 3 is used:
    • Element 0 is assigned to the first new array.
    • Element 1 is assigned to the second new array.
    • Element 2 is assigned to the third new array.
    • Element 3 is assigned to the first new array again.
  • complete partitioning decomposes the array into individual elements. For a one-dimensional array, this corresponds to resolving a memory into individual registers. For multi-dimensional arrays, specify the partitioning of each dimension, or use -dim 0 to partition all dimensions.
The default is complete.

Example 1

Partitions array AB[13] in function func into four arrays. Because four is not an integer factor of 13:

  • Three arrays have three elements.
  • One array has four elements (AB[9:12]).
set_directive_array_partition -type block -factor 4 func AB

Partitions array AB[6][4] in function func into two arrays, each of dimension [6][2].

set_directive_array_partition -type block -factor 2 -dim 2 func AB

Partitions all dimensions of AB[4][10][6] in function func into individual elements.

set_directive_array_partition -type complete -dim 0 func AB

Example 2

Partitioned arrays can be addressed in your code by the new structure of the array, as shown in the following code example;

struct SS
{
  int x[N];
  int y[N];
};
  
int top(SS *a, int b[4][6], SS &c) {...}

set_directive_array_partition top b -type complete -dim 1
set_directive_interface -mode ap_memory top b[0]
set_directive_interface -mode ap_memory top b[1]
set_directive_interface -mode ap_memory top b[2]
set_directive_interface -mode ap_memory top b[3]