CANN/hcomm Profiling模块分析

发布时间:2026/7/15 15:39:05

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/7/15 15:39:05

如何用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/7/15 15:39:05

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

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

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

2026/7/15 15:39:05

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

HarmonyOS知识库——笔记列表的多源数据与实时搜索

HarmonyOS知识库——笔记列表的多源数据与实时搜索

2026/7/15 17:09:09

知识库 App 的 NoteList 是一个"万能列表页"——从不同入口进来时显示不同数据:从笔记本卡片进来显示该笔记本的笔记,从搜索 tab 进来显示全部笔记,从标签进来显示该标签的笔记。同一个页面承载三种数据源,靠的是路由参…

Uncle小说阅读器:一站式PC端数字阅读解决方案终极指南

Uncle小说阅读器:一站式PC端数字阅读解决方案终极指南

2026/7/15 17:09:09

Uncle小说阅读器:一站式PC端数字阅读解决方案终极指南 【免费下载链接】uncle-novel 📖 Uncle小说,PC版,一个全网小说下载器及阅读器,目录解析与书源结合,支持有声小说与文本小说,可下载mobi、e…

TDA3x处理器接口信号深度解析:从引脚定义到硬件设计实战

TDA3x处理器接口信号深度解析:从引脚定义到硬件设计实战

2026/7/15 17:09:09

1. 项目概述:为什么接口信号是嵌入式设计的“交通规则”在嵌入式硬件设计的江湖里,处理器就像一座繁忙的城市核心,而接口信号就是连接这座核心与外部世界(传感器、存储器、通信模块)的条条道路和交通规则。你可能会觉得…

如何高效解决Windows上HEIF图片兼容性问题:免费开源工具完整指南

如何高效解决Windows上HEIF图片兼容性问题:免费开源工具完整指南

2026/7/15 17:09:09

如何高效解决Windows上HEIF图片兼容性问题:免费开源工具完整指南 【免费下载链接】HEIF-Utility HEIF Utility - View/Convert Apple HEIF images on Windows. 项目地址: https://gitcode.com/gh_mirrors/he/HEIF-Utility 还在为iPhone拍摄的照片在Windows电…

RimWorld开局终极指南:如何用EdB Prepare Carefully打造完美殖民者

RimWorld开局终极指南:如何用EdB Prepare Carefully打造完美殖民者

2026/7/15 17:09:09

RimWorld开局终极指南:如何用EdB Prepare Carefully打造完美殖民者 【免费下载链接】EdBPrepareCarefully EdB Prepare Carefully, a RimWorld mod 项目地址: https://gitcode.com/gh_mirrors/ed/EdBPrepareCarefully 你是否曾经在《边缘世界》开局时&#x…

3分钟快速上手:Greenshot便携版完全指南,告别繁琐安装

3分钟快速上手:Greenshot便携版完全指南,告别繁琐安装

2026/7/15 16:59:08

3分钟快速上手:Greenshot便携版完全指南,告别繁琐安装 【免费下载链接】greenshot Greenshot for Windows - for more information look here: 项目地址: https://gitcode.com/gh_mirrors/gr/greenshot Greenshot是一款功能强大的免费开源截图工具…

Unity游戏文本翻译架构深度解析:XUnity.AutoTranslator的技术实现与工程实践

Unity游戏文本翻译架构深度解析:XUnity.AutoTranslator的技术实现与工程实践

2026/7/14 10:03:09

Unity游戏文本翻译架构深度解析:XUnity.AutoTranslator的技术实现与工程实践 【免费下载链接】XUnity.AutoTranslator 项目地址: https://gitcode.com/gh_mirrors/xu/XUnity.AutoTranslator XUnity.AutoTranslator作为Unity游戏社区中最成熟的文本翻译解决方…

openEuler Raspberry Pi Kernel设备驱动开发指南:为树莓派硬件添加支持

openEuler Raspberry Pi Kernel设备驱动开发指南:为树莓派硬件添加支持

2026/7/13 20:43:19

openEuler Raspberry Pi Kernel设备驱动开发指南:为树莓派硬件添加支持 【免费下载链接】raspberrypi-kernel It provides openEuler kernel source for Raspberry Pi 项目地址: https://gitcode.com/openeuler/raspberrypi-kernel 前往项目官网免费下载&…

openEuler系统集成测试实战:基于smoke-test套件的环境验证技巧

openEuler系统集成测试实战:基于smoke-test套件的环境验证技巧

2026/7/15 0:26:43

openEuler系统集成测试实战:基于smoke-test套件的环境验证技巧 【免费下载链接】integration-test The repo contains test suits for system integration test 项目地址: https://gitcode.com/openeuler/integration-test 前往项目官网免费下载:…

【LINUX】驱动

【LINUX】驱动

2026/7/15 0:08:14

【LINUX驱动】【字符设备】【中断】【Platform】【网课 设备树】【GPIO】【PINCTRL】【INPUT】【IIC】【SPI】【网络驱动】【屏幕驱动】【一 设备树】【二 内核模块编译】【三 基本驱动框架】【四 Platform总线设备驱动框架】【五 驱动子系统】【六 综合】

【1982-2026】全国高精度建筑轮廓|村级精度|SHP矢量

【1982-2026】全国高精度建筑轮廓|村级精度|SHP矢量

2026/7/15 0:08:14

🔍 数据简介 本次分享1982-2026年全国村级精度建筑轮廓矢量数据,覆盖全国各省市区县,到村级别精细,为2026年最新实时采集成果,非网传仅60/77个城市的老旧数据。 数据含带高度/不带高度双版本,单体建筑边界精…

【1975-2026】全国水系水路数据|河流/水库/运河|SHP矢量

【1975-2026】全国水系水路数据|河流/水库/运河|SHP矢量

2026/7/15 0:08:14

🔍 数据简介 本次分享1975-2026年全国高精度水系水路矢量数据,覆盖全国全域,包含河流、水系、水库、运河、湿地、冰川、沟渠等全类别水文要素。 数据集包含双层矢量图层,字段分类清晰、要素齐全,支持2013-2026逐年完整…