"examples/langchain-python-rag-privategpt/requirements.txt" did not exist on "89a92477ad4c85f81cb7b44058378a7959945163"
topo_utils.h 2.85 KB
Newer Older
lishen's avatar
lishen committed
1
2
#pragma once

3
4
5
#include <map>
#include <string>
#include <cstddef>
lishen's avatar
lishen committed
6
#include "base.h"
7
8
#include "net.h"
#include "hardware_utils.h"
lishen's avatar
lishen committed
9
10
11
12
13

namespace sccl {
namespace hardware {
namespace topology {

14
15
16
17
18
19
20
21
22
23
24
25
constexpr int SCCL_TOPO_NODE_TYPES        = 6; // 硬件node的类型数量
constexpr int SCCL_TOPO_MAX_NODE_PER_TYPE = 4; // 每个硬件node类型中节点的数量,间接表明网络拓扑结构的最大层数
constexpr int SCCL_TOPO_RANK_MAX_LINKS    = 8; // 每个rank中节点与当前rank中其他节点的链接数量

typedef enum : int {
    CPU = 1, // 实际是numa域
    PCI = 2,
    GPU = 3,
    NVS = 4, // 包括XGMI和NVLink
    NIC = 5,
    NET = 6 // 主要是RDMA网卡
} nodeType_t;
lishen's avatar
lishen committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

// 定义 topoPathType_t 枚举类型,用于表示不同的路径类型。
enum topoPathType {
    PATH_LOC = 0, // 本地路径
    PATH_NVL = 1, // 通过 NVLink 连接
    PATH_NVB = 2, // 通过中间 GPU 使用 NVLink 连接
    PATH_PIX = 3, // 通过最多一个 PCIe 桥连接
    PATH_PXB = 4, // 通过多个 PCIe 桥连接(不经过 PCIe 主桥)
    PATH_PXN = 5, // GPU 和 NIC 之间通过中间 GPU 连接
    PATH_PHB = 6, // 通过 PCIe 以及 PCIe 主桥连接
    PATH_SYS = 7, // 通过 PCIe 以及 NUMA 节点之间的 SMP 互连连接
    PATH_NET = 8, // 通过网络连接
    PATH_DIS = 9  // 断开连接
};

////////////////////////////////////////////////////////////////////////////////////////////////

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// // 定义拓扑节点的结构体
// struct scclTopoNode;

// // 定义拓扑链接的结构体
// struct scclTopoLink {
//     int type;                     // 链接类型
//     float bw;                     // 带宽
//     struct scclTopoNode* remNode; // 远程节点指针
// };
// // 用于表示一组拓扑节点
// struct scclTopoNodeSet {
//     int count;                                              // 节点数量
//     struct scclTopoNode nodes[SCCL_TOPO_MAX_NODE_PER_TYPE]; //
// };
// // struct scclTopoNodeSet nodes[SCCL_TOPO_NODE_TYPES];

//     //// 计算直接相连的nodes信息
//     int nlinks;                                          // 链接数量
//     struct scclTopoLink links[SCCL_TOPO_RANK_MAX_LINKS]; // rank内部直接相连的其他node的链接列表

////////////////////////////////////////////////////////////////////////////////////////////////
scclResult_t scclTopoGetStrFromSys(const char* path, const char* fileName, char* strValue);

lishen's avatar
lishen committed
66
67
68
69
70
71
// 将64位整数转换为总线ID字符串
scclResult_t int64ToBusId(int64_t id, char* busId);

// 将总线ID字符串转换为64位整数
scclResult_t busIdToInt64(const char* busId, int64_t* id);

72
73
scclResult_t getPciPath(const char* busId, char** path);

lishen's avatar
lishen committed
74
75
76
77
78
79
// 将PCI路径转换为64位整数,路径偏移量和最小偏移量作为参数
scclResult_t pciPathToInt64(char* path, int offset, int minOffset, int64_t* id);

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