Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef P2P_MGMT_PUB_H
12 : #define P2P_MGMT_PUB_H
13 :
14 : #include <map>
15 : #include <mutex>
16 : #include <vector>
17 : #include <atomic>
18 : #include "hccl/hccl_types.h"
19 :
20 : namespace hccl {
21 : enum class P2PStatus {
22 : P2P_STATUS_DISABLED = 0,
23 : P2P_STATUS_ENABLING,
24 : P2P_STATUS_ENABLED
25 : };
26 :
27 : using P2PConnectionInfo = struct P2PConnectionInfoDef {
28 : uint32_t reference = 0;
29 : P2PStatus status = P2PStatus::P2P_STATUS_DISABLED;
30 : };
31 :
32 : class P2PMgmt;
33 : class P2PMgmtPub {
34 : public:
35 : static HcclResult EnableP2P(std::vector<uint32_t> remoteDevices);
36 : static HcclResult DisableP2P(std::vector<uint32_t> remoteDevices);
37 : static HcclResult WaitP2PEnabled(std::vector<uint32_t> remoteDevices,
38 0 : std::function<bool()> needStop = []() { return false; });
39 : };
40 : } // namespace hccl
41 :
42 : #endif // P2P_MGMT_H
|