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