CANN/hccl自定义通信算子AllGather

发布时间:2026/8/28 13:36:12

CANN/hccl自定义通信算子AllGather
Custom Communication Operator - AllGather【免费下载链接】hccl集合通信库Huawei Collective Communication Library简称HCCL是基于昇腾AI处理器的高性能集合通信库为计算集群提供高性能、高可靠的通信方案项目地址: https://gitcode.com/cann/hcclSample DescriptionThis sample demonstrates how to develop an AllGather communication operator based on the HCCL communication programming interface. It covers the following features:Implement an AllGather collective communication operator based on the CCU_SCHED communication engine.Support independent building and deployment of custom operator packages.Directory Structure├── CMakeLists.txt # Compilation and build configuration file ├── op_host/ | ├── allgather.cc # HcclAllGatherCustom operator implementation source file | ├── utils.cc # Utility module (channel acquisition, thread acquisition, Kernel registration) | └── utils.h # Utility module header file ├── op_kernel_ccu/ | ├── ccu_kernel.cc # CCU Kernel implementation logic | ├── ccu_kernel.h # CCU Kernel header file | ├── exec_op.cc # CCU operator orchestration logic | └── exec_op.h # CCU operator orchestration header file ├── inc/ | ├── hccl_custom_allgather.h # Custom AllGather operator interface header file | ├── common.h # Common type header file | └── log.h # Log macro definitions └── testcase/ ├── main.cc # Sample implementation source file └── Makefile # Compilation and build configuration fileThe custom operator compilation project depends on the cmake configuration and the build.sh compilation script in the HCCL repository.cmake contains CMake configuration, MakeSelf packaging configuration, and so on.build.sh is the compilation entry for the project.1. Environment Preparation1.1 Environment RequirementsThis sample supports the following Ascend products in a single-server N-card configuration (N 2):Ascend 950PR / Ascend 950DTThe following software dependencies are required for compiling this sample. Ensure that the version requirements are met:gcc and g 7.3.0cmake 3.16.01.2 Install the CANN Toolkit Development Kit PackageRefer to the Ascend Documentation Center - CANN Software Installation Guide to install the CANN Toolkit development kit package version 9.1.0 that matches the sample.The installation supports both default path and specified path installation:Default path installation: Do not specify the--install-pathparameter. After installation, the software is located at/usr/local/Ascend(root user) or${HOME}/Ascend(non-root user).Specified path installation: Use the--install-pathparameter to specify the installation directory. After installation, the software is located at${install_path}. Use this path for subsequent compilation and environment variable configuration.# Ensure the installation package has executable permissions chmod x Ascend-cann-toolkit_${cann_version}_linux-${arch}.run # Default path installation ./Ascend-cann-toolkit_${cann_version}_linux-${arch}.run --install # Specified path installation (replace ${install_path} with the actual installation directory) # ./Ascend-cann-toolkit_${cann_version}_linux-${arch}.run --install --install-path${install_path}1.3 Configure Environment VariablesAfter installing the CANN Toolkit development kit package, select the corresponding environment variable configuration command based on the installation method to apply the environment variables.# Default path installation, using the root user as an example (for non-root users, replace /usr/local with ${HOME}) source /usr/local/Ascend/cann/set_env.sh # Specified path installation. ${install_path} indicates the actual CANN-Toolkit package installation path. # source ${install_path}/cann/set_env.shset_env.shis an environment initialization script that configures environment variables such as PATH, LD_LIBRARY_PATH, and PYTHONPATH, enabling the compiler and runtime to correctly find the Ascend NPU toolchain, library files, and operator libraries.2. Compiling the Custom Operator PackageThe HCCL repository provides a custom operator compilation and packaging project. This project depends on the following files in the repository:├── build.sh # Compilation entry in the hccl repository root directory ├── CMakeLists.txt # Compilation and build configuration file in the hccl repository root directory ├── cmake/ | ├── config.cmake # CMake variable definitions | ├── func.cmake # CMake function definitions | ├── package.cmake # Signature and packaging function definitions | └── makeself_custom.cmake # MakeSelf packaging logic └── scripts/ ├── custom/install.sh # Custom operator package installation script └── sign/add_header_sign.py # Operator package signing scriptTherefore, developers first need to download the hccl repository, then runbuild.shfrom the repository root directory for compilation, specifying the custom operator project path usingcustom_ops_path:# Download the hccl repository git clone https://gitcode.com/cann/hccl.git # Compile the custom operator package cd hccl bash build.sh --vendorcust --opsallgather_ccu --custom_ops_path./examples/05_custom_ops_allgather/ccuWhere:--vendorspecifies the custom operator identifier.--opsspecifies the custom operator name.--custom_ops_pathspecifies the custom operator project path.3. Installing the Custom Operator PackageThe custom operator installation package is located in the./build_outdirectory. Install it using the--installparameter:./build_out/cann-hccl_custom_allgather_ccu_linux-arch.run --install --install-pathascend_cann_pathWhere:archis the system architecture of the current compilation environment.ascend_cann_pathis an optional parameter indicating the CANN software package installation directory. The default value is the CANN software package path where theASCEND_CUSTOM_OPP_PATHorASCEND_OPP_PATHenvironment variable is located.The custom operator package installation information is as follows:Header file:${ASCEND_HOME_PATH}/opp/vendors/cust/include/hccl_custom_allgather.hDynamic library:${ASCEND_HOME_PATH}/opp/vendors/cust/lib64/libhccl_custom_allgather.so${ASCEND_HOME_PATH}is the CANN-Toolkit installation path.4. Running the Custom Operator4.1 Compile the Test SampleRun the following commands in theexamples/05_custom_ops_allgather/ccu/testcasedirectory:# Compile the test sample make4.2 Run the Test SampleRun the following commands in theexamples/05_custom_ops_allgather/ccu/testcasedirectory:# Run the test sample make test # Or run the sample binary directly export LD_LIBRARY_PATH${ASCEND_HOME_PATH}/opp/vendors/cust/lib64:${LD_LIBRARY_PATH} ./custom_allgather_ccu4.3 Sample OutputThe input data of all nodes is initialized to the Device ID of that node. After successful execution, the terminal displays log output similar to the following (using 2 cards as an example):Found 2 NPU device(s) available rankId: 1, input: [ 1 ] rankId: 0, input: [ 0 ] rankId: 0, output: [ 0 1 ] rankId: 1, output: [ 0 1 ]【免费下载链接】hccl集合通信库Huawei Collective Communication Library简称HCCL是基于昇腾AI处理器的高性能集合通信库为计算集群提供高性能、高可靠的通信方案项目地址: https://gitcode.com/cann/hccl创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关新闻

TestNG入门指南:从零搭建Java自动化测试框架

TestNG入门指南:从零搭建Java自动化测试框架

2026/8/27 11:27:01

1. 项目概述:为什么选择TestNG作为你的第一个测试框架?如果你刚开始接触Java自动化测试,面对JUnit、TestNG这些名词可能有点懵。我刚开始做测试开发那会儿,也纠结过到底该从哪个入手。后来在多个实际项目中摸爬滚打,发…

CANN Task A 产出验证

CANN Task A 产出验证

2026/8/26 13:11:36

Task A 产出验证 【免费下载链接】cannbot-skills CANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。 项目地址: https://gitcode.com/cann/cannbot-skills 校验 S2P1_path_list.json 中对源码的声明是否真实。…

NCSN模型架构详解:ConvResBlock与DeconvResBlock的设计艺术

NCSN模型架构详解:ConvResBlock与DeconvResBlock的设计艺术

2026/8/27 9:50:19

NCSN模型架构详解:ConvResBlock与DeconvResBlock的设计艺术 【免费下载链接】ncsn Noise Conditional Score Networks (NeurIPS 2019, Oral) 项目地址: https://gitcode.com/gh_mirrors/nc/ncsn Noise Conditional Score Networks (NCSN) 是NeurIPS 2019的口…

蓝桥杯扩散问题:曼哈顿距离与暴力枚举的算法优化实践

蓝桥杯扩散问题:曼哈顿距离与暴力枚举的算法优化实践

2026/8/29 2:49:47

1. 项目概述:蓝桥杯“扩散”问题解析最近在整理蓝桥杯的历年真题,第十一届国赛C组的B题“扩散”给我留下了挺深的印象。这道题乍一看描述很简单,但想要在竞赛的时限内高效求解,却需要一些巧妙的算法思维和数据结构知识&#xff0c…

Llama全链路实战:从环境配置到量化微调工具调用

Llama全链路实战:从环境配置到量化微调工具调用

2026/8/29 2:49:47

如果你最近开始接触 Llama 系列模型,大概会遇到类似的场景:模型下载下来了,中文 README 也看过几篇,但真正要让它跑起来,却要在 GGUF、量化等级、推理后端、微调框架这些名词之间来回折腾。有人卡在 llama-cpp-python …

微服务流量治理:Sentinel核心原理、规则配置与生产实践

微服务流量治理:Sentinel核心原理、规则配置与生产实践

2026/8/29 2:49:46

1. 项目概述:为什么我们需要Sentinel? 在微服务架构里,服务之间的调用关系变得像一张复杂的蜘蛛网。一个订单服务可能要调用用户服务、库存服务和支付服务。想象一下,如果库存服务因为数据库压力过大,响应变得极其缓慢…

WeatherNext:把天气预报变成可复现的工程流程

WeatherNext:把天气预报变成可复现的工程流程

2026/8/29 2:49:46

第一次打开 google-deepmind/weathernext 这个仓库时,我下意识地以为它只是又一个“能预测天气的 AI 模型”:下载权重、跑一次推理、生成一张未来几天的天气图,任务就结束了。但当我真正去梳理输入数据、输出格式、依赖环境和评估脚本之后&am…

粒子群优化算法实战:从原理到无人机路径规划应用

粒子群优化算法实战:从原理到无人机路径规划应用

2026/8/29 2:49:46

1. 从一道赛题到一种思想:我眼中的PSO算法实战2019年的美国大学生数学建模竞赛(MCM/ICM)B题,题目是“无人机救援:灾后医疗物资配送”。这道题在当时让不少队伍挠头,核心难点在于如何为多架无人机规划出高效…

C++函数模板实现通用元素查找:从顺序查找到二分查找的泛型编程实践

C++函数模板实现通用元素查找:从顺序查找到二分查找的泛型编程实践

2026/8/29 2:39:46

1. 项目概述:为什么我们需要“元素查找”函数模板?在C编程里,尤其是处理数据结构和算法时,“查找”是一个高频到不能再高频的操作。无论是验证用户输入、过滤数据,还是在游戏里判断某个道具是否在背包中,本…

[光学原理与应用-521]:对光的错误理解与纠偏

[光学原理与应用-521]:对光的错误理解与纠偏

2026/8/27 11:10:02

首先光是一种能量的载体和形态,宏观上观察到的光是由无数个微观的光量子组成的,每个光子在产生的瞬间,其在真空的空间中以确定不变的速度沿着一个初始的方向一直向前,在微观层面,每个光量子的运动轨迹是以波函数所展现…

SIP通话转接原理与REFER方法实战解析

SIP通话转接原理与REFER方法实战解析

2026/8/27 7:25:23

1. 通话转接不是“挂断再拨号”,而是SIP会话的动态重定向你有没有遇到过这样的场景:客服坐席A正在和客户通电话,突然需要把这通对话无缝转给专家坐席B,客户完全感知不到中间的断连——既没听到忙音,也没被要求重新拨号…

Kolla-ansible单节点OpenStack部署实战:从环境准备到排坑指南

Kolla-ansible单节点OpenStack部署实战:从环境准备到排坑指南

2026/8/28 7:34:42

1. 为什么选择Kolla-ansible来部署单节点OpenStack?如果你正在寻找一种能把OpenStack从“概念”快速变成“可用的实验环境”的方法,那么Kolla-ansible几乎是当前最主流、最省心的选择。我见过太多人卡在手动编译依赖、配置服务、处理版本冲突的泥潭里&am…

四款热门降AI工具测评:研究生和本科生怎么选?

四款热门降AI工具测评:研究生和本科生怎么选?

2026/8/29 0:09:39

马上要交论文了,最近真的被论文ai率折磨的够呛。 明明查重都没问题了,但是ai率就是居高不下,崩溃了,明明都是我自己写的,天杀的,明明都是我亲生的啊 改来改去,终于给我搞出一套完美的降ai方案…

论文降AI率免费攻略:自查、提示词与工具推荐

论文降AI率免费攻略:自查、提示词与工具推荐

2026/8/29 0:09:39

马上要交论文了,最近真的被论文ai率折磨的够呛。 明明查重都没问题了,但是ai率就是居高不下,崩溃了,明明都是我自己写的,天杀的,明明都是我亲生的啊 改来改去,终于给我搞出一套完美的降ai方案…

北京GEO优化服务商推荐:预算型企业如何选北京GEO优化服务商?

北京GEO优化服务商推荐:预算型企业如何选北京GEO优化服务商?

2026/8/29 0:09:39

前言:预算有限的企业更关心投入能否形成可持续的品牌资产。评估北京GEO优化服务商时,不能只比较单篇内容或单月报价,还要看是否能够把问题词、官网、信源和监测串成完整链路。本期重点放在预算配置、试点范围和交付边界,帮助企业先…

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

2026/8/28 7:35:26

一天写完毕业论文在2026年已不再是天方夜谭。2026年最炸裂、实测能大幅提速的AI论文写作工具,覆盖选题构思、文献整理、内容生成、格式排版等核心场景,真正帮你高效搞定论文难题。 一、全流程王者:一站式搞定论文全链路(一天定稿首…

导师推荐!2026最新AI论文工具测评与实用推荐

导师推荐!2026最新AI论文工具测评与实用推荐

2026/8/28 7:34:51

2026年真正好用的AI论文工具,核心看生成的论文质量、低AI味、格式正确、学术适配四大指标。综合实测,千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队,覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 一、…

告别游戏崩溃:XCOM 2模组管理器的智能革命

告别游戏崩溃:XCOM 2模组管理器的智能革命

2026/8/28 7:34:35

告别游戏崩溃:XCOM 2模组管理器的智能革命 【免费下载链接】xcom2-launcher The Alternative Mod Launcher (AML) is a replacement for the default game launchers from XCOM 2 and XCOM Chimera Squad. 项目地址: https://gitcode.com/gh_mirrors/xc/xcom2-lau…