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 CCU_URMA_CHANNEL_H
12 : #define CCU_URMA_CHANNEL_H
13 :
14 : #include <memory>
15 : #include <vector>
16 : #include <atomic>
17 :
18 : #include "../channel.h"
19 :
20 : #include "urma_endpoint.h"
21 : #include "ccu_transport_.h"
22 :
23 : namespace hcomm {
24 :
25 : class CcuUrmaChannel : public Channel {
26 : public:
27 : // 当前仅支持交换hccl buffer
28 : CcuUrmaChannel(const EndpointHandle locEndpointHandle, const HcommChannelDesc& channelDesc);
29 60 : ~CcuUrmaChannel() override = default;
30 :
31 : HcclResult Init() override;
32 : ChannelStatus GetStatus() override;
33 :
34 : HcclResult GetNotifyNum(uint32_t* notifyNum) const override;
35 : HcclResult GetRemoteMems(uint32_t* memNum, CommMem** remoteMem, char*** memInfos) override;
36 : HcclResult UpdateMemInfo(HcommMemHandle* memHandles, uint32_t memHandleNum) override;
37 :
38 : HcclResult Clean() override;
39 : HcclResult Resume() override;
40 :
41 : HcclResult ChannelFence() override;
42 : HcclResult NotifyRecord(const uint32_t remoteNotifyIdx) override;
43 : HcclResult NotifyWait(const uint32_t localNotifyIdx, const uint32_t timeout) override;
44 : HcclResult WriteWithNotify(void* dst, const void* src, const uint64_t len, uint32_t remoteNotifyIdx) override;
45 : HcclResult Write(void* dst, const void* src, uint64_t len) override;
46 : HcclResult Read(void* dst, const void* src, uint64_t len) override;
47 :
48 : public:
49 : uint32_t GetDieId() const;
50 : uint32_t GetChannelId() const;
51 : HcclResult GetRmtSignalAddrByIndex(uint32_t index, uint64_t& rmtCkeAddr) const;
52 : HcclResult GetRmtCcuBufferTokenInfo(uint32_t& rmtTokenId, uint32_t& rmtTokenValue) const;
53 : HcclResult GetRmtVarAddrByIndex(uint32_t index, uint64_t& rmtXnAddr) const;
54 : HcclResult GetLocCkeByIndex(const uint32_t index, uint32_t& locCkeId) const;
55 : HcclResult GetLocXnByIndex(const uint32_t index, uint32_t& locXnId) const;
56 :
57 : HcclResult GetRmtCkeByIndex(const uint32_t index, uint32_t& rmtCkeId) const;
58 : HcclResult GetRmtXnByIndex(const uint32_t index, uint32_t& rmtXnId) const;
59 :
60 : HcclResult GetRmtWishCntXnAddr(const std::string& resGroupTag, uint64_t& wishCntXnAddr) const;
61 :
62 : HcclResult GetRmtBuffer(uint64_t& addr, uint32_t& size, uint32_t& tokenId, uint32_t& tokenValue) const;
63 :
64 0 : EndpointHandle GetlocEndPointHandle() { return locEndpointHandle_; }
65 15 : const HcommChannelDesc& GetChannelDesc() const override { return channelDesc_; }
66 :
67 : private:
68 : std::atomic<bool> isFirstPrintChannelInfo_{true}; // 是否第一次打印通道建链信息,避免重复打印日志刷屏
69 : std::unique_ptr<CcuTransport> impl_{nullptr};
70 : EndpointHandle locEndpointHandle_{nullptr};
71 : HcommChannelDesc channelDesc_{};
72 : };
73 :
74 : } // namespace hcomm
75 : #endif // CCU_URMA_CHANNEL_H
|