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 : #include "aiv_ub_mem_channel.h"
12 :
13 : namespace hcomm {
14 :
15 3 : AivUbMemChannel::AivUbMemChannel(EndpointHandle endpointHandle, const HcommChannelDesc& channelDesc)
16 3 : : endpointHandle_(endpointHandle),
17 3 : channelDesc_(channelDesc)
18 3 : {}
19 :
20 0 : HcclResult AivUbMemChannel::ParseInputParam()
21 : {
22 0 : socket_ = reinterpret_cast<Hccl::Socket*>(channelDesc_.socket);
23 0 : return HCCL_SUCCESS;
24 : }
25 :
26 0 : HcclResult AivUbMemChannel::BuildTransport()
27 : {
28 0 : EXCEPTION_CATCH(transport_ = std::make_unique<AivUbMemTransport>(socket_, channelDesc_), return HCCL_E_PTR);
29 0 : CHK_PTR_NULL(transport_);
30 0 : CHK_RET(transport_->Init());
31 0 : return HCCL_SUCCESS;
32 : }
33 :
34 0 : HcclResult AivUbMemChannel::Init()
35 : {
36 : // TODO: 处理抛异常
37 0 : CHK_RET(ParseInputParam());
38 0 : CHK_RET(BuildTransport());
39 0 : return HCCL_SUCCESS;
40 : }
41 :
42 0 : ChannelStatus AivUbMemChannel::GetStatus() { return Channel::TransportStatusToChannelStatus(transport_->GetStatus()); }
43 :
44 0 : HcclResult AivUbMemChannel::GetNotifyNum(uint32_t* notifyNum) const
45 : {
46 0 : HCCL_INFO("AivUbMemChannel GetNotifyNum is not supported.");
47 0 : return HCCL_SUCCESS;
48 : }
49 :
50 0 : HcclResult AivUbMemChannel::GetRemoteMems(uint32_t* memNum, CommMem** remoteMem, char*** memInfos)
51 : {
52 0 : return transport_->GetRemoteMems(memNum, remoteMem, memInfos);
53 : }
54 :
55 0 : HcclResult AivUbMemChannel::UpdateMemInfo(HcommMemHandle* memHandles, uint32_t memHandleNum)
56 : {
57 0 : return transport_->UpdateMemInfo(memHandles, memHandleNum);
58 : }
59 :
60 2 : HcclResult AivUbMemChannel::Clean()
61 : {
62 : // 该模式当前不支持N秒快恢
63 2 : return HCCL_SUCCESS;
64 : }
65 :
66 2 : HcclResult AivUbMemChannel::Resume()
67 : {
68 : // 该模式当前不支持N秒快恢
69 2 : return HCCL_SUCCESS;
70 : }
71 :
72 0 : HcclResult AivUbMemChannel::NotifyRecord(const uint32_t remoteNotifyIdx)
73 : {
74 0 : HCCL_INFO("[AivUbMemChannel::%s] not supported yet.", __func__);
75 0 : return HCCL_E_NOT_SUPPORT;
76 : }
77 :
78 0 : HcclResult AivUbMemChannel::NotifyWait(const uint32_t localNotifyIdx, const uint32_t timeout)
79 : {
80 0 : HCCL_INFO("[AivUbMemChannel::%s] not supported yet.", __func__);
81 0 : return HCCL_E_NOT_SUPPORT;
82 : }
83 :
84 0 : HcclResult AivUbMemChannel::WriteWithNotify(void* dst, const void* src, const uint64_t len, uint32_t remoteNotifyIdx)
85 : {
86 0 : HCCL_INFO("[AivUbMemChannel::%s] not supported yet.", __func__);
87 0 : return HCCL_E_NOT_SUPPORT;
88 : }
89 :
90 0 : HcclResult AivUbMemChannel::Write(void* dst, const void* src, uint64_t len)
91 : {
92 0 : HCCL_INFO("[AivUbMemChannel::%s] not supported yet.", __func__);
93 0 : return HCCL_E_NOT_SUPPORT;
94 : }
95 :
96 0 : HcclResult AivUbMemChannel::Read(void* dst, const void* src, uint64_t len)
97 : {
98 0 : HCCL_INFO("[AivUbMemChannel::%s] not supported yet.", __func__);
99 0 : return HCCL_E_NOT_SUPPORT;
100 : }
101 :
102 0 : HcclResult AivUbMemChannel::ChannelFence()
103 : {
104 0 : HCCL_INFO("[AivUbMemChannel::%s] not supported yet.", __func__);
105 0 : return HCCL_E_NOT_SUPPORT;
106 : }
107 : } // namespace hcomm
|