During the link phase, the tool connects the memory ports of the kernels to memory resources such as DDR, LPDDR, and PLRAM.
By default, all kernel memory interfaces connect to the same global
memory bank (or gmem). As a result, only one kernel
interface can transfer data to or from the memory bank at one time, which limits application
performance due to memory access contention.
Explicitly specify which global memory bank each kernel argument (or interface) connects to. Correct kernel-to-memory connectivity maximizes bandwidth, optimizes data transfers, and improves overall performance. Even if the design contains only one compute unit, mapping its input and output arguments to different global memory banks can improve performance by enabling simultaneous access to input and output data.
The following block diagram illustrates how a kernel connects to two separate global memory banks. The input pointer interface connects to DDR bank 0, and the output pointer interface connects to DDR bank 1.
--connectivity.sp option to
distribute connections across different memory banks as described in this topic.Start by assigning the kernel arguments to separate bundles to increase the available interface ports, then assign the arguments to separate memory banks. The following example uses the interfaces described in HW Interfaces in the Data Center Acceleration using Vitis (UG1700).
- In the C/C++ kernel code, assign arguments to separate bundles using
the INTERFACE pragma before compiling:
In this example, thevoid cnn( int *pixel, // Input pixel int *weights, // Input Weight Matrix int *out, // Output pixel ... // Other input or Output ports #pragma HLS INTERFACE m_axi port=pixel offset=slave bundle=gmem #pragma HLS INTERFACE m_axi port=weights offset=slave bundle=gmem1 #pragma HLS INTERFACE m_axi port=out offset=slave bundle=gmemcnnkernel has three arguments:pixel,weights, andout. Using the bundle attribute of the INTERFACE pragma, each argument maps to a specific interface. Thepixelandoutarguments both map to the same interface namedgmem. The weights argument maps to a different interface namedgmem1. The kernel therefore has two distinct interfaces (gmemandgmem1), which can connect to different memory banks.Important: Specifybundle=names using all lowercase characters to assign them to a specific memory bank using the--connectivity.spoption. - Use the
--connectivity.spoption, or include it in a config file, as described in --connectivity Options .For example, for thecnnkernel shown above, theconnectivity.spoption in the config file is as follows:[connectivity] #sp=<compute_unit_name>.<argument>:<bank name> sp=cnn_1.pixel:DDR[0] sp=cnn_1.weights:PLRAM[0] sp=cnn_1.out:DDR[0] #sp=<aie_instance>.<gmio_port>:<memory_sp_tag_name>[bank_number] sp=ai_engine_0.my_gmio:LPDDR[0]Where:
-
<compute_unit_name>is an instance name of the CU as determined by theconnectivity.nkoption, described in Creating Multiple Instances of a Kernel, or is simply<kernel_name>_1if multiple CUs are not specified. -
<argument>is the name of the kernel argument. You can also specify the kernel interface name as defined by the HLS INTERFACE pragma for C/C++ kernels, includingm_axi_and thebundlename. In thecnnkernel above, the ports arem_axi_gmemandm_axi_gmem1.Tip: For RTL kernels, the interface name comes from the kernel.xml file. -
<bank_name>is denoted asDDR[0],DDR[1],DDR[2], andDDR[3]for a platform with four DDR banks.Some platforms also support LPDDR, PLRAM, or HBM memory. Use
LPDDR[0],PLRAM[0], orHBM[0]accordingly. Use theplatforminfoutility to list the global memory banks available for a specified platform. Refer to platforminfo Utility in the Vitis Reference Guide (UG1702) for more information.On platforms that include both DDR and HBM memory banks, kernels must use separate AXI interfaces to access the different memories. DDR and PLRAM access can share a single port.
Note: The SP tag name is declared in the Vivado block design as part of the platform properties. You can customize SP tag names to identify specific memory controllers.Tip: Assigning kernel interfaces to specific memory banks might also require you to specify the SLR placement for the kernel.
-
Use the Device Hardware Transaction view in Vitis Analyzer to observe DDR bank communication and analyze DDR usage.