当前位置: 首页 > news >正文

950基础矩阵乘法TLA示例

950 Basic Matmul TLA Example Readme

【免费下载链接】catlass本项目是CANN的算子模板库,提供NPU上高性能矩阵乘及其相关融合类算子模板样例。项目地址: https://gitcode.com/cann/catlass

Note: The community package does not currently support 950 capabilities. Stay tuned for a future supported version.

Code Organization

├── 43_ascend950_basic_matmul │ ├── CMakeLists.txt # CMake build file │ ├── README.md │ └── basic_matmul_tla.cpp # Main file

Usage Example

  • After obtaining the code, build the corresponding operator executable. See Template Library Quick Start. This case is a 950 operator, and-DCATLASS_ARCH=3510must be added during build.
  • Run the operator.
# Build the specified case bash scripts/build.sh 43_ascend950_basic_matmul -DCATLASS_ARCH=3510 cd output/bin # Executable file name | matrix m axis | n axis | k axis | Device ID # Device ID is optional and defaults to 0 ./43_ascend950_basic_matmul 256 512 1024 0

The execution result is as follows, indicating that the precision comparison succeeds.

Compare success.

Usage Notes

The DispatchPolicy MmadPingpong used by BasicMatmul by default supports the following template parameters:

Template ParameterDefault ValueParameter Description
ArchTagNoneSpecifies the architecture model
enableUnitFlagfalseSpecifies whether to enable UnitFlag. It must be set to false when L0C multi-buffering is enabled
useHF32falseSpecifies whether to enable HF32. Only the float type is supported
l0CStages1Specifies the number of L0C buffers. Set it to 2 to enable L0C double buffering
enableL1ResidentfalseSpecifies whether to enable L1 residency
l1AStages2Number of buffers for loading matrix A on L1
l1BStages2Number of buffers for loading matrix B on L1
l0AStages2Number of buffers for loading matrix A on L0
l0BStages2Number of buffers for loading matrix B on L0

Assume the matrix Shape isM N K, the tile size on L1 ism1 n1 k1, the number of tiles in the M direction ismTiles = CeilDiv(M, m1), the number of tiles in the N direction isnTiles = CeilDiv(N, n1), and the total number of tasks istaskBlocks = mTiles * nTiles. enableL1Resident can be enabled in the following two cases:

  1. mTiles = 1,nTiles > CoreNum, andK < 2 * k1. In this case,l0CStages=2can also be set (enableUnitFlag must be disabled). If there is not enough space andl0CStages=2cannot be set, setn1to half of the original value.

  2. nTiles = 1,mTiles > CoreNum, andK < 2 * k1. In this case,l0CStages=2can also be set (enableUnitFlag must be disabled). If there is not enough space andl0CStages=2cannot be set, setm1to half of the original value.

BasicMatmul also supports DispatchPolicy MmadPreloadAsyncWithCallback, which supports the following template parameters:

Template ParameterDefault ValueParameter Description
ArchTagNoneSpecifies the architecture model
preloadStagesNoneSpecifies the number of preloads
l1AStages2Number of buffers for loading matrix A on L1
l1BStages2Number of buffers for loading matrix B on L1
l0AStages2Number of buffers for loading matrix A on L0
l0BStages2Number of buffers for loading matrix B on L0
l0CStages1Specifies the number of L0C buffers. Set it to 2 to enable L0C double buffering
enableUnitFlagfalseSpecifies whether to enable UnitFlag. It must be set to false when L0C multi-buffering is enabled
enableShuffleKfalseSpecifies whether to enable K-direction staggered reading
useHF32falseSpecifies whether to enable HF32. Only the float type is supported
enableL1ResidentfalseSpecifies whether to enable L1 residency

Compared withMmadPingpong,MmadPreloadAsyncWithCallbackhas two more template parameters. One ispreloadStages. This parameter is usually set to 1 and specifies the number of preloads. When this parameter is set to 1, the first loop only loads data and does not perform matmul computation. The second loop first loads the data for the second loop, and then completes the Matmul computation of the previous loop, and so on. After the final loop ends, one additional Matmul computation is performed. The benefit is that the data required for the current Matmul computation has already been moved in the previous loop. Therefore, instruction issue is advanced, which reduces the performance loss caused by instruction issue latency.

The second parameter isenableShuffleK. This parameter is mainly used to avoid bandwidth loss caused by same-address access conflicts. The main principle is to stagger the data read addresses of each core. This parameter does not need to be enabled on 950.

Compared withMmadPingpong,MmadPreloadAsyncWithCallbackhas more optimization points, but its logic is also more complex and has higher Scalar overhead. Use it based on the scenario, especially for small Shape scenarios.

【免费下载链接】catlass本项目是CANN的算子模板库,提供NPU上高性能矩阵乘及其相关融合类算子模板样例。项目地址: https://gitcode.com/cann/catlass

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

http://www.jsqmd.com/news/1071108/

相关文章:

  • Raylib即时模式GUI的底层架构解析:从状态管理到渲染优化的全链路技术实现
  • TruecallerJS错误处理与调试指南:常见问题排查与解决方案
  • Super Productivity容器化部署实战:构建企业级时间管理系统的技术架构解析
  • CANN/ge DataFlow Python开发指南附录
  • CANN/runtime模型流切换示例
  • Auto-evaluator错误处理与调试:常见问题解决方案的完整清单
  • CANN/runtime:资源限制内核执行示例
  • Dify.AI语音交互系统深度解析与架构设计
  • Reflex框架终极实战指南:5分钟解决Python Web应用开发难题
  • FlagGems性能调优秘籍:10个实用技巧助你针对特定硬件后端最大化加速比
  • Elastic Integrations故障排查指南:从日志分析到问题解决的实用技巧
  • laravel-money宏与混入功能:如何优雅扩展货币处理能力?
  • Awesome Claude Skills:构建AI工作流的终极指南与完整实践
  • 7-Zip DLL选择指南:bit7z兼容的7z.dll/7za.dll功能对比
  • 终极iOS越狱指南:使用palera1n轻松解锁iPhone系统权限
  • Javinizer元数据抓取原理深度解析:如何从8大网站获取最全信息
  • 学术PDF翻译的终极解决方案:BabelDOC如何完美保留格式与公式
  • 深度解析开源microG项目:如何为无GMS设备提供完整Google服务替代方案
  • wasm-git高级教程:使用Web Worker实现浏览器中的Git仓库克隆与提交
  • GroupViT模型训练全指南:从环境配置到COCO数据集评估,新手也能轻松掌握
  • 中国象棋AlphaZero实现:从理论到实践的技术探索
  • Meta-Transfer Learning终极指南:从元学习到参数缩放与平移的完整解析
  • 10分钟自主搭建零成本内网穿透:bore轻量级隧道实战指南
  • 5分钟快速上手:Unity物理卡通着色器UniToon完全指南 [特殊字符]
  • PhoneVR项目路线图:未来功能和发展方向展望
  • Binwalk v3.1.0:固件分析架构跃迁,性能重构实现10倍加速
  • 如何用BRAT插件轻松管理Obsidian测试版插件:完整指南与实战技巧
  • OpenInference故障诊断:常见问题排查与调试技巧大全
  • DJITelloPy:Python无人机编程实战指南 - 从基础飞行到多机编队
  • 如何搭建自动化域名监控系统:Domain Admin终极指南