graph.cpp 1.84 KB
Newer Older
1
#include <iostream>
2
#include "base.h"
3
4
5
6
7
8
9
10
#include "graph.h"
#include "paths.h"

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

11
Graph::Graph(int rank, int nRanks) : rank(rank), nRanks(nRanks) {
12
13
14
15
16
17
18
    // 构造函数的实现
}

Graph::~Graph() {
    // 析构函数的实现
}

19
scclResult_t Graph::calculateCommunicationPaths(const BootstrapComm_t* bootstrap_comm, scclTopoGraph_t* topo_graph, Bootstrap* sccl_bootstrap) {
20
21
    // 通信路径计算的实现
    std::cout << "Calculating communication paths..." << std::endl;
22
23

    // 调用pathFinder类,实现硬件路径搜索
24
    auto path_finder = PathFinder(bootstrap_comm);
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    printf("calculateCommunicationPaths pos 1\n");
    // 将搜索结果写入topo_graph中,并记录有效node
    SCCLCHECK(path_finder.computeTopoGpuP2pMap(topo_graph));
    printf("calculateCommunicationPaths pos 2\n");

    // 调用bootstrap类,将transport_map进行allgather统计
    uint8_t* local_transport_map = topo_graph->getTransportMapRowStart(rank);
    SCCLCHECK(sccl_bootstrap->bootstrapAllGather(local_transport_map, topo_graph->transport_map.data(), nRanks * sizeof(uint8_t)));
    printf("calculateCommunicationPaths pos 3\n");

    // 打印transport_map
    if(bootstrap_comm->rank == 0) {
        SCCLCHECK(topo_graph->printTransportMap());
    }
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

    return scclSuccess;
}

scclResult_t Graph::buildLogicalTopology() {
    // 逻辑拓扑构建的实现
    std::cout << "Building logical topology..." << std::endl;
    // 具体的实现细节
    return scclSuccess;
}

scclResult_t Graph::calculateTopoChannels() {
    // 根据无向图计算topo路径的实现
    std::cout << "Calculating topo paths based on undirected graph..." << std::endl;
    // 具体的实现细节
    return scclSuccess;
}

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