High Bandwidth Memory (or HBM) provides high bandwidth by splitting arrays into different banks/pseudo-channels in the design. This is a common practice in partitioning an array into different memory regions in high-performance computing. The software application interacting with the hardware allocates a single buffer, which will be spread across the pseudo-channels.
Enabling Dependence Analysis on Different Arguments
Vitis HLS considers different pointers to be
independent channels, and removes any dependency analysis. But the software
application allocates a single buffer for both pointers, and this lets the tool
maintain dependency analysis through pragma HLS
ALIAS
. The ALIAS pragma informs data dependence analysis about the
pointer distance. Refer to the ALIAS pragma
or directive for more information.
arg0
is allocated in
bank0
and kernel arg1
is allocated in
bank1
. The pointer distance should be specified in the distance
option of the ALIAS pragma as shown below:
//Assume that the host code looks like this:
int *buf = clCreateBuffer(ctxt, CL_MEM_READ_ONLY, 2*bank_size, ...);
clSetKernelArg(kernel, 0, 0x20000000, buf); // bank0
clSetKernelArg(kernel, 1, 0x20000000, buf+bank_size); // bank1
//The ALIAS pragma informs data dependence analysis about the pointer distance
void kernel(int *bank0, int *bank1, ...)
{
#pragma HLS alias ports=bank0,bank1 distance=bank_size
The ALIAS pragma can be specified using one of the following forms:
- Constant distance:
#pragma HLS alias ports=arr0,arr1,arr2,arr3 distance=1024
- Variable
distance:
#pragma HLS alias ports=arr0,arr1,arr2,arr3 offset=0,512,1024,2048
Constraints:
- The depths of all the ports in the interface pragma must be the same
- All ports must be assigned to different bundles, bound to different HBM controllers
-
The number of ports specified in the second form must be the same as the number of offsets specified, one offset per port.
#pragma HLS interface offset=off
is not supported - Each port can only be used in one ALIAS pragma