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

CANN/hcomm集群心跳监控模块

ClusterMonitor Cluster Heartbeat Detection Function Description

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


Function Description

ClusterMonitoris the cluster-level heartbeat monitoring module of HCCL (Huawei Collective Communication Library) under thecoll_communicator_mgr/dfxpath, mainly used forcontinuous detection of reachability and liveness of all participating nodes and abnormal propagation after the establishment of a collective communication domain (Communicator).

Core capabilities include:

  1. Node UID identification: Each Rank is encoded as a uniqueClusterUIDType(up to 2048 bytes) vianetInstId + localId, used for cross-layer (device / server / pod / superPod) node identification.
  2. Dual Ring link establishment: Within eachnetLayerplane, nodes are sorted bylocalIdornetInstIdto form a Ring topology; each Rank establishes heartbeat socket connections with the "left" and "right" neighbors on the ring (only one neighbor when there are only 2 nodes).
  3. Async link establishment: Each remote UID starts an independent threadCreateLinkWithRemotePonitforSocketCreate+ status polling, controlled byHCCL_CONNECT_TIMEOUT.
  4. Periodic heartbeat send/receive: The backgroundMonitorThreadtraverses all sockets atBROADCAST_INTERVALintervals, firstSocketSendNbto send heartbeats thenSocketRecvNbto receive heartbeats;lostNumaccumulates everyHEARTBEAT_COUNTcycles, and whenHCCL_LOST_THRESHOLD(30s) is reached, the status is determined asLOST.
  5. Abnormal status propagation: NodeLOSTorCQE_ERRstatus is broadcast to other neighbors via the Ring link (SetStatuserrRankQueue_ProcessExceptionEventSendFrame).
  6. Error information reporting: Through theGetCqeErrInfoFromTaskExceptioncallback registered via__attribute__((constructor)), CQE errors from AICPU/CCU tasks are collected intocqeErrInfo_, and triggered viaSetStatus(..., CLUSTER_MONITOR_CQE_ERR, true)to broadcast; the query interfaceGetErrStatusVecFromCluserMonitorformats error descriptions by priority (CQE_ERR > LOST) and returns them to the upper layer.

The module belongs to the DFX (Design For X) category and is a key component of HCCL for providing "network disconnection / peer CoreDump" observability at the cluster level.


Directory Description

cluster_monitor/ ├── CMakeLists.txt # Build script, only adds cluster_monitor.cc to the hcomm target ├── cluster_monitor.h # Class and data structure definitions (ClusterMonitor, Frame, SockCtx, UID, etc.) └── cluster_monitor.cc # Module implementation, including heartbeat main thread, async link establishment, frame send/receive, exception handling

Directory features:

  • Located incoll_communicator_mgr/dfx/, belongs to DFX monitoring functionality;
  • Module autonomous: singleton (GetInstance(u32 deviceId)), does not depend on other files in the directory;
  • External dependencies:ring_buffer,reference_map,hcclCommSocket,hccl_communicator,hcclCommDfx,coll_comm,log,comm_addr_logger, etc.

Flow Description (Mermaid Sequence Diagram)

Overall Registration / Link Establishment / Heartbeat / Deregistration Main Flow

CQE Exception Reporting and Broadcast Sequence


Data Description (Mermaid Class Diagram)


Interface Description

Public API (External)

InterfaceDescription
static ClusterMonitor& GetInstance(u32 deviceId)Get module singleton by device (held indirectly viaCollCommMgr).
HcclResult RegisterToClusterMonitor(HcclComm comm)Register a communicator: build UID context, calculate Ring connection set, push intoclusterLinkContext_waiting for background link establishment; first registration startsMonitorThread.
HcclResult UnRegisterToClusterMonitor(hccl::CollComm* collComm)Deregister a communicator: clear reference counts for that commId inclusterLinkContext_,commIdMap_,monitorLinkStatusMap_,uid2SocketRefMap_; triggersDeInitwhen the last commId is deregistered.
void GetCqeErrInfoFromTaskException(u32 remoteLocalId, uint16_t status, std::string localEid, std::string remoteEid, std::string remoteInsId)Called by the AICPU/CCU CQE error callback, records CQE errors and propagates them via broadcast.
std::vector<std::string> GetErrStatusVecFromCluserMonitor()DrainerrStatusQueue_, format error descriptions by priority (CQE_ERR > LOST), for upper layer queries.
HcclResult RunMonitorThread()Explicitly start the background heartbeat thread (MonitorThread).
HcclResult DeInit()Stop the heartbeat thread, destroy sockets, clean up all internal containers; idempotent.
void SetStatus(crimer, informer, status, needBroadcast=true)Set / update a node's status, push intoerrRankQueue_if broadcast is needed.
ClusterUIDType FormatUID(ClusterUIDCxt cxt)Assemble UID usingnetInstId/localId.
std::string FormatConnTag(role, uidPair)Generate a socket tag in the formatHeartBeat_<src>_to_<dst>.

Internal / Private Interfaces

InterfaceDescription
GetRemEndpointDescs / GetRemEndpointDescsPerLayerEnumerate all ranks in eachnetLayerfromRankGraph, generateUIDContext, initializeuid2FrameStatusMap_,commIdMap_.
InsertClusterMonitorCxtGiven a peer UID, query RankGraph to obtain link and devicePort, decide SERVER/CLIENT role and constructSocketDesc.
GetSamePlaneRankSelect left and right neighbors within the same plane according to Ring topology (only one neighbor when size==2).
GetConnectRankMerge netLayer=0 plane (sorted bylocalId) with>=1plane (sorted bynetInstId), form rings respectively.
CreateHBLinksAsyncBackground thread entry, traverseclusterLinkContext_to start / restart independent link establishment threads for each remUID.
CreateLinkWithRemotePonitLink establishment thread entry for a single remUID:SocketCreate→ pollSocketGetStatus→ initializerecvBuffer→ register intouid2SocketRefMap_.
CreateTransportHandleWrapSocketCreateto avoid duplicate creation.
SendFrame/RecvFrame/ParseFrameNon-blocking heartbeat frame send (with partial send resume), non-blocking receive (with ring buffer), validity check and status update.
MonitorThreadBackground main loop:CreateHBLinksAsync→ send heartbeat + accumulatelostNumeveryHEARTBEAT_COUNTcycles → receive heartbeat → handlelostNumthreshold exceeded →ProcessExceptionEvent.
DelErrorSocketDestroy sockets marked as abnormal inerrorSocket_.
ProcessExceptionEventConsumeerrRankQueue_, broadcast abnormal frames to all neighbors where "rem != informer and status == OK".
PrintEvents / MakeErrMsgFormatClusterMonitorFramequeue into readable string vectors.

Cross-module Callback Registration (__attribute__((constructor)))

ClusterMonitorCallBackInit() { RegisterGetAicpuCqeErrInfoCallBackHcomm(GetCqeErrInfoFromTaskException); RegisterGetCcuCqeErrInfoCallBackHcomm(GetCqeErrInfoFromTaskException); RegisterAicpuGetErrStatusVecCallBack(GetErrStatusVecFromCluserMonitor); RegisterCcuGetErrStatusVecCallBack(GetErrStatusVecFromCluserMonitor); }

The module registers two callbacks with the AICPU/CCU framework at load time:Exception Entry(error reporting) andError Query(error formatting export), which are the only coupling points between the module and the upper-layer Task exception system.


Usage Limitations (Supported Scenarios and Constraint Specifications)

Supported Scenarios

  1. Multi-Rank communicator: rankSize >= 2 communicators; when rankSize == 1,RegisterToClusterMonitordirectly returnsHCCL_SUCCESSwith aWARNINGlog and no link establishment.
  2. Multi-plane topology: Supports dual Ring link establishment fornetLayer = 0(within same server/device, sorted bylocalId) andnetLayer >= 1(cross-server/pod/superPod, sorted bynetInstId).
  3. Cross-communicator shared socket: Viahccl::ReferenceMapcounting, only one socket is created when multiple communicators connect to the same remote node; reference count--on deregistration, truly destroyed only when it reaches zero.
  4. Ring fault propagation: Single nodeLOST/CQE_ERRstatus can spread to other nodes along the Ring link, enabling querying cluster-wide exceptions from any node.
  5. CQE error capture: ReceivesTaskexceptions via AICPU/CCU callbacks, formatted as readable logs with local / remoteinstanceId / localId / Eid.
  6. Toggle switch: The environment variableHCCL_DFS_CONFIG.cluster_heartbeatcan disable heartbeat registration / CQE error capture chain.
  7. HCCL v2 communicator: Depends onHcclCommunicator::GetRankGraphV2andRankGraph, only effective whenCommunicatorV2exists; otherwise fails withCHK_PTR_NULLinGetRemEndpointDescs.

Constraint Specifications

CategoryConstraint
Thread model1MonitorThread(Hccl_HeartBeat) + NLinkThreads (hb );threadLock_protectscommIdMap_ / uid2SocketRefMap_ / uid2FrameStatusMap_ / monitorLinkStatusMap_ / errRankQueue_ / errStatusQueue_;clusertMonitorLinkMtx_protectsclusterLinkContext_.
LifecycleModule singleton is held byCollCommMgr;DeInitis triggered by the last commId deregistration or~ClusterMonitor, idempotent (guarded byisDeInit_).
Timeout controlLink establishment timeout taken fromEnvConfig::GetSocketConfig().GetLinkTimeOut()(i.e.,HCCL_CONNECT_TIMEOUT); heartbeat loss thresholdlostThreshold_ = HCCL_LOST_THRESHOLD(30s).
Port validitydevicePort/rmtPortmust be<= Hccl::MAX_VALUE_TCPPORT, otherwise returnsHCCL_E_PARA.
Frame sizeClusterMonitorFramecontains 4 UIDs of 2048 bytes each + status + dual timestamps + 256 bytes reserved, fixed total length (sizeof(ClusterMonitorFrame));recvBuffer.Initcapacity isBASE_NUMBER * frameSize(approximately 2x).
UID lengthHcclClusterMonitorUID.idis fixed at 2048 bytes, requiringnetInstId + "/" + localIdto not exceed 2048 bytes.
Role decisionSERVER/CLIENT is determined bylocalIpAddr < remoteIpAddr; when local is SERVER, fill locallistenPort, otherwise fill peerrmtPort, must be consistent with SocketConfig's listener strategy.
Broadcast strategyProcessExceptionEventonly broadcasts to neighbors where "rem != informerandstatus == OK", avoiding loop storms; non-OK neighbors are already self-aware.
Status priorityError query order: CQE_ERR > LOST (call order withinPrintEvents).
Device scopeSingleton maintained per device; each device has independent heartbeats in multi-device scenarios without mutual interference.
Platform dependenciesDepends onHcclCommunicator(v2),RankGraph, and Socket abstraction layer (SocketCreate/SendNb/RecvNb/GetStatus/Destroy); v1 communicator path is not supported.
Environment switchWhenclusterHeartBeatEnable = false, no new sockets are created during registration (commIdMap_ markers are retained), CQE error callbacks directlyreturn.
Error propagation pathAbnormal frames spread gradually through the Ring link; propagation delay ≈BROADCAST_INTERVAL× Ring hops; not instantaneous synchronization.
Resource releaseDeInit/UnRegisterboth performSocketDestroyand clear reference mappings; multiple calls are safe (guarded byisDeInit_,while(uid2SocketRefMap_.erase(rem)) {}spin).

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

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

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

相关文章:

  • Neural Artistic Style开发者指南:如何扩展项目功能与自定义风格网络
  • Linux PAM 故障排除完全手册:解决常见认证问题的10个方法
  • 从CSV到交互式地图:Nanocube数据建模与.map文件配置终极教程
  • 华为Sound X5智能音箱:金标音质技术解析与智能家居体验
  • Jboot安全框架整合:Shiro认证授权与JWT令牌登录实现
  • 影刀RPA 常见数据格式校验:身份证、手机号、邮箱、URL的验证套路
  • AI视频情感分析与符号解读:从微表情到道具叙事的影视内容分析
  • 车载测试技术栈全解析:从CAN总线到HIL测试实战指南
  • TASO与TensorFlow/PyTorch集成指南:无缝提升现有模型推理速度
  • 卖黄金避坑指南,口碑回收老店推荐,实时金价结算无折旧提纯费 - 衡金阁
  • 历史影像数字修复与分析技术:从梵蒂冈档案到反重力现象验证
  • REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE:编程社区中最具创意的多语言项目
  • FES2014潮汐模型:从数据下载到中国沿海精度验证的实践指南
  • C++与AutoHotkey深度集成:进程通信、DLL调用与脚本嵌入实战指南
  • 深入解析IWR1443毫米波雷达的JTAG调试与引导模式配置
  • AI TreasureBox开发者手册:如何贡献和维护这个AI资源聚合平台
  • DN-Splatter高级技巧:深度平滑损失与法线监督的优化配置指南
  • Java ThreadLocal 内存泄漏:原理、复现与正确姿势
  • 如何在openEuler集群部署sionlib?超详细步骤图解
  • 高中学习干预系统:知识图谱+学情诊断+自适应闭环
  • TradingView Webhooks Bot Docker部署完全指南:云端与本地部署最佳实践
  • 婺源卖金踩坑实录!5 家门店真实测评,全域上门回收认准清月知语 - 行行星
  • CANN/cannbot-skills CP4性能验收标准
  • DS90UB964-Q1行拼接模式配置实战:多路传感器数据融合与I2C控制详解
  • 【时序陷阱】DHT11单总线通信的微秒级时序调试与超时处理实战
  • NeatCSS深度解析:为什么这个极简框架值得你关注
  • 从零实现C++线程池:深入理解多线程编程核心原理与实践
  • wastebin扩展开发终极指南:如何快速添加新的语法高亮语言支持
  • CANN交付件模板索引
  • Spring Boot实战:基于JWT与拦截器构建无状态Token认证系统