0. Graph

graph LR
   =============== 适配层实现 ======================
  subgraph Gloo适配层
    glooAdaptor["flagcxCCLAdaptor /glooAdaptor"]
    innerComm["flagcxInnerComm"]
    glooCtx["flagcxGlooContext /继承自 gloo::Context"]
    transportCtx["gloo::transport::Context"]
    device["gloo::transport::tcp::Device"]
    helpers["类型与ReduceOp映射 / GENERATE_GLOO_TYPES / getFunction & setInput"]
  end

   =============== 连接关系 =======================
  flagcxAPI --> glooAdaptor
  glooAdaptor --> innerComm
  innerComm --> glooCtx
  glooCtx --> glooBase
  glooCtx --> transportCtx
  transportCtx --> device
  glooAdaptor --> collectives
  helpers --> collectives
  glooAdaptor --> helpers
  bootstrapState --> glooCtx

1. 数据类型 函数映射

flagcxRedOp_t返回gloo内置静态指针。

typedef void (*flagcxGlooReduceFunc)(void*, const void*, const void*, size_t);
template <typename T>
flagcxGlooReduceFunc getGlooReduceFunc(flagcxRedOp_t op)
{
    switch (op)
    {
    case flagcxSum:
        return flagcxGlooReduceFunc(&::gloo::sum<T>);
    case flagcxProd:
        return flagcxGlooReduceFunc(&::gloo::product<T>);
    case flagcxMax:
        return flagcxGlooReduceFunc(&::gloo::max<T>);
    case flagcxMin:
        return flagcxGlooReduceFunc(&::gloo::min<T>);
    case flagcxAvg:
        printf("Gloo backend does not support flagcxAvg Redop\n");
        return nullptr;
    default:
        return nullptr;
    }
}

2. Context包装

3. flagcvInnerComm接口