CANN/hcomm Profiling模块分析

发布时间:2026/9/29 7:46:58

CANN/hcomm Profiling模块分析
Profiling Module Code Analysis【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcommFeature DescriptionThe Profiling module is responsible for collecting and reporting performance data of HCCL collective communication tasks. It is a core component of the HCCL DFX (Diagnostics and Observability) system. The module is deployed on both the Host side and the Device side, providing unified profiling capabilities.Core capabilities:Report communication tasks: Report execution information of collective communication tasks (AllReduce, Broadcast, and so on) to the Profiling framework.Report operator information: Report key metrics such as start and end times and operator types for communication operators (Host side only).Report MC2 communication information: Report Stream, Rank, and other metadata of the MC2 communication domain (Host side only).Report Kernel: Report AICPU or AIV Kernel execution timeline information. The Device side reports kernel start and end task events.Update Profiling status: Update Profiling statistics based on task queue consumption progress.Manage Profiling switches: Respond to subscription and unsubscription commands from the Profiling framework to control data collection start and stop.External InterfacesHeader FileInterfaceSideDescriptionhccl_diag.hHcclDfxRegOpInfoByCommIdHost DeviceRegisters operator information with the communication domain, recordsbeginTime, and stores it inMirrorTaskManager.hccl_diag.hHcclProfilingReportOpHostReports operator execution events: firstReportAllTasks, thenReportOp.hccl_diag.hHcclReportAicpuKernelHostReports AICPU Kernel execution events, records taskId and streamId, and adds task information.hccl_diag.hHcclReportAivKernelHostReports AIV Kernel execution events, records taskId and streamId, and adds task information.hccl_diag.hHcommGetProfilingSysCycleTimeHostObtains the Profiling system cycle time.hcomm_diag.hHcommProfilingReportDeviceOpDeviceReports Device operator execution events: firstReportAllTasks, then reports OP information throughProfilingHandlerLite.hcomm_diag.hHcommProfilingReportKernelStartTaskDeviceReports kernel start task events, reports HEAD typeFlagTaskInfothroughProfilingHandlerLite.hcomm_diag.hHcommProfilingReportKernelEndTaskDeviceReports kernel end task events, reports TAIL typeFlagTaskInfothroughProfilingHandlerLite.Directory Descriptionprofiling/ ├── CMakeLists.txt # Top-level build, includes aicpu and host subdirectories ├── host/ │ ├── CMakeLists.txt # Host-side build, compiles hcclCommProfiling.cc │ ├── hcclCommProfiling.h # Host-side Profiling facade class definition │ └── hcclCommProfiling.cc # Host-side Profiling facade class implementation └── aicpu/ ├── CMakeLists.txt # AICPU-side build, compiles hcclCommProfilingLite.cc ├── hcclCommProfilingLite.h # AICPU-side Profiling facade class definition ├── hcclCommProfilingLite.cc # AICPU-side Profiling facade class implementation ├── aicpu_ts_urma_dfx_kernel.h # [Deprecated] URMA DFX Kernel └── aicpu_ts_urma_dfx_kernel.cc # [Deprecated] URMA DFX KernelFile RelationshipsFileFunctionDependencieshost/hcclCommProfiling.hHost-side Profiling facade class declarationDepends onMirrorTaskManager,ProfilingReporterhost/hcclCommProfiling.ccHost-side Profiling facade class implementationDepends onprofiling_reporter.h,profiling_handler.h,dlprof_function.haicpu/hcclCommProfilingLite.hAICPU-side Profiling facade class declarationDepends onMirrorTaskManagerLite,ProfilingReporterLiteaicpu/hcclCommProfilingLite.ccAICPU-side Profiling facade class implementationDepends onprofiling_reporter_lite.h,mirror_task_manager_lite.hProfiling File InteractionFlow DescriptionHost Profiling FlowRegister Operator Information (HcclDfxRegOpInfoByCommId)Report Operator (HcclProfilingReportOp)Report AICPU Kernel (HcclReportAicpuKernel)Report AIV Kernel (HcclReportAivKernel)Report MC2 Communication InformationManage Host-Side Profiling SwitchDevice Profiling FlowRegister Operator Information (HcclDfxRegOpInfoByCommId)Report Device Operator (HcommProfilingReportDeviceOp)Report Kernel Start Task (HcommProfilingReportKernelStartTask)Report Kernel End Task (HcommProfilingReportKernelEndTask)Manage Device-Side Profiling SwitchReport Level and Type Constants SummaryConstant NameValueDescriptionMSPROF_REPORT_ACL_LEVEL20000ACL level, used for Host API reportingMSPROF_REPORT_NODE_LEVEL10000Node level, used for Node BasicInfo, HCCL OP, and MC2 CommInfo reportingMSPROF_REPORT_HCCL_NODE_LEVEL5500HCCL Node level, used for Task details and CCU information reportingMSPROF_REPORT_ACL_HOST_HCCL_BASE_TYPE0x070000ACL Host HCCL base typeMSPROF_REPORT_NODE_LAUNCH_TYPE5Node Launch type, used forReportNodeApiMSPROF_REPORT_NODE_BASIC_INFO_TYPE0Node basic information type, used forReportNodeBasicInfoMSPROF_REPORT_NODE_HCCL_OP_INFO_TYPE10Node HCCL OP information typeMSPROF_REPORT_NODE_MC2_COMMINFO_TYPE12Node MC2 communication resource information typeMSPROF_REPORT_HCCL_MASTER_TYPE0x010001HCCL main stream typeMSPROF_REPORT_HCCL_SLAVE_TYPE0x010002HCCL slave stream typeMSPROF_REPORT_CCU_TASK_INFO14CCU Task information typeMSPROF_REPORT_CCU_WAIT_SIGNAL_INFO15CCU Wait Signal information typeMSPROF_REPORT_CCU_GROUP_INFO16CCU Group information typeSwitch Control and Report Content MappingSwitchCorresponding MaskControlled Report ContentenableHostApi_PROF_ACL_API_MASK 0x1Host API timestamp reporting (ReportAclApi,ReportNodeApi,ReportHcclOpApi,ReportHcclOpInfo,ReportMc2AdditionInfo)enableHcclL0_PROF_TASK_TIME_MASK 0x800HCCL operator granularity tracing (ReportHcclOpApi)enableHcclNode_PROF_TASK_TIME_L1_MASK 0x2Task granularity tracing (ReportHcclTaskApi)enableHcclL1_PROF_TASK_TIME_L1_MASK 0x2Task details reporting (CallAddtionInfo,ReportNodeBasicInfo)enableHcclL2_PROF_TASK_TIME_L2_MASK 0x2000CCU details reporting (ReportCcuInfo)Interface Description (Class Diagram)Interface DescriptionHcclCommProfiling (Host Side)InterfaceTypeParametersReturn ValueDescriptionHcclCommProfilingPublic[in] u32 deviceId,[in] MirrorTaskManager* mirrorTaskManager-Constructor, saves the task manager pointer, creates aProfilingReporterinstance (associated withProfilingHandler::GetInstance()).ReportAllTasksPublic[in] bool cachedReq falsevoidReports all communication tasks. WhencachedReqtrue, indicates cache request mode. Delegates toProfilingReporter::ReportAllTasksto traverse the task queue and report throughProfilingHandler.ReportOpPublic[in] uint64_t beginTime,[in] bool cachedReq,[in] bool opbasedvoidReports operator information. Delegates toProfilingReporter::ReportOp, which ultimately calls the profapi componentdlMsprofReportApithroughProfilingHandler::ReportHostApi.ReportMc2CommInfoPublic[in] const Mc2CommInfo mc2CommInfovoidReports MC2 communication domain information. Splits theMc2CommInfofields and callsProfilingReporter::CallReportMc2CommInfo, which ultimately reports throughdlMsprofReportAdditionalInfo.UpdateProfStatPublic-voidUpdates Profiling statistics. Delegates toProfilingReporter::UpdateProfStatto update the switch status.GetMirrorTaskManagerPublic-MirrorTaskManager*Returns the internally heldMirrorTaskManagerpointer.ReportKernelPublic[in] uint64_t beginTime,[in] const string commTag,[in] const string kernelName,[in] uint32_t threadId,[in] bool cachedReqHcclResultReports CCU Kernel information. Calls the profapi componentdlMsprofSysCycleTimeto get endTime anddlMsprofStr2Idto get cmdItemId, then callsProfilingHandlerto reportReportNodeApiandReportNodeBasicInfo. TheEXCEPTION_CATCHmacro catches exceptions and returnsHCCL_E_PTRon failure.HcclCommProfilingLite (Device Side)InterfaceTypeParametersReturn ValueDescriptionHcclCommProfilingLitePublic[in] DevId deviceId,[in] MirrorTaskManagerLite* mirrorTaskManagerLite-Constructor, saves the task manager pointer, creates aProfilingReporterLiteinstance (isIndoptrue, associated withProfilingHandlerLite::GetInstance()).ReportAllTasksPublic-voidReports all communication tasks. Delegates toProfilingReporterLite::ReportAllTasks, which ultimately calls the profapi componentMsprofReportAdditionalInfothrough a weak symbol.UpdateProfStatPublic-voidUpdates Profiling statistics. Delegates toProfilingReporterLite::UpdateProfStatto update the switch status.GetMirrorTaskManagerLitePublic-MirrorTaskManagerLite*Returns the internally heldMirrorTaskManagerLitepointer.Usage LimitationsSupported ScenariosScenarioHost SideDevice SideDescriptionRegister operator informationSupportedSupportedRegistered throughHcclDfxRegOpInfoByCommId.Report operatorSupportedSupportedHost reports throughHcclProfilingReportOp; Device reports throughHcommProfilingReportDeviceOp.Report KernelSupportedSupportedHost supports AICPU and AIV Kernel reporting; Device supports kernel start and end task reporting.Report MC2 communication infoSupportedNot supportedOnly the Host side supportsReportMc2CommInfo.Update Profiling statusSupportedSupportedBoth sides support this.Multi-device task managementSupportedNot supportedThe Host-sideMirrorTaskManagersupports multi-device queue mapping.Report CCU informationSupportedNot supportedOnly the Host side supports CCU Task, WaitSignal, and Group information reporting.Get system cycle timeSupportedNot supportedOnly the Host side supportsHcommGetProfilingSysCycleTime.Constraint SpecificationsMaximum device count: The Host-sideProfilingReporterstatic arrayallLastPoses_has a size ofREPORTER_MAX_MODULE_DEVICE_NUM 65, supporting profiling position records for up to 65 devices.ProfilingHandler singleton pattern: Both Host-side and Device-sideProfilingHandlerandProfilingHandlerLiteare singletons, globally unique. Copying and assignment are prohibited.DlProfFunction dynamic loading: The Host side dynamically loadslibprofapi.sothroughDlProfFunctionusingdlopen. If the SDK is unavailable, it falls back to stub functions (printing a WARNING log and skipping).Device-side weak symbol linking: The Device side declares profapi component functions through__attribute__((weak))(such asMsprofReportAdditionalInfoandAdprofReportAdditionalInfo). At runtime, the selection priority is:MsprofReportBatchAdditionalInfoAdprofReportAdditionalInfoMsprofReportAdditionalInfo.Null pointer protection: All reporting interfaces check for non-null pointers before calling the Reporter to avoid null pointer dereferences.EXCEPTION_CATCH macro:ReportKerneluses theEXCEPTION_CATCHmacro to catch exceptions duringProfilingHandlerreporting, returningHCCL_E_PTRon failure.MC2 Stream group reporting:ReportMc2CommInfogroups every 8 streamIds into a group and reports them throughProfilingDeviceCommResInfo. ThecommStreamIdsarray size is fixed at 8.Device-side device type restriction:HcommProfilingReportDeviceOp,HcommProfilingReportKernelStartTask, andHcommProfilingReportKernelEndTaskonly execute onDEV_TYPE_950devices. For other device types, they directly return success.Known Limitationsaicpu_ts_urma_dfx_kernelis deprecated: The Device-sideaicpu_ts_urma_dfx_kernel.hand.ccfiles are deprecated and no longer maintained, but the build entry is still retained inCMakeLists.txt.Mc2CommInfohas no validation: TheReportMc2CommInfointerface does not validate the length of thestreamsIdvector inmc2CommInfo. This is handled by the underlyingCallReportMc2CommInfo.Thread safety: The Host-sideProfilingHandleruses multiple mutexes (cacheTaskInfosMutex_,cachedTaskApiInfoMutex_,cacheHcclOpInfoMutex_,cacheHcclAdditionInfoMutex_) to protect cached data. The Device-sideProfilingHandlerLitedoes not use locks and relies on a single-threaded execution environment.Device-side switch query mode: Unlike the Host side, which receives switch status passively through callbacks, the Device-sideProfilingHandlerLitemust actively callUpdateProfSwitch()to query the switch status from the profapi component.Non-V2 communication domain handling: OnDEV_TYPE_910Bdevices,HcclProfilingReportOpdirectly returns success and skips reporting for non-CommunicatorV2communication domains. For other device types,HCCL_E_NOT_SUPPORTis returned for non-V2 domains.【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关新闻

如何用taskt免费RPA工具实现零代码自动化办公

如何用taskt免费RPA工具实现零代码自动化办公

2026/9/29 7:46:52

如何用taskt免费RPA工具实现零代码自动化办公 【免费下载链接】taskt taskt (pronounced tasked and formely sharpRPA) is free and open-source robotic process automation (rpa) built in C# powered by the .NET Framework 项目地址: https://gitcode.com/gh_mirrors/ta…

计算机毕业设计之基于springboot反诈科普平台的设计与实现

计算机毕业设计之基于springboot反诈科普平台的设计与实现

2026/9/27 16:35:41

当前,由于人们生活水平的提高和思想观念的改变,然后随着经济全球化的背景之下,互联网技术将进一步提高社会综合发展的效率和速度,互联网技术也会涉及到各个领域,于是传统的管理方式对时间、地点的限制太多,…

游戏AI实战:用行为树打造智能僵尸敌人系统

游戏AI实战:用行为树打造智能僵尸敌人系统

2026/9/4 9:57:28

1. 项目概述:当僵尸“活”起来,游戏才真正开始 在生存类游戏里,僵尸从来不只是会移动的靶子。一个只会直线冲向你、攻击模式单一的僵尸,玩上十分钟就会让人感到乏味。真正的挑战和沉浸感,来自于那些会观察、会思考、会…

CANN/GE ACL数据集缓冲区添加函数

CANN/GE ACL数据集缓冲区添加函数

2026/9/28 4:08:17

aclmdlAddDatasetBuffer 【免费下载链接】ge GE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、Te…

用ffmpeg高效批量调整图片尺寸的实战指南

用ffmpeg高效批量调整图片尺寸的实战指南

2026/9/28 16:01:49

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

Transformers 音频特征提取工具库 audio_utils 全解析:从 Mel 刻度换算到对数 Mel 频谱

Transformers 音频特征提取工具库 audio_utils 全解析:从 Mel 刻度换算到对数 Mel 频谱

2026/9/28 2:15:29

Transformers 音频特征提取工具库 audio_utils 全解析:从 Mel 刻度换算到对数 Mel 频谱 【免费下载链接】transformers 🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and mu…

RustFS 多节点集群重启与滚动升级实战:Readiness、Quorum 与 Degraded 模式完全指南

RustFS 多节点集群重启与滚动升级实战:Readiness、Quorum 与 Degraded 模式完全指南

2026/9/28 3:14:54

RustFS 多节点集群重启与滚动升级实战:Readiness、Quorum 与 Degraded 模式完全指南 【免费下载链接】rustfs 🚀2.3x faster than MinIO for 4KB object payloads. RustFS is an open-source, S3-compatible high-performance object storage system sup…

Java Integer缓存揭秘:128陷阱原理、避坑与面试全解

Java Integer缓存揭秘:128陷阱原理、避坑与面试全解

2026/9/28 3:58:00

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

RustFS Scanner 数据用量发布权威性决策:配额准入如何获得可用的权威依据

RustFS Scanner 数据用量发布权威性决策:配额准入如何获得可用的权威依据

2026/9/28 3:47:14

RustFS Scanner 数据用量发布权威性决策:配额准入如何获得可用的权威依据 【免费下载链接】rustfs 🚀2.3x faster than MinIO for 4KB object payloads. RustFS is an open-source, S3-compatible high-performance object storage system supporting mi…

远程协作的工作台整理

远程协作的工作台整理

2026/9/28 16:01:48

远程协作的工作台整理远程协作的核心不是再加一个工具,而是让交接信息足够完整。异步任务要写明目标、输入位置、完成标准和需要决策的人。 工作台的最小配置 将日程、待办、代码和沟通入口收拢到少数固定位置;通知按紧急程度分层。工作台不需要模仿办公…

持续集成 流水线自动化与 声明式交付 实践:原型怎样变成可用功能

持续集成 流水线自动化与 声明式交付 实践:原型怎样变成可用功能

2026/9/28 5:05:21

持续集成 流水线自动化与 声明式交付 实践:原型怎样变成可用功能分类:[AI/大模型]细分主题:AI 增强型 CI/CD 流水线自动化与 GitOps 实践:Agent 工作流、工具调用与任务拆解:从原型到生产的验收清单很多团队在尝试用大…

容器编排 生产环境运维与排障实战:复盘记录怎样真正派上用场

容器编排 生产环境运维与排障实战:复盘记录怎样真正派上用场

2026/9/28 16:01:48

容器编排 生产环境运维与排障实战:复盘记录怎样真正派上用场分类:[工程技术]细分主题:Kubernetes 生产环境运维与排障实战:可复制的项目复盘模板与决策记录大部分团队的事故复盘报告,最后都变成了躺在 Confluence 或钉…