当前位置:网站首页>开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
2022-07-02 22:01:00 【碎碎思】
本文作者:赛灵思产品应用工程师 Wen Chen
Vitis HLS 在从Vivaido HLS的升级换代中,以axi_master接口为起点的设计正在变得更易上手,其中很重要的一点就是更多的MAXI端口设计参数可以让用户通过指令传达到。这些参数可以分为两类:
静态参数指标:这些参数会影响内存性能,可以在 C 综合期间的编译时从编译的结果中很清楚地知道,突发读写地长度、数据端口宽度加宽、对齐等。
动态参数指标:这些参数本质上是动态的,取决于系统。例如,与 DDR/HBM 的通信效率在C综合编译时是未知的。
本文给大家提供利用axi_master接口指令端的几个静态参数的优化技巧,从扩展总线接口数量,扩展总线位宽,循环展开等角度入手。最核心的优化思想就是以资源面积换取高带宽的以便并行计算。
熟记这本文几个关键的设计点,让你的HLS内核接口效率不再成为设计的瓶颈!
以上代码在进行了c综合后,我们所有的指针变量都会依据指令的设置映射到axi-master上,但是因为根据指令中所有的端口都绑定到了一条总线gmem上。所以在综合的警告里面会提示:
WARNING: [HLS 200-885] The II Violation in module 'example_Pipeline_VITIS_LOOP_55_1' (loop 'VITIS_LOOP_55_1'): Unable to schedule bus request operation ('gmem_load_1_req', example.cpp:56) on port 'gmem' (example.cpp:56) due to limited memory ports (II = 1). Please consider using a memory core with more ports or partitioning the array.
因为在axi-master总线上最高只能支持一个读入和一个写出同时进行,如果绑定到一条总线则无法同时从总线读入两个数据,所以最终的循环的II=2。解决这个问题的方法就是用面积换速度,我们实例化两条axi总线gmem和gmem0,最终达到II=1。
当总线数量满足了我们并行读入的要求后,读取数据的位宽就成为了我们优化的方向:
因为读取的数据格式是int类型,所以这里的数据位宽就是32bit。
为了能够转移数据传输瓶颈,在Vitis kernel target flow中,数据位宽在512bit的时候能够达到最高的数据吞吐效率。在Vitis HLS 中的新增了 max_widen_bitwidth 选项来自动将较短的数据位宽拼接到设定的较长的数据位宽选项。在这里我们可以将位宽设置到512bit的位宽,但是同时要向编译器说明,原数据位宽和指定的扩展位宽成整数倍关系。这个操作很简单,在数据读取的循环边界上,用(size/16)*16示意编译器即可。
扩展位宽后的结果可以在综合报告的接口部分看到数据位宽已经从32位扩展到512位。
优化到这一步我们的设计可以进行大位宽的同步读写,但是发现循环的trip count还是执行了1024次, 也就是说虽然位宽拓展到512后,还是一个循环周期计算一次32bit的累加。实际上512bit的数据位宽可以允许16个累加计算并行执行。
为了完成并行度的优化,我们需要在循环中添加系数为16的unroll 指令,这样就可以生成16个并行执行累加计算的硬件模块以及线程。
在循环中并行执行的累加操作,我们可以从schedule viewer中观察到并行度,可以从bind_op窗口中观察到operation实现所使用的硬件资源,可以从循环的trip_count 降低到了1024/16=64个周期,以及大大缩小的模块的整个latency中得以证明。
最后我们比较了一下并行执行16个累加计算前后的综合结果,可以发现由于有数据的按位读写拆分拼接等操作,整个模块的延迟虽然没有缩短为16分之一,但是缩短为5分之一也是性能的极大提升了。
最后的最后,RTL级别的co-sim仿真才让我们更加确信了数据的从两个并行读写,循环执行的周期减小至了64个时钟周期。
以上内容是设计者在AXI总线接口中使用传统的数据类型时,提升数据传输效率和带宽的一揽子有效方法:
第一,扩展总线接口数量,以便并行读写。
第二,扩展总线位宽,增加读写带宽。
第三,循环展开,例化更多计算资源以便并行计算。
本文的优化方式还是基于内核设计本身的,下一篇文章,我们将使用Alveo板卡做一些突发传输的实验,深度定制传输需求,以真实仿真波形和测得的传输速度,从系统级别强化我们对于突发读写效率的认知。
赛灵思中文技术支持社区
欢迎在赛灵思中文技术支持社区中留言讨论开发过程中遇到的问题与启发!本社区致力于为Xilinx 用户及生态合作伙伴提供一个分享、讨论和相互协作解决问题的交流社区,注册即可浏览论坛内容或者参与讨论。
https://support.xilinx.com/s/?language=zh_CN
边栏推荐
- Find objects you can't see! Nankai & Wuhan University & eth proposed sinet for camouflage target detection, and the code has been open source
- 关于测试用例
- [shutter] shutter resource file use (import resource pictures | use image resources)
- 一周生活
- "New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba
- Market Research - current situation and future development trend of preclinical medical device testing service market
- Unity3D学习笔记4——创建Mesh高级接口
- The failure rate is as high as 80%. What should we do about digital transformation?
- Market Research - current situation and future development trend of cell-based seafood market
- Market Research - current market situation and future development trend of high tibial osteotomy plate
猜你喜欢
Introduction to victoriametrics
tinymce可视化编辑器增加百度地图插件
C language, to achieve three chess games
[shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)
From "bronze" to "King", there are three secrets of enterprise digitalization
Micro service gateway selection, please accept my knees!
How do I access the kubernetes API?
Pip install whl file Error: Error: … Ce n'est pas une roue supportée sur cette plateforme
[zero foundation I] Navicat download link
"Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks!
随机推荐
Market Research - current situation and future development trend of sickle cell therapy Market
Official announcement! The golden decade of new programmers and developers was officially released
:last-child 不生效解决
使用 EMQX Cloud 实现物联网设备一机一密验证
【C 题集】of Ⅴ
腾讯三面:进程写文件过程中,进程崩溃了,文件数据会丢吗?
Ransack组合条件搜索实现
【剑指 Offer】56 - I. 数组中数字出现的次数
2019 Nanchang (relive the classic)
pyqt图片解码 编码后加载图片
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
pip安裝whl文件報錯:ERROR: ... is not a supported wheel on this platform
Market Research - current situation and future development trend of anterior cruciate ligament (ACL) reconstruction Market
Web侧防御指南
SQL必需掌握的100个重要知识点:管理事务处理
Market Research - current market situation and future development trend of night vision goggles for pilots
Blue Bridge Cup Winter vacation homework (DFS backtracking + pruning)
From personal heroes to versatile developers, the era of programmer 3.0 is coming
Secondary development of ANSYS APDL: post processing uses command flow to analyze the result file
*C language final course design * -- address book management system (complete project + source code + detailed notes)