graph.h 1.4 KB
Newer Older
1
2
3
4
5
#pragma once

#include <vector>
#include "base.h"
#include "graph_utils.h"
6
#include "paths.h"
7
8
9
10
11
12
13
14

namespace sccl {
namespace hardware {
namespace topology {
namespace graph {

class Graph {
public:
15
    Graph(const Bootstrap* bootstrap);
16
17
    virtual ~Graph();

18
19
    scclResult_t establishGraph(const BootstrapComm_t* bootstrap_comm);

20
    // 通信路径计算
21
    scclResult_t calculateCommunicationPaths(const BootstrapComm_t* bootstrap_comm, scclTopoGraph_t* topo_graph);
22
23

    // 逻辑拓扑构建
24
    scclResult_t searchLogicalTopology();
25
26
27
28
29

    // 根据无向图计算topo路径
    scclResult_t calculateTopoChannels();

private:
30
31
32
33
34
35
36
37
38
39
    // 额外处理nRanks个nodes的连接关系
    scclResult_t bootstrapNodesLink(void* node_info_vec, int node_info_total_bytes);

private:
    const Bootstrap* sccl_bootstrap; // 为了调用class Bootstrap中的函数

    // 记录所有rank中node信息
    std::vector<char> node_info_vec;  // 实际为std::vector<scclNodeInfo_t>,vector不支持scclNodeInfo_t变长
    size_t node_info_total_bytes = 0; // 记录可变长度scclNodeInfo_t类型数据的实际大小

40
    std::vector<std::vector<int>> adjacencyMatrix; // 使用邻接矩阵表示图
41

42
    // rank信息
43
    int rank, nRanks;
44
45
    int localRank, nLocalRanks;
    int interRank, nInterRanks; // 整个节点在全部节点中的位置
46
47
48
49
50
51
};

} // namespace graph
} // namespace topology
} // namespace hardware
} // namespace sccl