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

CANN/hcomm多线程通信器示例

Communicator Management - One NPU Device per Thread

【免费下载链接】hcommHCOMM(Huawei Communication)是HCCL的通信基础库,提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm

Sample Overview

This sample demonstrates how to use theHcclCommInitRootInfoConfig()API to initialize a communicator in a single process, with each thread managing one NPU device. It covers the following features:

  • Device detection: Query the number of available devices using theaclrtGetDeviceCount()API.

  • Use rank0 as the root node and generate rootinfo identification information through theHcclGetRootInfo()API.

    The rootinfo identification information mainly includes the Device IP, Device ID, and so on. This information must be broadcast to all ranks in the cluster to initialize the communicator.

  • Initialize the communicator in each thread based on the rootinfo identification information using theHcclCommInitRootInfoConfig()API.

  • Call theHcclAllReduce()operator and print the results.

Directory Structure

├── main.cc # Sample source file ├── Makefile # Build or configuration file └── one_device_per_pthread # Compiled executable

Environment Preparation

Requirements

This sample supports the following products:

  • Ascend 950PR / Ascend 950DT
  • Atlas A3 training series products / Atlas A3 inference series products
  • Atlas A2 training series products
  • Atlas training series products / Atlas inference series products

Software Dependencies

Running this sample requires the CANN ops operator package to be installed. For detailed installation steps, see the "Install the CANN Software Package" section in Source Code Build.

Disabling Signature Verification

Thecann-hcomm_<version>_linux-<arch>.runsoftware package generated from this source repository contains the following tar.gz subpackages:

  • cann-hcomm-compat.tar.gz: HCOMM compatibility upgrade package.
  • cann-hccd-compat.tar.gz: DataFlow compatibility upgrade package.
  • aicpu_hcomm.tar.gz: AI CPU communication base package.

These tar.gz packages are loaded to the Device when the service starts. During the loading process, the driver performs security signature verification by default to ensure the package is trusted. Because the tar.gz packages compiled from this source repository do not contain a signature header, the driver security signature verification mechanism needs to be disabled. For the method to disable signature verification, refer to the "Disable Signature Verification" section in Source Code Build.

Configuring Environment Variables

# Set CANN environment variables, using the root user default installation path as an example source /usr/local/Ascend/cann/set_env.sh

Compiling and Running the Sample

Execute the following commands in the sample code directory:

make make test

Note: You can set theHCCL_OP_EXPANSION_MODEenvironment variable to configure the expansion mode of communication operators. For the range supported by different product models, refer to the usage of this environment variable in the Environment Variable List.

# Set the expansion mode of communication operators to AI CPU communication engine export HCCL_OP_EXPANSION_MODE=AI_CPU

Sample Output

The data for each rank is initialized to 0 to 7. After the AllReduce operation, the result for each rank is the sum of the data at the corresponding positions across all ranks (the data from 8 ranks is summed).

Found 8 NPU device(s) available rankId: 0, output: [ 0 8 16 24 32 40 48 56 ] rankId: 1, output: [ 0 8 16 24 32 40 48 56 ] rankId: 2, output: [ 0 8 16 24 32 40 48 56 ] rankId: 3, output: [ 0 8 16 24 32 40 48 56 ] rankId: 4, output: [ 0 8 16 24 32 40 48 56 ] rankId: 5, output: [ 0 8 16 24 32 40 48 56 ] rankId: 6, output: [ 0 8 16 24 32 40 48 56 ] rankId: 7, output: [ 0 8 16 24 32 40 48 56 ]

【免费下载链接】hcommHCOMM(Huawei Communication)是HCCL的通信基础库,提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm

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

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

相关文章:

  • 终极指南:Windows任务栏透明美化神器TranslucentTB完全使用手册
  • 从理论到实践:PBD约束大全与物理模拟实战指南
  • CANN数据类型转换API
  • Ornith-1.0-35B-5bit高级玩法:自定义生成参数调优与多模态任务扩展
  • 2024计算机保研机试通关指南:从北师大、川大到天大的实战复盘与策略
  • 2026年成都赞誉高的公司注销代办4家优选指南,助你轻松搞定! - 企业推荐官
  • OSPerformanceTools安装与配置:新手入门详细教程
  • 益阳蹲便厨卫支管老旧铸铁管油污淤积/打捞/渗水检测 同城上门评测榜单 (2026 新) - 北京金修达天津维修部
  • 如何用leven轻松计算字符串相似度?5分钟快速上手教程
  • FDB表-ARP表-路由表:网络数据转发的三层寻址逻辑
  • 为什么选择BiSheng JDK-build:华为毕昇JDK构建工具的7大优势
  • TradingView Webhooks Bot事件系统详解:构建复杂交易策略的基石
  • 3个问题,1个解决方案:SMUDebugTool如何彻底改变你的AMD Ryzen调试体验
  • 从机械到腾讯:我的两年自学转行与六轮面试闯关实录
  • 乐山装修公司对比:哪家靠谱、口碑好、高性价比?2026 - 装企精灵GEO
  • 大学城数据清洗实战:从混乱文本到可信分析资产
  • CANN/HCOMM HCCL测试框架
  • 【软件设计师-从小白到大牛】下午题进阶篇:第四章 算法策略实战与代码填空精解
  • 亲身探访上海雅典官方售后服务中心|最新热线和完整维修地址(2026年7月最新) - 亨得利官方服务中心
  • 毕业证公证2026全攻略:材料清单、办理流程与时效费用详解 - 叮咚办真方便
  • ZonyLrcToolsX深度解析:基于C的多平台歌词下载技术实现
  • VideoDownloadHelper:高效实用的Chrome视频下载助手完整指南
  • OpenVINO性能调优实战:在openEuler平台上实现AI推理速度提升300%的技巧
  • 百度网盘直连解析工具:3步解锁极速下载体验
  • Claude Code:从智能补全到代码库对话的AI编程助手实战
  • 2026年7月青岛口碑比较好的刑事辩护律师推荐孙伟伟:深耕青岛刑事辩护八年,以细致质证与实务经验化解刑案困境 - 十大排行榜推荐
  • 毕节人注意!旧金饰别乱卖,这6家靠谱黄金回收店请收好,覆盖全区县! - 清奢黄金上门回收
  • 【楚雄同城种草】闲置黄金怎么卖最划算?这6家宝藏黄金回收店请收藏! - 清奢黄金上门回收
  • mlx-community/gemma-4-31b-it-mxfp8高级技巧:如何优化生成质量与速度
  • 革命性窗口管理神器:AlwaysOnTop彻底解决多任务遮挡难题