graph TD ===== 顶层应用 ===== userApp["FlagCX 应用"]:::phase --> flagcxCall["调用 FlagCX API"]:::phase ===== 通信阶段(核心流程)===== setValid --> commOps["集合通信 AllReduce/Bcast/..."]:::logic commOps --> checkComm["validateComm 验证通信器"]:::logic checkComm -->|有效| execCall["callMpiFunction 模板\n+ 类型/操作转换"]:::logic checkComm -->|无效| setErr2["记录通信器无效"]:::error execCall --> callMPI["调用底层 MPI 接口"]:::logic callMPI --> checkResult{{MPI 返回状态}}:::logic checkResult -->|成功| returnOk["返回 OK"]:::logic checkResult -->|失败| setErr3["记录 MPI 错误"]:::error ===== 数据结构关系(灰色虚线)===== flagcxCall -.-> adaptor["flagcxCCLAdaptor\n(mpiAdaptor)"]:::faded adaptor -.-> mpiCtx["flagcxMpiContext\n(MPI_Comm, isValid_, error)"]:::data createCtx -.-> mpiCtx checkComm -.-> mpiCtx %% class assignments class userApp,flagcxCall,createCtx,validateEnv,commOps,checkComm,execCall,callMPI,checkResult,cleanup,commInit,mpiCheck,mpiInit,setValid,returnOk logic class setErr1,setErr2,setErr3 error class adaptor,mpiCtx data