communication_group.hpp 709 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include "dist_config.hpp"

#include <infiniccl.h>
#include <infinicore/context/context.hpp>

#include <vector>

namespace infinilm::engine::distributed {

// Communicator each rank will hold
struct RankCommunicator {
    RankInfo info;
    infinicclComm_t comm;
};

// The communication group managed by model infer engine
class CommunicationGroup {
public:
    explicit CommunicationGroup(const DistConfig &dist_config);

    const DistConfig &getDistConfig() const;

    RankCommunicator getRankCommunicator(int rank) const;

    ~CommunicationGroup();

protected:
    DistConfig dist_config_;
    std::vector<infinicclComm_t> communicators_;
};

} // namespace infinilm::engine::distributed